| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/login_prompt.h" | 5 #include "chrome/browser/login_prompt.h" |
| 6 | 6 |
| 7 #include <gtk/gtk.h> | 7 #include <gtk/gtk.h> |
| 8 | 8 |
| 9 #include "app/l10n_util.h" | 9 #include "app/l10n_util.h" |
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 } | 52 } |
| 53 } | 53 } |
| 54 | 54 |
| 55 virtual ~LoginHandlerGtk() { | 55 virtual ~LoginHandlerGtk() { |
| 56 if (login_model_) | 56 if (login_model_) |
| 57 login_model_->SetObserver(NULL); | 57 login_model_->SetObserver(NULL); |
| 58 root_.Destroy(); | 58 root_.Destroy(); |
| 59 } | 59 } |
| 60 | 60 |
| 61 void SetModel(LoginModel* model) { | 61 void SetModel(LoginModel* model) { |
| 62 if (login_model_) |
| 63 login_model_->SetObserver(NULL); |
| 62 login_model_ = model; | 64 login_model_ = model; |
| 63 if (login_model_) | 65 if (login_model_) |
| 64 login_model_->SetObserver(this); | 66 login_model_->SetObserver(this); |
| 65 } | 67 } |
| 66 | 68 |
| 67 // LoginModelObserver implementation. | 69 // LoginModelObserver implementation. |
| 68 virtual void OnAutofillDataAvailable(const std::wstring& username, | 70 virtual void OnAutofillDataAvailable(const std::wstring& username, |
| 69 const std::wstring& password) { | 71 const std::wstring& password) { |
| 70 // NOTE: Would be nice to use gtk_entry_get_text_length, but it is fairly | 72 // NOTE: Would be nice to use gtk_entry_get_text_length, but it is fairly |
| 71 // new and not always in our GTK version. | 73 // new and not always in our GTK version. |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 } | 201 } |
| 200 | 202 |
| 201 virtual void DeleteDelegate() { | 203 virtual void DeleteDelegate() { |
| 202 if (!WasAuthHandled(true)) { | 204 if (!WasAuthHandled(true)) { |
| 203 request_loop_->PostTask(FROM_HERE, NewRunnableMethod( | 205 request_loop_->PostTask(FROM_HERE, NewRunnableMethod( |
| 204 this, &LoginHandlerGtk::CancelAuthDeferred)); | 206 this, &LoginHandlerGtk::CancelAuthDeferred)); |
| 205 ui_loop_->PostTask(FROM_HERE, NewRunnableMethod( | 207 ui_loop_->PostTask(FROM_HERE, NewRunnableMethod( |
| 206 this, &LoginHandlerGtk::SendNotifications)); | 208 this, &LoginHandlerGtk::SendNotifications)); |
| 207 } | 209 } |
| 208 | 210 |
| 211 SetModel(NULL); |
| 212 |
| 209 // Delete this object once all InvokeLaters have been called. | 213 // Delete this object once all InvokeLaters have been called. |
| 210 request_loop_->ReleaseSoon(FROM_HERE, this); | 214 request_loop_->ReleaseSoon(FROM_HERE, this); |
| 211 } | 215 } |
| 212 | 216 |
| 213 private: | 217 private: |
| 214 friend class LoginPrompt; | 218 friend class LoginPrompt; |
| 215 | 219 |
| 216 // Calls SetAuth from the request_loop. | 220 // Calls SetAuth from the request_loop. |
| 217 void SetAuthDeferred(const std::wstring& username, | 221 void SetAuthDeferred(const std::wstring& username, |
| 218 const std::wstring& password) { | 222 const std::wstring& password) { |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 337 // so it doesn't try and access this when its too late. | 341 // so it doesn't try and access this when its too late. |
| 338 LoginModel* login_model_; | 342 LoginModel* login_model_; |
| 339 | 343 |
| 340 DISALLOW_COPY_AND_ASSIGN(LoginHandlerGtk); | 344 DISALLOW_COPY_AND_ASSIGN(LoginHandlerGtk); |
| 341 }; | 345 }; |
| 342 | 346 |
| 343 // static | 347 // static |
| 344 LoginHandler* LoginHandler::Create(URLRequest* request, MessageLoop* ui_loop) { | 348 LoginHandler* LoginHandler::Create(URLRequest* request, MessageLoop* ui_loop) { |
| 345 return new LoginHandlerGtk(request, ui_loop); | 349 return new LoginHandlerGtk(request, ui_loop); |
| 346 } | 350 } |
| OLD | NEW |