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

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 scott'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"
12 11
13 namespace { 12 namespace {
14 13
15 // Duration of the animations used by this class (AnimateTo()). 14 // Duration of the animations used by this class (AnimateTo()).
16 const int kAnimationDuration = 180; 15 const int kAnimationDuration = 180;
17 16
18 } 17 }
19 18
20 LocationBarContainer::LocationBarContainer(views::View* parent, 19 LocationBarContainer::LocationBarContainer(views::View* parent,
21 bool instant_extended_api_enabled) 20 bool instant_extended_api_enabled)
22 : animator_(parent), 21 : animator_(parent),
23 view_parent_(NULL), 22 view_parent_(NULL),
24 location_bar_view_(NULL), 23 location_bar_view_(NULL),
25 native_view_host_(NULL), 24 native_view_host_(NULL),
26 in_toolbar_(true), 25 in_toolbar_(true),
27 instant_extended_api_enabled_(instant_extended_api_enabled) { 26 instant_extended_api_enabled_(instant_extended_api_enabled) {
28 parent->AddChildView(this); 27 parent->AddChildView(this);
29 animator_.set_tween_type(ui::Tween::EASE_IN_OUT); 28 animator_.set_tween_type(ui::Tween::EASE_IN_OUT);
30 PlatformInit(); 29 PlatformInit();
31 if (instant_extended_api_enabled) { 30 if (instant_extended_api_enabled) {
32 view_parent_->set_background( 31 view_parent_->set_background(
33 views::Background::CreateSolidBackground(GetBackgroundColor())); 32 views::Background::CreateSolidBackground(GetBackgroundColor()));
34 } 33 }
35 SetLayoutManager(new views::FillLayout);
36 } 34 }
37 35
38 LocationBarContainer::~LocationBarContainer() { 36 LocationBarContainer::~LocationBarContainer() {
39 } 37 }
40 38
41 void LocationBarContainer::SetLocationBarView(LocationBarView* view) { 39 void LocationBarContainer::SetLocationBarView(LocationBarView* view) {
42 DCHECK(!location_bar_view_ && view); 40 DCHECK(!location_bar_view_ && view);
43 location_bar_view_ = view; 41 location_bar_view_ = view;
44 view_parent_->AddChildView(location_bar_view_); 42 view_parent_->AddChildView(location_bar_view_);
45 DCHECK_EQ(1, view_parent_->child_count()); // Only support one child. 43 DCHECK_EQ(1, view_parent_->child_count()); // Only support one child.
(...skipping 14 matching lines...) Expand all
60 } 58 }
61 59
62 std::string LocationBarContainer::GetClassName() const { 60 std::string LocationBarContainer::GetClassName() const {
63 return "browser/ui/views/location_bar/LocationBarContainer"; 61 return "browser/ui/views/location_bar/LocationBarContainer";
64 } 62 }
65 63
66 gfx::Size LocationBarContainer::GetPreferredSize() { 64 gfx::Size LocationBarContainer::GetPreferredSize() {
67 return location_bar_view_->GetPreferredSize(); 65 return location_bar_view_->GetPreferredSize();
68 } 66 }
69 67
68 void LocationBarContainer::Layout() {
69 // |location_bar_view_| fills the entire width of the container, but retains
70 // its preferred height, so that it's not resized which, if shrunk, will
71 // squish the placeholder text within a smaller vertical space.
72 location_bar_view_->SetBounds(0, 0, bounds().width(),
73 location_bar_view_->GetPreferredSize().height());
74 }
75
70 bool LocationBarContainer::SkipDefaultKeyEventProcessing( 76 bool LocationBarContainer::SkipDefaultKeyEventProcessing(
71 const ui::KeyEvent& event) { 77 const ui::KeyEvent& event) {
72 return location_bar_view_->SkipDefaultKeyEventProcessing(event); 78 return location_bar_view_->SkipDefaultKeyEventProcessing(event);
73 } 79 }
74 80
75 void LocationBarContainer::GetAccessibleState( 81 void LocationBarContainer::GetAccessibleState(
76 ui::AccessibleViewState* state) { 82 ui::AccessibleViewState* state) {
77 location_bar_view_->GetAccessibleState(state); 83 location_bar_view_->GetAccessibleState(state);
78 } 84 }
79 85
80 void LocationBarContainer::OnBoundsAnimatorDone( 86 void LocationBarContainer::OnBoundsAnimatorDone(
81 views::BoundsAnimator* animator) { 87 views::BoundsAnimator* animator) {
82 SetInToolbar(true); 88 SetInToolbar(true);
83 } 89 }
84 90
85 // static 91 // static
86 int LocationBarContainer::GetAnimationDuration() { 92 int LocationBarContainer::GetAnimationDuration() {
87 return kAnimationDuration * InstantUI::GetSlowAnimationScaleFactor(); 93 return kAnimationDuration * InstantUI::GetSlowAnimationScaleFactor();
88 } 94 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698