Home | History | Annotate | Download | only in options
      1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 #ifndef CHROME_BROWSER_UI_WEBUI_OPTIONS_FONT_SETTINGS_HANDLER_H_
      6 #define CHROME_BROWSER_UI_WEBUI_OPTIONS_FONT_SETTINGS_HANDLER_H_
      7 
      8 #include "base/memory/scoped_ptr.h"
      9 #include "base/prefs/pref_member.h"
     10 #include "chrome/browser/ui/webui/options/options_ui.h"
     11 #include "content/public/browser/notification_observer.h"
     12 #include "content/public/browser/notification_registrar.h"
     13 
     14 namespace base {
     15 class ListValue;
     16 }
     17 
     18 namespace extensions {
     19 class Extension;
     20 }
     21 
     22 namespace options {
     23 
     24 // Font settings overlay page UI handler.
     25 class FontSettingsHandler : public OptionsPageUIHandler,
     26                             public content::NotificationObserver {
     27  public:
     28   FontSettingsHandler();
     29   virtual ~FontSettingsHandler();
     30 
     31   // OptionsPageUIHandler implementation.
     32   virtual void GetLocalizedValues(
     33       base::DictionaryValue* localized_strings) OVERRIDE;
     34   virtual void InitializeHandler() OVERRIDE;
     35   virtual void InitializePage() OVERRIDE;
     36 
     37   // WebUIMessageHandler implementation.
     38   virtual void RegisterMessages() OVERRIDE;
     39 
     40  private:
     41   // content::NotificationObserver implementation.
     42   virtual void Observe(int type,
     43                        const content::NotificationSource& source,
     44                        const content::NotificationDetails& details) OVERRIDE;
     45 
     46   void HandleFetchFontsData(const base::ListValue* args);
     47 
     48   void FontsListHasLoaded(scoped_ptr<base::ListValue> list);
     49 
     50   void SetUpStandardFontSample();
     51   void SetUpSerifFontSample();
     52   void SetUpSansSerifFontSample();
     53   void SetUpFixedFontSample();
     54   void SetUpMinimumFontSample();
     55 
     56   // Returns the Advanced Font Settings Extension if it's installed and enabled,
     57   // or NULL otherwise.
     58   const extensions::Extension* GetAdvancedFontSettingsExtension();
     59   // Notifies the web UI about whether the Advanced Font Settings Extension is
     60   // installed and enabled.
     61   void NotifyAdvancedFontSettingsAvailability();
     62   // Opens the options page of the Advanced Font Settings Extension.
     63   void HandleOpenAdvancedFontSettingsOptions(const base::ListValue* args);
     64 
     65   void OnWebKitDefaultFontSizeChanged();
     66 
     67   StringPrefMember standard_font_;
     68   StringPrefMember serif_font_;
     69   StringPrefMember sans_serif_font_;
     70   StringPrefMember fixed_font_;
     71   StringPrefMember font_encoding_;
     72   IntegerPrefMember default_font_size_;
     73   IntegerPrefMember default_fixed_font_size_;
     74   IntegerPrefMember minimum_font_size_;
     75 
     76   content::NotificationRegistrar registrar_;
     77 
     78   DISALLOW_COPY_AND_ASSIGN(FontSettingsHandler);
     79 };
     80 
     81 }  // namespace options
     82 
     83 #endif  // CHROME_BROWSER_UI_WEBUI_OPTIONS_FONT_SETTINGS_HANDLER_H_
     84