| 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 // We calculate the size of the view by taking the current width and | 211 // We calculate the size of the view by taking the current width and |
| 212 // subtracting resize_amount_ (the latter represents how far the user is | 212 // subtracting resize_amount_ (the latter represents how far the user is |
| 213 // resizing the view or, if animating the snapping, how far to animate it). | 213 // resizing the view or, if animating the snapping, how far to animate it). |
| 214 // But we also clamp it to a minimum size and the maximum size, so that the | 214 // But we also clamp it to a minimum size and the maximum size, so that the |
| 215 // container can never shrink too far or take up more space than it needs. In | 215 // container can never shrink too far or take up more space than it needs. In |
| 216 // other words: MinimumNonemptyWidth() < width() - resize < ClampTo(MAX). | 216 // other words: MinimumNonemptyWidth() < width() - resize < ClampTo(MAX). |
| 217 int preferred_width = std::min( | 217 int preferred_width = std::min( |
| 218 std::max(MinimumNonemptyWidth(), container_width_ - resize_amount_), | 218 std::max(MinimumNonemptyWidth(), container_width_ - resize_amount_), |
| 219 IconCountToWidth(-1, false)); | 219 IconCountToWidth(-1, false)); |
| 220 // Height will be ignored by the ToolbarView. | 220 // Height will be ignored by the ToolbarView. |
| 221 return gfx::Size(preferred_width, 0); | 221 return gfx::Size(preferred_width, 0); |
| 222 } | 222 } |
| 223 | 223 |
| 224 gfx::Size BrowserActionsContainer::GetMinimumSize() { | 224 gfx::Size BrowserActionsContainer::GetMinimumSize() const { |
| 225 int min_width = std::min(MinimumNonemptyWidth(), IconCountToWidth(-1, false)); | 225 int min_width = std::min(MinimumNonemptyWidth(), IconCountToWidth(-1, false)); |
| 226 // Height will be ignored by the ToolbarView. | 226 // Height will be ignored by the ToolbarView. |
| 227 return gfx::Size(min_width, 0); | 227 return gfx::Size(min_width, 0); |
| 228 } | 228 } |
| 229 | 229 |
| 230 void BrowserActionsContainer::Layout() { | 230 void BrowserActionsContainer::Layout() { |
| 231 if (browser_action_views_.empty()) { | 231 if (browser_action_views_.empty()) { |
| 232 SetVisible(false); | 232 SetVisible(false); |
| 233 return; | 233 return; |
| 234 } | 234 } |
| (...skipping 691 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 926 views::BubbleBorder::TOP_RIGHT, | 926 views::BubbleBorder::TOP_RIGHT, |
| 927 show_action); | 927 show_action); |
| 928 popup_->GetWidget()->AddObserver(this); | 928 popup_->GetWidget()->AddObserver(this); |
| 929 popup_button_ = button; | 929 popup_button_ = button; |
| 930 | 930 |
| 931 // Only set button as pushed if it was triggered by a user click. | 931 // Only set button as pushed if it was triggered by a user click. |
| 932 if (should_grant) | 932 if (should_grant) |
| 933 popup_button_->SetButtonPushed(); | 933 popup_button_->SetButtonPushed(); |
| 934 return true; | 934 return true; |
| 935 } | 935 } |
| OLD | NEW |