| 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 #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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 { | 59 class ClearFontFunction : public SyncExtensionFunction { |
| 60 public: | 60 public: |
| 61 DECLARE_EXTENSION_FUNCTION_NAME("experimental.fontSettings.clearFont") |
| 62 |
| 63 protected: |
| 64 virtual ~ClearFontFunction() {} |
| 65 |
| 66 // ExtensionFunction: |
| 61 virtual bool RunImpl() OVERRIDE; | 67 virtual bool RunImpl() OVERRIDE; |
| 62 DECLARE_EXTENSION_FUNCTION_NAME("experimental.fontSettings.clearFont") | |
| 63 }; | 68 }; |
| 64 | 69 |
| 65 class GetFontFunction : public SyncExtensionFunction { | 70 class GetFontFunction : public SyncExtensionFunction { |
| 66 public: | 71 public: |
| 72 DECLARE_EXTENSION_FUNCTION_NAME("experimental.fontSettings.getFont") |
| 73 |
| 74 protected: |
| 75 virtual ~GetFontFunction() {} |
| 76 |
| 77 // ExtensionFunction: |
| 67 virtual bool RunImpl() OVERRIDE; | 78 virtual bool RunImpl() OVERRIDE; |
| 68 DECLARE_EXTENSION_FUNCTION_NAME("experimental.fontSettings.getFont") | |
| 69 }; | 79 }; |
| 70 | 80 |
| 71 class SetFontFunction : public SyncExtensionFunction { | 81 class SetFontFunction : public SyncExtensionFunction { |
| 72 public: | 82 public: |
| 83 DECLARE_EXTENSION_FUNCTION_NAME("experimental.fontSettings.setFont") |
| 84 |
| 85 protected: |
| 86 virtual ~SetFontFunction() {} |
| 87 |
| 88 // ExtensionFunction: |
| 73 virtual bool RunImpl() OVERRIDE; | 89 virtual bool RunImpl() OVERRIDE; |
| 74 DECLARE_EXTENSION_FUNCTION_NAME("experimental.fontSettings.setFont") | |
| 75 }; | 90 }; |
| 76 | 91 |
| 77 class GetFontListFunction : public AsyncExtensionFunction { | 92 class GetFontListFunction : public AsyncExtensionFunction { |
| 78 public: | 93 public: |
| 94 DECLARE_EXTENSION_FUNCTION_NAME("experimental.fontSettings.getFontList") |
| 95 |
| 96 protected: |
| 97 virtual ~GetFontListFunction() {} |
| 98 |
| 99 // ExtensionFunction: |
| 79 virtual bool RunImpl() OVERRIDE; | 100 virtual bool RunImpl() OVERRIDE; |
| 80 DECLARE_EXTENSION_FUNCTION_NAME("experimental.fontSettings.getFontList") | |
| 81 | 101 |
| 82 private: | 102 private: |
| 83 void FontListHasLoaded(scoped_ptr<base::ListValue> list); | 103 void FontListHasLoaded(scoped_ptr<base::ListValue> list); |
| 84 bool CopyFontsToResult(base::ListValue* fonts); | 104 bool CopyFontsToResult(base::ListValue* fonts); |
| 85 }; | 105 }; |
| 86 | 106 |
| 87 // Base class for functions that clear a font pref. | 107 // Base class for functions that clear a font pref. |
| 88 class ClearFontPrefExtensionFunction : public SyncExtensionFunction { | 108 class ClearFontPrefExtensionFunction : public SyncExtensionFunction { |
| 89 protected: | 109 protected: |
| 110 virtual ~ClearFontPrefExtensionFunction() {} |
| 111 |
| 112 // ExtensionFunction: |
| 90 virtual bool RunImpl() OVERRIDE; | 113 virtual bool RunImpl() OVERRIDE; |
| 91 | 114 |
| 92 // Implementations should return the name of the preference to clear, like | 115 // Implementations should return the name of the preference to clear, like |
| 93 // "webkit.webprefs.default_font_size". | 116 // "webkit.webprefs.default_font_size". |
| 94 virtual const char* GetPrefName() = 0; | 117 virtual const char* GetPrefName() = 0; |
| 95 }; | 118 }; |
| 96 | 119 |
| 97 // Base class for functions that get a font pref. | 120 // Base class for functions that get a font pref. |
| 98 class GetFontPrefExtensionFunction : public SyncExtensionFunction { | 121 class GetFontPrefExtensionFunction : public SyncExtensionFunction { |
| 99 protected: | 122 protected: |
| 123 virtual ~GetFontPrefExtensionFunction() {} |
| 124 |
| 125 // ExtensionFunction: |
| 100 virtual bool RunImpl() OVERRIDE; | 126 virtual bool RunImpl() OVERRIDE; |
| 101 | 127 |
| 102 // Implementations should return the name of the preference to get, like | 128 // Implementations should return the name of the preference to get, like |
| 103 // "webkit.webprefs.default_font_size". | 129 // "webkit.webprefs.default_font_size". |
| 104 virtual const char* GetPrefName() = 0; | 130 virtual const char* GetPrefName() = 0; |
| 105 | 131 |
| 106 // Implementations should return the key for the value in the extension API, | 132 // Implementations should return the key for the value in the extension API, |
| 107 // like "pixelSize". | 133 // like "pixelSize". |
| 108 virtual const char* GetKey() = 0; | 134 virtual const char* GetKey() = 0; |
| 109 }; | 135 }; |
| 110 | 136 |
| 111 // Base class for functions that set a font pref. | 137 // Base class for functions that set a font pref. |
| 112 class SetFontPrefExtensionFunction : public SyncExtensionFunction { | 138 class SetFontPrefExtensionFunction : public SyncExtensionFunction { |
| 113 protected: | 139 protected: |
| 140 virtual ~SetFontPrefExtensionFunction() {} |
| 141 |
| 142 // ExtensionFunction: |
| 114 virtual bool RunImpl() OVERRIDE; | 143 virtual bool RunImpl() OVERRIDE; |
| 115 | 144 |
| 116 // Implementations should return the name of the preference to set, like | 145 // Implementations should return the name of the preference to set, like |
| 117 // "webkit.webprefs.default_font_size". | 146 // "webkit.webprefs.default_font_size". |
| 118 virtual const char* GetPrefName() = 0; | 147 virtual const char* GetPrefName() = 0; |
| 119 | 148 |
| 120 // Implementations should return the key for the value in the extension API, | 149 // Implementations should return the key for the value in the extension API, |
| 121 // like "pixelSize". | 150 // like "pixelSize". |
| 122 virtual const char* GetKey() = 0; | 151 virtual const char* GetKey() = 0; |
| 123 }; | 152 }; |
| 124 | 153 |
| 125 class ClearDefaultFontSizeFunction : public ClearFontPrefExtensionFunction { | 154 class ClearDefaultFontSizeFunction : public ClearFontPrefExtensionFunction { |
| 126 public: | 155 public: |
| 127 DECLARE_EXTENSION_FUNCTION_NAME( | 156 DECLARE_EXTENSION_FUNCTION_NAME( |
| 128 "experimental.fontSettings.clearDefaultFontSize") | 157 "experimental.fontSettings.clearDefaultFontSize") |
| 129 | 158 |
| 130 protected: | 159 protected: |
| 160 virtual ~ClearDefaultFontSizeFunction() {} |
| 161 |
| 162 // ClearFontPrefExtensionFunction: |
| 131 virtual const char* GetPrefName() OVERRIDE; | 163 virtual const char* GetPrefName() OVERRIDE; |
| 132 }; | 164 }; |
| 133 | 165 |
| 134 class GetDefaultFontSizeFunction : public GetFontPrefExtensionFunction { | 166 class GetDefaultFontSizeFunction : public GetFontPrefExtensionFunction { |
| 135 public: | 167 public: |
| 136 DECLARE_EXTENSION_FUNCTION_NAME( | 168 DECLARE_EXTENSION_FUNCTION_NAME( |
| 137 "experimental.fontSettings.getDefaultFontSize") | 169 "experimental.fontSettings.getDefaultFontSize") |
| 138 | 170 |
| 139 protected: | 171 protected: |
| 172 virtual ~GetDefaultFontSizeFunction() {} |
| 173 |
| 174 // GetFontPrefExtensionFunction: |
| 140 virtual const char* GetPrefName() OVERRIDE; | 175 virtual const char* GetPrefName() OVERRIDE; |
| 141 virtual const char* GetKey() OVERRIDE; | 176 virtual const char* GetKey() OVERRIDE; |
| 142 }; | 177 }; |
| 143 | 178 |
| 144 class SetDefaultFontSizeFunction : public SetFontPrefExtensionFunction { | 179 class SetDefaultFontSizeFunction : public SetFontPrefExtensionFunction { |
| 145 public: | 180 public: |
| 146 DECLARE_EXTENSION_FUNCTION_NAME( | 181 DECLARE_EXTENSION_FUNCTION_NAME( |
| 147 "experimental.fontSettings.setDefaultFontSize") | 182 "experimental.fontSettings.setDefaultFontSize") |
| 148 | 183 |
| 149 protected: | 184 protected: |
| 185 virtual ~SetDefaultFontSizeFunction() {} |
| 186 |
| 187 // SetFontPrefExtensionFunction: |
| 150 virtual const char* GetPrefName() OVERRIDE; | 188 virtual const char* GetPrefName() OVERRIDE; |
| 151 virtual const char* GetKey() OVERRIDE; | 189 virtual const char* GetKey() OVERRIDE; |
| 152 }; | 190 }; |
| 153 | 191 |
| 154 class ClearDefaultFixedFontSizeFunction | 192 class ClearDefaultFixedFontSizeFunction |
| 155 : public ClearFontPrefExtensionFunction { | 193 : public ClearFontPrefExtensionFunction { |
| 156 public: | 194 public: |
| 157 DECLARE_EXTENSION_FUNCTION_NAME( | 195 DECLARE_EXTENSION_FUNCTION_NAME( |
| 158 "experimental.fontSettings.clearDefaultFixedFontSize") | 196 "experimental.fontSettings.clearDefaultFixedFontSize") |
| 159 | 197 |
| 160 protected: | 198 protected: |
| 199 virtual ~ClearDefaultFixedFontSizeFunction() {} |
| 200 |
| 201 // ClearFontPrefExtensionFunction: |
| 161 virtual const char* GetPrefName() OVERRIDE; | 202 virtual const char* GetPrefName() OVERRIDE; |
| 162 }; | 203 }; |
| 163 | 204 |
| 164 class GetDefaultFixedFontSizeFunction : public GetFontPrefExtensionFunction { | 205 class GetDefaultFixedFontSizeFunction : public GetFontPrefExtensionFunction { |
| 165 public: | 206 public: |
| 166 DECLARE_EXTENSION_FUNCTION_NAME( | 207 DECLARE_EXTENSION_FUNCTION_NAME( |
| 167 "experimental.fontSettings.getDefaultFixedFontSize") | 208 "experimental.fontSettings.getDefaultFixedFontSize") |
| 168 | 209 |
| 169 protected: | 210 protected: |
| 211 virtual ~GetDefaultFixedFontSizeFunction() {} |
| 212 |
| 213 // GetFontPrefExtensionFunction: |
| 170 virtual const char* GetPrefName() OVERRIDE; | 214 virtual const char* GetPrefName() OVERRIDE; |
| 171 virtual const char* GetKey() OVERRIDE; | 215 virtual const char* GetKey() OVERRIDE; |
| 172 }; | 216 }; |
| 173 | 217 |
| 174 class SetDefaultFixedFontSizeFunction : public SetFontPrefExtensionFunction { | 218 class SetDefaultFixedFontSizeFunction : public SetFontPrefExtensionFunction { |
| 175 public: | 219 public: |
| 176 DECLARE_EXTENSION_FUNCTION_NAME( | 220 DECLARE_EXTENSION_FUNCTION_NAME( |
| 177 "experimental.fontSettings.setDefaultFixedFontSize") | 221 "experimental.fontSettings.setDefaultFixedFontSize") |
| 178 | 222 |
| 179 protected: | 223 protected: |
| 224 virtual ~SetDefaultFixedFontSizeFunction() {} |
| 225 |
| 226 // SetFontPrefExtensionFunction: |
| 180 virtual const char* GetPrefName() OVERRIDE; | 227 virtual const char* GetPrefName() OVERRIDE; |
| 181 virtual const char* GetKey() OVERRIDE; | 228 virtual const char* GetKey() OVERRIDE; |
| 182 }; | 229 }; |
| 183 | 230 |
| 184 class ClearMinimumFontSizeFunction : public ClearFontPrefExtensionFunction { | 231 class ClearMinimumFontSizeFunction : public ClearFontPrefExtensionFunction { |
| 185 public: | 232 public: |
| 186 DECLARE_EXTENSION_FUNCTION_NAME( | 233 DECLARE_EXTENSION_FUNCTION_NAME( |
| 187 "experimental.fontSettings.clearMinimumFontSize") | 234 "experimental.fontSettings.clearMinimumFontSize") |
| 188 | 235 |
| 189 protected: | 236 protected: |
| 237 virtual ~ClearMinimumFontSizeFunction() {} |
| 238 |
| 239 // ClearFontPrefExtensionFunction: |
| 190 virtual const char* GetPrefName() OVERRIDE; | 240 virtual const char* GetPrefName() OVERRIDE; |
| 191 }; | 241 }; |
| 192 | 242 |
| 193 class GetMinimumFontSizeFunction : public GetFontPrefExtensionFunction { | 243 class GetMinimumFontSizeFunction : public GetFontPrefExtensionFunction { |
| 194 public: | 244 public: |
| 195 DECLARE_EXTENSION_FUNCTION_NAME( | 245 DECLARE_EXTENSION_FUNCTION_NAME( |
| 196 "experimental.fontSettings.getMinimumFontSize") | 246 "experimental.fontSettings.getMinimumFontSize") |
| 197 | 247 |
| 198 protected: | 248 protected: |
| 249 virtual ~GetMinimumFontSizeFunction() {} |
| 250 |
| 251 // GetFontPrefExtensionFunction: |
| 199 virtual const char* GetPrefName() OVERRIDE; | 252 virtual const char* GetPrefName() OVERRIDE; |
| 200 virtual const char* GetKey() OVERRIDE; | 253 virtual const char* GetKey() OVERRIDE; |
| 201 }; | 254 }; |
| 202 | 255 |
| 203 class SetMinimumFontSizeFunction : public SetFontPrefExtensionFunction { | 256 class SetMinimumFontSizeFunction : public SetFontPrefExtensionFunction { |
| 204 public: | 257 public: |
| 205 DECLARE_EXTENSION_FUNCTION_NAME( | 258 DECLARE_EXTENSION_FUNCTION_NAME( |
| 206 "experimental.fontSettings.setMinimumFontSize") | 259 "experimental.fontSettings.setMinimumFontSize") |
| 207 | 260 |
| 208 protected: | 261 protected: |
| 262 virtual ~SetMinimumFontSizeFunction() {} |
| 263 |
| 264 // SetFontPrefExtensionFunction: |
| 209 virtual const char* GetPrefName() OVERRIDE; | 265 virtual const char* GetPrefName() OVERRIDE; |
| 210 virtual const char* GetKey() OVERRIDE; | 266 virtual const char* GetKey() OVERRIDE; |
| 211 }; | 267 }; |
| 212 | 268 |
| 213 class ClearDefaultCharacterSetFunction : public ClearFontPrefExtensionFunction { | 269 class ClearDefaultCharacterSetFunction : public ClearFontPrefExtensionFunction { |
| 214 public: | 270 public: |
| 215 DECLARE_EXTENSION_FUNCTION_NAME( | 271 DECLARE_EXTENSION_FUNCTION_NAME( |
| 216 "experimental.fontSettings.clearDefaultCharacterSet") | 272 "experimental.fontSettings.clearDefaultCharacterSet") |
| 217 | 273 |
| 218 protected: | 274 protected: |
| 275 virtual ~ClearDefaultCharacterSetFunction() {} |
| 276 |
| 277 // ClearFontPrefExtensionFunction: |
| 219 virtual const char* GetPrefName() OVERRIDE; | 278 virtual const char* GetPrefName() OVERRIDE; |
| 220 }; | 279 }; |
| 221 | 280 |
| 222 class GetDefaultCharacterSetFunction : public GetFontPrefExtensionFunction { | 281 class GetDefaultCharacterSetFunction : public GetFontPrefExtensionFunction { |
| 223 public: | 282 public: |
| 224 DECLARE_EXTENSION_FUNCTION_NAME( | 283 DECLARE_EXTENSION_FUNCTION_NAME( |
| 225 "experimental.fontSettings.getDefaultCharacterSet") | 284 "experimental.fontSettings.getDefaultCharacterSet") |
| 226 | 285 |
| 227 protected: | 286 protected: |
| 287 virtual ~GetDefaultCharacterSetFunction() {} |
| 288 |
| 289 // GetFontPrefExtensionFunction: |
| 228 virtual const char* GetPrefName() OVERRIDE; | 290 virtual const char* GetPrefName() OVERRIDE; |
| 229 virtual const char* GetKey() OVERRIDE; | 291 virtual const char* GetKey() OVERRIDE; |
| 230 }; | 292 }; |
| 231 | 293 |
| 232 class SetDefaultCharacterSetFunction : public SetFontPrefExtensionFunction { | 294 class SetDefaultCharacterSetFunction : public SetFontPrefExtensionFunction { |
| 233 public: | 295 public: |
| 234 DECLARE_EXTENSION_FUNCTION_NAME( | 296 DECLARE_EXTENSION_FUNCTION_NAME( |
| 235 "experimental.fontSettings.setDefaultCharacterSet") | 297 "experimental.fontSettings.setDefaultCharacterSet") |
| 236 | 298 |
| 237 protected: | 299 protected: |
| 300 virtual ~SetDefaultCharacterSetFunction() {} |
| 301 |
| 302 // SetFontPrefExtensionFunction: |
| 238 virtual const char* GetPrefName() OVERRIDE; | 303 virtual const char* GetPrefName() OVERRIDE; |
| 239 virtual const char* GetKey() OVERRIDE; | 304 virtual const char* GetKey() OVERRIDE; |
| 240 }; | 305 }; |
| 241 | 306 |
| 242 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_FONT_SETTINGS_API_H__ | 307 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_FONT_SETTINGS_API_H__ |
| OLD | NEW |