| 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_API_EXTENSION_ACTION_EXTENSION_ACTION_API_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_EXTENSION_ACTION_EXTENSION_ACTION_API_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_API_EXTENSION_ACTION_EXTENSION_ACTION_API_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_API_EXTENSION_ACTION_EXTENSION_ACTION_API_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/observer_list.h" | 10 #include "base/observer_list.h" |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 const std::string& extension_id, | 117 const std::string& extension_id, |
| 118 const std::string& event_name, | 118 const std::string& event_name, |
| 119 scoped_ptr<base::ListValue> event_args); | 119 scoped_ptr<base::ListValue> event_args); |
| 120 | 120 |
| 121 // Called when either a browser or page action is executed. Figures out which | 121 // Called when either a browser or page action is executed. Figures out which |
| 122 // event to send based on what the extension wants. | 122 // event to send based on what the extension wants. |
| 123 void ExtensionActionExecuted(const ExtensionAction& extension_action, | 123 void ExtensionActionExecuted(const ExtensionAction& extension_action, |
| 124 content::WebContents* web_contents); | 124 content::WebContents* web_contents); |
| 125 | 125 |
| 126 // BrowserContextKeyedAPI implementation. | 126 // BrowserContextKeyedAPI implementation. |
| 127 virtual void Shutdown() OVERRIDE; | 127 virtual void Shutdown() override; |
| 128 static const char* service_name() { return "ExtensionActionAPI"; } | 128 static const char* service_name() { return "ExtensionActionAPI"; } |
| 129 static const bool kServiceRedirectedInIncognito = true; | 129 static const bool kServiceRedirectedInIncognito = true; |
| 130 | 130 |
| 131 ObserverList<Observer> observers_; | 131 ObserverList<Observer> observers_; |
| 132 | 132 |
| 133 content::BrowserContext* browser_context_; | 133 content::BrowserContext* browser_context_; |
| 134 | 134 |
| 135 DISALLOW_COPY_AND_ASSIGN(ExtensionActionAPI); | 135 DISALLOW_COPY_AND_ASSIGN(ExtensionActionAPI); |
| 136 }; | 136 }; |
| 137 | 137 |
| 138 // Implementation of the browserAction and pageAction APIs. | 138 // Implementation of the browserAction and pageAction APIs. |
| 139 // | 139 // |
| 140 // Divergent behaviour between the two is minimal (pageAction has required | 140 // Divergent behaviour between the two is minimal (pageAction has required |
| 141 // tabIds while browserAction's are optional, they have different internal | 141 // tabIds while browserAction's are optional, they have different internal |
| 142 // browser notification requirements, and not all functions are defined for all | 142 // browser notification requirements, and not all functions are defined for all |
| 143 // APIs). | 143 // APIs). |
| 144 class ExtensionActionFunction : public ChromeSyncExtensionFunction { | 144 class ExtensionActionFunction : public ChromeSyncExtensionFunction { |
| 145 public: | 145 public: |
| 146 static bool ParseCSSColorString(const std::string& color_string, | 146 static bool ParseCSSColorString(const std::string& color_string, |
| 147 SkColor* result); | 147 SkColor* result); |
| 148 | 148 |
| 149 protected: | 149 protected: |
| 150 ExtensionActionFunction(); | 150 ExtensionActionFunction(); |
| 151 virtual ~ExtensionActionFunction(); | 151 virtual ~ExtensionActionFunction(); |
| 152 virtual bool RunSync() OVERRIDE; | 152 virtual bool RunSync() override; |
| 153 virtual bool RunExtensionAction() = 0; | 153 virtual bool RunExtensionAction() = 0; |
| 154 | 154 |
| 155 bool ExtractDataFromArguments(); | 155 bool ExtractDataFromArguments(); |
| 156 void NotifyChange(); | 156 void NotifyChange(); |
| 157 bool SetVisible(bool visible); | 157 bool SetVisible(bool visible); |
| 158 | 158 |
| 159 // All the extension action APIs take a single argument called details that | 159 // All the extension action APIs take a single argument called details that |
| 160 // is a dictionary. | 160 // is a dictionary. |
| 161 base::DictionaryValue* details_; | 161 base::DictionaryValue* details_; |
| 162 | 162 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 175 // Implementations of each extension action API. | 175 // Implementations of each extension action API. |
| 176 // | 176 // |
| 177 // pageAction and browserAction bindings are created for these by extending them | 177 // pageAction and browserAction bindings are created for these by extending them |
| 178 // then declaring an EXTENSION_FUNCTION_NAME. | 178 // then declaring an EXTENSION_FUNCTION_NAME. |
| 179 // | 179 // |
| 180 | 180 |
| 181 // show | 181 // show |
| 182 class ExtensionActionShowFunction : public ExtensionActionFunction { | 182 class ExtensionActionShowFunction : public ExtensionActionFunction { |
| 183 protected: | 183 protected: |
| 184 virtual ~ExtensionActionShowFunction() {} | 184 virtual ~ExtensionActionShowFunction() {} |
| 185 virtual bool RunExtensionAction() OVERRIDE; | 185 virtual bool RunExtensionAction() override; |
| 186 }; | 186 }; |
| 187 | 187 |
| 188 // hide | 188 // hide |
| 189 class ExtensionActionHideFunction : public ExtensionActionFunction { | 189 class ExtensionActionHideFunction : public ExtensionActionFunction { |
| 190 protected: | 190 protected: |
| 191 virtual ~ExtensionActionHideFunction() {} | 191 virtual ~ExtensionActionHideFunction() {} |
| 192 virtual bool RunExtensionAction() OVERRIDE; | 192 virtual bool RunExtensionAction() override; |
| 193 }; | 193 }; |
| 194 | 194 |
| 195 // setIcon | 195 // setIcon |
| 196 class ExtensionActionSetIconFunction : public ExtensionActionFunction { | 196 class ExtensionActionSetIconFunction : public ExtensionActionFunction { |
| 197 protected: | 197 protected: |
| 198 virtual ~ExtensionActionSetIconFunction() {} | 198 virtual ~ExtensionActionSetIconFunction() {} |
| 199 virtual bool RunExtensionAction() OVERRIDE; | 199 virtual bool RunExtensionAction() override; |
| 200 }; | 200 }; |
| 201 | 201 |
| 202 // setTitle | 202 // setTitle |
| 203 class ExtensionActionSetTitleFunction : public ExtensionActionFunction { | 203 class ExtensionActionSetTitleFunction : public ExtensionActionFunction { |
| 204 protected: | 204 protected: |
| 205 virtual ~ExtensionActionSetTitleFunction() {} | 205 virtual ~ExtensionActionSetTitleFunction() {} |
| 206 virtual bool RunExtensionAction() OVERRIDE; | 206 virtual bool RunExtensionAction() override; |
| 207 }; | 207 }; |
| 208 | 208 |
| 209 // setPopup | 209 // setPopup |
| 210 class ExtensionActionSetPopupFunction : public ExtensionActionFunction { | 210 class ExtensionActionSetPopupFunction : public ExtensionActionFunction { |
| 211 protected: | 211 protected: |
| 212 virtual ~ExtensionActionSetPopupFunction() {} | 212 virtual ~ExtensionActionSetPopupFunction() {} |
| 213 virtual bool RunExtensionAction() OVERRIDE; | 213 virtual bool RunExtensionAction() override; |
| 214 }; | 214 }; |
| 215 | 215 |
| 216 // setBadgeText | 216 // setBadgeText |
| 217 class ExtensionActionSetBadgeTextFunction : public ExtensionActionFunction { | 217 class ExtensionActionSetBadgeTextFunction : public ExtensionActionFunction { |
| 218 protected: | 218 protected: |
| 219 virtual ~ExtensionActionSetBadgeTextFunction() {} | 219 virtual ~ExtensionActionSetBadgeTextFunction() {} |
| 220 virtual bool RunExtensionAction() OVERRIDE; | 220 virtual bool RunExtensionAction() override; |
| 221 }; | 221 }; |
| 222 | 222 |
| 223 // setBadgeBackgroundColor | 223 // setBadgeBackgroundColor |
| 224 class ExtensionActionSetBadgeBackgroundColorFunction | 224 class ExtensionActionSetBadgeBackgroundColorFunction |
| 225 : public ExtensionActionFunction { | 225 : public ExtensionActionFunction { |
| 226 protected: | 226 protected: |
| 227 virtual ~ExtensionActionSetBadgeBackgroundColorFunction() {} | 227 virtual ~ExtensionActionSetBadgeBackgroundColorFunction() {} |
| 228 virtual bool RunExtensionAction() OVERRIDE; | 228 virtual bool RunExtensionAction() override; |
| 229 }; | 229 }; |
| 230 | 230 |
| 231 // getTitle | 231 // getTitle |
| 232 class ExtensionActionGetTitleFunction : public ExtensionActionFunction { | 232 class ExtensionActionGetTitleFunction : public ExtensionActionFunction { |
| 233 protected: | 233 protected: |
| 234 virtual ~ExtensionActionGetTitleFunction() {} | 234 virtual ~ExtensionActionGetTitleFunction() {} |
| 235 virtual bool RunExtensionAction() OVERRIDE; | 235 virtual bool RunExtensionAction() override; |
| 236 }; | 236 }; |
| 237 | 237 |
| 238 // getPopup | 238 // getPopup |
| 239 class ExtensionActionGetPopupFunction : public ExtensionActionFunction { | 239 class ExtensionActionGetPopupFunction : public ExtensionActionFunction { |
| 240 protected: | 240 protected: |
| 241 virtual ~ExtensionActionGetPopupFunction() {} | 241 virtual ~ExtensionActionGetPopupFunction() {} |
| 242 virtual bool RunExtensionAction() OVERRIDE; | 242 virtual bool RunExtensionAction() override; |
| 243 }; | 243 }; |
| 244 | 244 |
| 245 // getBadgeText | 245 // getBadgeText |
| 246 class ExtensionActionGetBadgeTextFunction : public ExtensionActionFunction { | 246 class ExtensionActionGetBadgeTextFunction : public ExtensionActionFunction { |
| 247 protected: | 247 protected: |
| 248 virtual ~ExtensionActionGetBadgeTextFunction() {} | 248 virtual ~ExtensionActionGetBadgeTextFunction() {} |
| 249 virtual bool RunExtensionAction() OVERRIDE; | 249 virtual bool RunExtensionAction() override; |
| 250 }; | 250 }; |
| 251 | 251 |
| 252 // getBadgeBackgroundColor | 252 // getBadgeBackgroundColor |
| 253 class ExtensionActionGetBadgeBackgroundColorFunction | 253 class ExtensionActionGetBadgeBackgroundColorFunction |
| 254 : public ExtensionActionFunction { | 254 : public ExtensionActionFunction { |
| 255 protected: | 255 protected: |
| 256 virtual ~ExtensionActionGetBadgeBackgroundColorFunction() {} | 256 virtual ~ExtensionActionGetBadgeBackgroundColorFunction() {} |
| 257 virtual bool RunExtensionAction() OVERRIDE; | 257 virtual bool RunExtensionAction() override; |
| 258 }; | 258 }; |
| 259 | 259 |
| 260 // | 260 // |
| 261 // browserAction.* aliases for supported browserAction APIs. | 261 // browserAction.* aliases for supported browserAction APIs. |
| 262 // | 262 // |
| 263 | 263 |
| 264 class BrowserActionSetIconFunction : public ExtensionActionSetIconFunction { | 264 class BrowserActionSetIconFunction : public ExtensionActionSetIconFunction { |
| 265 public: | 265 public: |
| 266 DECLARE_EXTENSION_FUNCTION("browserAction.setIcon", BROWSERACTION_SETICON) | 266 DECLARE_EXTENSION_FUNCTION("browserAction.setIcon", BROWSERACTION_SETICON) |
| 267 | 267 |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 361 public content::NotificationObserver { | 361 public content::NotificationObserver { |
| 362 public: | 362 public: |
| 363 DECLARE_EXTENSION_FUNCTION("browserAction.openPopup", | 363 DECLARE_EXTENSION_FUNCTION("browserAction.openPopup", |
| 364 BROWSERACTION_OPEN_POPUP) | 364 BROWSERACTION_OPEN_POPUP) |
| 365 BrowserActionOpenPopupFunction(); | 365 BrowserActionOpenPopupFunction(); |
| 366 | 366 |
| 367 private: | 367 private: |
| 368 virtual ~BrowserActionOpenPopupFunction() {} | 368 virtual ~BrowserActionOpenPopupFunction() {} |
| 369 | 369 |
| 370 // ExtensionFunction: | 370 // ExtensionFunction: |
| 371 virtual bool RunAsync() OVERRIDE; | 371 virtual bool RunAsync() override; |
| 372 | 372 |
| 373 virtual void Observe(int type, | 373 virtual void Observe(int type, |
| 374 const content::NotificationSource& source, | 374 const content::NotificationSource& source, |
| 375 const content::NotificationDetails& details) OVERRIDE; | 375 const content::NotificationDetails& details) override; |
| 376 void OpenPopupTimedOut(); | 376 void OpenPopupTimedOut(); |
| 377 | 377 |
| 378 content::NotificationRegistrar registrar_; | 378 content::NotificationRegistrar registrar_; |
| 379 bool response_sent_; | 379 bool response_sent_; |
| 380 | 380 |
| 381 DISALLOW_COPY_AND_ASSIGN(BrowserActionOpenPopupFunction); | 381 DISALLOW_COPY_AND_ASSIGN(BrowserActionOpenPopupFunction); |
| 382 }; | 382 }; |
| 383 | 383 |
| 384 } // namespace extensions | 384 } // namespace extensions |
| 385 | 385 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 442 class PageActionGetPopupFunction | 442 class PageActionGetPopupFunction |
| 443 : public extensions::ExtensionActionGetPopupFunction { | 443 : public extensions::ExtensionActionGetPopupFunction { |
| 444 public: | 444 public: |
| 445 DECLARE_EXTENSION_FUNCTION("pageAction.getPopup", PAGEACTION_GETPOPUP) | 445 DECLARE_EXTENSION_FUNCTION("pageAction.getPopup", PAGEACTION_GETPOPUP) |
| 446 | 446 |
| 447 protected: | 447 protected: |
| 448 virtual ~PageActionGetPopupFunction() {} | 448 virtual ~PageActionGetPopupFunction() {} |
| 449 }; | 449 }; |
| 450 | 450 |
| 451 #endif // CHROME_BROWSER_EXTENSIONS_API_EXTENSION_ACTION_EXTENSION_ACTION_API_H
_ | 451 #endif // CHROME_BROWSER_EXTENSIONS_API_EXTENSION_ACTION_EXTENSION_ACTION_API_H
_ |
| OLD | NEW |