| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/ui/views/browser_actions_container.h" | 5 #include "chrome/browser/ui/views/browser_actions_container.h" |
| 6 | 6 |
| 7 #include "base/stl_util.h" | 7 #include "base/stl_util.h" |
| 8 #include "chrome/browser/extensions/extension_service.h" | 8 #include "chrome/browser/extensions/extension_service.h" |
| 9 #include "chrome/browser/prefs/pref_service.h" | 9 #include "chrome/browser/prefs/pref_service.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 // TODO(mpcomplete): remove this after users are upgraded to 5.0. | 120 // TODO(mpcomplete): remove this after users are upgraded to 5.0. |
| 121 int predefined_width = | 121 int predefined_width = |
| 122 profile_->GetPrefs()->GetInteger(prefs::kBrowserActionContainerWidth); | 122 profile_->GetPrefs()->GetInteger(prefs::kBrowserActionContainerWidth); |
| 123 if (predefined_width != 0) | 123 if (predefined_width != 0) |
| 124 model_->SetVisibleIconCount(WidthToIconCount(predefined_width)); | 124 model_->SetVisibleIconCount(WidthToIconCount(predefined_width)); |
| 125 } | 125 } |
| 126 if (model_ && model_->extensions_initialized()) | 126 if (model_ && model_->extensions_initialized()) |
| 127 SetContainerWidth(); | 127 SetContainerWidth(); |
| 128 } | 128 } |
| 129 | 129 |
| 130 Browser* BrowserActionsContainer::GetBrowser() const { |
| 131 return browser_; |
| 132 } |
| 133 |
| 130 int BrowserActionsContainer::GetCurrentTabId() const { | 134 int BrowserActionsContainer::GetCurrentTabId() const { |
| 131 TabContentsWrapper* tab = browser_->GetSelectedTabContentsWrapper(); | 135 TabContentsWrapper* tab = browser_->GetSelectedTabContentsWrapper(); |
| 132 return tab ? tab->restore_tab_helper()->session_id().id() : -1; | 136 return tab ? tab->restore_tab_helper()->session_id().id() : -1; |
| 133 } | 137 } |
| 134 | 138 |
| 135 BrowserActionView* BrowserActionsContainer::GetBrowserActionView( | 139 BrowserActionView* BrowserActionsContainer::GetBrowserActionView( |
| 136 ExtensionAction* action) { | 140 ExtensionAction* action) { |
| 137 for (BrowserActionViews::iterator iter = browser_action_views_.begin(); | 141 for (BrowserActionViews::iterator iter = browser_action_views_.begin(); |
| 138 iter != browser_action_views_.end(); ++iter) { | 142 iter != browser_action_views_.end(); ++iter) { |
| 139 if ((*iter)->button()->browser_action() == action) | 143 if ((*iter)->button()->browser_action() == action) |
| (...skipping 27 matching lines...) Expand all Loading... |
| 167 HidePopup(); | 171 HidePopup(); |
| 168 STLDeleteElements(&browser_action_views_); | 172 STLDeleteElements(&browser_action_views_); |
| 169 } | 173 } |
| 170 | 174 |
| 171 void BrowserActionsContainer::OnBrowserActionVisibilityChanged() { | 175 void BrowserActionsContainer::OnBrowserActionVisibilityChanged() { |
| 172 SetVisible(!browser_action_views_.empty()); | 176 SetVisible(!browser_action_views_.empty()); |
| 173 owner_view_->Layout(); | 177 owner_view_->Layout(); |
| 174 owner_view_->SchedulePaint(); | 178 owner_view_->SchedulePaint(); |
| 175 } | 179 } |
| 176 | 180 |
| 181 gfx::Size BrowserActionsContainer::GetContentOffset() const { |
| 182 return gfx::Size(0, ToolbarView::kVertSpacing); |
| 183 } |
| 184 |
| 185 |
| 177 size_t BrowserActionsContainer::VisibleBrowserActions() const { | 186 size_t BrowserActionsContainer::VisibleBrowserActions() const { |
| 178 size_t visible_actions = 0; | 187 size_t visible_actions = 0; |
| 179 for (size_t i = 0; i < browser_action_views_.size(); ++i) { | 188 for (size_t i = 0; i < browser_action_views_.size(); ++i) { |
| 180 if (browser_action_views_[i]->visible()) | 189 if (browser_action_views_[i]->visible()) |
| 181 ++visible_actions; | 190 ++visible_actions; |
| 182 } | 191 } |
| 183 return visible_actions; | 192 return visible_actions; |
| 184 } | 193 } |
| 185 | 194 |
| 186 void BrowserActionsContainer::OnBrowserActionExecuted( | 195 void BrowserActionsContainer::OnBrowserActionExecuted( |
| (...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 806 views::BubbleBorder::ArrowLocation arrow_location = base::i18n::IsRTL() ? | 815 views::BubbleBorder::ArrowLocation arrow_location = base::i18n::IsRTL() ? |
| 807 views::BubbleBorder::TOP_LEFT : views::BubbleBorder::TOP_RIGHT; | 816 views::BubbleBorder::TOP_LEFT : views::BubbleBorder::TOP_RIGHT; |
| 808 popup_ = ExtensionPopup::ShowPopup(popup_url, | 817 popup_ = ExtensionPopup::ShowPopup(popup_url, |
| 809 browser_, | 818 browser_, |
| 810 reference_view, | 819 reference_view, |
| 811 arrow_location); | 820 arrow_location); |
| 812 popup_->GetWidget()->AddObserver(this); | 821 popup_->GetWidget()->AddObserver(this); |
| 813 popup_button_ = button; | 822 popup_button_ = button; |
| 814 popup_button_->SetButtonPushed(); | 823 popup_button_->SetButtonPushed(); |
| 815 } | 824 } |
| OLD | NEW |