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 <string> | 11 #include <string> |
12 | 12 |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "base/prefs/public/pref_change_registrar.h" | 14 #include "base/prefs/public/pref_change_registrar.h" |
15 #include "chrome/browser/extensions/event_router.h" | 15 #include "chrome/browser/extensions/event_router.h" |
16 #include "chrome/browser/extensions/extension_function.h" | 16 #include "chrome/browser/extensions/extension_function.h" |
17 #include "chrome/browser/prefs/pref_service.h" | 17 #include "chrome/browser/prefs/pref_service.h" |
18 #include "chrome/browser/profiles/profile_keyed_service.h" | 18 #include "chrome/browser/profiles/profile_keyed_service.h" |
19 | 19 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 class FontSettingsAPI : public ProfileKeyedService { | 73 class FontSettingsAPI : public ProfileKeyedService { |
74 public: | 74 public: |
75 explicit FontSettingsAPI(Profile* profile); | 75 explicit FontSettingsAPI(Profile* profile); |
76 virtual ~FontSettingsAPI(); | 76 virtual ~FontSettingsAPI(); |
77 | 77 |
78 private: | 78 private: |
79 scoped_ptr<FontSettingsEventRouter> font_settings_event_router_; | 79 scoped_ptr<FontSettingsEventRouter> font_settings_event_router_; |
80 }; | 80 }; |
81 | 81 |
82 // fontSettings.clearFont API function. | 82 // fontSettings.clearFont API function. |
83 class ClearFontFunction : public SyncExtensionFunction { | 83 class FontSettingsClearFontFunction : public SyncExtensionFunction { |
84 public: | 84 public: |
85 DECLARE_EXTENSION_FUNCTION_NAME("fontSettings.clearFont") | 85 DECLARE_EXTENSION_FUNCTION_NAME("fontSettings.clearFont") |
86 | 86 |
87 protected: | 87 protected: |
88 // RefCounted types have non-public destructors, as with all extension | 88 // RefCounted types have non-public destructors, as with all extension |
89 // functions in this file. | 89 // functions in this file. |
90 virtual ~ClearFontFunction() {} | 90 virtual ~FontSettingsClearFontFunction() {} |
91 | 91 |
92 // ExtensionFunction: | 92 // ExtensionFunction: |
93 virtual bool RunImpl() OVERRIDE; | 93 virtual bool RunImpl() OVERRIDE; |
94 }; | 94 }; |
95 | 95 |
96 // fontSettings.getFont API function. | 96 // fontSettings.getFont API function. |
97 class GetFontFunction : public SyncExtensionFunction { | 97 class FontSettingsGetFontFunction : public SyncExtensionFunction { |
98 public: | 98 public: |
99 DECLARE_EXTENSION_FUNCTION_NAME("fontSettings.getFont") | 99 DECLARE_EXTENSION_FUNCTION_NAME("fontSettings.getFont") |
100 | 100 |
101 protected: | 101 protected: |
102 virtual ~GetFontFunction() {} | 102 virtual ~FontSettingsGetFontFunction() {} |
103 | 103 |
104 // ExtensionFunction: | 104 // ExtensionFunction: |
105 virtual bool RunImpl() OVERRIDE; | 105 virtual bool RunImpl() OVERRIDE; |
106 }; | 106 }; |
107 | 107 |
108 // fontSettings.setFont API function. | 108 // fontSettings.setFont API function. |
109 class SetFontFunction : public SyncExtensionFunction { | 109 class FontSettingsSetFontFunction : public SyncExtensionFunction { |
110 public: | 110 public: |
111 DECLARE_EXTENSION_FUNCTION_NAME("fontSettings.setFont") | 111 DECLARE_EXTENSION_FUNCTION_NAME("fontSettings.setFont") |
112 | 112 |
113 protected: | 113 protected: |
114 virtual ~SetFontFunction() {} | 114 virtual ~FontSettingsSetFontFunction() {} |
115 | 115 |
116 // ExtensionFunction: | 116 // ExtensionFunction: |
117 virtual bool RunImpl() OVERRIDE; | 117 virtual bool RunImpl() OVERRIDE; |
118 }; | 118 }; |
119 | 119 |
120 // fontSettings.getFontList API function. | 120 // fontSettings.getFontList API function. |
121 class GetFontListFunction : public AsyncExtensionFunction { | 121 class FontSettingsGetFontListFunction : public AsyncExtensionFunction { |
122 public: | 122 public: |
123 DECLARE_EXTENSION_FUNCTION_NAME("fontSettings.getFontList") | 123 DECLARE_EXTENSION_FUNCTION_NAME("fontSettings.getFontList") |
124 | 124 |
125 protected: | 125 protected: |
126 virtual ~GetFontListFunction() {} | 126 virtual ~FontSettingsGetFontListFunction() {} |
127 | 127 |
128 // ExtensionFunction: | 128 // ExtensionFunction: |
129 virtual bool RunImpl() OVERRIDE; | 129 virtual bool RunImpl() OVERRIDE; |
130 | 130 |
131 private: | 131 private: |
132 void FontListHasLoaded(scoped_ptr<base::ListValue> list); | 132 void FontListHasLoaded(scoped_ptr<base::ListValue> list); |
133 bool CopyFontsToResult(base::ListValue* fonts); | 133 bool CopyFontsToResult(base::ListValue* fonts); |
134 }; | 134 }; |
135 | 135 |
136 // Base class for extension API functions that clear a browser font pref. | 136 // Base class for extension API functions that clear a browser font pref. |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 virtual const char* GetPrefName() = 0; | 176 virtual const char* GetPrefName() = 0; |
177 | 177 |
178 // Implementations should return the key for the value in the extension API, | 178 // Implementations should return the key for the value in the extension API, |
179 // like "pixelSize". | 179 // like "pixelSize". |
180 virtual const char* GetKey() = 0; | 180 virtual const char* GetKey() = 0; |
181 }; | 181 }; |
182 | 182 |
183 // The following are get/set/clear API functions that act on a browser font | 183 // The following are get/set/clear API functions that act on a browser font |
184 // pref. | 184 // pref. |
185 | 185 |
186 class ClearDefaultFontSizeFunction : public ClearFontPrefExtensionFunction { | 186 class FontSettingsClearDefaultFontSizeFunction |
| 187 : public ClearFontPrefExtensionFunction { |
187 public: | 188 public: |
188 DECLARE_EXTENSION_FUNCTION_NAME("fontSettings.clearDefaultFontSize") | 189 DECLARE_EXTENSION_FUNCTION_NAME("fontSettings.clearDefaultFontSize") |
189 | 190 |
190 protected: | 191 protected: |
191 virtual ~ClearDefaultFontSizeFunction() {} | 192 virtual ~FontSettingsClearDefaultFontSizeFunction() {} |
192 | 193 |
193 // ClearFontPrefExtensionFunction: | 194 // ClearFontPrefExtensionFunction: |
194 virtual const char* GetPrefName() OVERRIDE; | 195 virtual const char* GetPrefName() OVERRIDE; |
195 }; | 196 }; |
196 | 197 |
197 class GetDefaultFontSizeFunction : public GetFontPrefExtensionFunction { | 198 class FontSettingsGetDefaultFontSizeFunction |
| 199 : public GetFontPrefExtensionFunction { |
198 public: | 200 public: |
199 DECLARE_EXTENSION_FUNCTION_NAME("fontSettings.getDefaultFontSize") | 201 DECLARE_EXTENSION_FUNCTION_NAME("fontSettings.getDefaultFontSize") |
200 | 202 |
201 protected: | 203 protected: |
202 virtual ~GetDefaultFontSizeFunction() {} | 204 virtual ~FontSettingsGetDefaultFontSizeFunction() {} |
203 | 205 |
204 // GetFontPrefExtensionFunction: | 206 // GetFontPrefExtensionFunction: |
205 virtual const char* GetPrefName() OVERRIDE; | 207 virtual const char* GetPrefName() OVERRIDE; |
206 virtual const char* GetKey() OVERRIDE; | 208 virtual const char* GetKey() OVERRIDE; |
207 }; | 209 }; |
208 | 210 |
209 class SetDefaultFontSizeFunction : public SetFontPrefExtensionFunction { | 211 class FontSettingsSetDefaultFontSizeFunction |
| 212 : public SetFontPrefExtensionFunction { |
210 public: | 213 public: |
211 DECLARE_EXTENSION_FUNCTION_NAME("fontSettings.setDefaultFontSize") | 214 DECLARE_EXTENSION_FUNCTION_NAME("fontSettings.setDefaultFontSize") |
212 | 215 |
213 protected: | 216 protected: |
214 virtual ~SetDefaultFontSizeFunction() {} | 217 virtual ~FontSettingsSetDefaultFontSizeFunction() {} |
215 | 218 |
216 // SetFontPrefExtensionFunction: | 219 // SetFontPrefExtensionFunction: |
217 virtual const char* GetPrefName() OVERRIDE; | 220 virtual const char* GetPrefName() OVERRIDE; |
218 virtual const char* GetKey() OVERRIDE; | 221 virtual const char* GetKey() OVERRIDE; |
219 }; | 222 }; |
220 | 223 |
221 class ClearDefaultFixedFontSizeFunction | 224 class FontSettingsClearDefaultFixedFontSizeFunction |
222 : public ClearFontPrefExtensionFunction { | 225 : public ClearFontPrefExtensionFunction { |
223 public: | 226 public: |
224 DECLARE_EXTENSION_FUNCTION_NAME("fontSettings.clearDefaultFixedFontSize") | 227 DECLARE_EXTENSION_FUNCTION_NAME("fontSettings.clearDefaultFixedFontSize") |
225 | 228 |
226 protected: | 229 protected: |
227 virtual ~ClearDefaultFixedFontSizeFunction() {} | 230 virtual ~FontSettingsClearDefaultFixedFontSizeFunction() {} |
228 | 231 |
229 // ClearFontPrefExtensionFunction: | 232 // ClearFontPrefExtensionFunction: |
230 virtual const char* GetPrefName() OVERRIDE; | 233 virtual const char* GetPrefName() OVERRIDE; |
231 }; | 234 }; |
232 | 235 |
233 class GetDefaultFixedFontSizeFunction : public GetFontPrefExtensionFunction { | 236 class FontSettingsGetDefaultFixedFontSizeFunction |
| 237 : public GetFontPrefExtensionFunction { |
234 public: | 238 public: |
235 DECLARE_EXTENSION_FUNCTION_NAME("fontSettings.getDefaultFixedFontSize") | 239 DECLARE_EXTENSION_FUNCTION_NAME("fontSettings.getDefaultFixedFontSize") |
236 | 240 |
237 protected: | 241 protected: |
238 virtual ~GetDefaultFixedFontSizeFunction() {} | 242 virtual ~FontSettingsGetDefaultFixedFontSizeFunction() {} |
239 | 243 |
240 // GetFontPrefExtensionFunction: | 244 // GetFontPrefExtensionFunction: |
241 virtual const char* GetPrefName() OVERRIDE; | 245 virtual const char* GetPrefName() OVERRIDE; |
242 virtual const char* GetKey() OVERRIDE; | 246 virtual const char* GetKey() OVERRIDE; |
243 }; | 247 }; |
244 | 248 |
245 class SetDefaultFixedFontSizeFunction : public SetFontPrefExtensionFunction { | 249 class FontSettingsSetDefaultFixedFontSizeFunction |
| 250 : public SetFontPrefExtensionFunction { |
246 public: | 251 public: |
247 DECLARE_EXTENSION_FUNCTION_NAME("fontSettings.setDefaultFixedFontSize") | 252 DECLARE_EXTENSION_FUNCTION_NAME("fontSettings.setDefaultFixedFontSize") |
248 | 253 |
249 protected: | 254 protected: |
250 virtual ~SetDefaultFixedFontSizeFunction() {} | 255 virtual ~FontSettingsSetDefaultFixedFontSizeFunction() {} |
251 | 256 |
252 // SetFontPrefExtensionFunction: | 257 // SetFontPrefExtensionFunction: |
253 virtual const char* GetPrefName() OVERRIDE; | 258 virtual const char* GetPrefName() OVERRIDE; |
254 virtual const char* GetKey() OVERRIDE; | 259 virtual const char* GetKey() OVERRIDE; |
255 }; | 260 }; |
256 | 261 |
257 class ClearMinimumFontSizeFunction : public ClearFontPrefExtensionFunction { | 262 class FontSettingsClearMinimumFontSizeFunction |
| 263 : public ClearFontPrefExtensionFunction { |
258 public: | 264 public: |
259 DECLARE_EXTENSION_FUNCTION_NAME("fontSettings.clearMinimumFontSize") | 265 DECLARE_EXTENSION_FUNCTION_NAME("fontSettings.clearMinimumFontSize") |
260 | 266 |
261 protected: | 267 protected: |
262 virtual ~ClearMinimumFontSizeFunction() {} | 268 virtual ~FontSettingsClearMinimumFontSizeFunction() {} |
263 | 269 |
264 // ClearFontPrefExtensionFunction: | 270 // ClearFontPrefExtensionFunction: |
265 virtual const char* GetPrefName() OVERRIDE; | 271 virtual const char* GetPrefName() OVERRIDE; |
266 }; | 272 }; |
267 | 273 |
268 class GetMinimumFontSizeFunction : public GetFontPrefExtensionFunction { | 274 class FontSettingsGetMinimumFontSizeFunction |
| 275 : public GetFontPrefExtensionFunction { |
269 public: | 276 public: |
270 DECLARE_EXTENSION_FUNCTION_NAME("fontSettings.getMinimumFontSize") | 277 DECLARE_EXTENSION_FUNCTION_NAME("fontSettings.getMinimumFontSize") |
271 | 278 |
272 protected: | 279 protected: |
273 virtual ~GetMinimumFontSizeFunction() {} | 280 virtual ~FontSettingsGetMinimumFontSizeFunction() {} |
274 | 281 |
275 // GetFontPrefExtensionFunction: | 282 // GetFontPrefExtensionFunction: |
276 virtual const char* GetPrefName() OVERRIDE; | 283 virtual const char* GetPrefName() OVERRIDE; |
277 virtual const char* GetKey() OVERRIDE; | 284 virtual const char* GetKey() OVERRIDE; |
278 }; | 285 }; |
279 | 286 |
280 class SetMinimumFontSizeFunction : public SetFontPrefExtensionFunction { | 287 class FontSettingsSetMinimumFontSizeFunction |
| 288 : public SetFontPrefExtensionFunction { |
281 public: | 289 public: |
282 DECLARE_EXTENSION_FUNCTION_NAME("fontSettings.setMinimumFontSize") | 290 DECLARE_EXTENSION_FUNCTION_NAME("fontSettings.setMinimumFontSize") |
283 | 291 |
284 protected: | 292 protected: |
285 virtual ~SetMinimumFontSizeFunction() {} | 293 virtual ~FontSettingsSetMinimumFontSizeFunction() {} |
286 | 294 |
287 // SetFontPrefExtensionFunction: | 295 // SetFontPrefExtensionFunction: |
288 virtual const char* GetPrefName() OVERRIDE; | 296 virtual const char* GetPrefName() OVERRIDE; |
289 virtual const char* GetKey() OVERRIDE; | 297 virtual const char* GetKey() OVERRIDE; |
290 }; | 298 }; |
291 | 299 |
292 } // namespace extensions | 300 } // namespace extensions |
293 | 301 |
294 #endif // CHROME_BROWSER_EXTENSIONS_API_FONT_SETTINGS_FONT_SETTINGS_API_H__ | 302 #endif // CHROME_BROWSER_EXTENSIONS_API_FONT_SETTINGS_FONT_SETTINGS_API_H_ |
OLD | NEW |