| OLD | NEW |
| 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/login/login_prompt.h" | 5 #include "chrome/browser/ui/login/login_prompt.h" |
| 6 | 6 |
| 7 #include <gtk/gtk.h> | 7 #include <gtk/gtk.h> |
| 8 | 8 |
| 9 #include "base/string16.h" | 9 #include "base/string16.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 class LoginHandlerGtk : public LoginHandler, | 38 class LoginHandlerGtk : public LoginHandler, |
| 39 public ConstrainedWindowGtkDelegate { | 39 public ConstrainedWindowGtkDelegate { |
| 40 public: | 40 public: |
| 41 LoginHandlerGtk(net::AuthChallengeInfo* auth_info, net::URLRequest* request) | 41 LoginHandlerGtk(net::AuthChallengeInfo* auth_info, net::URLRequest* request) |
| 42 : LoginHandler(auth_info, request), | 42 : LoginHandler(auth_info, request), |
| 43 username_entry_(NULL), | 43 username_entry_(NULL), |
| 44 password_entry_(NULL), | 44 password_entry_(NULL), |
| 45 ok_(NULL) { | 45 ok_(NULL) { |
| 46 } | 46 } |
| 47 | 47 |
| 48 virtual ~LoginHandlerGtk() { | |
| 49 root_.Destroy(); | |
| 50 } | |
| 51 | |
| 52 // LoginModelObserver implementation. | 48 // LoginModelObserver implementation. |
| 53 virtual void OnAutofillDataAvailable(const string16& username, | 49 virtual void OnAutofillDataAvailable(const string16& username, |
| 54 const string16& password) { | 50 const string16& password) { |
| 55 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 51 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 56 | 52 |
| 57 // NOTE: Would be nice to use gtk_entry_get_text_length, but it is fairly | 53 // NOTE: Would be nice to use gtk_entry_get_text_length, but it is fairly |
| 58 // new and not always in our GTK version. | 54 // new and not always in our GTK version. |
| 59 if (strlen(gtk_entry_get_text(GTK_ENTRY(username_entry_))) == 0) { | 55 if (strlen(gtk_entry_get_text(GTK_ENTRY(username_entry_))) == 0) { |
| 60 gtk_entry_set_text(GTK_ENTRY(username_entry_), | 56 gtk_entry_set_text(GTK_ENTRY(username_entry_), |
| 61 UTF16ToUTF8(username).c_str()); | 57 UTF16ToUTF8(username).c_str()); |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 virtual void DeleteDelegate() { | 131 virtual void DeleteDelegate() { |
| 136 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 132 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 137 | 133 |
| 138 // The constrained window is going to delete itself; clear our pointer. | 134 // The constrained window is going to delete itself; clear our pointer. |
| 139 SetDialog(NULL); | 135 SetDialog(NULL); |
| 140 SetModel(NULL); | 136 SetModel(NULL); |
| 141 | 137 |
| 142 ReleaseSoon(); | 138 ReleaseSoon(); |
| 143 } | 139 } |
| 144 | 140 |
| 141 protected: |
| 142 virtual ~LoginHandlerGtk() { |
| 143 root_.Destroy(); |
| 144 } |
| 145 |
| 145 private: | 146 private: |
| 146 friend class LoginPrompt; | 147 friend class LoginPrompt; |
| 147 | 148 |
| 148 CHROMEGTK_CALLBACK_0(LoginHandlerGtk, void, OnOKClicked); | 149 CHROMEGTK_CALLBACK_0(LoginHandlerGtk, void, OnOKClicked); |
| 149 CHROMEGTK_CALLBACK_0(LoginHandlerGtk, void, OnCancelClicked); | 150 CHROMEGTK_CALLBACK_0(LoginHandlerGtk, void, OnCancelClicked); |
| 150 CHROMEGTK_CALLBACK_1(LoginHandlerGtk, void, OnPromptHierarchyChanged, | 151 CHROMEGTK_CALLBACK_1(LoginHandlerGtk, void, OnPromptHierarchyChanged, |
| 151 GtkWidget*); | 152 GtkWidget*); |
| 152 | 153 |
| 153 // The GtkWidgets that form our visual hierarchy: | 154 // The GtkWidgets that form our visual hierarchy: |
| 154 // The root container we pass to our parent. | 155 // The root container we pass to our parent. |
| (...skipping 28 matching lines...) Expand all Loading... |
| 183 // button the default action and mess with the focus. | 184 // button the default action and mess with the focus. |
| 184 gtk_widget_set_can_default(ok_, TRUE); | 185 gtk_widget_set_can_default(ok_, TRUE); |
| 185 gtk_widget_grab_default(ok_); | 186 gtk_widget_grab_default(ok_); |
| 186 } | 187 } |
| 187 | 188 |
| 188 // static | 189 // static |
| 189 LoginHandler* LoginHandler::Create(net::AuthChallengeInfo* auth_info, | 190 LoginHandler* LoginHandler::Create(net::AuthChallengeInfo* auth_info, |
| 190 net::URLRequest* request) { | 191 net::URLRequest* request) { |
| 191 return new LoginHandlerGtk(auth_info, request); | 192 return new LoginHandlerGtk(auth_info, request); |
| 192 } | 193 } |
| OLD | NEW |