Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / ui / webui / options / font_settings_handler.h
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   ~FontSettingsHandler() override;
31
32   // OptionsPageUIHandler implementation.
33   void GetLocalizedValues(base::DictionaryValue* localized_strings) override;
34   void InitializeHandler() override;
35   void InitializePage() override;
36
37   // WebUIMessageHandler implementation.
38   void RegisterMessages() override;
39
40   // ExtensionRegistryObserver implementation.
41   void OnExtensionLoaded(content::BrowserContext* browser_context,
42                          const extensions::Extension* extension) override;
43   void OnExtensionUnloaded(
44       content::BrowserContext* browser_context,
45       const extensions::Extension* extension,
46       extensions::UnloadedExtensionInfo::Reason reason) override;
47
48  private:
49   void HandleFetchFontsData(const base::ListValue* args);
50
51   void FontsListHasLoaded(scoped_ptr<base::ListValue> list);
52
53   void SetUpStandardFontSample();
54   void SetUpSerifFontSample();
55   void SetUpSansSerifFontSample();
56   void SetUpFixedFontSample();
57   void SetUpMinimumFontSample();
58
59   // Returns the Advanced Font Settings Extension if it's installed and enabled,
60   // or NULL otherwise.
61   const extensions::Extension* GetAdvancedFontSettingsExtension();
62   // Notifies the web UI about whether the Advanced Font Settings Extension is
63   // installed and enabled.
64   void NotifyAdvancedFontSettingsAvailability();
65   // Opens the options page of the Advanced Font Settings Extension.
66   void HandleOpenAdvancedFontSettingsOptions(const base::ListValue* args);
67
68   void OnWebKitDefaultFontSizeChanged();
69
70   StringPrefMember standard_font_;
71   StringPrefMember serif_font_;
72   StringPrefMember sans_serif_font_;
73   StringPrefMember fixed_font_;
74   StringPrefMember font_encoding_;
75   IntegerPrefMember default_font_size_;
76   IntegerPrefMember default_fixed_font_size_;
77   IntegerPrefMember minimum_font_size_;
78
79   ScopedObserver<extensions::ExtensionRegistry,
80                  extensions::ExtensionRegistryObserver>
81       extension_registry_observer_;
82
83   DISALLOW_COPY_AND_ASSIGN(FontSettingsHandler);
84 };
85
86 }  // namespace options
87
88 #endif  // CHROME_BROWSER_UI_WEBUI_OPTIONS_FONT_SETTINGS_HANDLER_H_