| 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 <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "base/synchronization/lock.h" | 11 #include "base/synchronization/lock.h" |
| 12 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
| 13 #include "chrome/browser/password_manager/password_manager.h" | 13 #include "chrome/browser/password_manager/password_manager.h" |
| 14 #include "chrome/browser/tab_contents/tab_util.h" | 14 #include "chrome/browser/tab_contents/tab_util.h" |
| 15 #include "chrome/browser/ui/constrained_window.h" | 15 #include "chrome/browser/ui/web_contents_modal_dialog.h" |
| 16 #include "chrome/common/chrome_notification_types.h" | 16 #include "chrome/common/chrome_notification_types.h" |
| 17 #include "content/public/browser/browser_thread.h" | 17 #include "content/public/browser/browser_thread.h" |
| 18 #include "content/public/browser/notification_registrar.h" | 18 #include "content/public/browser/notification_registrar.h" |
| 19 #include "content/public/browser/notification_service.h" | 19 #include "content/public/browser/notification_service.h" |
| 20 #include "content/public/browser/render_view_host.h" | 20 #include "content/public/browser/render_view_host.h" |
| 21 #include "content/public/browser/resource_dispatcher_host.h" | 21 #include "content/public/browser/resource_dispatcher_host.h" |
| 22 #include "content/public/browser/resource_request_info.h" | 22 #include "content/public/browser/resource_request_info.h" |
| 23 #include "content/public/browser/web_contents.h" | 23 #include "content/public/browser/web_contents.h" |
| 24 #include "grit/generated_resources.h" | 24 #include "grit/generated_resources.h" |
| 25 #include "net/base/auth.h" | 25 #include "net/base/auth.h" |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 } | 235 } |
| 236 | 236 |
| 237 void LoginHandler::SetModel(LoginModel* model) { | 237 void LoginHandler::SetModel(LoginModel* model) { |
| 238 if (login_model_) | 238 if (login_model_) |
| 239 login_model_->SetObserver(NULL); | 239 login_model_->SetObserver(NULL); |
| 240 login_model_ = model; | 240 login_model_ = model; |
| 241 if (login_model_) | 241 if (login_model_) |
| 242 login_model_->SetObserver(this); | 242 login_model_->SetObserver(this); |
| 243 } | 243 } |
| 244 | 244 |
| 245 void LoginHandler::SetDialog(ConstrainedWindow* dialog) { | 245 void LoginHandler::SetDialog(WebContentsModalDialog* dialog) { |
| 246 dialog_ = dialog; | 246 dialog_ = dialog; |
| 247 } | 247 } |
| 248 | 248 |
| 249 void LoginHandler::NotifyAuthNeeded() { | 249 void LoginHandler::NotifyAuthNeeded() { |
| 250 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 250 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 251 if (WasAuthHandled()) | 251 if (WasAuthHandled()) |
| 252 return; | 252 return; |
| 253 | 253 |
| 254 content::NotificationService* service = | 254 content::NotificationService* service = |
| 255 content::NotificationService::current(); | 255 content::NotificationService::current(); |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 // Verify that CancelAuth doesn't destroy the request via our delegate. | 370 // Verify that CancelAuth doesn't destroy the request via our delegate. |
| 371 DCHECK(request_ != NULL); | 371 DCHECK(request_ != NULL); |
| 372 ResetLoginHandlerForRequest(request_); | 372 ResetLoginHandlerForRequest(request_); |
| 373 } | 373 } |
| 374 } | 374 } |
| 375 | 375 |
| 376 // Closes the view_contents from the UI loop. | 376 // Closes the view_contents from the UI loop. |
| 377 void LoginHandler::CloseContentsDeferred() { | 377 void LoginHandler::CloseContentsDeferred() { |
| 378 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 378 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 379 | 379 |
| 380 // The hosting ConstrainedWindow may have been freed. | 380 // The hosting WebContentsModalDialog may have been freed. |
| 381 if (dialog_) | 381 if (dialog_) |
| 382 dialog_->CloseConstrainedWindow(); | 382 dialog_->CloseWebContentsModalDialog(); |
| 383 } | 383 } |
| 384 | 384 |
| 385 // Helper to create a PasswordForm and stuff it into a vector as input | 385 // Helper to create a PasswordForm and stuff it into a vector as input |
| 386 // for PasswordManager::PasswordFormsParsed, the hook into PasswordManager. | 386 // for PasswordManager::PasswordFormsParsed, the hook into PasswordManager. |
| 387 void MakeInputForPasswordManager( | 387 void MakeInputForPasswordManager( |
| 388 const GURL& request_url, | 388 const GURL& request_url, |
| 389 net::AuthChallengeInfo* auth_info, | 389 net::AuthChallengeInfo* auth_info, |
| 390 LoginHandler* handler, | 390 LoginHandler* handler, |
| 391 std::vector<PasswordForm>* password_manager_input) { | 391 std::vector<PasswordForm>* password_manager_input) { |
| 392 PasswordForm dialog_form; | 392 PasswordForm dialog_form; |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 467 | 467 |
| 468 LoginHandler* CreateLoginPrompt(net::AuthChallengeInfo* auth_info, | 468 LoginHandler* CreateLoginPrompt(net::AuthChallengeInfo* auth_info, |
| 469 net::URLRequest* request) { | 469 net::URLRequest* request) { |
| 470 LoginHandler* handler = LoginHandler::Create(auth_info, request); | 470 LoginHandler* handler = LoginHandler::Create(auth_info, request); |
| 471 BrowserThread::PostTask( | 471 BrowserThread::PostTask( |
| 472 BrowserThread::UI, FROM_HERE, | 472 BrowserThread::UI, FROM_HERE, |
| 473 base::Bind(&LoginDialogCallback, request->url(), | 473 base::Bind(&LoginDialogCallback, request->url(), |
| 474 make_scoped_refptr(auth_info), make_scoped_refptr(handler))); | 474 make_scoped_refptr(auth_info), make_scoped_refptr(handler))); |
| 475 return handler; | 475 return handler; |
| 476 } | 476 } |
| OLD | NEW |