| 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..5227f3e4b58af5e6ecfd53218c6e91ee73c5fe1e 100644
|
| --- a/chrome/browser/ui/gtk/browser_actions_toolbar_gtk.cc
|
| +++ b/chrome/browser/ui/gtk/browser_actions_toolbar_gtk.cc
|
| @@ -252,21 +252,25 @@ class BrowserActionButton : public content::NotificationObserver,
|
| }
|
|
|
| private:
|
| - // Activate the browser action.
|
| - void Activate(GtkWidget* widget) {
|
| + // Activate the browser action. Returns true if a popup was shown. Showing the
|
| + // popup will grant tab permissions if |should_grant| is true. Popup's shown
|
| + // via an API should not grant permissions.
|
| + bool Activate(GtkWidget* widget, bool should_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, should_grant)) {
|
| case ExtensionToolbarModel::ACTION_NONE:
|
| break;
|
| case ExtensionToolbarModel::ACTION_SHOW_POPUP:
|
| ExtensionPopupGtk::Show(popup_url, browser, widget,
|
| ExtensionPopupGtk::SHOW);
|
| - break;
|
| + return true;
|
| }
|
| + return false;
|
| }
|
|
|
| // MenuGtk::Delegate implementation.
|
| @@ -323,7 +327,7 @@ class BrowserActionButton : public content::NotificationObserver,
|
|
|
| static void OnClicked(GtkWidget* widget, BrowserActionButton* button) {
|
| if (button->enabled_)
|
| - button->Activate(widget);
|
| + button->Activate(widget, true);
|
| }
|
|
|
| static gboolean OnExposeEvent(GtkWidget* widget,
|
| @@ -364,7 +368,7 @@ class BrowserActionButton : public content::NotificationObserver,
|
| // The anchor might be in the overflow menu. Then we point to the chevron.
|
| if (!gtk_widget_get_visible(anchor))
|
| anchor = button->toolbar_->chevron();
|
| - button->Activate(anchor);
|
| + button->Activate(anchor, true);
|
| return TRUE;
|
| }
|
|
|
| @@ -669,14 +673,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 +775,24 @@ void BrowserActionsToolbarGtk::BrowserActionMoved(const Extension* extension,
|
| gtk_box_reorder_child(GTK_BOX(button_hbox_.get()), button_widget, index);
|
| }
|
|
|
| +bool BrowserActionsToolbarGtk::BrowserActionShowPopup(
|
| + const Extension* extension) {
|
| + // Do not override other popups and only show in active window.
|
| + if (ExtensionPopupGtk::get_current_extension_popup() ||
|
| + !browser_->window()->IsActive()) {
|
| + return false;
|
| + }
|
| +
|
| + BrowserActionButton* button = GetBrowserActionButton(extension);
|
| + if (button == NULL || button->widget() == NULL)
|
| + return false;
|
| +
|
| + GtkWidget* anchor = button->widget();
|
| + if (!gtk_widget_get_visible(anchor))
|
| + anchor = button->toolbar_->chevron();
|
| + return button->Activate(anchor, false);
|
| +}
|
| +
|
| void BrowserActionsToolbarGtk::ModelLoaded() {
|
| SetContainerWidth();
|
| }
|
| @@ -807,7 +832,8 @@ void BrowserActionsToolbarGtk::ExecuteCommand(int command_id, int event_flags) {
|
| const Extension* extension = model_->toolbar_items()[command_id].get();
|
| GURL popup_url;
|
|
|
| - switch (model_->ExecuteBrowserAction(extension, browser(), &popup_url)) {
|
| + switch (model_->ExecuteBrowserAction(
|
| + extension,browser(), &popup_url, true)) {
|
| case ExtensionToolbarModel::ACTION_NONE:
|
| break;
|
| case ExtensionToolbarModel::ACTION_SHOW_POPUP:
|
| @@ -1077,13 +1103,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;
|
|
|
|
|