| Index: chrome/browser/ui/gtk/browser_actions_toolbar_gtk.cc
|
| diff --git a/chrome/browser/ui/gtk/browser_actions_toolbar_gtk.cc b/chrome/browser/ui/gtk/browser_actions_toolbar_gtk.cc
|
| index 34f300ac07e04720260efa3d538186ec84698fb7..3db47cb27f65345ada31c75b61944a0db2ddf1f4 100644
|
| --- a/chrome/browser/ui/gtk/browser_actions_toolbar_gtk.cc
|
| +++ b/chrome/browser/ui/gtk/browser_actions_toolbar_gtk.cc
|
| @@ -24,6 +24,7 @@
|
| #include "chrome/browser/profiles/profile.h"
|
| #include "chrome/browser/sessions/session_tab_helper.h"
|
| #include "chrome/browser/ui/browser.h"
|
| +#include "chrome/browser/ui/browser_list.h"
|
| #include "chrome/browser/ui/gtk/browser_window_gtk.h"
|
| #include "chrome/browser/ui/gtk/custom_button.h"
|
| #include "chrome/browser/ui/gtk/extensions/extension_popup_gtk.h"
|
| @@ -254,12 +255,17 @@ class BrowserActionButton : public content::NotificationObserver,
|
| private:
|
| // Activate the browser action.
|
| void Activate(GtkWidget* widget) {
|
| + Activate(widget, true);
|
| + }
|
| +
|
| + void Activate(GtkWidget* widget, bool allow_grant) {
|
| ExtensionToolbarModel* model = toolbar_->model();
|
| const Extension* extension = extension_;
|
| Browser* browser = toolbar_->browser();
|
| GURL popup_url;
|
|
|
| - switch (model->ExecuteBrowserAction(extension, browser, &popup_url)) {
|
| + switch (model->ExecuteBrowserAction(
|
| + extension, browser, &popup_url, allow_grant)) {
|
| case ExtensionToolbarModel::ACTION_NONE:
|
| break;
|
| case ExtensionToolbarModel::ACTION_SHOW_POPUP:
|
| @@ -669,14 +675,17 @@ void BrowserActionsToolbarGtk::CreateButtonForExtension(
|
| UpdateVisibility();
|
| }
|
|
|
| -GtkWidget* BrowserActionsToolbarGtk::GetBrowserActionWidget(
|
| +BrowserActionButton* BrowserActionsToolbarGtk::GetBrowserActionButton(
|
| const Extension* extension) {
|
| ExtensionButtonMap::iterator it = extension_button_map_.find(
|
| extension->id());
|
| - if (it == extension_button_map_.end())
|
| - return NULL;
|
| + return it == extension_button_map_.end() ? NULL : it->second.get();
|
| +}
|
|
|
| - return it->second.get()->widget();
|
| +GtkWidget* BrowserActionsToolbarGtk::GetBrowserActionWidget(
|
| + const Extension* extension) {
|
| + BrowserActionButton* button = GetBrowserActionButton(extension);
|
| + return button == NULL ? NULL : button->widget();
|
| }
|
|
|
| void BrowserActionsToolbarGtk::RemoveButtonForExtension(
|
| @@ -768,6 +777,25 @@ void BrowserActionsToolbarGtk::BrowserActionMoved(const Extension* extension,
|
| gtk_box_reorder_child(GTK_BOX(button_hbox_.get()), button_widget, index);
|
| }
|
|
|
| +void BrowserActionsToolbarGtk::BrowserActionShowPopup(
|
| + const Extension* extension) {
|
| + // Do not override other popups and only show in active window.
|
| + if (ExtensionPopupGtk::get_current_extension_popup() ||
|
| + BrowserList::GetInstance(chrome::GetActiveDesktop())->GetLastActive() !=
|
| + browser_) {
|
| + return;
|
| + }
|
| +
|
| + BrowserActionButton* button = GetBrowserActionButton(extension);
|
| + if (button == NULL || button->widget() == NULL)
|
| + return;
|
| +
|
| + GtkWidget* anchor = button->widget();
|
| + if (!gtk_widget_get_visible(anchor))
|
| + anchor = button->toolbar_->chevron();
|
| + button->Activate(anchor, false);
|
| +}
|
| +
|
| void BrowserActionsToolbarGtk::ModelLoaded() {
|
| SetContainerWidth();
|
| }
|
| @@ -1077,13 +1105,13 @@ gboolean BrowserActionsToolbarGtk::OnOverflowMenuButtonPress(
|
| item_index = model_->IncognitoIndexToOriginal(item_index);
|
|
|
| const Extension* extension = model_->toolbar_items()[item_index].get();
|
| - ExtensionButtonMap::iterator it = extension_button_map_.find(extension->id());
|
| - if (it == extension_button_map_.end()) {
|
| + BrowserActionButton* button = GetBrowserActionButton(extension);
|
| + if (button == NULL) {
|
| NOTREACHED();
|
| return FALSE;
|
| }
|
|
|
| - MenuGtk* menu = it->second.get()->GetContextMenu();
|
| + MenuGtk* menu = button->GetContextMenu();
|
| if (!menu)
|
| return FALSE;
|
|
|
|
|