| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_BROWSER_ACTIONS_API_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_BROWSER_ACTIONS_API_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_BROWSER_ACTIONS_API_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_BROWSER_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 class ExtensionAction; | 12 class ExtensionAction; |
| 13 | 13 |
| 14 namespace base { | 14 namespace base { |
| 15 class DictionaryValue; | 15 class DictionaryValue; |
| 16 } | 16 } |
| 17 | 17 |
| 18 // Base class for chrome.browserAction.* APIs. | 18 // Base class for chrome.browserAction.* APIs. |
| 19 class BrowserActionFunction : public SyncExtensionFunction { | 19 class BrowserActionFunction : public SyncExtensionFunction { |
| 20 protected: | 20 protected: |
| 21 BrowserActionFunction() | 21 BrowserActionFunction() |
| 22 : details_(NULL), | 22 : details_(NULL), |
| 23 tab_id_(ExtensionAction::kDefaultTabId), | 23 tab_id_(ExtensionAction::kDefaultTabId), |
| 24 browser_action_(NULL) {} | 24 browser_action_(NULL) {} |
| 25 virtual ~BrowserActionFunction() {} | 25 virtual ~BrowserActionFunction() {} |
| 26 virtual bool RunImpl(); | 26 virtual bool RunImpl() OVERRIDE; |
| 27 virtual bool RunBrowserAction() = 0; | 27 virtual bool RunBrowserAction() = 0; |
| 28 | 28 |
| 29 // All the browser action APIs take a single argument called details that is | 29 // All the browser action APIs take a single argument called details that is |
| 30 // a dictionary. | 30 // a dictionary. |
| 31 base::DictionaryValue* details_; | 31 base::DictionaryValue* details_; |
| 32 | 32 |
| 33 // The tab id the browser action function should apply to, if any, or | 33 // The tab id the browser action function should apply to, if any, or |
| 34 // kDefaultTabId if none was specified. | 34 // kDefaultTabId if none was specified. |
| 35 int tab_id_; | 35 int tab_id_; |
| 36 | 36 |
| 37 // The browser action for the current extension. | 37 // The browser action for the current extension. |
| 38 ExtensionAction* browser_action_; | 38 ExtensionAction* browser_action_; |
| 39 }; | 39 }; |
| 40 | 40 |
| 41 // Implement chrome.browserAction.setIcon(). | 41 // Implement chrome.browserAction.setIcon(). |
| 42 class BrowserActionSetIconFunction : public BrowserActionFunction { | 42 class BrowserActionSetIconFunction : public BrowserActionFunction { |
| 43 virtual ~BrowserActionSetIconFunction() {} | 43 virtual ~BrowserActionSetIconFunction() {} |
| 44 virtual bool RunBrowserAction(); | 44 virtual bool RunBrowserAction() OVERRIDE; |
| 45 DECLARE_EXTENSION_FUNCTION_NAME("browserAction.setIcon") | 45 DECLARE_EXTENSION_FUNCTION_NAME("browserAction.setIcon") |
| 46 }; | 46 }; |
| 47 | 47 |
| 48 // Implement chrome.browserAction.setTitle(). | 48 // Implement chrome.browserAction.setTitle(). |
| 49 class BrowserActionSetTitleFunction : public BrowserActionFunction { | 49 class BrowserActionSetTitleFunction : public BrowserActionFunction { |
| 50 virtual ~BrowserActionSetTitleFunction() {} | 50 virtual ~BrowserActionSetTitleFunction() {} |
| 51 virtual bool RunBrowserAction(); | 51 virtual bool RunBrowserAction() OVERRIDE; |
| 52 DECLARE_EXTENSION_FUNCTION_NAME("browserAction.setTitle") | 52 DECLARE_EXTENSION_FUNCTION_NAME("browserAction.setTitle") |
| 53 }; | 53 }; |
| 54 | 54 |
| 55 // Implement chrome.browserActions.setPopup(). | 55 // Implement chrome.browserActions.setPopup(). |
| 56 class BrowserActionSetPopupFunction : public BrowserActionFunction { | 56 class BrowserActionSetPopupFunction : public BrowserActionFunction { |
| 57 virtual ~BrowserActionSetPopupFunction() {} | 57 virtual ~BrowserActionSetPopupFunction() {} |
| 58 virtual bool RunBrowserAction(); | 58 virtual bool RunBrowserAction() OVERRIDE; |
| 59 DECLARE_EXTENSION_FUNCTION_NAME("browserAction.setPopup") | 59 DECLARE_EXTENSION_FUNCTION_NAME("browserAction.setPopup") |
| 60 }; | 60 }; |
| 61 | 61 |
| 62 // Implement chrome.browserAction.setBadgeText(). | 62 // Implement chrome.browserAction.setBadgeText(). |
| 63 class BrowserActionSetBadgeTextFunction : public BrowserActionFunction { | 63 class BrowserActionSetBadgeTextFunction : public BrowserActionFunction { |
| 64 virtual ~BrowserActionSetBadgeTextFunction() {} | 64 virtual ~BrowserActionSetBadgeTextFunction() {} |
| 65 virtual bool RunBrowserAction(); | 65 virtual bool RunBrowserAction() OVERRIDE; |
| 66 DECLARE_EXTENSION_FUNCTION_NAME("browserAction.setBadgeText") | 66 DECLARE_EXTENSION_FUNCTION_NAME("browserAction.setBadgeText") |
| 67 }; | 67 }; |
| 68 | 68 |
| 69 // Implement chrome.browserAction.setBadgeBackgroundColor(). | 69 // Implement chrome.browserAction.setBadgeBackgroundColor(). |
| 70 class BrowserActionSetBadgeBackgroundColorFunction | 70 class BrowserActionSetBadgeBackgroundColorFunction |
| 71 : public BrowserActionFunction { | 71 : public BrowserActionFunction { |
| 72 virtual ~BrowserActionSetBadgeBackgroundColorFunction() {} | 72 virtual ~BrowserActionSetBadgeBackgroundColorFunction() {} |
| 73 virtual bool RunBrowserAction(); | 73 virtual bool RunBrowserAction() OVERRIDE; |
| 74 DECLARE_EXTENSION_FUNCTION_NAME("browserAction.setBadgeBackgroundColor") | 74 DECLARE_EXTENSION_FUNCTION_NAME("browserAction.setBadgeBackgroundColor") |
| 75 }; | 75 }; |
| 76 | 76 |
| 77 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_BROWSER_ACTIONS_API_H_ | 77 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_BROWSER_ACTIONS_API_H_ |
| OLD | NEW |