| 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 |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 std::unique_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 UIThreadExtensionFunction { |
| 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. |
| 109 ~FontSettingsClearFontFunction() override {} | 109 ~FontSettingsClearFontFunction() override {} |
| 110 | 110 |
| 111 // ExtensionFunction: | 111 // ExtensionFunction: |
| 112 bool RunSync() override; | 112 ResponseAction Run() override; |
| 113 }; | 113 }; |
| 114 | 114 |
| 115 // fontSettings.getFont API function. | 115 // fontSettings.getFont API function. |
| 116 class FontSettingsGetFontFunction : public ChromeSyncExtensionFunction { | 116 class FontSettingsGetFontFunction : public UIThreadExtensionFunction { |
| 117 public: | 117 public: |
| 118 DECLARE_EXTENSION_FUNCTION("fontSettings.getFont", FONTSETTINGS_GETFONT) | 118 DECLARE_EXTENSION_FUNCTION("fontSettings.getFont", FONTSETTINGS_GETFONT) |
| 119 | 119 |
| 120 protected: | 120 protected: |
| 121 ~FontSettingsGetFontFunction() override {} | 121 ~FontSettingsGetFontFunction() override {} |
| 122 | 122 |
| 123 // ExtensionFunction: | 123 // ExtensionFunction: |
| 124 bool RunSync() override; | 124 ResponseAction Run() override; |
| 125 }; | 125 }; |
| 126 | 126 |
| 127 // fontSettings.setFont API function. | 127 // fontSettings.setFont API function. |
| 128 class FontSettingsSetFontFunction : public ChromeSyncExtensionFunction { | 128 class FontSettingsSetFontFunction : public UIThreadExtensionFunction { |
| 129 public: | 129 public: |
| 130 DECLARE_EXTENSION_FUNCTION("fontSettings.setFont", FONTSETTINGS_SETFONT) | 130 DECLARE_EXTENSION_FUNCTION("fontSettings.setFont", FONTSETTINGS_SETFONT) |
| 131 | 131 |
| 132 protected: | 132 protected: |
| 133 ~FontSettingsSetFontFunction() override {} | 133 ~FontSettingsSetFontFunction() override {} |
| 134 | 134 |
| 135 // ExtensionFunction: | 135 // ExtensionFunction: |
| 136 bool RunSync() override; | 136 ResponseAction Run() override; |
| 137 }; | 137 }; |
| 138 | 138 |
| 139 // fontSettings.getFontList API function. | 139 // fontSettings.getFontList API function. |
| 140 class FontSettingsGetFontListFunction : public ChromeAsyncExtensionFunction { | 140 class FontSettingsGetFontListFunction : public ChromeAsyncExtensionFunction { |
| 141 public: | 141 public: |
| 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(std::unique_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 UIThreadExtensionFunction { |
| 158 protected: | 158 protected: |
| 159 ~ClearFontPrefExtensionFunction() override {} | 159 ~ClearFontPrefExtensionFunction() override {} |
| 160 | 160 |
| 161 // ExtensionFunction: | 161 // ExtensionFunction: |
| 162 bool RunSync() override; | 162 ResponseAction Run() override; |
| 163 | 163 |
| 164 // Implementations should return the name of the preference to clear, like | 164 // Implementations should return the name of the preference to clear, like |
| 165 // "webkit.webprefs.default_font_size". | 165 // "webkit.webprefs.default_font_size". |
| 166 virtual const char* GetPrefName() = 0; | 166 virtual const char* GetPrefName() = 0; |
| 167 }; | 167 }; |
| 168 | 168 |
| 169 // Base class for extension API functions that get a browser font pref. | 169 // Base class for extension API functions that get a browser font pref. |
| 170 class GetFontPrefExtensionFunction : public ChromeSyncExtensionFunction { | 170 class GetFontPrefExtensionFunction : public UIThreadExtensionFunction { |
| 171 protected: | 171 protected: |
| 172 ~GetFontPrefExtensionFunction() override {} | 172 ~GetFontPrefExtensionFunction() override {} |
| 173 | 173 |
| 174 // ExtensionFunction: | 174 // ExtensionFunction: |
| 175 bool RunSync() override; | 175 ResponseAction Run() override; |
| 176 | 176 |
| 177 // Implementations should return the name of the preference to get, like | 177 // Implementations should return the name of the preference to get, like |
| 178 // "webkit.webprefs.default_font_size". | 178 // "webkit.webprefs.default_font_size". |
| 179 virtual const char* GetPrefName() = 0; | 179 virtual const char* GetPrefName() = 0; |
| 180 | 180 |
| 181 // Implementations should return the key for the value in the extension API, | 181 // Implementations should return the key for the value in the extension API, |
| 182 // like "pixelSize". | 182 // like "pixelSize". |
| 183 virtual const char* GetKey() = 0; | 183 virtual const char* GetKey() = 0; |
| 184 }; | 184 }; |
| 185 | 185 |
| 186 // Base class for extension API functions that set a browser font pref. | 186 // Base class for extension API functions that set a browser font pref. |
| 187 class SetFontPrefExtensionFunction : public ChromeSyncExtensionFunction { | 187 class SetFontPrefExtensionFunction : public UIThreadExtensionFunction { |
| 188 protected: | 188 protected: |
| 189 ~SetFontPrefExtensionFunction() override {} | 189 ~SetFontPrefExtensionFunction() override {} |
| 190 | 190 |
| 191 // ExtensionFunction: | 191 // ExtensionFunction: |
| 192 bool RunSync() override; | 192 ResponseAction Run() override; |
| 193 | 193 |
| 194 // Implementations should return the name of the preference to set, like | 194 // Implementations should return the name of the preference to set, like |
| 195 // "webkit.webprefs.default_font_size". | 195 // "webkit.webprefs.default_font_size". |
| 196 virtual const char* GetPrefName() = 0; | 196 virtual const char* GetPrefName() = 0; |
| 197 | 197 |
| 198 // Implementations should return the key for the value in the extension API, | 198 // Implementations should return the key for the value in the extension API, |
| 199 // like "pixelSize". | 199 // like "pixelSize". |
| 200 virtual const char* GetKey() = 0; | 200 virtual const char* GetKey() = 0; |
| 201 }; | 201 }; |
| 202 | 202 |
| (...skipping 119 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 |