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 eab721e90e9d2e8a4b78b715fde6be620026db65..55be6edca57cddef505760e690d1440d56451c76 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_); |
|
Peter Kasting
2012/07/26 20:37:17
Nit: Is it posisble to factor this out to some pla
yefimt
2012/07/31 00:10:11
Not sure, I dont know where I can put this code
|
| + 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::Size BrowserActionsContainer::GetViewContentOffset() const { |
| + return gfx::Size(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); |
| } |