Chromium Code Reviews| Index: chrome/browser/ui/views/browser_actions_container.cc |
| diff --git a/chrome/browser/ui/views/browser_actions_container.cc b/chrome/browser/ui/views/browser_actions_container.cc |
| index 850189762babaf027940beb6b62b50d63e4e86c2..d3f1125b2f0a1ab817b94602d233f5a9d51aaa81 100644 |
| --- a/chrome/browser/ui/views/browser_actions_container.cc |
| +++ b/chrome/browser/ui/views/browser_actions_container.cc |
| @@ -13,6 +13,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/tabs/tab_strip_model.h" |
| #include "chrome/browser/ui/view_ids.h" |
| #include "chrome/browser/ui/views/browser_action_view.h" |
| @@ -686,6 +687,26 @@ void BrowserActionsContainer::BrowserActionMoved(const Extension* extension, |
| SchedulePaint(); |
| } |
| +void BrowserActionsContainer::BrowserActionShowPopup( |
| + const extensions::Extension* extension) { |
| + // Do not override other popups and only show in active window. |
| + if (popup_ || |
| + BrowserList::GetInstance(chrome::GetActiveDesktop())->GetLastActive() != |
|
sky
2013/10/16 14:19:25
browser_->window()->IsActive()?
justinlin
2013/10/16 19:31:29
Done.
|
| + browser_) { |
| + return; |
| + } |
| + |
| + BrowserActionButton* button = NULL; |
| + for (BrowserActionViews::iterator it = browser_action_views_.begin(); |
| + it != browser_action_views_.end(); ++it) { |
| + if ((*it)->button()->extension() == extension) { |
| + button = (*it)->button(); |
|
sky
2013/10/16 14:19:25
How about showing right here and returning?
justinlin
2013/10/16 19:31:29
Done.
|
| + } |
| + } |
| + if (button != NULL) |
| + ShowPopup(button, ExtensionPopup::SHOW, false); |
| +} |
| + |
| void BrowserActionsContainer::ModelLoaded() { |
| SetContainerWidth(); |
| } |
| @@ -815,9 +836,17 @@ bool BrowserActionsContainer::ShouldDisplayBrowserAction( |
| void BrowserActionsContainer::ShowPopup( |
| BrowserActionButton* button, |
| ExtensionPopup::ShowAction show_action) { |
| + ShowPopup(button, show_action, true); |
| +} |
| + |
| +void BrowserActionsContainer::ShowPopup( |
| + BrowserActionButton* button, |
| + ExtensionPopup::ShowAction show_action, |
| + bool should_grant) { |
| const Extension* extension = button->extension(); |
| GURL popup_url; |
| - if (model_->ExecuteBrowserAction(extension, browser_, &popup_url) != |
| + if (model_->ExecuteBrowserAction( |
| + extension, browser_, &popup_url, should_grant) != |
| ExtensionToolbarModel::ACTION_SHOW_POPUP) { |
| return; |
| } |
| @@ -845,5 +874,9 @@ void BrowserActionsContainer::ShowPopup( |
| show_action); |
| popup_->GetWidget()->AddObserver(this); |
| popup_button_ = button; |
| - popup_button_->SetButtonPushed(); |
| + |
| + // If the popup was triggered in such a way that the tab should not be |
| + // granted tab permissions, then it was not by a user click. |
|
Finnur
2013/10/16 15:01:26
nit: double negative. Can you reword?
justinlin
2013/10/16 19:31:29
Done.
|
| + if (should_grant) |
| + popup_button_->SetButtonPushed(); |
| } |