diff options
author | aa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-15 06:36:08 +0000 |
---|---|---|
committer | aa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-15 06:36:08 +0000 |
commit | 83fe23a3ff26c5dea371ce94f6a909c4d081b145 (patch) | |
tree | 5117b7c3928d608f51f31a3279997e2716db6110 /chrome/browser/browser.cc | |
parent | 8d34c475c53b27511a912880aebea627ad651625 (diff) | |
download | chromium_src-83fe23a3ff26c5dea371ce94f6a909c4d081b145.zip chromium_src-83fe23a3ff26c5dea371ce94f6a909c4d081b145.tar.gz chromium_src-83fe23a3ff26c5dea371ce94f6a909c4d081b145.tar.bz2 |
Reverting r29095 (removes wrench integration for
browser actions).
TBR=mpcomplete@chromium.org
BUG=24379,24671
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@29097 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/browser.cc')
-rw-r--r-- | chrome/browser/browser.cc | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/chrome/browser/browser.cc b/chrome/browser/browser.cc index 3dcd0fb..60a78ce 100644 --- a/chrome/browser/browser.cc +++ b/chrome/browser/browser.cc @@ -137,6 +137,8 @@ Browser::Browser(Type type, Profile* profile) NotificationService::AllSources()); registrar_.Add(this, NotificationType::EXTENSION_UPDATE_DISABLED, NotificationService::AllSources()); + registrar_.Add(this, NotificationType::EXTENSION_LOADED, + NotificationService::AllSources()); registrar_.Add(this, NotificationType::EXTENSION_UNLOADED, NotificationService::AllSources()); registrar_.Add(this, NotificationType::EXTENSION_PROCESS_CRASHED, @@ -1467,6 +1469,27 @@ void Browser::ExecuteCommandWithDisposition( // Browser, CommandUpdater::CommandUpdaterDelegate implementation: void Browser::ExecuteCommand(int id) { + if (id >= IDC_BROWSER_ACTION_FIRST && id <= IDC_BROWSER_ACTION_LAST) { + ExtensionsService* service = profile_->GetExtensionsService(); + DCHECK(service); // No browser action command should have been created + // in this window. + + // Go find the browser action in question. + std::vector<ExtensionAction*> browser_actions = + service->GetBrowserActions(false); // false means no popup actions. + for (size_t i = 0; i < browser_actions.size(); ++i) { + if (browser_actions[i]->command_id() == id) { + ExtensionBrowserEventRouter::GetInstance()->BrowserActionExecuted( + profile_, browser_actions[i]->extension_id(), this); + return; + } + } + + // Could not find the command in question. Perhaps it went away while the + // menu was open? More likely, it is a bug. + LOG(WARNING) << "Unknown browser action executed: " << id; + } + ExecuteCommandWithDisposition(id, CURRENT_TAB); } @@ -2167,6 +2190,16 @@ void Browser::Observe(NotificationType type, break; } + case NotificationType::EXTENSION_LOADED: { + // Enable the browser action for the extension, if it has one. + Extension* extension = Details<Extension>(details).ptr(); + if (extension->browser_action()) { + command_updater_.UpdateCommandEnabled( + extension->browser_action()->command_id(), true); + } + break; + } + case NotificationType::EXTENSION_UNLOADED: { window()->GetLocationBar()->InvalidatePageActions(); @@ -2181,6 +2214,12 @@ void Browser::Observe(NotificationType type, } } + // Disable the browser action for the extension, if it has one. + if (extension->browser_action()) { + command_updater_.UpdateCommandEnabled( + extension->browser_action()->command_id(), false); + } + break; } @@ -2338,6 +2377,17 @@ void Browser::InitCommandState() { command_updater_.UpdateCommandEnabled(IDC_CONTROL_PANEL, true); #endif + // Set up any browser action commands that are installed. + ExtensionsService* service = profile()->GetExtensionsService(); + if (service) { + std::vector<ExtensionAction*> browser_actions = + service->GetBrowserActions(false); // false means no popup actions. + for (size_t i = 0; i < browser_actions.size(); ++i) { + command_updater_.UpdateCommandEnabled(browser_actions[i]->command_id(), + true); + } + } + // Initialize other commands based on the window type. { bool normal_window = type() == TYPE_NORMAL; |