Index: chrome/browser/ui/views/toolbar/browser_actions_container.cc |
diff --git a/chrome/browser/ui/views/toolbar/browser_actions_container.cc b/chrome/browser/ui/views/toolbar/browser_actions_container.cc |
index 1b591bb1d78367b66a495f27f40ffd6fb4914053..a79e8e25da9a93b3efb00e059cf042124515b6ec 100644 |
--- a/chrome/browser/ui/views/toolbar/browser_actions_container.cc |
+++ b/chrome/browser/ui/views/toolbar/browser_actions_container.cc |
@@ -66,15 +66,6 @@ const int kIconsPerMenuRow = 8; // The menu on Linux is wider. |
const int kIconsPerMenuRow = 7; |
#endif |
-// Returns the ExtensionAction for the given |extension|. |
-ExtensionAction* GetExtensionAction(const Extension& extension, |
- Profile* profile) { |
- extensions::ExtensionActionManager* action_manager = |
- extensions::ExtensionActionManager::Get(profile); |
- ExtensionAction* action = action_manager->GetBrowserAction(extension); |
- return action ? action : action_manager->GetPageAction(extension); |
-} |
- |
// A version of MenuButton with almost empty insets to fit properly on the |
// toolbar. |
class ChevronMenuButton : public views::MenuButton { |
@@ -227,6 +218,8 @@ void BrowserActionsContainer::CreateBrowserActionViews() { |
if (!model_) |
return; |
+ extensions::ExtensionActionManager* action_manager = |
+ extensions::ExtensionActionManager::Get(profile_); |
const extensions::ExtensionList& toolbar_items = model_->toolbar_items(); |
for (extensions::ExtensionList::const_iterator i(toolbar_items.begin()); |
i != toolbar_items.end(); ++i) { |
@@ -235,7 +228,7 @@ void BrowserActionsContainer::CreateBrowserActionViews() { |
BrowserActionView* view = |
new BrowserActionView(i->get(), |
- GetExtensionAction(*i->get(), profile_), |
+ action_manager->GetExtensionAction(**i), |
browser_, |
this); |
browser_action_views_.push_back(view); |
@@ -813,7 +806,8 @@ void BrowserActionsContainer::ToolbarExtensionAdded(const Extension* extension, |
index = model_->OriginalIndexToIncognito(index); |
BrowserActionView* view = |
new BrowserActionView(extension, |
- GetExtensionAction(*extension, profile_), |
+ extensions::ExtensionActionManager::Get(profile_)-> |
+ GetExtensionAction(*extension), |
browser_, |
this); |
browser_action_views_.insert(browser_action_views_.begin() + index, view); |
@@ -910,8 +904,14 @@ void BrowserActionsContainer::ToolbarExtensionUpdated( |
} |
bool BrowserActionsContainer::ShowExtensionActionPopup( |
- const Extension* extension) { |
- return ShowPopupForExtension(extension, false, false); |
+ const Extension* extension, bool grant_active_tab) { |
Peter Kasting
2014/08/27 19:41:19
Nit: One arg per line
Devlin
2014/08/27 20:47:16
Done.
|
+ // Don't override another popup, and only show in the active window. |
+ if (popup_owner_ || !browser_->window()->IsActive()) |
+ return false; |
+ |
+ BrowserActionView* view = GetViewForExtension(extension); |
+ return view ? view->view_controller()->ExecuteAction( |
+ ExtensionPopup::SHOW, grant_active_tab) : false; |
Peter Kasting
2014/08/27 19:41:19
Nit: This seems a little briefer:
return view &
Devlin
2014/08/27 20:47:16
Done.
|
} |
void BrowserActionsContainer::ToolbarVisibleCountChanged() { |
@@ -932,6 +932,10 @@ void BrowserActionsContainer::ToolbarHighlightModeChanged( |
Animate(gfx::Tween::LINEAR, browser_action_views_.size()); |
} |
+Browser* BrowserActionsContainer::GetBrowser() { |
+ return browser_; |
+} |
+ |
void BrowserActionsContainer::LoadImages() { |
ui::ThemeProvider* tp = GetThemeProvider(); |
if (!tp || !chevron_) |
@@ -1054,26 +1058,6 @@ bool BrowserActionsContainer::ShouldDisplayBrowserAction( |
extensions::util::IsIncognitoEnabled(extension->id(), profile_); |
} |
-bool BrowserActionsContainer::ShowPopupForExtension( |
- const extensions::Extension* extension, |
- bool grant_tab_permissions, |
- bool can_override) { |
- // If the popup cannot override other views, then no other popups can be |
- // showing, and it must be shown in the active widow with a visible toolbar. |
- // TODO(justinlin): Remove toolbar check when http://crbug.com/308645 is |
- // fixed. |
- if (!can_override && |
- (popup_owner_ || |
- !browser_->window()->IsActive() || |
- !browser_->window()->IsToolbarVisible())) { |
- return false; |
- } |
- |
- BrowserActionView* view = GetViewForExtension(extension); |
- return view ? view->view_controller()->ExecuteAction( |
- ExtensionPopup::SHOW, grant_tab_permissions) : false; |
-} |
- |
BrowserActionView* BrowserActionsContainer::GetViewForExtension( |
const Extension* extension) { |
for (BrowserActionViews::iterator view = browser_action_views_.begin(); |