diff options
author | mpcomplete@chromium.org <mpcomplete@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-01 18:06:47 +0000 |
---|---|---|
committer | mpcomplete@chromium.org <mpcomplete@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-01 18:06:47 +0000 |
commit | ec9ac0df1c02dc01550b1020ef7e74bd795a2008 (patch) | |
tree | 818d466044a5b587157b02c384e2b84a505415aa /chrome/common/extensions | |
parent | 4d9ae4ab9dd6d4f27c5cef5481f41979b3d58d1b (diff) | |
download | chromium_src-ec9ac0df1c02dc01550b1020ef7e74bd795a2008.zip chromium_src-ec9ac0df1c02dc01550b1020ef7e74bd795a2008.tar.gz chromium_src-ec9ac0df1c02dc01550b1020ef7e74bd795a2008.tar.bz2 |
Add chrome.browserAction.setName and .setIcon.
BUG=23379
TEST=Load the print_browser_action extension from the samples test dir and click it. The icon and name should update.
Review URL: http://codereview.chromium.org/242081
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@27741 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/extensions')
-rwxr-xr-x | chrome/common/extensions/api/extension_api.json | 24 | ||||
-rw-r--r-- | chrome/common/extensions/extension.cc | 3 | ||||
-rw-r--r-- | chrome/common/extensions/extension.h | 6 | ||||
-rw-r--r-- | chrome/common/extensions/extension_action.h | 3 |
4 files changed, 36 insertions, 0 deletions
diff --git a/chrome/common/extensions/api/extension_api.json b/chrome/common/extensions/api/extension_api.json index e26a2d2..357944c 100755 --- a/chrome/common/extensions/api/extension_api.json +++ b/chrome/common/extensions/api/extension_api.json @@ -803,6 +803,30 @@ ] }, { + "namespace": "browserAction", + "types": [], + "functions": [ + { + "name": "setName", + "type": "function", + "description": "Sets the extension's browser action name.", + "parameters": [ + {"type": "string", "name": "name", "description": "The string the browser action should display when moused over.", optional: false} + ] + }, + { + "name": "setIcon", + "type": "function", + "description": "Sets icon", + "parameters": [ + {"type": "integer", "name": "iconId", "minimum": 0, "optional": true, "description": "A zero-based index into the |icons| vector specified in the manifest. This id is useful to represent different browser action states. Example: A GMail checker could have a 'new email' icon and a 'no unread email' icon."} + ] + } + ], + "events": [ + ] + }, + { "namespace": "bookmarks", "types": [ { diff --git a/chrome/common/extensions/extension.cc b/chrome/common/extensions/extension.cc index 07fa897..9760efe 100644 --- a/chrome/common/extensions/extension.cc +++ b/chrome/common/extensions/extension.cc @@ -960,6 +960,9 @@ bool Extension::InitFromValue(const DictionaryValue& source, bool require_id, ExtensionAction::BROWSER_ACTION)); if (!browser_action_.get()) return false; // Failed to parse browser action definition. + + browser_action_state_.reset( + new ExtensionActionState(browser_action_->name(), 0)); } // Initialize the permissions (optional). diff --git a/chrome/common/extensions/extension.h b/chrome/common/extensions/extension.h index af16698..d77e5e27 100644 --- a/chrome/common/extensions/extension.h +++ b/chrome/common/extensions/extension.h @@ -196,6 +196,9 @@ class Extension { const UserScriptList& content_scripts() const { return content_scripts_; } const ExtensionActionMap& page_actions() const { return page_actions_; } ExtensionAction* browser_action() const { return browser_action_.get(); } + ExtensionActionState* browser_action_state() { + return browser_action_state_.get(); + } const std::vector<PrivacyBlacklistInfo>& privacy_blacklists() const { return privacy_blacklists_; } @@ -340,6 +343,9 @@ class Extension { // The extension's browser action, if any. scoped_ptr<ExtensionAction> browser_action_; + // The state of the browser action. Valid iff browser_action_ is non-NULL. + scoped_ptr<ExtensionActionState> browser_action_state_; + // Optional list of privacy blacklistrom. std::vector<PrivacyBlacklistInfo> privacy_blacklists_; diff --git a/chrome/common/extensions/extension_action.h b/chrome/common/extensions/extension_action.h index 53f6124..f091487 100644 --- a/chrome/common/extensions/extension_action.h +++ b/chrome/common/extensions/extension_action.h @@ -78,7 +78,10 @@ class ExtensionActionState { } std::string title() const { return title_; } + void set_title(const std::string& title) { title_ = title; } + int icon_index() const { return icon_index_; } + void set_icon_index(int icon_index) { icon_index_ = icon_index; } private: // The title to use. |