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

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

Issue 10830180: Moving font_settings extensions API to api/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Moving "namespace extensions" up Created 8 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/extensions/api/font_settings/font_settings_api.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_EXTENSION_FONT_SETTINGS_API_H__ 8 #ifndef CHROME_BROWSER_EXTENSIONS_API_FONT_SETTINGS_FONT_SETTINGS_API_H__
9 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_FONT_SETTINGS_API_H__ 9 #define CHROME_BROWSER_EXTENSIONS_API_FONT_SETTINGS_FONT_SETTINGS_API_H__
10 10
11 #include <map> 11 #include <map>
12 #include <string> 12 #include <string>
13 #include <utility> 13 #include <utility>
14 14
15 #include "chrome/browser/extensions/extension_function.h" 15 #include "chrome/browser/extensions/extension_function.h"
16 #include "chrome/browser/prefs/pref_change_registrar.h" 16 #include "chrome/browser/prefs/pref_change_registrar.h"
17 17
18 namespace extensions {
19
18 // This class observes pref changed events on a profile and dispatches the 20 // This class observes pref changed events on a profile and dispatches the
19 // corresponding extension API events to extensions. 21 // corresponding extension API events to extensions.
20 class ExtensionFontSettingsEventRouter : public content::NotificationObserver { 22 class FontSettingsEventRouter : public content::NotificationObserver {
21 public: 23 public:
22 // Constructor for observing pref changed events on |profile|. Stores a 24 // Constructor for observing pref changed events on |profile|. Stores a
23 // pointer to |profile| but does not take ownership. |profile| must be 25 // pointer to |profile| but does not take ownership. |profile| must be
24 // non-NULL and remain alive for the lifetime of the instance. Init() must be 26 // non-NULL and remain alive for the lifetime of the instance. Init() must be
25 // called to start observing pref changed events. 27 // called to start observing pref changed events.
26 explicit ExtensionFontSettingsEventRouter(Profile* profile); 28 explicit FontSettingsEventRouter(Profile* profile);
27 virtual ~ExtensionFontSettingsEventRouter(); 29 virtual ~FontSettingsEventRouter();
28 30
29 // Starts observing pref changed events on the profile. Must not be called 31 // Starts observing pref changed events on the profile. Must not be called
30 // more than once. 32 // more than once.
31 void Init(); 33 void Init();
32 34
33 private: 35 private:
34 typedef std::pair<std::string, std::string> EventAndKeyPair; 36 typedef std::pair<std::string, std::string> EventAndKeyPair;
35 // Map of pref name to a pair of event name and key (defined in the extension 37 // Map of pref name to a pair of event name and key (defined in the extension
36 // API) for dispatching a pref changed event. For example, 38 // API) for dispatching a pref changed event. For example,
37 // "webkit.webprefs.default_font_size" to ("onDefaultFontSizedChanged", 39 // "webkit.webprefs.default_font_size" to ("onDefaultFontSizedChanged",
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 77
76 // Manages pref observation registration. 78 // Manages pref observation registration.
77 PrefChangeRegistrar registrar_; 79 PrefChangeRegistrar registrar_;
78 80
79 // Maps browser pref names to extension API <event name, key> pairs. 81 // Maps browser pref names to extension API <event name, key> pairs.
80 PrefEventMap pref_event_map_; 82 PrefEventMap pref_event_map_;
81 83
82 // Weak, owns us (transitively via ExtensionService). 84 // Weak, owns us (transitively via ExtensionService).
83 Profile* profile_; 85 Profile* profile_;
84 86
85 DISALLOW_COPY_AND_ASSIGN(ExtensionFontSettingsEventRouter); 87 DISALLOW_COPY_AND_ASSIGN(FontSettingsEventRouter);
86 }; 88 };
87 89
88 // fontSettings.clearFont API function. 90 // fontSettings.clearFont API function.
89 class ClearFontFunction : public SyncExtensionFunction { 91 class ClearFontFunction : public SyncExtensionFunction {
90 public: 92 public:
91 DECLARE_EXTENSION_FUNCTION_NAME("fontSettings.clearFont") 93 DECLARE_EXTENSION_FUNCTION_NAME("fontSettings.clearFont")
92 94
93 protected: 95 protected:
94 // RefCounted types have non-public destructors, as with all extension 96 // RefCounted types have non-public destructors, as with all extension
95 // functions in this file. 97 // functions in this file.
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 DECLARE_EXTENSION_FUNCTION_NAME("fontSettings.setMinimumFontSize") 290 DECLARE_EXTENSION_FUNCTION_NAME("fontSettings.setMinimumFontSize")
289 291
290 protected: 292 protected:
291 virtual ~SetMinimumFontSizeFunction() {} 293 virtual ~SetMinimumFontSizeFunction() {}
292 294
293 // SetFontPrefExtensionFunction: 295 // SetFontPrefExtensionFunction:
294 virtual const char* GetPrefName() OVERRIDE; 296 virtual const char* GetPrefName() OVERRIDE;
295 virtual const char* GetKey() OVERRIDE; 297 virtual const char* GetKey() OVERRIDE;
296 }; 298 };
297 299
298 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_FONT_SETTINGS_API_H__ 300 } // namespace extensions
301
302 #endif // CHROME_BROWSER_EXTENSIONS_API_FONT_SETTINGS_FONT_SETTINGS_API_H__
OLDNEW
« no previous file with comments | « no previous file | 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