Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(874)

Unified Diff: chrome/browser/extensions/extension_page_actions_module.cc

Issue 327007: Revert 29861 since this fail on the interactive... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/extension_page_actions_module.cc
===================================================================
--- chrome/browser/extensions/extension_page_actions_module.cc (revision 29866)
+++ chrome/browser/extensions/extension_page_actions_module.cc (working copy)
@@ -21,12 +21,12 @@
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 @@
}
}
- 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 @@
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();
« no previous file with comments | « chrome/browser/extensions/extension_browsertests_misc.cc ('k') | chrome/browser/gtk/location_bar_view_gtk.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698