diff options
author | skerner@chromium.org <skerner@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-28 00:10:29 +0000 |
---|---|---|
committer | skerner@chromium.org <skerner@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-28 00:10:29 +0000 |
commit | e478d670823e9c72dc00bf39123c8b19606510de (patch) | |
tree | bd8a898e9139d0960142889714e35c719d90b200 /chrome/browser/extensions/extension_page_actions_module.cc | |
parent | 3a3a617805faf1f681155fdfddd2de0b47a4244f (diff) | |
download | chromium_src-e478d670823e9c72dc00bf39123c8b19606510de.zip chromium_src-e478d670823e9c72dc00bf39123c8b19606510de.tar.gz chromium_src-e478d670823e9c72dc00bf39123c8b19606510de.tar.bz2 |
Allow extensions to add, remove, or change their page action popup.
A similar change will be made for browser action popups.
BUG=27526
TEST=Added unit tests. Manual testing on linux.
Review URL: http://codereview.chromium.org/545068
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@37353 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/extension_page_actions_module.cc')
-rw-r--r-- | chrome/browser/extensions/extension_page_actions_module.cc | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/chrome/browser/extensions/extension_page_actions_module.cc b/chrome/browser/extensions/extension_page_actions_module.cc index ace9317..1379b2f 100644 --- a/chrome/browser/extensions/extension_page_actions_module.cc +++ b/chrome/browser/extensions/extension_page_actions_module.cc @@ -192,6 +192,29 @@ bool PageActionSetTitleFunction::RunImpl() { return true; } +bool PageActionSetPopupFunction::RunImpl() { + EXTENSION_FUNCTION_VALIDATE(args_->IsType(Value::TYPE_DICTIONARY)); + const DictionaryValue* args = args_as_dictionary(); + + int tab_id; + EXTENSION_FUNCTION_VALIDATE(args->GetInteger(L"tabId", &tab_id)); + if (!InitCommon(tab_id)) + return false; + + // TODO(skerner): Consider allowing null and undefined to mean the popup + // should be removed. + std::string popup_string; + EXTENSION_FUNCTION_VALIDATE(args->GetString(L"popup", &popup_string)); + + GURL popup_url; + if (!popup_string.empty()) + popup_url = GetExtension()->GetResourceURL(popup_string); + + page_action_->SetPopupUrl(tab_id, popup_url); + contents_->PageActionStateChanged(); + return true; +} + // Not currently exposed to extensions. To re-enable, add mapping in // extension_function_dispatcher. bool PageActionSetBadgeBackgroundColorFunction::RunImpl() { |