diff options
author | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-04 01:57:59 +0000 |
---|---|---|
committer | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-04 01:57:59 +0000 |
commit | 2f4dead0246a6043ad9539ed8a95ab2955aab442 (patch) | |
tree | 0f829467bd0ddd1645f73279bf587b7139185726 /chrome/browser/login_prompt_gtk.cc | |
parent | 29de42c9c4ed71039af911a3331be51c2da9a098 (diff) | |
download | chromium_src-2f4dead0246a6043ad9539ed8a95ab2955aab442.zip chromium_src-2f4dead0246a6043ad9539ed8a95ab2955aab442.tar.gz chromium_src-2f4dead0246a6043ad9539ed8a95ab2955aab442.tar.bz2 |
reland r57885 with a fix for the DCHECK failures observed by nsylvain.
Now we only delay shutdown of the constrained window in the escape case (see constrained_window_gtk.cc). Locally this fixes the DCHECKs in both manual testing and the login prompt ui tests.
BUG=53242, 50799
TEST=ui_tests --gtest_filter=LoginPromptTest*
Review URL: http://codereview.chromium.org/3351006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@58570 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/login_prompt_gtk.cc')
-rw-r--r-- | chrome/browser/login_prompt_gtk.cc | 76 |
1 files changed, 45 insertions, 31 deletions
diff --git a/chrome/browser/login_prompt_gtk.cc b/chrome/browser/login_prompt_gtk.cc index c3e89d0..a9cfb4b 100644 --- a/chrome/browser/login_prompt_gtk.cc +++ b/chrome/browser/login_prompt_gtk.cc @@ -7,6 +7,7 @@ #include <gtk/gtk.h> #include "app/l10n_util.h" +#include "app/gtk_signal.h" #include "base/utf_string_conversions.h" #include "chrome/browser/chrome_thread.h" #include "chrome/browser/gtk/constrained_window_gtk.h" @@ -16,6 +17,7 @@ #include "chrome/browser/renderer_host/resource_dispatcher_host.h" #include "chrome/browser/tab_contents/navigation_controller.h" #include "chrome/browser/tab_contents/tab_contents.h" +#include "chrome/browser/tab_contents/tab_contents_view_gtk.h" #include "chrome/browser/tab_contents/tab_util.h" #include "chrome/common/notification_service.h" #include "grit/generated_resources.h" @@ -89,15 +91,15 @@ class LoginHandlerGtk : public LoginHandler, gtk_button_set_label( GTK_BUTTON(ok_), l10n_util::GetStringUTF8(IDS_LOGIN_DIALOG_OK_BUTTON_LABEL).c_str()); - g_signal_connect(ok_, "clicked", G_CALLBACK(OnOKClicked), this); + g_signal_connect(ok_, "clicked", G_CALLBACK(OnOKClickedThunk), this); gtk_box_pack_end(GTK_BOX(hbox), ok_, FALSE, FALSE, 0); GtkWidget* cancel = gtk_button_new_from_stock(GTK_STOCK_CANCEL); - g_signal_connect(cancel, "clicked", G_CALLBACK(OnCancelClicked), this); + g_signal_connect(cancel, "clicked", G_CALLBACK(OnCancelClickedThunk), this); gtk_box_pack_end(GTK_BOX(hbox), cancel, FALSE, FALSE, 0); g_signal_connect(root_.get(), "hierarchy-changed", - G_CALLBACK(OnPromptShown), this); + G_CALLBACK(OnPromptHierarchyChangedThunk), this); SetModel(manager); @@ -129,34 +131,10 @@ class LoginHandlerGtk : public LoginHandler, private: friend class LoginPrompt; - static void OnOKClicked(GtkButton *button, LoginHandlerGtk* handler) { - DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI)); - - handler->SetAuth( - UTF8ToWide(gtk_entry_get_text(GTK_ENTRY(handler->username_entry_))), - UTF8ToWide(gtk_entry_get_text(GTK_ENTRY(handler->password_entry_)))); - } - - static void OnCancelClicked(GtkButton *button, LoginHandlerGtk* handler) { - DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI)); - - handler->CancelAuth(); - } - - static void OnPromptShown(GtkButton* root, - GtkWidget* previous_toplevel, - LoginHandlerGtk* handler) { - DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI)); - - if (!GTK_WIDGET_TOPLEVEL(gtk_widget_get_toplevel(handler->ok_))) - return; - - // Now that we have attached ourself to the window, we can make our OK - // button the default action and mess with the focus. - GTK_WIDGET_SET_FLAGS(handler->ok_, GTK_CAN_DEFAULT); - gtk_widget_grab_default(handler->ok_); - gtk_widget_grab_focus(handler->username_entry_); - } + CHROMEGTK_CALLBACK_0(LoginHandlerGtk, void, OnOKClicked); + CHROMEGTK_CALLBACK_0(LoginHandlerGtk, void, OnCancelClicked); + CHROMEGTK_CALLBACK_1(LoginHandlerGtk, void, OnPromptHierarchyChanged, + GtkWidget*); // The GtkWidgets that form our visual hierarchy: // The root container we pass to our parent. @@ -170,6 +148,42 @@ class LoginHandlerGtk : public LoginHandler, DISALLOW_COPY_AND_ASSIGN(LoginHandlerGtk); }; +void LoginHandlerGtk::OnOKClicked(GtkWidget* sender) { + SetAuth( + UTF8ToWide(gtk_entry_get_text(GTK_ENTRY(username_entry_))), + UTF8ToWide(gtk_entry_get_text(GTK_ENTRY(password_entry_)))); +} + +void LoginHandlerGtk::OnCancelClicked(GtkWidget* sender) { + CancelAuth(); +} + +void LoginHandlerGtk::OnPromptHierarchyChanged(GtkWidget* sender, + GtkWidget* previous_toplevel) { + DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI)); + + if (!GTK_WIDGET_TOPLEVEL(gtk_widget_get_toplevel(ok_))) + return; + + // Now that we have attached ourself to the window, we can make our OK + // button the default action and mess with the focus. + GTK_WIDGET_SET_FLAGS(ok_, GTK_CAN_DEFAULT); + gtk_widget_grab_default(ok_); + + // The user may have focused another tab. In this case do not grab focus + // until this tab is refocused. + if (gtk_util::IsWidgetAncestryVisible(username_entry_)) { + gtk_widget_grab_focus(username_entry_); + } else { + // TODO(estade): this define should not need to be here because this class + // should not be used on linux/views. +#if defined(TOOLKIT_GTK) + static_cast<TabContentsViewGtk*>(GetTabContentsForLogin()->view())-> + SetFocusedWidget(username_entry_); +#endif + } +} + // static LoginHandler* LoginHandler::Create(net::AuthChallengeInfo* auth_info, URLRequest* request) { |