Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3397)

Unified Diff: chrome/browser/ui/views/toolbar/browser_actions_container.cc

Issue 489183005: Make a ShowExtensionActionPopup function (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Peter's Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 04c4cc0ccdfbf39eb0a6891776cead795fd2ae7f..e62a333227531fc16c019dcc016c4cec9fbb7928 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 {
@@ -226,6 +217,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) {
@@ -234,7 +227,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);
@@ -812,7 +805,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);
@@ -909,8 +903,15 @@ void BrowserActionsContainer::ToolbarExtensionUpdated(
}
bool BrowserActionsContainer::ShowExtensionActionPopup(
- const Extension* extension) {
- return ShowPopupForExtension(extension, false, false);
+ const Extension* extension,
+ bool grant_active_tab) {
+ // 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);
}
void BrowserActionsContainer::ToolbarVisibleCountChanged() {
@@ -931,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_)
@@ -1053,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();
« no previous file with comments | « chrome/browser/ui/views/toolbar/browser_actions_container.h ('k') | chrome/browser/ui/views/toolbar/toolbar_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698