Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(435)

Side by Side Diff: chrome/browser/ui/webui/settings/font_handler.h

Issue 1877923002: [MD settings] advanced font settings extension link (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review changes Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_UI_WEBUI_SETTINGS_FONT_HANDLER_H_ 5 #ifndef CHROME_BROWSER_UI_WEBUI_SETTINGS_FONT_HANDLER_H_
6 #define CHROME_BROWSER_UI_WEBUI_SETTINGS_FONT_HANDLER_H_ 6 #define CHROME_BROWSER_UI_WEBUI_SETTINGS_FONT_HANDLER_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 10
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/memory/weak_ptr.h" 12 #include "base/memory/weak_ptr.h"
13 #include "base/scoped_observer.h"
13 #include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h" 14 #include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h"
15 #include "extensions/browser/extension_registry_observer.h"
14 16
15 namespace base { 17 namespace base {
16 class ListValue; 18 class ListValue;
17 } 19 }
18 20
19 namespace content { 21 namespace content {
20 class WebUI; 22 class WebUI;
21 } 23 }
22 24
25 namespace extensions {
26 class Extension;
27 class ExtensionRegistry;
28 }
29
23 class Profile; 30 class Profile;
24 31
25 namespace settings { 32 namespace settings {
26 33
27 // Handle OS font list, font preference settings and character encoding. 34 // Handle OS font list, font preference settings and character encoding.
28 class FontHandler : public SettingsPageUIHandler { 35 class FontHandler : public SettingsPageUIHandler,
36 public extensions::ExtensionRegistryObserver {
29 public: 37 public:
30 explicit FontHandler(content::WebUI* webui); 38 explicit FontHandler(content::WebUI* webui);
31 ~FontHandler() override; 39 ~FontHandler() override;
32 40
33 // SettingsPageUIHandler implementation. 41 // SettingsPageUIHandler implementation.
34 void RegisterMessages() override; 42 void RegisterMessages() override;
43 void RenderViewReused() override;
44
45 // ExtensionRegistryObserver implementation.
46 void OnExtensionLoaded(content::BrowserContext* browser_context,
47 const extensions::Extension* extension) override;
48 void OnExtensionUnloaded(
49 content::BrowserContext* browser_context,
50 const extensions::Extension* extension,
51 extensions::UnloadedExtensionInfo::Reason reason) override;
35 52
36 private: 53 private:
37 // Handler for script asking for font information. 54 // Handler for script asking for font information.
38 void HandleFetchFontsData(const base::ListValue* args); 55 void HandleFetchFontsData(const base::ListValue* args);
39 56
57 // Listen for changes to whether the advanced font extension is available.
58 // An initial update will be sent when observation begins.
59 void HandleObserveAdvancedFontExtensionAvailable(const base::ListValue* args);
60
61 // Open the advanced font settings page.
62 void HandleOpenAdvancedFontSettings(const base::ListValue* args);
63
40 // Callback to handle fonts loading. 64 // Callback to handle fonts loading.
41 void FontListHasLoaded(std::string callback_id, 65 void FontListHasLoaded(std::string callback_id,
42 std::unique_ptr<base::ListValue> list); 66 std::unique_ptr<base::ListValue> list);
43 67
68 const extensions::Extension* GetAdvancedFontSettingsExtension();
69
70 void NotifyAdvancedFontSettingsAvailability();
71
72 ScopedObserver<extensions::ExtensionRegistry,
73 extensions::ExtensionRegistryObserver>
74 extension_registry_observer_;
75
44 Profile* profile_; // Weak pointer. 76 Profile* profile_; // Weak pointer.
45 77
46 base::WeakPtrFactory<FontHandler> weak_ptr_factory_; 78 base::WeakPtrFactory<FontHandler> weak_ptr_factory_;
47 79
48 DISALLOW_COPY_AND_ASSIGN(FontHandler); 80 DISALLOW_COPY_AND_ASSIGN(FontHandler);
49 }; 81 };
50 82
51 } // namespace settings 83 } // namespace settings
52 84
53 #endif // CHROME_BROWSER_UI_WEBUI_SETTINGS_FONT_HANDLER_H_ 85 #endif // CHROME_BROWSER_UI_WEBUI_SETTINGS_FONT_HANDLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698