| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/ui/views/location_bar/location_bar_container.h" |
| 6 |
| 7 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" |
| 8 #include "ui/views/background.h" |
| 9 #include "ui/views/layout/fill_layout.h" |
| 10 |
| 11 namespace { |
| 12 |
| 13 // Duration of the animations used by this class (AnimateTo()). |
| 14 const int kAnimationDuration = 180; |
| 15 |
| 16 } |
| 17 |
| 18 LocationBarContainer::LocationBarContainer(views::View* parent) |
| 19 : animator_(parent), |
| 20 view_parent_(NULL), |
| 21 location_bar_view_(NULL), |
| 22 native_view_host_(NULL) { |
| 23 parent->AddChildView(this); |
| 24 animator_.SetAnimationDuration(kAnimationDuration); |
| 25 animator_.set_tween_type(ui::Tween::EASE_IN_OUT); |
| 26 PlatformInit(); |
| 27 // TODO(sky): conditionally enable this. |
| 28 // view_parent_->set_background( |
| 29 // views::Background::CreateSolidBackground(GetBackgroundColor())); |
| 30 SetLayoutManager(new views::FillLayout); |
| 31 } |
| 32 |
| 33 LocationBarContainer::~LocationBarContainer() { |
| 34 } |
| 35 |
| 36 void LocationBarContainer::SetLocationBarView(LocationBarView* view) { |
| 37 DCHECK(!location_bar_view_ && view); |
| 38 location_bar_view_ = view; |
| 39 view_parent_->AddChildView(location_bar_view_); |
| 40 DCHECK_EQ(1, view_parent_->child_count()); // Only support one child. |
| 41 } |
| 42 |
| 43 void LocationBarContainer::AnimateTo(const gfx::Rect& bounds) { |
| 44 #if defined(USE_AURA) |
| 45 SetPaintToLayer(true); |
| 46 layer()->SetFillsBoundsOpaquely(false); |
| 47 #endif |
| 48 animator_.AnimateViewTo(this, bounds); |
| 49 } |
| 50 |
| 51 bool LocationBarContainer::IsAnimating() const { |
| 52 return animator_.IsAnimating(); |
| 53 } |
| 54 |
| 55 gfx::Rect LocationBarContainer::GetTargetBounds() { |
| 56 return animator_.GetTargetBounds(this); |
| 57 } |
| 58 |
| 59 gfx::Size LocationBarContainer::GetPreferredSize() { |
| 60 return location_bar_view_->GetPreferredSize(); |
| 61 } |
| 62 |
| 63 bool LocationBarContainer::SkipDefaultKeyEventProcessing( |
| 64 const views::KeyEvent& event) { |
| 65 return location_bar_view_->SkipDefaultKeyEventProcessing(event); |
| 66 } |
| 67 |
| 68 void LocationBarContainer::GetAccessibleState( |
| 69 ui::AccessibleViewState* state) { |
| 70 location_bar_view_->GetAccessibleState(state); |
| 71 } |
| 72 |
| 73 void LocationBarContainer::OnBoundsAnimatorDone( |
| 74 views::BoundsAnimator* animator) { |
| 75 #if defined(USE_AURA) |
| 76 SetPaintToLayer(false); |
| 77 #endif |
| 78 } |
| OLD | NEW |