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" | 16 #include "chrome/browser/extensions/api/profile_keyed_api_factory.h" |
17 #include "chrome/browser/extensions/chrome_extension_function.h" | 17 #include "chrome/browser/extensions/chrome_extension_function.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 { |
| 23 class BrowserContext; |
| 24 } |
| 25 |
22 namespace extensions { | 26 namespace extensions { |
23 | 27 |
24 // This class observes pref changed events on a profile and dispatches the | 28 // This class observes pref changed events on a profile and dispatches the |
25 // corresponding extension API events to extensions. | 29 // corresponding extension API events to extensions. |
26 class FontSettingsEventRouter { | 30 class FontSettingsEventRouter { |
27 public: | 31 public: |
28 // Constructor for observing pref changed events on |profile|. Stores a | 32 // Constructor for observing pref changed events on |profile|. Stores a |
29 // pointer to |profile| but does not take ownership. |profile| must be | 33 // pointer to |profile| but does not take ownership. |profile| must be |
30 // non-NULL and remain alive for the lifetime of the instance. | 34 // non-NULL and remain alive for the lifetime of the instance. |
31 explicit FontSettingsEventRouter(Profile* profile); | 35 explicit FontSettingsEventRouter(Profile* profile); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 Profile* profile_; | 69 Profile* profile_; |
66 | 70 |
67 DISALLOW_COPY_AND_ASSIGN(FontSettingsEventRouter); | 71 DISALLOW_COPY_AND_ASSIGN(FontSettingsEventRouter); |
68 }; | 72 }; |
69 | 73 |
70 // The profile-keyed service that manages the font_settings extension API. | 74 // The profile-keyed service that manages the font_settings extension API. |
71 // 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 |
72 // 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. |
73 class FontSettingsAPI : public ProfileKeyedAPI { | 77 class FontSettingsAPI : public ProfileKeyedAPI { |
74 public: | 78 public: |
75 explicit FontSettingsAPI(Profile* profile); | 79 explicit FontSettingsAPI(content::BrowserContext* context); |
76 virtual ~FontSettingsAPI(); | 80 virtual ~FontSettingsAPI(); |
77 | 81 |
78 // ProfileKeyedAPI implementation. | 82 // ProfileKeyedAPI implementation. |
79 static ProfileKeyedAPIFactory<FontSettingsAPI>* GetFactoryInstance(); | 83 static ProfileKeyedAPIFactory<FontSettingsAPI>* GetFactoryInstance(); |
80 | 84 |
81 private: | 85 private: |
82 friend class ProfileKeyedAPIFactory<FontSettingsAPI>; | 86 friend class ProfileKeyedAPIFactory<FontSettingsAPI>; |
83 | 87 |
84 // ProfileKeyedAPI implementation. | 88 // ProfileKeyedAPI implementation. |
85 static const char* service_name() { | 89 static const char* service_name() { |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 virtual ~FontSettingsSetMinimumFontSizeFunction() {} | 318 virtual ~FontSettingsSetMinimumFontSizeFunction() {} |
315 | 319 |
316 // SetFontPrefExtensionFunction: | 320 // SetFontPrefExtensionFunction: |
317 virtual const char* GetPrefName() OVERRIDE; | 321 virtual const char* GetPrefName() OVERRIDE; |
318 virtual const char* GetKey() OVERRIDE; | 322 virtual const char* GetKey() OVERRIDE; |
319 }; | 323 }; |
320 | 324 |
321 } // namespace extensions | 325 } // namespace extensions |
322 | 326 |
323 #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 |