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/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 "app/l10n_util.h" | 9 #include "app/l10n_util.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
378 TabContentsWrapper::property_accessor()->GetProperty( | 378 TabContentsWrapper::property_accessor()->GetProperty( |
379 parent_contents->property_bag()); | 379 parent_contents->property_bag()); |
380 if (!wrapper) | 380 if (!wrapper) |
381 return; | 381 return; |
382 PasswordManager* password_manager = (*wrapper)->GetPasswordManager(); | 382 PasswordManager* password_manager = (*wrapper)->GetPasswordManager(); |
383 std::vector<PasswordForm> v; | 383 std::vector<PasswordForm> v; |
384 MakeInputForPasswordManager(&v); | 384 MakeInputForPasswordManager(&v); |
385 password_manager->PasswordFormsFound(v); | 385 password_manager->PasswordFormsFound(v); |
386 handler_->SetPasswordManager(password_manager); | 386 handler_->SetPasswordManager(password_manager); |
387 | 387 |
388 std::wstring explanation = auth_info_->realm.empty() ? | 388 string16 host_and_port_hack16 = WideToUTF16Hack(auth_info_->host_and_port); |
389 l10n_util::GetStringF(IDS_LOGIN_DIALOG_DESCRIPTION_NO_REALM, | 389 string16 realm_hack16 = WideToUTF16Hack(auth_info_->realm); |
390 auth_info_->host_and_port) : | 390 string16 explanation = realm_hack16.empty() ? |
391 l10n_util::GetStringF(IDS_LOGIN_DIALOG_DESCRIPTION, | 391 l10n_util::GetStringFUTF16(IDS_LOGIN_DIALOG_DESCRIPTION_NO_REALM, |
392 auth_info_->host_and_port, | 392 host_and_port_hack16) : |
393 auth_info_->realm); | 393 l10n_util::GetStringFUTF16(IDS_LOGIN_DIALOG_DESCRIPTION, |
| 394 host_and_port_hack16, |
| 395 realm_hack16); |
394 handler_->BuildViewForPasswordManager(password_manager, | 396 handler_->BuildViewForPasswordManager(password_manager, |
395 explanation); | 397 UTF16ToWideHack(explanation)); |
396 } | 398 } |
397 | 399 |
398 private: | 400 private: |
399 // Helper to create a PasswordForm and stuff it into a vector as input | 401 // Helper to create a PasswordForm and stuff it into a vector as input |
400 // for PasswordManager::PasswordFormsFound, the hook into PasswordManager. | 402 // for PasswordManager::PasswordFormsFound, the hook into PasswordManager. |
401 void MakeInputForPasswordManager( | 403 void MakeInputForPasswordManager( |
402 std::vector<PasswordForm>* password_manager_input) { | 404 std::vector<PasswordForm>* password_manager_input) { |
403 PasswordForm dialog_form; | 405 PasswordForm dialog_form; |
404 if (LowerCaseEqualsASCII(auth_info_->scheme, "basic")) { | 406 if (LowerCaseEqualsASCII(auth_info_->scheme, "basic")) { |
405 dialog_form.scheme = PasswordForm::SCHEME_BASIC; | 407 dialog_form.scheme = PasswordForm::SCHEME_BASIC; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
444 // Public API | 446 // Public API |
445 | 447 |
446 LoginHandler* CreateLoginPrompt(net::AuthChallengeInfo* auth_info, | 448 LoginHandler* CreateLoginPrompt(net::AuthChallengeInfo* auth_info, |
447 net::URLRequest* request) { | 449 net::URLRequest* request) { |
448 LoginHandler* handler = LoginHandler::Create(auth_info, request); | 450 LoginHandler* handler = LoginHandler::Create(auth_info, request); |
449 BrowserThread::PostTask( | 451 BrowserThread::PostTask( |
450 BrowserThread::UI, FROM_HERE, new LoginDialogTask( | 452 BrowserThread::UI, FROM_HERE, new LoginDialogTask( |
451 request->url(), auth_info, handler)); | 453 request->url(), auth_info, handler)); |
452 return handler; | 454 return handler; |
453 } | 455 } |
OLD | NEW |