Chromium Code Reviews| Index: chrome/browser/ui/views/location_bar/location_bar_view.cc |
| diff --git a/chrome/browser/ui/views/location_bar/location_bar_view.cc b/chrome/browser/ui/views/location_bar/location_bar_view.cc |
| index 5ee8ed62d0f2aaa6f922030217b99a16da82e1d2..18ff75951d3ea0479241a73fecc3ebb856a07198 100644 |
| --- a/chrome/browser/ui/views/location_bar/location_bar_view.cc |
| +++ b/chrome/browser/ui/views/location_bar/location_bar_view.cc |
| @@ -57,7 +57,6 @@ |
| #include "ui/gfx/image/image.h" |
| #include "ui/gfx/skia_util.h" |
| #include "ui/views/controls/label.h" |
| -#include "ui/views/controls/textfield/native_textfield_views.h" |
| #include "ui/views/drag_utils.h" |
| #if !defined(OS_CHROMEOS) |
| @@ -77,6 +76,12 @@ TabContents* GetTabContentsFromDelegate(LocationBarView::Delegate* delegate) { |
| return wrapper ? wrapper->tab_contents() : NULL; |
| } |
| +// A utility function to cast OmniboxView to OmniboxViewViews. |
| +OmniboxViewViews* AsViews(OmniboxView* view) { |
|
alicet1
2011/12/07 22:16:13
is it better as a static conversion method on Omni
oshima
2011/12/08 19:13:01
Only implementation needs this, and I prefer funct
|
| + DCHECK(views::Widget::IsPureViews()); |
| + return static_cast<OmniboxViewViews*>(view); |
| +} |
| + |
| } // namespace |
| // static |
| @@ -134,7 +139,6 @@ LocationBarView::LocationBarView(Browser* browser, |
| template_url_service_(NULL), |
| animation_offset_(0) { |
| set_id(VIEW_ID_LOCATION_BAR); |
| - set_focusable(true); |
| if (mode_ == NORMAL) { |
| painter_.reset( |
| @@ -193,6 +197,7 @@ void LocationBarView::Init() { |
| browser_->command_updater(), |
| mode_ == POPUP, |
| this)); |
| + SetOmniboxFocusable(true); |
| location_entry_view_ = location_entry_->AddToView(this); |
| location_entry_view_->set_id(VIEW_ID_AUTOCOMPLETE); |
| @@ -444,6 +449,19 @@ string16 LocationBarView::GetInstantSuggestion() const { |
| } |
| #endif |
| +void LocationBarView::SetOmniboxFocusable(bool focusable) { |
| + if (views::Widget::IsPureViews()) |
| + AsViews(location_entry_.get())->SetOmniboxFocusable(focusable); |
| + else |
| + set_focusable(focusable); |
| +} |
| + |
| +bool LocationBarView::IsOmniboxFocusableInRootView() const { |
| + return views::Widget::IsPureViews() ? |
| + AsViews(location_entry_.get())->IsOmniboxFocusableInRootView() : |
| + views::View::IsFocusableInRootView(); |
| +} |
| + |
| gfx::Size LocationBarView::GetPreferredSize() { |
| return gfx::Size(0, GetThemeProvider()->GetBitmapNamed(mode_ == POPUP ? |
| IDR_LOCATIONBG_POPUPMODE_CENTER : IDR_LOCATIONBG_C)->height()); |