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 "base/scoped_observer.h"
     11 #include "chrome/browser/ui/webui/options/options_ui.h"
     12 #include "extensions/browser/extension_registry_observer.h"
     13 
     14 namespace base {
     15 class ListValue;
     16 }
     17 
     18 namespace extensions {
     19 class Extension;
     20 class ExtensionRegistry;
     21 }
     22 
     23 namespace options {
     24 
     25 // Font settings overlay page UI handler.
     26 class FontSettingsHandler : public OptionsPageUIHandler,
     27                             public extensions::ExtensionRegistryObserver {
     28  public:
     29   FontSettingsHandler();
     30   virtual ~FontSettingsHandler();
     31 
     32   // OptionsPageUIHandler implementation.
     33   virtual void GetLocalizedValues(
     34       base::DictionaryValue* localized_strings) OVERRIDE;
     35   virtual void InitializeHandler() OVERRIDE;
     36   virtual void InitializePage() OVERRIDE;
     37 
     38   // WebUIMessageHandler implementation.
     39   virtual void RegisterMessages() OVERRIDE;
     40 
     41   // ExtensionRegistryObserver implementation.
     42   virtual void OnExtensionLoaded(
     43       content::BrowserContext* browser_context,
     44       const extensions::Extension* extension) OVERRIDE;
     45   virtual void OnExtensionUnloaded(
     46       content::BrowserContext* browser_context,
     47       const extensions::Extension* extension,
     48       extensions::UnloadedExtensionInfo::Reason reason) OVERRIDE;
     49 
     50  private:
     51   void HandleFetchFontsData(const base::ListValue* args);
     52 
     53   void FontsListHasLoaded(scoped_ptr<base::ListValue> list);
     54 
     55   void SetUpStandardFontSample();
     56   void SetUpSerifFontSample();
     57   void SetUpSansSerifFontSample();
     58   void SetUpFixedFontSample();
     59   void SetUpMinimumFontSample();
     60 
     61   // Returns the Advanced Font Settings Extension if it's installed and enabled,
     62   // or NULL otherwise.
     63   const extensions::Extension* GetAdvancedFontSettingsExtension();
     64   // Notifies the web UI about whether the Advanced Font Settings Extension is
     65   // installed and enabled.
     66   void NotifyAdvancedFontSettingsAvailability();
     67   // Opens the options page of the Advanced Font Settings Extension.
     68   void HandleOpenAdvancedFontSettingsOptions(const base::ListValue* args);
     69 
     70   void OnWebKitDefaultFontSizeChanged();
     71 
     72   StringPrefMember standard_font_;
     73   StringPrefMember serif_font_;
     74   StringPrefMember sans_serif_font_;
     75   StringPrefMember fixed_font_;
     76   StringPrefMember font_encoding_;
     77   IntegerPrefMember default_font_size_;
     78   IntegerPrefMember default_fixed_font_size_;
     79   IntegerPrefMember minimum_font_size_;
     80 
     81   ScopedObserver<extensions::ExtensionRegistry,
     82                  extensions::ExtensionRegistryObserver>
     83       extension_registry_observer_;
     84 
     85   DISALLOW_COPY_AND_ASSIGN(FontSettingsHandler);
     86 };
     87 
     88 }  // namespace options
     89 
     90 #endif  // CHROME_BROWSER_UI_WEBUI_OPTIONS_FONT_SETTINGS_HANDLER_H_
     91