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/pref_change_registrar.h" | 14 #include "base/prefs/pref_change_registrar.h" |
15 #include "base/prefs/pref_service.h" | 15 #include "base/prefs/pref_service.h" |
16 #include "chrome/browser/extensions/api/profile_keyed_api_factory.h" | |
17 #include "chrome/browser/extensions/chrome_extension_function.h" | 16 #include "chrome/browser/extensions/chrome_extension_function.h" |
| 17 #include "extensions/browser/browser_context_keyed_api_factory.h" |
18 #include "extensions/browser/event_router.h" | 18 #include "extensions/browser/event_router.h" |
19 | 19 |
20 class Profile; | 20 class Profile; |
21 | 21 |
22 namespace content { | 22 namespace content { |
23 class BrowserContext; | 23 class BrowserContext; |
24 } | 24 } |
25 | 25 |
26 namespace extensions { | 26 namespace extensions { |
27 | 27 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 | 67 |
68 // Weak, owns us (transitively via ExtensionService). | 68 // Weak, owns us (transitively via ExtensionService). |
69 Profile* profile_; | 69 Profile* profile_; |
70 | 70 |
71 DISALLOW_COPY_AND_ASSIGN(FontSettingsEventRouter); | 71 DISALLOW_COPY_AND_ASSIGN(FontSettingsEventRouter); |
72 }; | 72 }; |
73 | 73 |
74 // The profile-keyed service that manages the font_settings extension API. | 74 // The profile-keyed service that manages the font_settings extension API. |
75 // This is not an EventRouter::Observer (and does not lazily initialize) because | 75 // This is not an EventRouter::Observer (and does not lazily initialize) because |
76 // doing so caused a regression in perf tests. See crbug.com/163466. | 76 // doing so caused a regression in perf tests. See crbug.com/163466. |
77 class FontSettingsAPI : public ProfileKeyedAPI { | 77 class FontSettingsAPI : public BrowserContextKeyedAPI { |
78 public: | 78 public: |
79 explicit FontSettingsAPI(content::BrowserContext* context); | 79 explicit FontSettingsAPI(content::BrowserContext* context); |
80 virtual ~FontSettingsAPI(); | 80 virtual ~FontSettingsAPI(); |
81 | 81 |
82 // ProfileKeyedAPI implementation. | 82 // BrowserContextKeyedAPI implementation. |
83 static ProfileKeyedAPIFactory<FontSettingsAPI>* GetFactoryInstance(); | 83 static BrowserContextKeyedAPIFactory<FontSettingsAPI>* GetFactoryInstance(); |
84 | 84 |
85 private: | 85 private: |
86 friend class ProfileKeyedAPIFactory<FontSettingsAPI>; | 86 friend class BrowserContextKeyedAPIFactory<FontSettingsAPI>; |
87 | 87 |
88 // ProfileKeyedAPI implementation. | 88 // BrowserContextKeyedAPI implementation. |
89 static const char* service_name() { | 89 static const char* service_name() { |
90 return "FontSettingsAPI"; | 90 return "FontSettingsAPI"; |
91 } | 91 } |
92 static const bool kServiceIsNULLWhileTesting = true; | 92 static const bool kServiceIsNULLWhileTesting = true; |
93 | 93 |
94 scoped_ptr<FontSettingsEventRouter> font_settings_event_router_; | 94 scoped_ptr<FontSettingsEventRouter> font_settings_event_router_; |
95 }; | 95 }; |
96 | 96 |
97 // fontSettings.clearFont API function. | 97 // fontSettings.clearFont API function. |
98 class FontSettingsClearFontFunction : public ChromeSyncExtensionFunction { | 98 class FontSettingsClearFontFunction : public ChromeSyncExtensionFunction { |
(...skipping 219 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 |