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