Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(615)

Side by Side Diff: chrome/browser/ui/views/location_bar/location_bar_container.cc

Issue 10907038: alternate ntp: clip middle omnibox when resizing browser window (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: addressed david's comments Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/events/event.h" 9 #include "ui/base/events/event.h"
10 #include "ui/views/background.h" 10 #include "ui/views/background.h"
11 #include "ui/views/layout/fill_layout.h" 11 #include "ui/views/layout/fill_layout.h"
sky 2012/09/13 19:58:24 remove include
kuan 2012/09/13 20:13:28 Done.
12 12
13 namespace { 13 namespace {
14 14
15 // Duration of the animations used by this class (AnimateTo()). 15 // Duration of the animations used by this class (AnimateTo()).
16 const int kAnimationDuration = 180; 16 const int kAnimationDuration = 180;
17 17
18 } 18 }
19 19
20 LocationBarContainer::LocationBarContainer(views::View* parent, 20 LocationBarContainer::LocationBarContainer(views::View* parent,
21 bool instant_extended_api_enabled) 21 bool instant_extended_api_enabled)
22 : animator_(parent), 22 : animator_(parent),
23 view_parent_(NULL), 23 view_parent_(NULL),
24 location_bar_view_(NULL), 24 location_bar_view_(NULL),
25 native_view_host_(NULL), 25 native_view_host_(NULL),
26 in_toolbar_(true), 26 in_toolbar_(true),
27 instant_extended_api_enabled_(instant_extended_api_enabled) { 27 instant_extended_api_enabled_(instant_extended_api_enabled) {
28 parent->AddChildView(this); 28 parent->AddChildView(this);
29 animator_.set_tween_type(ui::Tween::EASE_IN_OUT); 29 animator_.set_tween_type(ui::Tween::EASE_IN_OUT);
30 PlatformInit(); 30 PlatformInit();
31 if (instant_extended_api_enabled) { 31 if (instant_extended_api_enabled) {
32 view_parent_->set_background( 32 view_parent_->set_background(
33 views::Background::CreateSolidBackground(GetBackgroundColor())); 33 views::Background::CreateSolidBackground(GetBackgroundColor()));
34 } 34 }
35 SetLayoutManager(new views::FillLayout);
36 } 35 }
37 36
38 LocationBarContainer::~LocationBarContainer() { 37 LocationBarContainer::~LocationBarContainer() {
39 } 38 }
40 39
41 void LocationBarContainer::SetLocationBarView(LocationBarView* view) { 40 void LocationBarContainer::SetLocationBarView(LocationBarView* view) {
42 DCHECK(!location_bar_view_ && view); 41 DCHECK(!location_bar_view_ && view);
43 location_bar_view_ = view; 42 location_bar_view_ = view;
44 view_parent_->AddChildView(location_bar_view_); 43 view_parent_->AddChildView(location_bar_view_);
45 DCHECK_EQ(1, view_parent_->child_count()); // Only support one child. 44 DCHECK_EQ(1, view_parent_->child_count()); // Only support one child.
(...skipping 14 matching lines...) Expand all
60 } 59 }
61 60
62 std::string LocationBarContainer::GetClassName() const { 61 std::string LocationBarContainer::GetClassName() const {
63 return "browser/ui/views/location_bar/LocationBarContainer"; 62 return "browser/ui/views/location_bar/LocationBarContainer";
64 } 63 }
65 64
66 gfx::Size LocationBarContainer::GetPreferredSize() { 65 gfx::Size LocationBarContainer::GetPreferredSize() {
67 return location_bar_view_->GetPreferredSize(); 66 return location_bar_view_->GetPreferredSize();
68 } 67 }
69 68
69 void LocationBarContainer::Layout() {
70 // |location_bar_view_| fills the entire width of the container, but retains
71 // its preferred height, so that it's not resized which, if shrunk, will
72 // squish the placeholder text within a smaller vertical space.
73 location_bar_view_->SetBounds(0, 0, bounds().width(),
74 location_bar_view_->GetPreferredSize().height());
75 }
76
70 bool LocationBarContainer::SkipDefaultKeyEventProcessing( 77 bool LocationBarContainer::SkipDefaultKeyEventProcessing(
71 const ui::KeyEvent& event) { 78 const ui::KeyEvent& event) {
72 return location_bar_view_->SkipDefaultKeyEventProcessing(event); 79 return location_bar_view_->SkipDefaultKeyEventProcessing(event);
73 } 80 }
74 81
75 void LocationBarContainer::GetAccessibleState( 82 void LocationBarContainer::GetAccessibleState(
76 ui::AccessibleViewState* state) { 83 ui::AccessibleViewState* state) {
77 location_bar_view_->GetAccessibleState(state); 84 location_bar_view_->GetAccessibleState(state);
78 } 85 }
79 86
80 void LocationBarContainer::OnBoundsAnimatorDone( 87 void LocationBarContainer::OnBoundsAnimatorDone(
81 views::BoundsAnimator* animator) { 88 views::BoundsAnimator* animator) {
82 SetInToolbar(true); 89 SetInToolbar(true);
83 } 90 }
84 91
85 // static 92 // static
86 int LocationBarContainer::GetAnimationDuration() { 93 int LocationBarContainer::GetAnimationDuration() {
87 return kAnimationDuration * InstantUI::GetSlowAnimationScaleFactor(); 94 return kAnimationDuration * InstantUI::GetSlowAnimationScaleFactor();
88 } 95 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698