Commit 05f54014 authored by Jan Wilken Dörrie's avatar Jan Wilken Dörrie Committed by Commit Bot

[Passwords] Add Pluralized String for Compromised Passwords

This change adds a pluralized string for the number of compromised
passwords. In order to do so it makes use of the recently introduced
PluralStringProxy that dispatches to the C++ backend to get the
correct string.

Bug: 1047726
Change-Id: I1b6223d72e67d5b32690b42c04b5644c5f9da067
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2093594
Commit-Queue: Jan Wilken Dörrie <jdoerrie@chromium.org>
Reviewed-by: default avatarFriedrich [CET] <fhorschig@chromium.org>
Reviewed-by: default avatarEsmael Elmoslimany <aee@chromium.org>
Cr-Commit-Position: refs/heads/master@{#748277}
parent 317e2281
......@@ -326,8 +326,11 @@
<message name="IDS_SETTINGS_CHECK_PASSWORDS_DESCRIPTION" desc="Explanation of the passwords bulk check feature found within the password settings.">
Keep your passwords safe from data breaches and other security issues
</message>
<message name="IDS_SETTINGS_LEAKED_PASSWORDS_COUNT" desc="Number of compromised passwords found during bulk check.">
<ph name="COUNT">$1<ex>5</ex></ph> compromised passwords
<message name="IDS_SETTINGS_COMPROMISED_PASSWORDS_COUNT" desc="Number of compromised passwords present in the database">
{COUNT, plural,
=0 {No compromised passwords found}
=1 {{COUNT} compromised password}
other {{COUNT} compromised passwords}}
</message>
<message name="IDS_SETTINGS_CHECK_PASSWORDS_AGAIN" desc="Button to start bulk password check manually in passwords check section.">
Check again
......
6d986169cb55c2109ba001bff3da1a2118946e46
\ No newline at end of file
956520bbbe69fb947a771b72de567f1bac2ac5c4
\ No newline at end of file
......@@ -92,6 +92,7 @@ js_library("credit_card_list_entry") {
js_library("password_check") {
deps = [
":password_manager_proxy",
"..:plural_string_proxy",
"//ui/webui/resources/js:i18n_behavior",
]
}
......
......@@ -3,6 +3,7 @@
<link rel="import" href="chrome://resources/cr_elements/cr_action_menu/cr_action_menu.html">
<link rel="import" href="chrome://resources/cr_elements/cr_button/cr_button.html">
<link rel="import" href="../i18n_setup.html">
<link rel="import" href="../plural_string_proxy.html">
<link rel="import" href="../settings_shared_css.html">
<link rel="import" href="chrome://resources/cr_elements/icons.html">
<link rel="import" href="chrome://resources/polymer/v1_0/iron-icon/iron-icon.html">
......@@ -30,9 +31,8 @@
&bull; [[lastCompletedCheck_]]
</span>
</div>
<div class="secondary" id="passwordLeakCount"
name="[[passwordLeakCount_]]">
[[getLeakedPasswordsCount_(passwordLeakCount_)]]
<div class="secondary" id="passwordLeakCount">
[[compromisedPasswordsCount_]]
</div>
</div>
<cr-button id="controlPasswordCheckButton"
......
......@@ -13,15 +13,15 @@ Polymer({
behaviors: [I18nBehavior],
properties: {
/** @private */
passwordLeakCount_: {
type: Number,
value: 0,
},
/** @private */
lastCompletedCheck_: String,
/**
* The number of compromised passwords as a formatted string.
* @private
*/
compromisedPasswordsCount_: String,
/**
* An array of leaked passwords to display.
* @type {!Array<!PasswordManagerProxy.CompromisedCredential>}
......@@ -79,8 +79,13 @@ Polymer({
const statusChangeListener = status => this.status_ = status;
const setLeakedCredentialsListener = info => {
this.leakedPasswords = info.compromisedCredentials;
this.passwordLeakCount_ = info.compromisedCredentials.length;
this.lastCompletedCheck_ = info.elapsedTimeSinceLastCheck;
settings.PluralStringProxyImpl.getInstance()
.getPluralString('compromisedPasswords', this.leakedPasswords.length)
.then(count => {
this.compromisedPasswordsCount_ = count;
});
};
this.statusChangedListener_ = statusChangeListener;
......@@ -119,14 +124,6 @@ Polymer({
this.passwordManager_.startBulkPasswordCheck();
},
/**
* @return {string}
* @private
*/
getLeakedPasswordsCount_() {
return this.i18n('checkPasswordLeakCount', this.passwordLeakCount_);
},
/**
* Returns true if there are any compromised credentials.
* @param {!Array<!PasswordManagerProxy.CompromisedCredential>} list
......
<link rel="import" href="chrome://resources/html/polymer.html">
<script src="password_manager_proxy.js"></script>
\ No newline at end of file
<script src="password_manager_proxy.js"></script>
......@@ -731,7 +731,6 @@ void AddAutofillStrings(content::WebUIDataSource* html_source,
{"checkPasswords", IDS_SETTINGS_CHECK_PASSWORDS},
{"checkedPasswords", IDS_SETTINGS_CHECKED_PASSWORDS},
{"checkPasswordsDescription", IDS_SETTINGS_CHECK_PASSWORDS_DESCRIPTION},
{"checkPasswordLeakCount", IDS_SETTINGS_LEAKED_PASSWORDS_COUNT},
{"checkPasswordsAgain", IDS_SETTINGS_CHECK_PASSWORDS_AGAIN},
{"compromisedPasswords", IDS_SETTINGS_COMPROMISED_PASSWORDS},
{"compromisedPasswordsDescription",
......
......@@ -305,7 +305,10 @@ SettingsUI::SettingsUI(content::WebUI* web_ui)
base::WrapUnique(ResetSettingsHandler::Create(html_source, profile)));
// Add a handler to provide pluralized strings.
web_ui->AddMessageHandler(std::make_unique<PluralStringHandler>());
auto plural_string_handler = std::make_unique<PluralStringHandler>();
plural_string_handler->AddLocalizedString(
"compromisedPasswords", IDS_SETTINGS_COMPROMISED_PASSWORDS_COUNT);
web_ui->AddMessageHandler(std::move(plural_string_handler));
// Add the metrics handler to write uma stats.
web_ui->AddMessageHandler(std::make_unique<MetricsHandler>());
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment