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/location_bar/location_bar_container.h" | 5 #include "chrome/browser/ui/views/location_bar/location_bar_container.h" |
6 | 6 |
7 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" | 7 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" |
8 #include "chrome/browser/ui/webui/instant_ui.h" | 8 #include "chrome/browser/ui/webui/instant_ui.h" |
9 #include "ui/base/event.h" | 9 #include "ui/base/event.h" |
10 #include "ui/views/background.h" | 10 #include "ui/views/background.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 view_parent_->set_background( | 31 view_parent_->set_background( |
32 views::Background::CreateSolidBackground(GetBackgroundColor())); | 32 views::Background::CreateSolidBackground(GetBackgroundColor())); |
33 } | 33 } |
34 SetLayoutManager(new views::FillLayout); | 34 SetLayoutManager(new views::FillLayout); |
35 } | 35 } |
36 | 36 |
37 LocationBarContainer::~LocationBarContainer() { | 37 LocationBarContainer::~LocationBarContainer() { |
38 } | 38 } |
39 | 39 |
40 void LocationBarContainer::SetLocationBarView(LocationBarView* view) { | 40 void LocationBarContainer::SetLocationBarView(LocationBarView* view) { |
41 DCHECK(!location_bar_view_ && view); | 41 DCHECK(view); |
| 42 |
| 43 if (location_bar_view_) { |
| 44 view_parent_->RemoveChildView(location_bar_view_); |
| 45 } |
| 46 |
42 location_bar_view_ = view; | 47 location_bar_view_ = view; |
43 view_parent_->AddChildView(location_bar_view_); | 48 view_parent_->AddChildView(location_bar_view_); |
44 DCHECK_EQ(1, view_parent_->child_count()); // Only support one child. | 49 DCHECK_EQ(1, view_parent_->child_count()); // Only support one child. |
45 } | 50 } |
46 | 51 |
47 void LocationBarContainer::AnimateTo(const gfx::Rect& bounds) { | 52 void LocationBarContainer::AnimateTo(const gfx::Rect& bounds) { |
48 // Animation duration can change during session. | 53 // Animation duration can change during session. |
49 animator_.SetAnimationDuration(GetAnimationDuration()); | 54 animator_.SetAnimationDuration(GetAnimationDuration()); |
50 animator_.AnimateViewTo(this, bounds); | 55 animator_.AnimateViewTo(this, bounds); |
51 } | 56 } |
(...skipping 26 matching lines...) Expand all Loading... |
78 | 83 |
79 void LocationBarContainer::OnBoundsAnimatorDone( | 84 void LocationBarContainer::OnBoundsAnimatorDone( |
80 views::BoundsAnimator* animator) { | 85 views::BoundsAnimator* animator) { |
81 SetInToolbar(true); | 86 SetInToolbar(true); |
82 } | 87 } |
83 | 88 |
84 // static | 89 // static |
85 int LocationBarContainer::GetAnimationDuration() { | 90 int LocationBarContainer::GetAnimationDuration() { |
86 return kAnimationDuration * InstantUI::GetSlowAnimationScaleFactor(); | 91 return kAnimationDuration * InstantUI::GetSlowAnimationScaleFactor(); |
87 } | 92 } |
OLD | NEW |