OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/toolbar/browser_actions_container.h" | 5 #include "chrome/browser/ui/views/toolbar/browser_actions_container.h" |
6 | 6 |
7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
10 #include "chrome/browser/extensions/extension_service.h" | 10 #include "chrome/browser/extensions/extension_service.h" |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 void BrowserActionsContainer::AddObserver( | 200 void BrowserActionsContainer::AddObserver( |
201 BrowserActionsContainerObserver* observer) { | 201 BrowserActionsContainerObserver* observer) { |
202 observers_.AddObserver(observer); | 202 observers_.AddObserver(observer); |
203 } | 203 } |
204 | 204 |
205 void BrowserActionsContainer::RemoveObserver( | 205 void BrowserActionsContainer::RemoveObserver( |
206 BrowserActionsContainerObserver* observer) { | 206 BrowserActionsContainerObserver* observer) { |
207 observers_.RemoveObserver(observer); | 207 observers_.RemoveObserver(observer); |
208 } | 208 } |
209 | 209 |
210 gfx::Size BrowserActionsContainer::GetPreferredSize() { | 210 gfx::Size BrowserActionsContainer::GetPreferredSize() const { |
211 if (browser_action_views_.empty()) | 211 if (browser_action_views_.empty()) |
212 return gfx::Size(ToolbarView::kStandardSpacing, 0); | 212 return gfx::Size(ToolbarView::kStandardSpacing, 0); |
213 | 213 |
214 // We calculate the size of the view by taking the current width and | 214 // We calculate the size of the view by taking the current width and |
215 // subtracting resize_amount_ (the latter represents how far the user is | 215 // subtracting resize_amount_ (the latter represents how far the user is |
216 // resizing the view or, if animating the snapping, how far to animate it). | 216 // resizing the view or, if animating the snapping, how far to animate it). |
217 // But we also clamp it to a minimum size and the maximum size, so that the | 217 // But we also clamp it to a minimum size and the maximum size, so that the |
218 // container can never shrink too far or take up more space than it needs. In | 218 // container can never shrink too far or take up more space than it needs. In |
219 // other words: ContainerMinSize() < width() - resize < ClampTo(MAX). | 219 // other words: ContainerMinSize() < width() - resize < ClampTo(MAX). |
220 int clamped_width = std::min( | 220 int clamped_width = std::min( |
(...skipping 701 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
922 views::BubbleBorder::TOP_RIGHT, | 922 views::BubbleBorder::TOP_RIGHT, |
923 show_action); | 923 show_action); |
924 popup_->GetWidget()->AddObserver(this); | 924 popup_->GetWidget()->AddObserver(this); |
925 popup_button_ = button; | 925 popup_button_ = button; |
926 | 926 |
927 // Only set button as pushed if it was triggered by a user click. | 927 // Only set button as pushed if it was triggered by a user click. |
928 if (should_grant) | 928 if (should_grant) |
929 popup_button_->SetButtonPushed(); | 929 popup_button_->SetButtonPushed(); |
930 return true; | 930 return true; |
931 } | 931 } |
OLD | NEW |