| 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 <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 // Also move the view in the child views vector. | 213 // Also move the view in the child views vector. |
| 214 ReorderChildView(toolbar_action_views_[i], i); | 214 ReorderChildView(toolbar_action_views_[i], i); |
| 215 } | 215 } |
| 216 } | 216 } |
| 217 } | 217 } |
| 218 | 218 |
| 219 Layout(); | 219 Layout(); |
| 220 } | 220 } |
| 221 | 221 |
| 222 void BrowserActionsContainer::ResizeAndAnimate(gfx::Tween::Type tween_type, | 222 void BrowserActionsContainer::ResizeAndAnimate(gfx::Tween::Type tween_type, |
| 223 int target_width, | 223 int target_width) { |
| 224 bool /*suppress_chevron*/) { | |
| 225 if (resize_animation_ && !toolbar_actions_bar_->suppress_animation()) { | 224 if (resize_animation_ && !toolbar_actions_bar_->suppress_animation()) { |
| 226 if (!ShownInsideMenu()) { | 225 if (!ShownInsideMenu()) { |
| 227 // Make sure we don't try to animate to wider than the allowed width. | 226 // Make sure we don't try to animate to wider than the allowed width. |
| 228 int max_width = GetToolbarView(browser_)->GetMaxBrowserActionsWidth(); | 227 int max_width = GetToolbarView(browser_)->GetMaxBrowserActionsWidth(); |
| 229 if (target_width > max_width) | 228 if (target_width > max_width) |
| 230 target_width = GetWidthForMaxWidth(max_width); | 229 target_width = GetWidthForMaxWidth(max_width); |
| 231 } | 230 } |
| 232 // Animate! We have to set the animation_target_size_ after calling Reset(), | 231 // Animate! We have to set the animation_target_size_ after calling Reset(), |
| 233 // because that could end up calling AnimationEnded which clears the value. | 232 // because that could end up calling AnimationEnded which clears the value. |
| 234 resize_animation_->Reset(); | 233 resize_animation_->Reset(); |
| 235 resize_starting_width_ = width(); | 234 resize_starting_width_ = width(); |
| 236 resize_animation_->SetTweenType(tween_type); | 235 resize_animation_->SetTweenType(tween_type); |
| 237 animation_target_size_ = target_width; | 236 animation_target_size_ = target_width; |
| 238 resize_animation_->Show(); | 237 resize_animation_->Show(); |
| 239 } else { | 238 } else { |
| 240 animation_target_size_ = target_width; | 239 animation_target_size_ = target_width; |
| 241 AnimationEnded(resize_animation_.get()); | 240 AnimationEnded(resize_animation_.get()); |
| 242 } | 241 } |
| 243 } | 242 } |
| 244 | 243 |
| 245 void BrowserActionsContainer::SetChevronVisibility(bool visible) {} | |
| 246 | |
| 247 int BrowserActionsContainer::GetWidth(GetWidthTime get_width_time) const { | 244 int BrowserActionsContainer::GetWidth(GetWidthTime get_width_time) const { |
| 248 return get_width_time == GET_WIDTH_AFTER_ANIMATION && | 245 return get_width_time == GET_WIDTH_AFTER_ANIMATION && |
| 249 animation_target_size_ > 0 | 246 animation_target_size_ > 0 |
| 250 ? animation_target_size_ | 247 ? animation_target_size_ |
| 251 : width(); | 248 : width(); |
| 252 } | 249 } |
| 253 | 250 |
| 254 bool BrowserActionsContainer::IsAnimating() const { | 251 bool BrowserActionsContainer::IsAnimating() const { |
| 255 return animating(); | 252 return animating(); |
| 256 } | 253 } |
| 257 | 254 |
| 258 void BrowserActionsContainer::StopAnimating() { | 255 void BrowserActionsContainer::StopAnimating() { |
| 259 animation_target_size_ = width(); | 256 animation_target_size_ = width(); |
| 260 resize_animation_->Reset(); | 257 resize_animation_->Reset(); |
| 261 } | 258 } |
| 262 | 259 |
| 263 int BrowserActionsContainer::GetChevronWidth() const { | |
| 264 return 0; | |
| 265 } | |
| 266 | |
| 267 void BrowserActionsContainer::ShowToolbarActionBubble( | 260 void BrowserActionsContainer::ShowToolbarActionBubble( |
| 268 std::unique_ptr<ToolbarActionsBarBubbleDelegate> controller) { | 261 std::unique_ptr<ToolbarActionsBarBubbleDelegate> controller) { |
| 269 // The container shouldn't be asked to show a bubble if it's animating. | 262 // The container shouldn't be asked to show a bubble if it's animating. |
| 270 DCHECK(!animating()); | 263 DCHECK(!animating()); |
| 271 DCHECK(!active_bubble_); | 264 DCHECK(!active_bubble_); |
| 272 | 265 |
| 273 views::View* anchor_view = nullptr; | 266 views::View* anchor_view = nullptr; |
| 274 if (!controller->GetAnchorActionId().empty()) { | 267 if (!controller->GetAnchorActionId().empty()) { |
| 275 ToolbarActionView* action_view = | 268 ToolbarActionView* action_view = |
| 276 GetViewForId(controller->GetAnchorActionId()); | 269 GetViewForId(controller->GetAnchorActionId()); |
| (...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 671 } | 664 } |
| 672 } | 665 } |
| 673 | 666 |
| 674 void BrowserActionsContainer::ClearActiveBubble(views::Widget* widget) { | 667 void BrowserActionsContainer::ClearActiveBubble(views::Widget* widget) { |
| 675 DCHECK(active_bubble_); | 668 DCHECK(active_bubble_); |
| 676 DCHECK_EQ(active_bubble_->GetWidget(), widget); | 669 DCHECK_EQ(active_bubble_->GetWidget(), widget); |
| 677 widget->RemoveObserver(this); | 670 widget->RemoveObserver(this); |
| 678 active_bubble_ = nullptr; | 671 active_bubble_ = nullptr; |
| 679 toolbar_actions_bar_->OnBubbleClosed(); | 672 toolbar_actions_bar_->OnBubbleClosed(); |
| 680 } | 673 } |
| OLD | NEW |