diff options
author | finnur@chromium.org <finnur@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-23 03:01:47 +0000 |
---|---|---|
committer | finnur@chromium.org <finnur@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-23 03:01:47 +0000 |
commit | 2ea65b94fade599f63a1b8599b5977a0a57680a2 (patch) | |
tree | 1c7f804c8a15de702d5d7d5d3d79aebe604cf09e /chrome/browser/extensions/extension_page_actions_module.cc | |
parent | 21abcc74837a6cb9537a8026a1b12efc9da402f0 (diff) | |
download | chromium_src-2ea65b94fade599f63a1b8599b5977a0a57680a2.zip chromium_src-2ea65b94fade599f63a1b8599b5977a0a57680a2.tar.gz chromium_src-2ea65b94fade599f63a1b8599b5977a0a57680a2.tar.bz2 |
Revert 29861 since this fail on the interactive
linux dbg bot, for some weird reason...
Page actions that don't specify an icon (ie.
have a spelling error in the manifest, such as
icon instead of icons/default_icon) caused a
crash when they try to display their icon.
We now check when the extension tries to enable
the page action whether there are any icons to
display. If not, we don't proceed and log an
error to the console.
TBR=nsylvain
BUG=25562
TEST=Covered by browser test.
Review URL: http://codereview.chromium.org/316018
TBR=finnur@chromium.org
Review URL: http://codereview.chromium.org/327007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@29867 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 | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/chrome/browser/extensions/extension_page_actions_module.cc b/chrome/browser/extensions/extension_page_actions_module.cc index 4738891..743e0a5 100644 --- a/chrome/browser/extensions/extension_page_actions_module.cc +++ b/chrome/browser/extensions/extension_page_actions_module.cc @@ -21,12 +21,12 @@ namespace keys = extension_page_actions_module_constants; namespace { // Errors. +const char kNoExtensionError[] = "No extension with id: *."; const char kNoTabError[] = "No tab with id: *."; const char kNoPageActionError[] = "This extension has no page action specified."; const char kUrlNotActiveError[] = "This url is no longer active: *."; const char kIconIndexOutOfBounds[] = "Page action icon index out of bounds."; -const char kNoIconSpecified[] = "Page action has no icons to show."; } // TODO(EXTENSIONS_DEPRECATED): obsolete API. @@ -56,19 +56,6 @@ bool PageActionFunction::SetPageActionEnabled(bool enable) { } } - const ExtensionAction* page_action = - dispatcher()->GetExtension()->page_action(); - if (!page_action) { - error_ = kNoPageActionError; - return false; - } - - if (icon_id < 0 || - static_cast<size_t>(icon_id) >= page_action->icon_paths().size()) { - error_ = (icon_id == 0) ? kNoIconSpecified : kIconIndexOutOfBounds; - return false; - } - // Find the TabContents that contains this tab id. TabContents* contents = NULL; ExtensionTabUtil::GetTabById(tab_id, profile(), NULL, NULL, &contents, NULL); @@ -85,6 +72,22 @@ bool PageActionFunction::SetPageActionEnabled(bool enable) { return false; } + // Find our extension. + Extension* extension = NULL; + ExtensionsService* service = profile()->GetExtensionsService(); + extension = service->GetExtensionById(extension_id()); + if (!extension) { + error_ = ExtensionErrorUtils::FormatErrorMessage(kNoExtensionError, + extension_id()); + return false; + } + + const ExtensionAction* page_action = extension->page_action(); + if (!page_action) { + error_ = kNoPageActionError; + return false; + } + // Set visibility and broadcast notifications that the UI should be updated. contents->SetPageActionEnabled(page_action, enable, title, icon_id); contents->PageActionStateChanged(); |