OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 // Defines the classes to realize the Font Settings Extension API as specified | 5 // Defines the classes to realize the Font Settings Extension API as specified |
6 // in the extension API JSON. | 6 // in the extension API JSON. |
7 | 7 |
8 #ifndef CHROME_BROWSER_EXTENSIONS_API_FONT_SETTINGS_FONT_SETTINGS_API_H_ | 8 #ifndef CHROME_BROWSER_EXTENSIONS_API_FONT_SETTINGS_FONT_SETTINGS_API_H_ |
9 #define CHROME_BROWSER_EXTENSIONS_API_FONT_SETTINGS_FONT_SETTINGS_API_H_ | 9 #define CHROME_BROWSER_EXTENSIONS_API_FONT_SETTINGS_FONT_SETTINGS_API_H_ |
10 | 10 |
| 11 #include <memory> |
11 #include <string> | 12 #include <string> |
12 | 13 |
13 #include "base/macros.h" | 14 #include "base/macros.h" |
14 #include "base/memory/scoped_ptr.h" | |
15 #include "chrome/browser/extensions/chrome_extension_function.h" | 15 #include "chrome/browser/extensions/chrome_extension_function.h" |
16 #include "components/prefs/pref_change_registrar.h" | 16 #include "components/prefs/pref_change_registrar.h" |
17 #include "components/prefs/pref_service.h" | 17 #include "components/prefs/pref_service.h" |
18 #include "extensions/browser/browser_context_keyed_api_factory.h" | 18 #include "extensions/browser/browser_context_keyed_api_factory.h" |
19 #include "extensions/browser/event_router.h" | 19 #include "extensions/browser/event_router.h" |
20 #include "extensions/browser/extension_event_histogram_value.h" | 20 #include "extensions/browser/extension_event_histogram_value.h" |
21 | 21 |
22 class Profile; | 22 class Profile; |
23 | 23 |
24 namespace content { | 24 namespace content { |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 | 88 |
89 private: | 89 private: |
90 friend class BrowserContextKeyedAPIFactory<FontSettingsAPI>; | 90 friend class BrowserContextKeyedAPIFactory<FontSettingsAPI>; |
91 | 91 |
92 // BrowserContextKeyedAPI implementation. | 92 // BrowserContextKeyedAPI implementation. |
93 static const char* service_name() { | 93 static const char* service_name() { |
94 return "FontSettingsAPI"; | 94 return "FontSettingsAPI"; |
95 } | 95 } |
96 static const bool kServiceIsNULLWhileTesting = true; | 96 static const bool kServiceIsNULLWhileTesting = true; |
97 | 97 |
98 scoped_ptr<FontSettingsEventRouter> font_settings_event_router_; | 98 std::unique_ptr<FontSettingsEventRouter> font_settings_event_router_; |
99 }; | 99 }; |
100 | 100 |
101 // fontSettings.clearFont API function. | 101 // fontSettings.clearFont API function. |
102 class FontSettingsClearFontFunction : public ChromeSyncExtensionFunction { | 102 class FontSettingsClearFontFunction : public ChromeSyncExtensionFunction { |
103 public: | 103 public: |
104 DECLARE_EXTENSION_FUNCTION("fontSettings.clearFont", FONTSETTINGS_CLEARFONT) | 104 DECLARE_EXTENSION_FUNCTION("fontSettings.clearFont", FONTSETTINGS_CLEARFONT) |
105 | 105 |
106 protected: | 106 protected: |
107 // RefCounted types have non-public destructors, as with all extension | 107 // RefCounted types have non-public destructors, as with all extension |
108 // functions in this file. | 108 // functions in this file. |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 DECLARE_EXTENSION_FUNCTION("fontSettings.getFontList", | 142 DECLARE_EXTENSION_FUNCTION("fontSettings.getFontList", |
143 FONTSETTINGS_GETFONTLIST) | 143 FONTSETTINGS_GETFONTLIST) |
144 | 144 |
145 protected: | 145 protected: |
146 ~FontSettingsGetFontListFunction() override {} | 146 ~FontSettingsGetFontListFunction() override {} |
147 | 147 |
148 // ExtensionFunction: | 148 // ExtensionFunction: |
149 bool RunAsync() override; | 149 bool RunAsync() override; |
150 | 150 |
151 private: | 151 private: |
152 void FontListHasLoaded(scoped_ptr<base::ListValue> list); | 152 void FontListHasLoaded(std::unique_ptr<base::ListValue> list); |
153 bool CopyFontsToResult(base::ListValue* fonts); | 153 bool CopyFontsToResult(base::ListValue* fonts); |
154 }; | 154 }; |
155 | 155 |
156 // Base class for extension API functions that clear a browser font pref. | 156 // Base class for extension API functions that clear a browser font pref. |
157 class ClearFontPrefExtensionFunction : public ChromeSyncExtensionFunction { | 157 class ClearFontPrefExtensionFunction : public ChromeSyncExtensionFunction { |
158 protected: | 158 protected: |
159 ~ClearFontPrefExtensionFunction() override {} | 159 ~ClearFontPrefExtensionFunction() override {} |
160 | 160 |
161 // ExtensionFunction: | 161 // ExtensionFunction: |
162 bool RunSync() override; | 162 bool RunSync() override; |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
322 ~FontSettingsSetMinimumFontSizeFunction() override {} | 322 ~FontSettingsSetMinimumFontSizeFunction() override {} |
323 | 323 |
324 // SetFontPrefExtensionFunction: | 324 // SetFontPrefExtensionFunction: |
325 const char* GetPrefName() override; | 325 const char* GetPrefName() override; |
326 const char* GetKey() override; | 326 const char* GetKey() override; |
327 }; | 327 }; |
328 | 328 |
329 } // namespace extensions | 329 } // namespace extensions |
330 | 330 |
331 #endif // CHROME_BROWSER_EXTENSIONS_API_FONT_SETTINGS_FONT_SETTINGS_API_H_ | 331 #endif // CHROME_BROWSER_EXTENSIONS_API_FONT_SETTINGS_FONT_SETTINGS_API_H_ |
OLD | NEW |