Chromium Code Reviews| 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_ACTIONS_API_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_EXTENSION_ACTION_EXTENSION_ACTIONS_API_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_API_EXTENSION_ACTION_EXTENSION_ACTIONS_API_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_API_EXTENSION_ACTION_EXTENSION_ACTIONS_API_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "chrome/browser/extensions/extension_function.h" | 9 #include "chrome/browser/extensions/extension_function.h" |
| 10 #include "chrome/common/extensions/extension_action.h" | 10 #include "chrome/common/extensions/extension_action.h" |
| 11 | 11 |
| 12 namespace base { | 12 namespace base { |
| 13 class DictionaryValue; | 13 class DictionaryValue; |
| 14 } | 14 } |
| 15 class ExtensionTabHelper; | |
| 15 class TabContents; | 16 class TabContents; |
| 16 | 17 |
| 17 // Implementation of the browserAction, pageAction, and scriptBadge APIs. | 18 // Implementation of the browserAction, pageAction, and scriptBadge APIs. |
| 18 // | 19 // |
| 19 // Divergent behaviour between the three is minimal (pageAction and scriptBadge | 20 // Divergent behaviour between the three is minimal (pageAction and scriptBadge |
| 20 // have required tabIds while browserAction's are optional, they have different | 21 // have required tabIds while browserAction's are optional, they have different |
| 21 // internal browser notification requirements, and not all functions are defined | 22 // internal browser notification requirements, and not all functions are defined |
| 22 // for all APIs). | 23 // for all APIs). |
| 23 class ExtensionActionFunction : public SyncExtensionFunction { | 24 class ExtensionActionFunction : public SyncExtensionFunction { |
| 24 public: | 25 public: |
| 25 static bool ParseCSSColorString(const std::string& color_string, | 26 static bool ParseCSSColorString(const std::string& color_string, |
| 26 SkColor* result); | 27 SkColor* result); |
| 27 | 28 |
| 28 protected: | 29 protected: |
| 29 ExtensionActionFunction(); | 30 ExtensionActionFunction(); |
| 30 virtual ~ExtensionActionFunction(); | 31 virtual ~ExtensionActionFunction(); |
| 31 virtual bool RunImpl() OVERRIDE; | 32 virtual bool RunImpl() OVERRIDE; |
| 32 virtual bool RunExtensionAction() = 0; | 33 virtual bool RunExtensionAction() = 0; |
| 33 void NotifyChange(); | 34 void NotifyChange(); |
| 34 void NotifyBrowserActionChange(); | 35 void NotifyBrowserActionChange(); |
| 35 void NotifyLocationBarChange(); | 36 void NotifyLocationBarChange(); |
| 36 bool SetVisible(bool visible); | 37 bool SetVisible(bool visible); |
| 37 | 38 |
| 39 // Extension-related information for |tab_id_|. | |
| 40 // CHECK-fails if there is no tab. | |
| 41 ExtensionTabHelper& tab_helper() const; | |
|
Aaron Boodman
2012/07/03 01:29:31
These are supposed to be const-ref in Chrome.
Jeffrey Yasskin
2012/07/10 21:52:33
I don't see that in the style guide. http://googl
Aaron Boodman
2012/07/10 22:50:46
Hm, ok.
| |
| 42 | |
| 38 // All the extension action APIs take a single argument called details that | 43 // All the extension action APIs take a single argument called details that |
| 39 // is a dictionary. | 44 // is a dictionary. |
| 40 base::DictionaryValue* details_; | 45 base::DictionaryValue* details_; |
| 41 | 46 |
| 42 // The tab id the extension action function should apply to, if any, or | 47 // The tab id the extension action function should apply to, if any, or |
| 43 // kDefaultTabId if none was specified. | 48 // kDefaultTabId if none was specified. |
| 44 int tab_id_; | 49 int tab_id_; |
| 45 | 50 |
| 46 // Tab content for |tab_id_| if one exists. | 51 // Tab content for |tab_id_| if one exists. |
| 47 TabContents* contents_; | 52 TabContents* contents_; |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 130 | 135 |
| 131 // getBadgeBackgroundColor | 136 // getBadgeBackgroundColor |
| 132 class ExtensionActionGetBadgeBackgroundColorFunction | 137 class ExtensionActionGetBadgeBackgroundColorFunction |
| 133 : public ExtensionActionFunction { | 138 : public ExtensionActionFunction { |
| 134 protected: | 139 protected: |
| 135 virtual ~ExtensionActionGetBadgeBackgroundColorFunction() {} | 140 virtual ~ExtensionActionGetBadgeBackgroundColorFunction() {} |
| 136 virtual bool RunExtensionAction() OVERRIDE; | 141 virtual bool RunExtensionAction() OVERRIDE; |
| 137 }; | 142 }; |
| 138 | 143 |
| 139 #endif // CHROME_BROWSER_EXTENSIONS_API_EXTENSION_ACTION_EXTENSION_ACTIONS_API_ H_ | 144 #endif // CHROME_BROWSER_EXTENSIONS_API_EXTENSION_ACTION_EXTENSION_ACTIONS_API_ H_ |
| OLD | NEW |