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

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

Issue 10177003: Font Settings Extension API: Add functions to clear prefs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 8 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.
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 10
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 PrefChangeRegistrar registrar_; 49 PrefChangeRegistrar registrar_;
50 50
51 PrefEventMap pref_event_map_; 51 PrefEventMap pref_event_map_;
52 52
53 // Weak, owns us (transitively via ExtensionService). 53 // Weak, owns us (transitively via ExtensionService).
54 Profile* profile_; 54 Profile* profile_;
55 55
56 DISALLOW_COPY_AND_ASSIGN(ExtensionFontSettingsEventRouter); 56 DISALLOW_COPY_AND_ASSIGN(ExtensionFontSettingsEventRouter);
57 }; 57 };
58 58
59 class ClearFontFunction : public SyncExtensionFunction {
60 public:
61 virtual bool RunImpl() OVERRIDE;
62 DECLARE_EXTENSION_FUNCTION_NAME("experimental.fontSettings.clearFont")
63 };
64
59 class GetFontFunction : public SyncExtensionFunction { 65 class GetFontFunction : public SyncExtensionFunction {
60 public: 66 public:
61 virtual bool RunImpl() OVERRIDE; 67 virtual bool RunImpl() OVERRIDE;
62 DECLARE_EXTENSION_FUNCTION_NAME("experimental.fontSettings.getFont") 68 DECLARE_EXTENSION_FUNCTION_NAME("experimental.fontSettings.getFont")
63 }; 69 };
64 70
65 class SetFontFunction : public SyncExtensionFunction { 71 class SetFontFunction : public SyncExtensionFunction {
66 public: 72 public:
67 virtual bool RunImpl() OVERRIDE; 73 virtual bool RunImpl() OVERRIDE;
68 DECLARE_EXTENSION_FUNCTION_NAME("experimental.fontSettings.setFont") 74 DECLARE_EXTENSION_FUNCTION_NAME("experimental.fontSettings.setFont")
69 }; 75 };
70 76
71 class GetFontListFunction : public AsyncExtensionFunction { 77 class GetFontListFunction : public AsyncExtensionFunction {
72 public: 78 public:
73 virtual bool RunImpl() OVERRIDE; 79 virtual bool RunImpl() OVERRIDE;
74 DECLARE_EXTENSION_FUNCTION_NAME("experimental.fontSettings.getFontList") 80 DECLARE_EXTENSION_FUNCTION_NAME("experimental.fontSettings.getFontList")
75 81
76 private: 82 private:
77 void FontListHasLoaded(scoped_ptr<base::ListValue> list); 83 void FontListHasLoaded(scoped_ptr<base::ListValue> list);
78 bool CopyFontsToResult(base::ListValue* fonts); 84 bool CopyFontsToResult(base::ListValue* fonts);
79 }; 85 };
80 86
87 // Base class for functions that clear a font pref.
88 class ClearFontPrefExtensionFunction : public SyncExtensionFunction {
89 protected:
90 virtual bool RunImpl() OVERRIDE;
91
92 // Implementations should return the name of the preference to clear, like
93 // "webkit.webprefs.default_font_size".
94 virtual const char* GetPrefName() = 0;
95 };
96
81 // Base class for functions that get a font pref. 97 // Base class for functions that get a font pref.
82 class GetFontPrefExtensionFunction : public SyncExtensionFunction { 98 class GetFontPrefExtensionFunction : public SyncExtensionFunction {
83 protected: 99 protected:
84 virtual bool RunImpl() OVERRIDE; 100 virtual bool RunImpl() OVERRIDE;
85 101
86 // Implementations should return the name of the preference to get, like 102 // Implementations should return the name of the preference to get, like
87 // "webkit.webprefs.default_font_size". 103 // "webkit.webprefs.default_font_size".
88 virtual const char* GetPrefName() = 0; 104 virtual const char* GetPrefName() = 0;
89 105
90 // Implementations should return the key for the value in the extension API, 106 // Implementations should return the key for the value in the extension API,
91 // like "pixelSize". 107 // like "pixelSize".
92 virtual const char* GetKey() = 0; 108 virtual const char* GetKey() = 0;
93 }; 109 };
94 110
95 // Base class for functions that set a font pref. 111 // Base class for functions that set a font pref.
96 class SetFontPrefExtensionFunction : public SyncExtensionFunction { 112 class SetFontPrefExtensionFunction : public SyncExtensionFunction {
97 protected: 113 protected:
98 virtual bool RunImpl() OVERRIDE; 114 virtual bool RunImpl() OVERRIDE;
99 115
100 // Implementations should return the name of the preference to set, like 116 // Implementations should return the name of the preference to set, like
101 // "webkit.webprefs.default_font_size". 117 // "webkit.webprefs.default_font_size".
102 virtual const char* GetPrefName() = 0; 118 virtual const char* GetPrefName() = 0;
103 119
104 // Implementations should return the key for the value in the extension API, 120 // Implementations should return the key for the value in the extension API,
105 // like "pixelSize". 121 // like "pixelSize".
106 virtual const char* GetKey() = 0; 122 virtual const char* GetKey() = 0;
107 }; 123 };
108 124
125 class ClearDefaultFontSizeFunction : public ClearFontPrefExtensionFunction {
126 public:
127 DECLARE_EXTENSION_FUNCTION_NAME(
128 "experimental.fontSettings.clearDefaultFontSize")
129
130 protected:
131 virtual const char* GetPrefName() OVERRIDE;
132 };
133
109 class GetDefaultFontSizeFunction : public GetFontPrefExtensionFunction { 134 class GetDefaultFontSizeFunction : public GetFontPrefExtensionFunction {
110 public: 135 public:
111 DECLARE_EXTENSION_FUNCTION_NAME( 136 DECLARE_EXTENSION_FUNCTION_NAME(
112 "experimental.fontSettings.getDefaultFontSize") 137 "experimental.fontSettings.getDefaultFontSize")
113 138
114 protected: 139 protected:
115 virtual const char* GetPrefName() OVERRIDE; 140 virtual const char* GetPrefName() OVERRIDE;
116 virtual const char* GetKey() OVERRIDE; 141 virtual const char* GetKey() OVERRIDE;
117 }; 142 };
118 143
119 class SetDefaultFontSizeFunction : public SetFontPrefExtensionFunction { 144 class SetDefaultFontSizeFunction : public SetFontPrefExtensionFunction {
120 public: 145 public:
121 DECLARE_EXTENSION_FUNCTION_NAME( 146 DECLARE_EXTENSION_FUNCTION_NAME(
122 "experimental.fontSettings.setDefaultFontSize") 147 "experimental.fontSettings.setDefaultFontSize")
123 148
124 protected: 149 protected:
125 virtual const char* GetPrefName() OVERRIDE; 150 virtual const char* GetPrefName() OVERRIDE;
126 virtual const char* GetKey() OVERRIDE; 151 virtual const char* GetKey() OVERRIDE;
127 }; 152 };
128 153
154 class ClearDefaultFixedFontSizeFunction
155 : public ClearFontPrefExtensionFunction {
156 public:
157 DECLARE_EXTENSION_FUNCTION_NAME(
158 "experimental.fontSettings.clearDefaultFixedFontSize")
159
160 protected:
161 virtual const char* GetPrefName() OVERRIDE;
162 };
163
129 class GetDefaultFixedFontSizeFunction : public GetFontPrefExtensionFunction { 164 class GetDefaultFixedFontSizeFunction : public GetFontPrefExtensionFunction {
130 public: 165 public:
131 DECLARE_EXTENSION_FUNCTION_NAME( 166 DECLARE_EXTENSION_FUNCTION_NAME(
132 "experimental.fontSettings.getDefaultFixedFontSize") 167 "experimental.fontSettings.getDefaultFixedFontSize")
133 168
134 protected: 169 protected:
135 virtual const char* GetPrefName() OVERRIDE; 170 virtual const char* GetPrefName() OVERRIDE;
136 virtual const char* GetKey() OVERRIDE; 171 virtual const char* GetKey() OVERRIDE;
137 }; 172 };
138 173
139 class SetDefaultFixedFontSizeFunction : public SetFontPrefExtensionFunction { 174 class SetDefaultFixedFontSizeFunction : public SetFontPrefExtensionFunction {
140 public: 175 public:
141 DECLARE_EXTENSION_FUNCTION_NAME( 176 DECLARE_EXTENSION_FUNCTION_NAME(
142 "experimental.fontSettings.setDefaultFixedFontSize") 177 "experimental.fontSettings.setDefaultFixedFontSize")
143 178
144 protected: 179 protected:
145 virtual const char* GetPrefName() OVERRIDE; 180 virtual const char* GetPrefName() OVERRIDE;
146 virtual const char* GetKey() OVERRIDE; 181 virtual const char* GetKey() OVERRIDE;
147 }; 182 };
148 183
184 class ClearMinimumFontSizeFunction : public ClearFontPrefExtensionFunction {
185 public:
186 DECLARE_EXTENSION_FUNCTION_NAME(
187 "experimental.fontSettings.clearMinimumFontSize")
188
189 protected:
190 virtual const char* GetPrefName() OVERRIDE;
191 };
192
149 class GetMinimumFontSizeFunction : public GetFontPrefExtensionFunction { 193 class GetMinimumFontSizeFunction : public GetFontPrefExtensionFunction {
150 public: 194 public:
151 DECLARE_EXTENSION_FUNCTION_NAME( 195 DECLARE_EXTENSION_FUNCTION_NAME(
152 "experimental.fontSettings.getMinimumFontSize") 196 "experimental.fontSettings.getMinimumFontSize")
153 197
154 protected: 198 protected:
155 virtual const char* GetPrefName() OVERRIDE; 199 virtual const char* GetPrefName() OVERRIDE;
156 virtual const char* GetKey() OVERRIDE; 200 virtual const char* GetKey() OVERRIDE;
157 }; 201 };
158 202
159 class SetMinimumFontSizeFunction : public SetFontPrefExtensionFunction { 203 class SetMinimumFontSizeFunction : public SetFontPrefExtensionFunction {
160 public: 204 public:
161 DECLARE_EXTENSION_FUNCTION_NAME( 205 DECLARE_EXTENSION_FUNCTION_NAME(
162 "experimental.fontSettings.setMinimumFontSize") 206 "experimental.fontSettings.setMinimumFontSize")
163 207
164 protected: 208 protected:
165 virtual const char* GetPrefName() OVERRIDE; 209 virtual const char* GetPrefName() OVERRIDE;
166 virtual const char* GetKey() OVERRIDE; 210 virtual const char* GetKey() OVERRIDE;
167 }; 211 };
168 212
213 class ClearDefaultCharacterSetFunction : public ClearFontPrefExtensionFunction {
214 public:
215 DECLARE_EXTENSION_FUNCTION_NAME(
216 "experimental.fontSettings.clearDefaultCharacterSet")
217
218 protected:
219 virtual const char* GetPrefName() OVERRIDE;
220 };
221
169 class GetDefaultCharacterSetFunction : public GetFontPrefExtensionFunction { 222 class GetDefaultCharacterSetFunction : public GetFontPrefExtensionFunction {
170 public: 223 public:
171 DECLARE_EXTENSION_FUNCTION_NAME( 224 DECLARE_EXTENSION_FUNCTION_NAME(
172 "experimental.fontSettings.getDefaultCharacterSet") 225 "experimental.fontSettings.getDefaultCharacterSet")
173 226
174 protected: 227 protected:
175 virtual const char* GetPrefName() OVERRIDE; 228 virtual const char* GetPrefName() OVERRIDE;
176 virtual const char* GetKey() OVERRIDE; 229 virtual const char* GetKey() OVERRIDE;
177 }; 230 };
178 231
179 class SetDefaultCharacterSetFunction : public SetFontPrefExtensionFunction { 232 class SetDefaultCharacterSetFunction : public SetFontPrefExtensionFunction {
180 public: 233 public:
181 DECLARE_EXTENSION_FUNCTION_NAME( 234 DECLARE_EXTENSION_FUNCTION_NAME(
182 "experimental.fontSettings.setDefaultCharacterSet") 235 "experimental.fontSettings.setDefaultCharacterSet")
183 236
184 protected: 237 protected:
185 virtual const char* GetPrefName() OVERRIDE; 238 virtual const char* GetPrefName() OVERRIDE;
186 virtual const char* GetKey() OVERRIDE; 239 virtual const char* GetKey() OVERRIDE;
187 }; 240 };
188 241
189 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_FONT_SETTINGS_API_H__ 242 #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