From e8a9a7472f544a839cbc47b8279d3ce99b0cf0a0 Mon Sep 17 00:00:00 2001 From: "jcampan@chromium.org" Date: Thu, 24 Sep 2009 19:54:15 +0000 Subject: Refactoring some of the NativeViewHost and NativeControl focus management so their consumers don't have to explicitly set the focused view. BUG=None TEST=Run all tests. Make sure focus is stored/restored properly in Chrome. Review URL: http://codereview.chromium.org/214029 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@27113 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/browser/views/location_bar_view.cc | 16 +++++----------- chrome/browser/views/location_bar_view.h | 1 - 2 files changed, 5 insertions(+), 12 deletions(-) (limited to 'chrome/browser/views') diff --git a/chrome/browser/views/location_bar_view.cc b/chrome/browser/views/location_bar_view.cc index 4becb2f..0bff973 100644 --- a/chrome/browser/views/location_bar_view.cc +++ b/chrome/browser/views/location_bar_view.cc @@ -157,6 +157,8 @@ void LocationBarView::Init() { location_entry_view_->SetID(VIEW_ID_AUTOCOMPLETE); AddChildView(location_entry_view_); location_entry_view_->set_focus_view(this); + location_entry_view_->set_focus_native_view(location_entry_-> + GetFocusNativeView()); location_entry_view_->Attach( #if defined(OS_WIN) location_entry_->m_hWnd @@ -290,8 +292,9 @@ void LocationBarView::InvalidatePageActions() { } void LocationBarView::Focus() { - // Focus the location entry native view. - location_entry_->SetFocus(); + // Forward the focus to the NativeViewHost that will focus the right + // native-view. + location_entry_view_->Focus(); } void LocationBarView::SetProfile(Profile* profile) { @@ -417,15 +420,6 @@ void LocationBarView::OnChanged() { DoLayout(false); } -void LocationBarView::OnSetFocus() { - views::FocusManager* focus_manager = GetFocusManager(); - if (!focus_manager) { - NOTREACHED(); - return; - } - focus_manager->SetFocusedView(this); -} - SkBitmap LocationBarView::GetFavIcon() const { DCHECK(delegate_); DCHECK(delegate_->GetTabContents()); diff --git a/chrome/browser/views/location_bar_view.h b/chrome/browser/views/location_bar_view.h index 343e7e6..e60edc9 100644 --- a/chrome/browser/views/location_bar_view.h +++ b/chrome/browser/views/location_bar_view.h @@ -125,7 +125,6 @@ class LocationBarView : public LocationBar, virtual void OnInputInProgress(bool in_progress) { delegate_->OnInputInProgress(in_progress); } - virtual void OnSetFocus(); virtual SkBitmap GetFavIcon() const; virtual std::wstring GetTitle() const; -- cgit v1.1