Commit ab56303a authored by David Roger's avatar David Roger Committed by Commit Bot

[signin] Update strings for profile switch promo

Screenshot:
https://storage.cloud.google.com/chromium-translation-screenshots/c76614ee7a694b28c9888e29efed8286c3677e5c

Mock:
https://screenshot.googleplex.com/87ZjBy33wCC6VX5.png

Bug: 1126238
Change-Id: I84f78c5c5b3f6bb23b8bb7218efdf2c807994d1e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2464937
Commit-Queue: David Roger <droger@chromium.org>
Commit-Queue: Monica Basta <msalama@chromium.org>
Reviewed-by: default avatarMonica Basta <msalama@chromium.org>
Cr-Commit-Position: refs/heads/master@{#816156}
parent 746f2131
...@@ -7958,6 +7958,12 @@ the Bookmarks menu."> ...@@ -7958,6 +7958,12 @@ the Bookmarks menu.">
<message name="IDS_SIGNIN_DICE_WEB_INTERCEPT_BUBBLE_CANCEL_BUTTON_LABEL" desc="Label of the cancel button in the web signin interception bubble"> <message name="IDS_SIGNIN_DICE_WEB_INTERCEPT_BUBBLE_CANCEL_BUTTON_LABEL" desc="Label of the cancel button in the web signin interception bubble">
No thanks No thanks
</message> </message>
<message name="IDS_SIGNIN_DICE_WEB_INTERCEPT_BUBBLE_CANCEL_SWITCH_BUTTON_LABEL" desc="Label of the cancel button in the web signin interception bubble (profile switch variant)">
Cancel
</message>
<message name="IDS_SIGNIN_DICE_WEB_INTERCEPT_BUBBLE_CONFIRM_SWITCH_BUTTON_LABEL" desc="Label of the profile switch button in the web signin interception bubble">
Switch
</message>
<message name="IDS_SIGNIN_DICE_WEB_INTERCEPT_CONSUMER_BUBBLE_DESC" desc="Body of the web signin interception bubble"> <message name="IDS_SIGNIN_DICE_WEB_INTERCEPT_CONSUMER_BUBBLE_DESC" desc="Body of the web signin interception bubble">
To keep your browsing separate, you can create a new profile for <ph name="NEW_USER">$1<ex>Bob</ex></ph> To keep your browsing separate, you can create a new profile for <ph name="NEW_USER">$1<ex>Bob</ex></ph>
</message> </message>
...@@ -7973,6 +7979,12 @@ the Bookmarks menu."> ...@@ -7973,6 +7979,12 @@ the Bookmarks menu.">
<message name="IDS_SIGNIN_DICE_WEB_INTERCEPT_ENTERPRISE_PROFILE_NAME" desc="Default name for work profiles created after signin interception"> <message name="IDS_SIGNIN_DICE_WEB_INTERCEPT_ENTERPRISE_PROFILE_NAME" desc="Default name for work profiles created after signin interception">
Work Work
</message> </message>
<message name="IDS_SIGNIN_DICE_WEB_INTERCEPT_SWITCH_BUBBLE_TITLE" desc="Title for the profile switch interception bubble">
Switch to another profile?
</message>
<message name="IDS_SIGNIN_DICE_WEB_INTERCEPT_SWITCH_BUBBLE_DESC" desc="Description for the profile switch interception bubble">
<ph name="EXISTING_USER">$2<ex>Bob</ex></ph>'s profile is already signed in to <ph name="NEW_USER">$1<ex>bob@gmail.com</ex></ph>
</message>
</if> </if>
<!-- Signin Error tab modal dialog --> <!-- Signin Error tab modal dialog -->
......
c76614ee7a694b28c9888e29efed8286c3677e5c
\ No newline at end of file
c76614ee7a694b28c9888e29efed8286c3677e5c
\ No newline at end of file
...@@ -18,7 +18,6 @@ js_library("dice_web_signin_intercept_app") { ...@@ -18,7 +18,6 @@ js_library("dice_web_signin_intercept_app") {
":dice_web_signin_intercept_browser_proxy", ":dice_web_signin_intercept_browser_proxy",
"//third_party/polymer/v3_0/components-chromium/iron-icon", "//third_party/polymer/v3_0/components-chromium/iron-icon",
"//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled", "//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled",
"//ui/webui/resources/js:load_time_data.m",
"//ui/webui/resources/js:web_ui_listener_behavior.m", "//ui/webui/resources/js:web_ui_listener_behavior.m",
] ]
} }
......
...@@ -116,9 +116,9 @@ ...@@ -116,9 +116,9 @@
<div class="action-container"> <div class="action-container">
<cr-button id="acceptButton" class="action-button" on-click="onAccept_" <cr-button id="acceptButton" class="action-button" on-click="onAccept_"
autofocus> autofocus>
$i18n{diceWebSigninInterceptAcceptLabel} [[interceptionParameters_.confirmButtonLabel]]
</cr-button> </cr-button>
<cr-button id="cancelButton" on-click="onCancel_"> <cr-button id="cancelButton" on-click="onCancel_">
$i18n{diceWebSigninInterceptCancelLabel} [[interceptionParameters_.cancelButtonLabel]]
</cr-button> </cr-button>
</div> </div>
...@@ -7,9 +7,7 @@ import 'chrome://resources/polymer/v3_0/iron-icon/iron-icon.js'; ...@@ -7,9 +7,7 @@ import 'chrome://resources/polymer/v3_0/iron-icon/iron-icon.js';
import './signin_icons.js'; import './signin_icons.js';
import './signin_shared_css.js'; import './signin_shared_css.js';
import './signin_vars_css.js'; import './signin_vars_css.js';
import './strings.m.js';
import {loadTimeData} from 'chrome://resources/js/load_time_data.m.js';
import {WebUIListenerBehavior} from 'chrome://resources/js/web_ui_listener_behavior.m.js'; import {WebUIListenerBehavior} from 'chrome://resources/js/web_ui_listener_behavior.m.js';
import {html, Polymer} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; import {html, Polymer} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js';
......
...@@ -22,6 +22,8 @@ export let AccountInfo; ...@@ -22,6 +22,8 @@ export let AccountInfo;
* headerText: string, * headerText: string,
* bodyTitle: string, * bodyTitle: string,
* bodyText: string, * bodyText: string,
* confirmButtonLabel: string,
* cancelButtonLabel: string,
* headerTextColor: string, * headerTextColor: string,
* headerBackgroundColor: string, * headerBackgroundColor: string,
* interceptedAccount: AccountInfo, * interceptedAccount: AccountInfo,
......
...@@ -154,10 +154,25 @@ base::Value DiceWebSigninInterceptHandler::GetAccountInfoValue( ...@@ -154,10 +154,25 @@ base::Value DiceWebSigninInterceptHandler::GetAccountInfoValue(
} }
base::Value DiceWebSigninInterceptHandler::GetInterceptionParametersValue() { base::Value DiceWebSigninInterceptHandler::GetInterceptionParametersValue() {
bool is_switch =
bubble_parameters_.interception_type ==
DiceWebSigninInterceptor::SigninInterceptionType::kProfileSwitch;
int confirmButtonStringID =
is_switch
? IDS_SIGNIN_DICE_WEB_INTERCEPT_BUBBLE_CONFIRM_SWITCH_BUTTON_LABEL
: IDS_SIGNIN_DICE_WEB_INTERCEPT_BUBBLE_NEW_PROFILE_BUTTON_LABEL;
int cancelButtonStringID =
is_switch
? IDS_SIGNIN_DICE_WEB_INTERCEPT_BUBBLE_CANCEL_SWITCH_BUTTON_LABEL
: IDS_SIGNIN_DICE_WEB_INTERCEPT_BUBBLE_CANCEL_BUTTON_LABEL;
base::Value parameters(base::Value::Type::DICTIONARY); base::Value parameters(base::Value::Type::DICTIONARY);
parameters.SetStringKey("headerText", GetHeaderText()); parameters.SetStringKey("headerText", GetHeaderText());
parameters.SetStringKey("bodyTitle", GetBodyTitle()); parameters.SetStringKey("bodyTitle", GetBodyTitle());
parameters.SetStringKey("bodyText", GetBodyText()); parameters.SetStringKey("bodyText", GetBodyText());
parameters.SetStringKey("confirmButtonLabel",
l10n_util::GetStringUTF8(confirmButtonStringID));
parameters.SetStringKey("cancelButtonLabel",
l10n_util::GetStringUTF8(cancelButtonStringID));
parameters.SetKey("interceptedAccount", parameters.SetKey("interceptedAccount",
GetAccountInfoValue(intercepted_account())); GetAccountInfoValue(intercepted_account()));
parameters.SetStringKey("headerBackgroundColor", parameters.SetStringKey("headerBackgroundColor",
...@@ -194,8 +209,8 @@ std::string DiceWebSigninInterceptHandler::GetBodyTitle() { ...@@ -194,8 +209,8 @@ std::string DiceWebSigninInterceptHandler::GetBodyTitle() {
return l10n_util::GetStringUTF8( return l10n_util::GetStringUTF8(
IDS_SIGNIN_DICE_WEB_INTERCEPT_CONSUMER_BUBBLE_TITLE); IDS_SIGNIN_DICE_WEB_INTERCEPT_CONSUMER_BUBBLE_TITLE);
case DiceWebSigninInterceptor::SigninInterceptionType::kProfileSwitch: case DiceWebSigninInterceptor::SigninInterceptionType::kProfileSwitch:
// TODO: use localized string once it's available. return l10n_util::GetStringUTF8(
return "Switch profile"; IDS_SIGNIN_DICE_WEB_INTERCEPT_SWITCH_BUBBLE_TITLE);
} }
} }
...@@ -222,10 +237,9 @@ std::string DiceWebSigninInterceptHandler::GetBodyText() { ...@@ -222,10 +237,9 @@ std::string DiceWebSigninInterceptHandler::GetBodyText() {
IDS_SIGNIN_DICE_WEB_INTERCEPT_CONSUMER_BUBBLE_DESC, IDS_SIGNIN_DICE_WEB_INTERCEPT_CONSUMER_BUBBLE_DESC,
base::UTF8ToUTF16(intercepted_account().given_name)); base::UTF8ToUTF16(intercepted_account().given_name));
case DiceWebSigninInterceptor::SigninInterceptionType::kProfileSwitch: case DiceWebSigninInterceptor::SigninInterceptionType::kProfileSwitch:
// TODO: use localized string once it's available. return l10n_util::GetStringFUTF8(
return base::StringPrintf( IDS_SIGNIN_DICE_WEB_INTERCEPT_SWITCH_BUBBLE_DESC,
"This account is already signed in in a different profile. Would " base::UTF8ToUTF16(intercepted_account().email),
"you like to switch to %s's profile?", base::UTF8ToUTF16(intercepted_account().given_name));
intercepted_account().given_name.c_str());
} }
} }
...@@ -8,10 +8,8 @@ ...@@ -8,10 +8,8 @@
#include "chrome/browser/profiles/profile_attributes_entry.h" #include "chrome/browser/profiles/profile_attributes_entry.h"
#include "chrome/browser/profiles/profile_avatar_icon_util.h" #include "chrome/browser/profiles/profile_avatar_icon_util.h"
#include "chrome/browser/ui/webui/signin/dice_web_signin_intercept_handler.h" #include "chrome/browser/ui/webui/signin/dice_web_signin_intercept_handler.h"
#include "chrome/browser/ui/webui/webui_util.h"
#include "chrome/common/webui_url_constants.h" #include "chrome/common/webui_url_constants.h"
#include "chrome/grit/browser_resources.h" #include "chrome/grit/browser_resources.h"
#include "chrome/grit/generated_resources.h"
#include "content/public/browser/web_ui.h" #include "content/public/browser/web_ui.h"
#include "content/public/browser/web_ui_data_source.h" #include "content/public/browser/web_ui_data_source.h"
#include "services/network/public/mojom/content_security_policy.mojom.h" #include "services/network/public/mojom/content_security_policy.mojom.h"
...@@ -32,17 +30,6 @@ DiceWebSigninInterceptUI::DiceWebSigninInterceptUI(content::WebUI* web_ui) ...@@ -32,17 +30,6 @@ DiceWebSigninInterceptUI::DiceWebSigninInterceptUI(content::WebUI* web_ui)
source->AddResourcePath("signin_shared_css.js", IDR_SIGNIN_SHARED_CSS_JS); source->AddResourcePath("signin_shared_css.js", IDR_SIGNIN_SHARED_CSS_JS);
source->AddResourcePath("signin_vars_css.js", IDR_SIGNIN_VARS_CSS_JS); source->AddResourcePath("signin_vars_css.js", IDR_SIGNIN_VARS_CSS_JS);
// Localized strings.
source->UseStringsJs();
source->EnableReplaceI18nInJS();
static constexpr webui::LocalizedString kLocalizedStrings[] = {
{"diceWebSigninInterceptAcceptLabel",
IDS_SIGNIN_DICE_WEB_INTERCEPT_BUBBLE_NEW_PROFILE_BUTTON_LABEL},
{"diceWebSigninInterceptCancelLabel",
IDS_SIGNIN_DICE_WEB_INTERCEPT_BUBBLE_CANCEL_BUTTON_LABEL},
};
webui::AddLocalizedStringsBulk(source, kLocalizedStrings);
// Resources for testing. // Resources for testing.
source->OverrideContentSecurityPolicy( source->OverrideContentSecurityPolicy(
network::mojom::CSPDirectiveName::ScriptSrc, network::mojom::CSPDirectiveName::ScriptSrc,
......
...@@ -35,6 +35,8 @@ suite('DiceWebSigninInterceptTest', function() { ...@@ -35,6 +35,8 @@ suite('DiceWebSigninInterceptTest', function() {
headerText: 'header_text', headerText: 'header_text',
bodyTitle: 'body_title', bodyTitle: 'body_title',
bodyText: 'body_text', bodyText: 'body_text',
confirmButtonLabel: 'confirm_label',
cancelButtonLabel: 'cancel_label',
headerTextColor: 'rgba(255, 255, 255, 1)', headerTextColor: 'rgba(255, 255, 255, 1)',
headerBackgroundColor: 'rgba(255, 0, 0, 1)', headerBackgroundColor: 'rgba(255, 0, 0, 1)',
interceptedAccount: {isManaged: false, pictureUrl: AVATAR_URL_1}, interceptedAccount: {isManaged: false, pictureUrl: AVATAR_URL_1},
...@@ -55,13 +57,18 @@ suite('DiceWebSigninInterceptTest', function() { ...@@ -55,13 +57,18 @@ suite('DiceWebSigninInterceptTest', function() {
* @param {string} expectedBodyText * @param {string} expectedBodyText
*/ */
function checkTextValues( function checkTextValues(
expectedHeaderText, expectedBodyTitle, expectedBodyText) { expectedHeaderText, expectedBodyTitle, expectedBodyText,
expectedConfirmLabel, expectedCancelLabel) {
const headerTextElement = app.$$('#headerText'); const headerTextElement = app.$$('#headerText');
assertEquals(expectedHeaderText, headerTextElement.textContent); assertEquals(expectedHeaderText, headerTextElement.textContent);
const titleElement = app.$$('#title'); const titleElement = app.$$('#title');
assertEquals(expectedBodyTitle, titleElement.textContent); assertEquals(expectedBodyTitle, titleElement.textContent);
const contentsElement = app.$$('#contents'); const contentsElement = app.$$('#contents');
assertEquals(expectedBodyText, contentsElement.textContent); assertEquals(expectedBodyText, contentsElement.textContent);
const confirmButton = app.$$('#acceptButton');
assertEquals(expectedConfirmLabel, confirmButton.textContent.trim());
const cancelButton = app.$$('#cancelButton');
assertEquals(expectedCancelLabel, cancelButton.textContent.trim());
} }
function checkImageUrl(elementId, expectedUrl) { function checkImageUrl(elementId, expectedUrl) {
...@@ -84,18 +91,24 @@ suite('DiceWebSigninInterceptTest', function() { ...@@ -84,18 +91,24 @@ suite('DiceWebSigninInterceptTest', function() {
test('TextValues', function() { test('TextValues', function() {
// Initial values. // Initial values.
checkTextValues('header_text', 'body_title', 'body_text'); checkTextValues(
'header_text', 'body_title', 'body_text', 'confirm_label',
'cancel_label');
// Update the values. // Update the values.
fireParametersChanged({ fireParametersChanged({
headerText: 'new_header_text', headerText: 'new_header_text',
bodyTitle: 'new_body_title', bodyTitle: 'new_body_title',
bodyText: 'new_body_text', bodyText: 'new_body_text',
confirmButtonLabel: 'new_confirm_label',
cancelButtonLabel: 'new_cancel_label',
headerTextColor: 'rgba(255, 255, 255, 1)', headerTextColor: 'rgba(255, 255, 255, 1)',
headerBackgroundColor: 'rgba(255, 0, 0, 1)', headerBackgroundColor: 'rgba(255, 0, 0, 1)',
interceptedAccount: {isManaged: false, pictureUrl: AVATAR_URL_1}, interceptedAccount: {isManaged: false, pictureUrl: AVATAR_URL_1},
}); });
checkTextValues('new_header_text', 'new_body_title', 'new_body_text'); checkTextValues(
'new_header_text', 'new_body_title', 'new_body_text',
'new_confirm_label', 'new_cancel_label');
}); });
test('Avatars', function() { test('Avatars', function() {
...@@ -107,6 +120,8 @@ suite('DiceWebSigninInterceptTest', function() { ...@@ -107,6 +120,8 @@ suite('DiceWebSigninInterceptTest', function() {
headerText: 'header_text', headerText: 'header_text',
bodyTitle: 'body_title', bodyTitle: 'body_title',
bodyText: 'body_text', bodyText: 'body_text',
confirmButtonLabel: 'confirm_label',
cancelButtonLabel: 'cancel_label',
headerTextColor: 'rgba(255, 255, 255, 1)', headerTextColor: 'rgba(255, 255, 255, 1)',
headerBackgroundColor: 'rgba(255, 0, 0, 1)', headerBackgroundColor: 'rgba(255, 0, 0, 1)',
interceptedAccount: {isManaged: false, pictureUrl: AVATAR_URL_2}, interceptedAccount: {isManaged: false, pictureUrl: AVATAR_URL_2},
......
...@@ -15,6 +15,8 @@ export class TestDiceWebSigninInterceptBrowserProxy extends TestBrowserProxy { ...@@ -15,6 +15,8 @@ export class TestDiceWebSigninInterceptBrowserProxy extends TestBrowserProxy {
headerText: '', headerText: '',
bodyTitle: '', bodyTitle: '',
bodyText: '', bodyText: '',
cancelButtonLabel: '',
confirmButtonLabel: '',
headerTextColor: '', headerTextColor: '',
headerBackgroundColor: '', headerBackgroundColor: '',
interceptedAccount: {isManaged: false, pictureUrl: ''}, interceptedAccount: {isManaged: false, pictureUrl: ''},
......
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