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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 class FontSettingsClearFontFunction : public ChromeSyncExtensionFunction { | 98 class FontSettingsClearFontFunction : public ChromeSyncExtensionFunction { |
99 public: | 99 public: |
100 DECLARE_EXTENSION_FUNCTION("fontSettings.clearFont", FONTSETTINGS_CLEARFONT) | 100 DECLARE_EXTENSION_FUNCTION("fontSettings.clearFont", FONTSETTINGS_CLEARFONT) |
101 | 101 |
102 protected: | 102 protected: |
103 // RefCounted types have non-public destructors, as with all extension | 103 // RefCounted types have non-public destructors, as with all extension |
104 // functions in this file. | 104 // functions in this file. |
105 virtual ~FontSettingsClearFontFunction() {} | 105 virtual ~FontSettingsClearFontFunction() {} |
106 | 106 |
107 // ExtensionFunction: | 107 // ExtensionFunction: |
108 virtual bool RunImpl() OVERRIDE; | 108 virtual bool RunSync() OVERRIDE; |
109 }; | 109 }; |
110 | 110 |
111 // fontSettings.getFont API function. | 111 // fontSettings.getFont API function. |
112 class FontSettingsGetFontFunction : public ChromeSyncExtensionFunction { | 112 class FontSettingsGetFontFunction : public ChromeSyncExtensionFunction { |
113 public: | 113 public: |
114 DECLARE_EXTENSION_FUNCTION("fontSettings.getFont", FONTSETTINGS_GETFONT) | 114 DECLARE_EXTENSION_FUNCTION("fontSettings.getFont", FONTSETTINGS_GETFONT) |
115 | 115 |
116 protected: | 116 protected: |
117 virtual ~FontSettingsGetFontFunction() {} | 117 virtual ~FontSettingsGetFontFunction() {} |
118 | 118 |
119 // ExtensionFunction: | 119 // ExtensionFunction: |
120 virtual bool RunImpl() OVERRIDE; | 120 virtual bool RunSync() OVERRIDE; |
121 }; | 121 }; |
122 | 122 |
123 // fontSettings.setFont API function. | 123 // fontSettings.setFont API function. |
124 class FontSettingsSetFontFunction : public ChromeSyncExtensionFunction { | 124 class FontSettingsSetFontFunction : public ChromeSyncExtensionFunction { |
125 public: | 125 public: |
126 DECLARE_EXTENSION_FUNCTION("fontSettings.setFont", FONTSETTINGS_SETFONT) | 126 DECLARE_EXTENSION_FUNCTION("fontSettings.setFont", FONTSETTINGS_SETFONT) |
127 | 127 |
128 protected: | 128 protected: |
129 virtual ~FontSettingsSetFontFunction() {} | 129 virtual ~FontSettingsSetFontFunction() {} |
130 | 130 |
131 // ExtensionFunction: | 131 // ExtensionFunction: |
132 virtual bool RunImpl() OVERRIDE; | 132 virtual bool RunSync() OVERRIDE; |
133 }; | 133 }; |
134 | 134 |
135 // fontSettings.getFontList API function. | 135 // fontSettings.getFontList API function. |
136 class FontSettingsGetFontListFunction : public ChromeAsyncExtensionFunction { | 136 class FontSettingsGetFontListFunction : public ChromeAsyncExtensionFunction { |
137 public: | 137 public: |
138 DECLARE_EXTENSION_FUNCTION("fontSettings.getFontList", | 138 DECLARE_EXTENSION_FUNCTION("fontSettings.getFontList", |
139 FONTSETTINGS_GETFONTLIST) | 139 FONTSETTINGS_GETFONTLIST) |
140 | 140 |
141 protected: | 141 protected: |
142 virtual ~FontSettingsGetFontListFunction() {} | 142 virtual ~FontSettingsGetFontListFunction() {} |
143 | 143 |
144 // ExtensionFunction: | 144 // ExtensionFunction: |
145 virtual bool RunImpl() OVERRIDE; | 145 virtual bool RunImpl() OVERRIDE; |
146 | 146 |
147 private: | 147 private: |
148 void FontListHasLoaded(scoped_ptr<base::ListValue> list); | 148 void FontListHasLoaded(scoped_ptr<base::ListValue> list); |
149 bool CopyFontsToResult(base::ListValue* fonts); | 149 bool CopyFontsToResult(base::ListValue* fonts); |
150 }; | 150 }; |
151 | 151 |
152 // Base class for extension API functions that clear a browser font pref. | 152 // Base class for extension API functions that clear a browser font pref. |
153 class ClearFontPrefExtensionFunction : public ChromeSyncExtensionFunction { | 153 class ClearFontPrefExtensionFunction : public ChromeSyncExtensionFunction { |
154 protected: | 154 protected: |
155 virtual ~ClearFontPrefExtensionFunction() {} | 155 virtual ~ClearFontPrefExtensionFunction() {} |
156 | 156 |
157 // ExtensionFunction: | 157 // ExtensionFunction: |
158 virtual bool RunImpl() OVERRIDE; | 158 virtual bool RunSync() OVERRIDE; |
159 | 159 |
160 // Implementations should return the name of the preference to clear, like | 160 // Implementations should return the name of the preference to clear, like |
161 // "webkit.webprefs.default_font_size". | 161 // "webkit.webprefs.default_font_size". |
162 virtual const char* GetPrefName() = 0; | 162 virtual const char* GetPrefName() = 0; |
163 }; | 163 }; |
164 | 164 |
165 // Base class for extension API functions that get a browser font pref. | 165 // Base class for extension API functions that get a browser font pref. |
166 class GetFontPrefExtensionFunction : public ChromeSyncExtensionFunction { | 166 class GetFontPrefExtensionFunction : public ChromeSyncExtensionFunction { |
167 protected: | 167 protected: |
168 virtual ~GetFontPrefExtensionFunction() {} | 168 virtual ~GetFontPrefExtensionFunction() {} |
169 | 169 |
170 // ExtensionFunction: | 170 // ExtensionFunction: |
171 virtual bool RunImpl() OVERRIDE; | 171 virtual bool RunSync() OVERRIDE; |
172 | 172 |
173 // Implementations should return the name of the preference to get, like | 173 // Implementations should return the name of the preference to get, like |
174 // "webkit.webprefs.default_font_size". | 174 // "webkit.webprefs.default_font_size". |
175 virtual const char* GetPrefName() = 0; | 175 virtual const char* GetPrefName() = 0; |
176 | 176 |
177 // Implementations should return the key for the value in the extension API, | 177 // Implementations should return the key for the value in the extension API, |
178 // like "pixelSize". | 178 // like "pixelSize". |
179 virtual const char* GetKey() = 0; | 179 virtual const char* GetKey() = 0; |
180 }; | 180 }; |
181 | 181 |
182 // Base class for extension API functions that set a browser font pref. | 182 // Base class for extension API functions that set a browser font pref. |
183 class SetFontPrefExtensionFunction : public ChromeSyncExtensionFunction { | 183 class SetFontPrefExtensionFunction : public ChromeSyncExtensionFunction { |
184 protected: | 184 protected: |
185 virtual ~SetFontPrefExtensionFunction() {} | 185 virtual ~SetFontPrefExtensionFunction() {} |
186 | 186 |
187 // ExtensionFunction: | 187 // ExtensionFunction: |
188 virtual bool RunImpl() OVERRIDE; | 188 virtual bool RunSync() OVERRIDE; |
189 | 189 |
190 // Implementations should return the name of the preference to set, like | 190 // Implementations should return the name of the preference to set, like |
191 // "webkit.webprefs.default_font_size". | 191 // "webkit.webprefs.default_font_size". |
192 virtual const char* GetPrefName() = 0; | 192 virtual const char* GetPrefName() = 0; |
193 | 193 |
194 // Implementations should return the key for the value in the extension API, | 194 // Implementations should return the key for the value in the extension API, |
195 // like "pixelSize". | 195 // like "pixelSize". |
196 virtual const char* GetKey() = 0; | 196 virtual const char* GetKey() = 0; |
197 }; | 197 }; |
198 | 198 |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
318 virtual ~FontSettingsSetMinimumFontSizeFunction() {} | 318 virtual ~FontSettingsSetMinimumFontSizeFunction() {} |
319 | 319 |
320 // SetFontPrefExtensionFunction: | 320 // SetFontPrefExtensionFunction: |
321 virtual const char* GetPrefName() OVERRIDE; | 321 virtual const char* GetPrefName() OVERRIDE; |
322 virtual const char* GetKey() OVERRIDE; | 322 virtual const char* GetKey() OVERRIDE; |
323 }; | 323 }; |
324 | 324 |
325 } // namespace extensions | 325 } // namespace extensions |
326 | 326 |
327 #endif // CHROME_BROWSER_EXTENSIONS_API_FONT_SETTINGS_FONT_SETTINGS_API_H_ | 327 #endif // CHROME_BROWSER_EXTENSIONS_API_FONT_SETTINGS_FONT_SETTINGS_API_H_ |
OLD | NEW |