| 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 <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "app/l10n_util.h" | 9 #include "app/l10n_util.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "base/lock.h" | 11 #include "base/lock.h" |
| 12 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
| 13 #include "chrome/browser/browser_thread.h" | 13 #include "chrome/browser/browser_thread.h" |
| 14 #include "chrome/browser/password_manager/password_manager.h" | 14 #include "chrome/browser/password_manager/password_manager.h" |
| 15 #include "chrome/browser/renderer_host/render_process_host.h" | 15 #include "chrome/browser/renderer_host/render_process_host.h" |
| 16 #include "chrome/browser/renderer_host/resource_dispatcher_host.h" | 16 #include "chrome/browser/renderer_host/resource_dispatcher_host.h" |
| 17 #include "chrome/browser/renderer_host/resource_dispatcher_host_request_info.h" | 17 #include "chrome/browser/renderer_host/resource_dispatcher_host_request_info.h" |
| 18 #include "chrome/browser/tab_contents/constrained_window.h" | 18 #include "chrome/browser/tab_contents/constrained_window.h" |
| 19 #include "chrome/browser/tab_contents/tab_contents.h" | 19 #include "chrome/browser/tab_contents/tab_contents.h" |
| 20 #include "chrome/browser/tab_contents/tab_util.h" | 20 #include "chrome/browser/tab_contents/tab_util.h" |
| 21 #include "chrome/browser/tab_contents_wrapper.h" |
| 21 #include "chrome/common/chrome_switches.h" | 22 #include "chrome/common/chrome_switches.h" |
| 22 #include "chrome/common/notification_service.h" | 23 #include "chrome/common/notification_service.h" |
| 23 #include "grit/generated_resources.h" | 24 #include "grit/generated_resources.h" |
| 24 #include "net/base/auth.h" | 25 #include "net/base/auth.h" |
| 25 #include "net/base/net_util.h" | 26 #include "net/base/net_util.h" |
| 26 #include "net/url_request/url_request.h" | 27 #include "net/url_request/url_request.h" |
| 27 | 28 |
| 28 using webkit_glue::PasswordForm; | 29 using webkit_glue::PasswordForm; |
| 29 | 30 |
| 30 class LoginHandlerImpl; | 31 class LoginHandlerImpl; |
| (...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 365 TabContents* parent_contents = handler_->GetTabContentsForLogin(); | 366 TabContents* parent_contents = handler_->GetTabContentsForLogin(); |
| 366 if (!parent_contents) { | 367 if (!parent_contents) { |
| 367 // The request may have been cancelled, or it may be for a renderer | 368 // The request may have been cancelled, or it may be for a renderer |
| 368 // not hosted by a tab (e.g. an extension). Cancel just in case | 369 // not hosted by a tab (e.g. an extension). Cancel just in case |
| 369 // (cancelling twice is a no-op). | 370 // (cancelling twice is a no-op). |
| 370 handler_->CancelAuth(); | 371 handler_->CancelAuth(); |
| 371 return; | 372 return; |
| 372 } | 373 } |
| 373 | 374 |
| 374 // Tell the password manager to look for saved passwords. | 375 // Tell the password manager to look for saved passwords. |
| 375 PasswordManager* password_manager = | 376 TabContentsWrapper** wrapper = |
| 376 parent_contents->GetPasswordManager(); | 377 TabContentsWrapper::property_accessor()->GetProperty( |
| 378 parent_contents->property_bag()); |
| 379 if (!wrapper) |
| 380 return; |
| 381 PasswordManager* password_manager = (*wrapper)->GetPasswordManager(); |
| 377 std::vector<PasswordForm> v; | 382 std::vector<PasswordForm> v; |
| 378 MakeInputForPasswordManager(&v); | 383 MakeInputForPasswordManager(&v); |
| 379 password_manager->PasswordFormsFound(v); | 384 password_manager->PasswordFormsFound(v); |
| 380 handler_->SetPasswordManager(password_manager); | 385 handler_->SetPasswordManager(password_manager); |
| 381 | 386 |
| 382 std::wstring explanation = auth_info_->realm.empty() ? | 387 std::wstring explanation = auth_info_->realm.empty() ? |
| 383 l10n_util::GetStringF(IDS_LOGIN_DIALOG_DESCRIPTION_NO_REALM, | 388 l10n_util::GetStringF(IDS_LOGIN_DIALOG_DESCRIPTION_NO_REALM, |
| 384 auth_info_->host_and_port) : | 389 auth_info_->host_and_port) : |
| 385 l10n_util::GetStringF(IDS_LOGIN_DIALOG_DESCRIPTION, | 390 l10n_util::GetStringF(IDS_LOGIN_DIALOG_DESCRIPTION, |
| 386 auth_info_->host_and_port, | 391 auth_info_->host_and_port, |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 438 // Public API | 443 // Public API |
| 439 | 444 |
| 440 LoginHandler* CreateLoginPrompt(net::AuthChallengeInfo* auth_info, | 445 LoginHandler* CreateLoginPrompt(net::AuthChallengeInfo* auth_info, |
| 441 URLRequest* request) { | 446 URLRequest* request) { |
| 442 LoginHandler* handler = LoginHandler::Create(auth_info, request); | 447 LoginHandler* handler = LoginHandler::Create(auth_info, request); |
| 443 BrowserThread::PostTask( | 448 BrowserThread::PostTask( |
| 444 BrowserThread::UI, FROM_HERE, new LoginDialogTask( | 449 BrowserThread::UI, FROM_HERE, new LoginDialogTask( |
| 445 request->url(), auth_info, handler)); | 450 request->url(), auth_info, handler)); |
| 446 return handler; | 451 return handler; |
| 447 } | 452 } |
| OLD | NEW |