Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(633)

Side by Side Diff: chrome/browser/extensions/api/font_settings/font_settings_api.h

Issue 11820041: Remove profile-keyed factory boilerplates. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/api/profile_keyed_api_factory.h"
15 #include "chrome/browser/extensions/event_router.h" 16 #include "chrome/browser/extensions/event_router.h"
16 #include "chrome/browser/extensions/extension_function.h" 17 #include "chrome/browser/extensions/extension_function.h"
17 #include "chrome/browser/prefs/pref_service.h" 18 #include "chrome/browser/prefs/pref_service.h"
18 #include "chrome/browser/profiles/profile_keyed_service.h"
19 19
20 class Profile; 20 class Profile;
21 21
22 namespace extensions { 22 namespace extensions {
23 23
24 // This class observes pref changed events on a profile and dispatches the 24 // This class observes pref changed events on a profile and dispatches the
25 // corresponding extension API events to extensions. 25 // corresponding extension API events to extensions.
26 class FontSettingsEventRouter { 26 class FontSettingsEventRouter {
27 public: 27 public:
28 // Constructor for observing pref changed events on |profile|. Stores a 28 // Constructor for observing pref changed events on |profile|. Stores a
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 63
64 // Weak, owns us (transitively via ExtensionService). 64 // Weak, owns us (transitively via ExtensionService).
65 Profile* profile_; 65 Profile* profile_;
66 66
67 DISALLOW_COPY_AND_ASSIGN(FontSettingsEventRouter); 67 DISALLOW_COPY_AND_ASSIGN(FontSettingsEventRouter);
68 }; 68 };
69 69
70 // The profile-keyed service that manages the font_settings extension API. 70 // The profile-keyed service that manages the font_settings extension API.
71 // This is not an EventRouter::Observer (and does not lazily initialize) because 71 // 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. 72 // doing so caused a regression in perf tests. See crbug.com/163466.
73 class FontSettingsAPI : public ProfileKeyedService { 73 class FontSettingsAPI : public ProfileKeyedAPI {
74 public: 74 public:
75 explicit FontSettingsAPI(Profile* profile); 75 explicit FontSettingsAPI(Profile* profile);
76 virtual ~FontSettingsAPI(); 76 virtual ~FontSettingsAPI();
77 77
78 // ProfileKeyedAPI implementation.
79 static ProfileKeyedAPIFactory<FontSettingsAPI>* GetFactoryInstance();
80
78 private: 81 private:
82 friend class ProfileKeyedAPIFactory<FontSettingsAPI>;
83
84 // ProfileKeyedAPI implementation.
85 static const char* service_name() {
86 return "FontSettingsAPI";
87 }
88 static const bool kServiceIsNULLWhileTesting = true;
89
79 scoped_ptr<FontSettingsEventRouter> font_settings_event_router_; 90 scoped_ptr<FontSettingsEventRouter> font_settings_event_router_;
80 }; 91 };
81 92
82 // fontSettings.clearFont API function. 93 // fontSettings.clearFont API function.
83 class FontSettingsClearFontFunction : public SyncExtensionFunction { 94 class FontSettingsClearFontFunction : public SyncExtensionFunction {
84 public: 95 public:
85 DECLARE_EXTENSION_FUNCTION_NAME("fontSettings.clearFont") 96 DECLARE_EXTENSION_FUNCTION_NAME("fontSettings.clearFont")
86 97
87 protected: 98 protected:
88 // RefCounted types have non-public destructors, as with all extension 99 // RefCounted types have non-public destructors, as with all extension
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 virtual ~FontSettingsSetMinimumFontSizeFunction() {} 304 virtual ~FontSettingsSetMinimumFontSizeFunction() {}
294 305
295 // SetFontPrefExtensionFunction: 306 // SetFontPrefExtensionFunction:
296 virtual const char* GetPrefName() OVERRIDE; 307 virtual const char* GetPrefName() OVERRIDE;
297 virtual const char* GetKey() OVERRIDE; 308 virtual const char* GetKey() OVERRIDE;
298 }; 309 };
299 310
300 } // namespace extensions 311 } // namespace extensions
301 312
302 #endif // CHROME_BROWSER_EXTENSIONS_API_FONT_SETTINGS_FONT_SETTINGS_API_H_ 313 #endif // CHROME_BROWSER_EXTENSIONS_API_FONT_SETTINGS_FONT_SETTINGS_API_H_
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/commands/commands.cc ('k') | chrome/browser/extensions/api/font_settings/font_settings_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698