Chromium Code Reviews| Index: chrome/browser/ui/webui/options/password_manager_handler.cc |
| diff --git a/chrome/browser/ui/webui/options/password_manager_handler.cc b/chrome/browser/ui/webui/options/password_manager_handler.cc |
| index 43198c1ba3b0cc34ff268e69cf3e08e678ef6a57..f103b8cff2a9ac6fac3f0f0f273f2a9aee542ffc 100644 |
| --- a/chrome/browser/ui/webui/options/password_manager_handler.cc |
| +++ b/chrome/browser/ui/webui/options/password_manager_handler.cc |
| @@ -25,17 +25,30 @@ |
| #include "components/password_manager/core/browser/affiliation_utils.h" |
| #include "components/password_manager/core/browser/password_bubble_experiment.h" |
| #include "components/password_manager/core/common/experiments.h" |
| +#include "components/url_formatter/url_formatter.h" |
| #include "content/public/browser/notification_details.h" |
| #include "content/public/browser/notification_source.h" |
| #include "content/public/browser/user_metrics.h" |
| #include "content/public/browser/web_contents.h" |
| #include "content/public/browser/web_ui.h" |
| #include "content/public/common/content_switches.h" |
| +#include "content/public/common/origin_util.h" |
| #include "net/base/net_util.h" |
| #include "ui/base/l10n/l10n_util.h" |
| namespace options { |
| +namespace { |
| +// The following constants should be synchronized with the constants in |
| +// chrome/browser/resources/options/password_manager_list.js. |
| +const char kOriginField[] = "origin"; |
|
Evan Stade
2015/10/13 17:15:01
ditto, not much use for these if you refactor/shar
kolos1
2015/10/15 09:34:53
I would like to have it. It gives explicit descrip
|
| +const char kShownUrlField[] = "shownUrl"; |
| +const char kIsSecureField[] = "isSecure"; |
| +const char kUsernameField[] = "username"; |
| +const char kPasswordField[] = "password"; |
| +const char kFederationField[] = "federation"; |
| +} |
| + |
| PasswordManagerHandler::PasswordManagerHandler() |
| : password_manager_presenter_(this) {} |
| @@ -56,24 +69,17 @@ void PasswordManagerHandler::GetLocalizedValues( |
| DCHECK(localized_strings); |
| static const OptionsStringResource resources[] = { |
| - { "autoSigninTitle", |
| - IDS_PASSWORDS_AUTO_SIGNIN_TITLE }, |
| - { "autoSigninDescription", |
| - IDS_PASSWORDS_AUTO_SIGNIN_DESCRIPTION }, |
| - { "savedPasswordsTitle", |
| - IDS_PASSWORDS_SHOW_PASSWORDS_TAB_TITLE }, |
| - { "passwordExceptionsTitle", |
| - IDS_PASSWORDS_EXCEPTIONS_TAB_TITLE }, |
| - { "passwordSearchPlaceholder", |
| - IDS_PASSWORDS_PAGE_SEARCH_PASSWORDS }, |
| - { "passwordShowButton", |
| - IDS_PASSWORDS_PAGE_VIEW_SHOW_BUTTON }, |
| - { "passwordHideButton", |
| - IDS_PASSWORDS_PAGE_VIEW_HIDE_BUTTON }, |
| - { "passwordsNoPasswordsDescription", |
| - IDS_PASSWORDS_PAGE_VIEW_NO_PASSWORDS_DESCRIPTION }, |
| - { "passwordsNoExceptionsDescription", |
| - IDS_PASSWORDS_PAGE_VIEW_NO_EXCEPTIONS_DESCRIPTION }, |
| + {"autoSigninTitle", IDS_PASSWORDS_AUTO_SIGNIN_TITLE}, |
| + {"autoSigninDescription", IDS_PASSWORDS_AUTO_SIGNIN_DESCRIPTION}, |
| + {"savedPasswordsTitle", IDS_PASSWORDS_SHOW_PASSWORDS_TAB_TITLE}, |
| + {"passwordExceptionsTitle", IDS_PASSWORDS_EXCEPTIONS_TAB_TITLE}, |
| + {"passwordSearchPlaceholder", IDS_PASSWORDS_PAGE_SEARCH_PASSWORDS}, |
| + {"passwordShowButton", IDS_PASSWORDS_PAGE_VIEW_SHOW_BUTTON}, |
| + {"passwordHideButton", IDS_PASSWORDS_PAGE_VIEW_HIDE_BUTTON}, |
| + {"passwordsNoPasswordsDescription", |
| + IDS_PASSWORDS_PAGE_VIEW_NO_PASSWORDS_DESCRIPTION}, |
| + {"passwordsNoExceptionsDescription", |
| + IDS_PASSWORDS_PAGE_VIEW_NO_EXCEPTIONS_DESCRIPTION}, |
| }; |
| RegisterStrings(localized_strings, resources, arraysize(resources)); |
| @@ -81,9 +87,9 @@ void PasswordManagerHandler::GetLocalizedValues( |
| const ProfileSyncService* sync_service = |
| ProfileSyncServiceFactory::GetForProfile(GetProfile()); |
| int title_id = |
| - password_bubble_experiment::IsSmartLockBrandingEnabled(sync_service) ? |
| - IDS_PASSWORD_MANAGER_SMART_LOCK_FOR_PASSWORDS : |
| - IDS_PASSWORDS_EXCEPTIONS_WINDOW_TITLE; |
| + password_bubble_experiment::IsSmartLockBrandingEnabled(sync_service) |
| + ? IDS_PASSWORD_MANAGER_SMART_LOCK_FOR_PASSWORDS |
| + : IDS_PASSWORDS_EXCEPTIONS_WINDOW_TITLE; |
| RegisterTitle(localized_strings, "passwordsPage", title_id); |
| localized_strings->SetString("passwordManagerLearnMoreURL", |
| @@ -206,24 +212,36 @@ void PasswordManagerHandler::SetPasswordList( |
| languages_ = GetProfile()->GetPrefs()->GetString(prefs::kAcceptLanguages); |
| base::string16 placeholder(base::ASCIIToUTF16(" ")); |
| for (size_t i = 0; i < password_list.size(); ++i) { |
| - base::ListValue* entry = new base::ListValue(); |
| - entry->AppendString(password_manager::GetHumanReadableOrigin( |
| - *password_list[i], languages_)); |
| - entry->AppendString(password_list[i]->username_value); |
| + scoped_ptr<base::DictionaryValue> entry(new base::DictionaryValue); |
| + |
| + entry->SetString(kOriginField, |
| + url_formatter::FormatUrl( |
| + password_list[i]->origin, languages_, |
| + url_formatter::kFormatUrlOmitNothing, |
| + net::UnescapeRule::SPACES, nullptr, nullptr, nullptr)); |
| + |
| + entry->SetString(kShownUrlField, password_manager::GetShownOrigin( |
| + password_list[i]->origin, languages_)); |
| + entry->SetBoolean(kIsSecureField, |
| + content::IsOriginSecure(password_list[i]->origin)); |
| + entry->SetString(kUsernameField, password_list[i]->username_value); |
| if (show_passwords) { |
| - entry->AppendString(password_list[i]->password_value); |
| + entry->SetString(kPasswordField, password_list[i]->password_value); |
| } else { |
| // Use a placeholder value with the same length as the password. |
| - entry->AppendString( |
| + entry->SetString( |
| + kPasswordField, |
| base::string16(password_list[i]->password_value.length(), ' ')); |
| } |
| const GURL& federation_url = password_list[i]->federation_url; |
| if (!federation_url.is_empty()) { |
| - entry->AppendString(l10n_util::GetStringFUTF16( |
| - IDS_PASSWORDS_VIA_FEDERATION, |
| - base::UTF8ToUTF16(federation_url.host()))); |
| + entry->SetString( |
| + kFederationField, |
| + l10n_util::GetStringFUTF16(IDS_PASSWORDS_VIA_FEDERATION, |
| + base::UTF8ToUTF16(federation_url.host()))); |
| } |
| - entries.Append(entry); |
| + |
| + entries.Append(entry.release()); |
| } |
| web_ui()->CallJavascriptFunction("PasswordManager.setSavedPasswordsList", |
| @@ -234,8 +252,20 @@ void PasswordManagerHandler::SetPasswordExceptionList( |
| const ScopedVector<autofill::PasswordForm>& password_exception_list) { |
| base::ListValue entries; |
| for (size_t i = 0; i < password_exception_list.size(); ++i) { |
|
Evan Stade
2015/10/13 17:15:01
for (const autofill::PasswordForm& exception : pas
kolos1
2015/10/15 09:34:54
Done. Thanks
|
| - entries.AppendString(password_manager::GetHumanReadableOrigin( |
| - *password_exception_list[i], languages_)); |
| + scoped_ptr<base::DictionaryValue> entry(new base::DictionaryValue); |
| + |
| + entry->SetString(kOriginField, |
| + url_formatter::FormatUrl( |
| + password_exception_list[i]->origin, languages_, |
| + url_formatter::kFormatUrlOmitNothing, |
| + net::UnescapeRule::SPACES, nullptr, nullptr, nullptr)); |
| + entry->SetString(kShownUrlField, |
| + password_manager::GetShownOrigin( |
| + password_exception_list[i]->origin, languages_)); |
| + entry->SetBoolean(kIsSecureField, content::IsOriginSecure( |
| + password_exception_list[i]->origin)); |
| + |
| + entries.Append(entry.release()); |
| } |
| web_ui()->CallJavascriptFunction("PasswordManager.setPasswordExceptionsList", |