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

Side by Side Diff: chrome/browser/extensions/extension_font_settings_api.h

Issue 10447013: CL for readability review. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 7 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/extension_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.
rpang 2012/05/29 17:10:17 File comments? http://www.corp.google.com/eng/doc
falken 2012/05/30 06:52:16 Done.
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 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_FONT_SETTINGS_API_H__ 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_FONT_SETTINGS_API_H__
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_FONT_SETTINGS_API_H__ 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_FONT_SETTINGS_API_H__
7 #pragma once 7 #pragma once
8 8
9 #include <map> 9 #include <map>
10 #include <string>
11 #include <utility>
10 12
11 #include "chrome/browser/extensions/extension_function.h" 13 #include "chrome/browser/extensions/extension_function.h"
12 #include "chrome/browser/prefs/pref_change_registrar.h" 14 #include "chrome/browser/prefs/pref_change_registrar.h"
13 15
14 class ExtensionFontSettingsEventRouter : public content::NotificationObserver { 16 class ExtensionFontSettingsEventRouter : public content::NotificationObserver {
rpang 2012/05/29 17:10:17 Class comments?
falken 2012/05/30 06:52:16 Done. What do you recommend for the group of simil
rpang 2012/05/30 11:45:51 This is fine.
15 public: 17 public:
16 explicit ExtensionFontSettingsEventRouter(Profile* profile); 18 explicit ExtensionFontSettingsEventRouter(Profile* profile);
rpang 2012/05/29 17:10:17 Comment on function, esp. the parameters. What doe
falken 2012/05/30 06:52:16 Done.
17 virtual ~ExtensionFontSettingsEventRouter(); 19 virtual ~ExtensionFontSettingsEventRouter();
18 20
19 void Init(); 21 void Init();
20 22
21 private: 23 private:
22 typedef std::pair<std::string, std::string> EventAndKeyPair; 24 typedef std::pair<std::string, std::string> EventAndKeyPair;
rpang 2012/05/29 17:10:17 I'm not familiar with chrome style, but STL in goo
falken 2012/05/30 06:52:16 Chrome code seems to consistently use std::. This
23 // Map of pref name to a pair of event name and key (defined in the API) for 25 // Map of pref name to a pair of event name and key (defined in the API) for
24 // dispatching a pref changed event. For example, 26 // dispatching a pref changed event. For example,
25 // "webkit.webprefs.default_font_size" to ("onDefaultFontSizedChanged", 27 // "webkit.webprefs.default_font_size" to ("onDefaultFontSizedChanged",
26 // "pixelSize"). 28 // "pixelSize").
27 typedef std::map<std::string, EventAndKeyPair> PrefEventMap; 29 typedef std::map<std::string, EventAndKeyPair> PrefEventMap;
28 30
29 void AddPrefToObserve(const char* pref_name, 31 void AddPrefToObserve(const char* pref_name,
30 const char* event_name, 32 const char* event_name,
31 const char* key); 33 const char* key);
32 34
33 // content::NotificationObserver implementation. 35 // content::NotificationObserver implementation.
34 virtual void Observe(int type, 36 virtual void Observe(int type,
35 const content::NotificationSource& source, 37 const content::NotificationSource& source,
36 const content::NotificationDetails& details) OVERRIDE; 38 const content::NotificationDetails& details) OVERRIDE;
37 39
38 void OnFontNamePrefChanged(PrefService* pref_service, 40 void OnFontNamePrefChanged(PrefService* pref_service,
39 const std::string& pref_name, 41 const std::string& pref_name,
40 const std::string& generic_family, 42 const std::string& generic_family,
41 const std::string& script, 43 const std::string& script,
42 bool incognito); 44 bool incognito);
43 void OnFontPrefChanged(PrefService* pref_service, 45 void OnFontPrefChanged(PrefService* pref_service,
44 const std::string& pref_name, 46 const std::string& pref_name,
45 const std::string& event_name, 47 const std::string& event_name,
46 const std::string& key, 48 const std::string& key,
47 bool incognito); 49 bool incognito);
48 50
49 PrefChangeRegistrar registrar_; 51 PrefChangeRegistrar registrar_;
rpang 2012/05/29 17:10:17 Comment on member variables.
falken 2012/05/30 06:52:16 Done.
50 52
51 PrefEventMap pref_event_map_; 53 PrefEventMap pref_event_map_;
52 54
53 // Weak, owns us (transitively via ExtensionService). 55 // Weak, owns us (transitively via ExtensionService).
54 Profile* profile_; 56 Profile* profile_;
55 57
56 DISALLOW_COPY_AND_ASSIGN(ExtensionFontSettingsEventRouter); 58 DISALLOW_COPY_AND_ASSIGN(ExtensionFontSettingsEventRouter);
57 }; 59 };
58 60
59 class ClearFontFunction : public SyncExtensionFunction { 61 class ClearFontFunction : public SyncExtensionFunction {
60 public: 62 public:
61 DECLARE_EXTENSION_FUNCTION_NAME("experimental.fontSettings.clearFont") 63 DECLARE_EXTENSION_FUNCTION_NAME("experimental.fontSettings.clearFont")
62 64
63 protected: 65 protected:
64 virtual ~ClearFontFunction() {} 66 virtual ~ClearFontFunction() {}
rpang 2012/05/29 17:10:17 Comment on why the destructor is protected.
falken 2012/05/30 06:52:16 Hm, I found most other extension APIs do this, but
Matt Perry 2012/05/30 18:39:05 This is from http://codereview.chromium.org/100710
65 67
66 // ExtensionFunction: 68 // ExtensionFunction:
67 virtual bool RunImpl() OVERRIDE; 69 virtual bool RunImpl() OVERRIDE;
68 }; 70 };
69 71
70 class GetFontFunction : public SyncExtensionFunction { 72 class GetFontFunction : public SyncExtensionFunction {
71 public: 73 public:
72 DECLARE_EXTENSION_FUNCTION_NAME("experimental.fontSettings.getFont") 74 DECLARE_EXTENSION_FUNCTION_NAME("experimental.fontSettings.getFont")
73 75
74 protected: 76 protected:
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 300
299 protected: 301 protected:
300 virtual ~SetDefaultCharacterSetFunction() {} 302 virtual ~SetDefaultCharacterSetFunction() {}
301 303
302 // SetFontPrefExtensionFunction: 304 // SetFontPrefExtensionFunction:
303 virtual const char* GetPrefName() OVERRIDE; 305 virtual const char* GetPrefName() OVERRIDE;
304 virtual const char* GetKey() OVERRIDE; 306 virtual const char* GetKey() OVERRIDE;
305 }; 307 };
306 308
307 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_FONT_SETTINGS_API_H__ 309 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_FONT_SETTINGS_API_H__
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/extension_font_settings_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698