diff options
author | georgey@chromium.org <georgey@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-07 00:55:16 +0000 |
---|---|---|
committer | georgey@chromium.org <georgey@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-07 00:55:16 +0000 |
commit | bda9556c63579835dd14055a048f4e2094e7b3f5 (patch) | |
tree | f215d883f2ded85f48bc14d27edd4048f12c364b /chrome | |
parent | c83c9e683a9376cea1ef675bfe92f7dbb98d45f5 (diff) | |
download | chromium_src-bda9556c63579835dd14055a048f4e2094e7b3f5.zip chromium_src-bda9556c63579835dd14055a048f4e2094e7b3f5.tar.gz chromium_src-bda9556c63579835dd14055a048f4e2094e7b3f5.tar.bz2 |
Addded notification when ancestor gets changed. So windows that lack focus manager, because of being
created on inactive tab, could do the necessary work when focus manager is actually attached.
This is relevant for Windows only, but some support functions (FindAllRootViews) could be useful for
other architectures as well.
BUG=22481
TEST=in the bug
Review URL: http://codereview.chromium.org/492025
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@35675 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/views/login_view.cc | 20 | ||||
-rw-r--r-- | chrome/browser/views/login_view.h | 8 |
2 files changed, 26 insertions, 2 deletions
diff --git a/chrome/browser/views/login_view.cc b/chrome/browser/views/login_view.cc index 0476892..1682965 100644 --- a/chrome/browser/views/login_view.cc +++ b/chrome/browser/views/login_view.cc @@ -33,7 +33,8 @@ LoginView::LoginView(const std::wstring& explanation) l10n_util::GetString(IDS_LOGIN_DIALOG_PASSWORD_FIELD))), message_label_(new views::Label(explanation)), ALLOW_THIS_IN_INITIALIZER_LIST(focus_grabber_factory_(this)), - login_model_(NULL) { + login_model_(NULL), + focus_delayed_(false) { message_label_->SetMultiLine(true); message_label_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); @@ -106,6 +107,16 @@ void LoginView::ViewHierarchyChanged(bool is_add, View *parent, View *child) { } } +void LoginView::NativeViewHierarchyChanged(bool attached, + gfx::NativeView native_view, + views::RootView* root_view) { + if (focus_delayed_ && attached) { + focus_delayed_ = false; + MessageLoop::current()->PostTask(FROM_HERE, + focus_grabber_factory_.NewRunnableMethod(&LoginView::FocusFirstField)); + } +} + void LoginView::OnAutofillDataAvailable(const std::wstring& username, const std::wstring& password) { if (username_field_->text().empty()) { @@ -119,5 +130,10 @@ void LoginView::OnAutofillDataAvailable(const std::wstring& username, // LoginView, private: void LoginView::FocusFirstField() { - username_field_->RequestFocus(); + if (GetFocusManager()) { + username_field_->RequestFocus(); + } else { + // We are invisible - delay until it is no longer the case. + focus_delayed_ = true; + } } diff --git a/chrome/browser/views/login_view.h b/chrome/browser/views/login_view.h index e5b7d20..330ff32 100644 --- a/chrome/browser/views/login_view.h +++ b/chrome/browser/views/login_view.h @@ -41,6 +41,10 @@ class LoginView : public views::View, public LoginModelObserver { virtual void ViewHierarchyChanged(bool is_add, views::View *parent, views::View *child); + virtual void NativeViewHierarchyChanged(bool attached, + gfx::NativeView native_view, + views::RootView* root_view); + private: void FocusFirstField(); @@ -61,6 +65,10 @@ class LoginView : public views::View, public LoginModelObserver { ScopedRunnableMethodFactory<LoginView> focus_grabber_factory_; + // Indicates that this view was created when focus manager was unavailable + // (on the hidden tab, for example). + bool focus_delayed_; + DISALLOW_COPY_AND_ASSIGN(LoginView); }; |