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

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

Issue 10533086: Action box menu (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Action box menu Created 8 years, 5 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/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 eab721e90e9d2e8a4b78b715fde6be620026db65..6e9a8ccadd2c9e82ce3f52573efe79c5cc8a7316 100644
--- a/chrome/browser/ui/views/browser_actions_container.cc
+++ b/chrome/browser/ui/views/browser_actions_container.cc
@@ -127,11 +127,6 @@ void BrowserActionsContainer::Init() {
SetContainerWidth();
}
-int BrowserActionsContainer::GetCurrentTabId() const {
- TabContents* tab = chrome::GetActiveTabContents(browser_);
- return tab ? tab->restore_tab_helper()->session_id().id() : -1;
-}
-
BrowserActionView* BrowserActionsContainer::GetBrowserActionView(
ExtensionAction* action) {
for (BrowserActionViews::iterator i(browser_action_views_.begin());
@@ -157,7 +152,7 @@ void BrowserActionsContainer::CreateBrowserActionViews() {
if (!ShouldDisplayBrowserAction(*i))
continue;
- BrowserActionView* view = new BrowserActionView(*i, this);
+ BrowserActionView* view = new BrowserActionView(*i, browser_, this);
browser_action_views_.push_back(view);
AddChildView(view);
}
@@ -168,12 +163,6 @@ void BrowserActionsContainer::DeleteBrowserActionViews() {
STLDeleteElements(&browser_action_views_);
}
-void BrowserActionsContainer::OnBrowserActionVisibilityChanged() {
- SetVisible(!browser_action_views_.empty());
- owner_view_->Layout();
- owner_view_->SchedulePaint();
-}
-
size_t BrowserActionsContainer::VisibleBrowserActions() const {
size_t visible_actions = 0;
for (size_t i = 0; i < browser_action_views_.size(); ++i) {
@@ -183,19 +172,6 @@ size_t BrowserActionsContainer::VisibleBrowserActions() const {
return visible_actions;
}
-void BrowserActionsContainer::OnBrowserActionExecuted(
- BrowserActionButton* button) {
- const Extension* extension = button->extension();
- GURL popup_url;
- switch (model_->ExecuteBrowserAction(extension, browser_, &popup_url)) {
- case ExtensionToolbarModel::ACTION_NONE:
- break;
- case ExtensionToolbarModel::ACTION_SHOW_POPUP:
- ShowPopup(button, popup_url);
- break;
- }
-}
-
gfx::Size BrowserActionsContainer::GetPreferredSize() {
if (browser_action_views_.empty())
return gfx::Size(ToolbarView::kStandardSpacing, 0);
@@ -387,7 +363,8 @@ void BrowserActionsContainer::OnMenuButtonClicked(views::View* source,
const gfx::Point& point) {
if (source == chevron_) {
overflow_menu_ = new BrowserActionOverflowMenuController(
- this, chevron_, browser_action_views_, VisibleBrowserActions());
+ this, browser_, chevron_, browser_action_views_,
+ VisibleBrowserActions());
overflow_menu_->set_observer(this);
overflow_menu_->RunMenu(GetWidget(), false);
}
@@ -477,6 +454,30 @@ void BrowserActionsContainer::OnWidgetClosing(views::Widget* widget) {
}
}
+int BrowserActionsContainer::GetCurrentTabId() const {
+ TabContents* tab = chrome::GetActiveTabContents(browser_);
+ return tab ? tab->restore_tab_helper()->session_id().id() : -1;
+}
+
+void BrowserActionsContainer::OnBrowserActionExecuted(
+ BrowserActionButton* button) {
+ const Extension* extension = button->extension();
+ GURL popup_url;
+ if (model_->ExecuteBrowserAction(extension, browser_, &popup_url) ==
+ ExtensionToolbarModel::ACTION_SHOW_POPUP)
+ ShowPopup(button, popup_url);
+}
+
+void BrowserActionsContainer::OnBrowserActionVisibilityChanged() {
+ SetVisible(!browser_action_views_.empty());
+ owner_view_->Layout();
+ owner_view_->SchedulePaint();
+}
+
+gfx::Point BrowserActionsContainer::GetViewContentOffset() const {
+ return gfx::Point(0, ToolbarView::kVertSpacing);
+}
+
void BrowserActionsContainer::MoveBrowserAction(const std::string& extension_id,
size_t new_index) {
ExtensionService* service = profile_->GetExtensionService();
@@ -593,7 +594,7 @@ void BrowserActionsContainer::BrowserActionAdded(const Extension* extension,
// Add the new browser action to the vector and the view hierarchy.
if (profile_->IsOffTheRecord())
index = model_->OriginalIndexToIncognito(index);
- BrowserActionView* view = new BrowserActionView(extension, this);
+ BrowserActionView* view = new BrowserActionView(extension, browser_, this);
browser_action_views_.insert(browser_action_views_.begin() + index, view);
AddChildViewAt(view, index);
@@ -705,7 +706,7 @@ void BrowserActionsContainer::ShowDropFolder() {
DCHECK(!overflow_menu_);
SetDropIndicator(-1);
overflow_menu_ = new BrowserActionOverflowMenuController(
- this, chevron_, browser_action_views_, VisibleBrowserActions());
+ this, browser_, chevron_, browser_action_views_, VisibleBrowserActions());
overflow_menu_->set_observer(this);
overflow_menu_->RunMenu(GetWidget(), true);
}

Powered by Google App Engine
This is Rietveld 408576698