Commit d2ca6661 authored by Maksim Ivanov's avatar Maksim Ivanov Committed by Commit Bot

Shorten smart card PIN error messages

To address the UX feedback, this CL makes the error messages displayed
in the smart card PIN scenarios shorter:
1. Don't display "Please try again".
2. Don't display the number of attempts left when it's greater than 3.

Bug: 1024251
Change-Id: I6450cd96a62a60fc2c414e71ef81af06d93e0e26
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2091355Reviewed-by: default avatarDenis Kuznetsov [CET] <antrim@chromium.org>
Commit-Queue: Maksim Ivanov <emaxx@chromium.org>
Cr-Commit-Position: refs/heads/master@{#748215}
parent 366a98a4
...@@ -7,6 +7,14 @@ ...@@ -7,6 +7,14 @@
* sign-in. * sign-in.
*/ */
(function() {
// Only inform the user about the number of attempts left if it's smaller or
// equal to this constant. (This is a pure UX heuristic.)
// Please keep this constant in sync with the one in
// //chromeos/components/security_token_pin/error_generator.cc.
const ATTEMPTS_LEFT_THRESHOLD = 3;
Polymer({ Polymer({
is: 'security-token-pin', is: 'security-token-pin',
...@@ -206,7 +214,8 @@ Polymer({ ...@@ -206,7 +214,8 @@ Polymer({
* @private * @private
*/ */
isAttemptsLeftVisible_(parameters) { isAttemptsLeftVisible_(parameters) {
return parameters && parameters.attemptsLeft != -1; return parameters && parameters.attemptsLeft >= 0 &&
parameters.attemptsLeft <= ATTEMPTS_LEFT_THRESHOLD;
}, },
/** /**
...@@ -245,15 +254,13 @@ Polymer({ ...@@ -245,15 +254,13 @@ Polymer({
// != NONE, so |errorLabelId| will be defined. // != NONE, so |errorLabelId| will be defined.
assert(errorLabelId); assert(errorLabelId);
// Format the error and, if present, the number of left attempts. // Format the error and, if present, the number of left attempts.
if (parameters && !parameters.enableUserInput) { if ((parameters && !parameters.enableUserInput) ||
!this.isAttemptsLeftVisible_(parameters)) {
return this.i18n(errorLabelId); return this.i18n(errorLabelId);
} }
if (!this.isAttemptsLeftVisible_(parameters)) {
return this.i18nRecursive(
locale, 'securityTokenPinDialogErrorRetry', errorLabelId);
}
return this.i18n( return this.i18n(
'securityTokenPinDialogErrorRetryAttempts', this.i18n(errorLabelId), 'securityTokenPinDialogErrorAttempts', this.i18n(errorLabelId),
parameters.attemptsLeft); parameters.attemptsLeft);
}, },
}); });
})();
...@@ -64,6 +64,7 @@ ...@@ -64,6 +64,7 @@
#include "chrome/common/pref_names.h" #include "chrome/common/pref_names.h"
#include "chrome/grit/generated_resources.h" #include "chrome/grit/generated_resources.h"
#include "chrome/installer/util/google_update_settings.h" #include "chrome/installer/util/google_update_settings.h"
#include "chromeos/components/security_token_pin/constants.h"
#include "chromeos/constants/chromeos_features.h" #include "chromeos/constants/chromeos_features.h"
#include "chromeos/constants/chromeos_switches.h" #include "chromeos/constants/chromeos_switches.h"
#include "chromeos/constants/devicetype.h" #include "chromeos/constants/devicetype.h"
...@@ -676,10 +677,8 @@ void GaiaScreenHandler::DeclareLocalizedValues( ...@@ -676,10 +677,8 @@ void GaiaScreenHandler::DeclareLocalizedValues(
IDS_SAML_SECURITY_TOKEN_PIN_DIALOG_TRY_AGAIN); IDS_SAML_SECURITY_TOKEN_PIN_DIALOG_TRY_AGAIN);
builder->Add("securityTokenPinDialogAttemptsLeft", builder->Add("securityTokenPinDialogAttemptsLeft",
IDS_REQUEST_PIN_DIALOG_ATTEMPTS_LEFT); IDS_REQUEST_PIN_DIALOG_ATTEMPTS_LEFT);
builder->Add("securityTokenPinDialogErrorRetry", builder->Add("securityTokenPinDialogErrorAttempts",
IDS_REQUEST_PIN_DIALOG_ERROR_RETRY); IDS_REQUEST_PIN_DIALOG_ERROR_ATTEMPTS);
builder->Add("securityTokenPinDialogErrorRetryAttempts",
IDS_REQUEST_PIN_DIALOG_ERROR_RETRY_ATTEMPTS);
builder->Add("securityTokenPinDialogUnknownError", builder->Add("securityTokenPinDialogUnknownError",
IDS_REQUEST_PIN_DIALOG_UNKNOWN_ERROR); IDS_REQUEST_PIN_DIALOG_UNKNOWN_ERROR);
builder->Add("securityTokenPinDialogUnknownInvalidPin", builder->Add("securityTokenPinDialogUnknownInvalidPin",
......
...@@ -295,13 +295,10 @@ Try tapping the mic to ask me anything. ...@@ -295,13 +295,10 @@ Try tapping the mic to ask me anything.
Unknown error. Unknown error.
</message> </message>
<message name="IDS_REQUEST_PIN_DIALOG_ATTEMPTS_LEFT" desc="The text displayed in the certificate provider PIN request dialog about the number of attempts left"> <message name="IDS_REQUEST_PIN_DIALOG_ATTEMPTS_LEFT" desc="The text displayed in the certificate provider PIN request dialog about the number of attempts left">
Attempts left: <ph name="ATTEMPTS_LEFT">$1<ex>3</ex></ph> <ph name="ATTEMPTS_LEFT">$1<ex>3</ex></ph> attempts left
</message> </message>
<message name="IDS_REQUEST_PIN_DIALOG_ERROR_RETRY" desc="The text displayed in the certificate provider PIN request dialog when the previous login attempt was unsuccessful, including the reason for the previous failure."> <message name="IDS_REQUEST_PIN_DIALOG_ERROR_ATTEMPTS" desc="The text displayed in the certificate provider PIN request dialog when the previous login attempt was unsuccessful but there are more attempts remaining. Includes the reason for the previous failure.">
<ph name="ERROR_MESSAGE">$1<ex>Invalid PIN.</ex></ph> Please try again. <ph name="ERROR_MESSAGE">$1<ex>Invalid PIN.</ex></ph> <ph name="ATTEMPTS_LEFT">$2<ex>3</ex></ph> attempts left
</message>
<message name="IDS_REQUEST_PIN_DIALOG_ERROR_RETRY_ATTEMPTS" desc="The text displayed in the certificate provider PIN request dialog when the previous login attempt was unsuccessful but there are more attempts remaining. Includes the reason for the previous failure.">
<ph name="ERROR_MESSAGE">$1<ex>Invalid PIN.</ex></ph> Please try again. Attempts left: <ph name="ATTEMPTS_LEFT">$2<ex>3</ex></ph>
</message> </message>
</messages> </messages>
</release> </release>
......
...@@ -11,6 +11,11 @@ ...@@ -11,6 +11,11 @@
namespace chromeos { namespace chromeos {
namespace security_token_pin { namespace security_token_pin {
// Only inform the user about the number of attempts left if it's smaller or
// equal to this constant. (This is a pure UX heuristic.)
// Please keep this constant in sync with the one in security_token_pin.js.
constexpr int kAttemptsLeftThreshold = 3;
base::string16 GenerateErrorMessage(ErrorLabel error_label, base::string16 GenerateErrorMessage(ErrorLabel error_label,
int attempts_left, int attempts_left,
bool accept_input) { bool accept_input) {
...@@ -38,18 +43,15 @@ base::string16 GenerateErrorMessage(ErrorLabel error_label, ...@@ -38,18 +43,15 @@ base::string16 GenerateErrorMessage(ErrorLabel error_label,
break; break;
} }
if (!accept_input) { if (!accept_input || attempts_left == -1 ||
attempts_left > kAttemptsLeftThreshold) {
return error_message; return error_message;
} }
if (attempts_left == -1) {
return l10n_util::GetStringFUTF16(IDS_REQUEST_PIN_DIALOG_ERROR_RETRY,
error_message);
}
if (error_message.empty()) { if (error_message.empty()) {
return l10n_util::GetStringFUTF16(IDS_REQUEST_PIN_DIALOG_ATTEMPTS_LEFT, return l10n_util::GetStringFUTF16(IDS_REQUEST_PIN_DIALOG_ATTEMPTS_LEFT,
base::FormatNumber(attempts_left)); base::FormatNumber(attempts_left));
} }
return l10n_util::GetStringFUTF16(IDS_REQUEST_PIN_DIALOG_ERROR_RETRY_ATTEMPTS, return l10n_util::GetStringFUTF16(IDS_REQUEST_PIN_DIALOG_ERROR_ATTEMPTS,
error_message, error_message,
base::FormatNumber(attempts_left)); base::FormatNumber(attempts_left));
} }
......
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