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.">
<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
</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">
To keep your browsing separate, you can create a new profile for <ph name="NEW_USER">$1<ex>Bob</ex></ph>
</message>
......@@ -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">
Work
</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>
<!-- 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") {
":dice_web_signin_intercept_browser_proxy",
"//third_party/polymer/v3_0/components-chromium/iron-icon",
"//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",
]
}
......
......@@ -116,9 +116,9 @@
<div class="action-container">
<cr-button id="acceptButton" class="action-button" on-click="onAccept_"
autofocus>
$i18n{diceWebSigninInterceptAcceptLabel}
[[interceptionParameters_.confirmButtonLabel]]
</cr-button>
<cr-button id="cancelButton" on-click="onCancel_">
$i18n{diceWebSigninInterceptCancelLabel}
[[interceptionParameters_.cancelButtonLabel]]
</cr-button>
</div>
......@@ -7,9 +7,7 @@ import 'chrome://resources/polymer/v3_0/iron-icon/iron-icon.js';
import './signin_icons.js';
import './signin_shared_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 {html, Polymer} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js';
......
......@@ -22,6 +22,8 @@ export let AccountInfo;
* headerText: string,
* bodyTitle: string,
* bodyText: string,
* confirmButtonLabel: string,
* cancelButtonLabel: string,
* headerTextColor: string,
* headerBackgroundColor: string,
* interceptedAccount: AccountInfo,
......
......@@ -154,10 +154,25 @@ base::Value DiceWebSigninInterceptHandler::GetAccountInfoValue(
}
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);
parameters.SetStringKey("headerText", GetHeaderText());
parameters.SetStringKey("bodyTitle", GetBodyTitle());
parameters.SetStringKey("bodyText", GetBodyText());
parameters.SetStringKey("confirmButtonLabel",
l10n_util::GetStringUTF8(confirmButtonStringID));
parameters.SetStringKey("cancelButtonLabel",
l10n_util::GetStringUTF8(cancelButtonStringID));
parameters.SetKey("interceptedAccount",
GetAccountInfoValue(intercepted_account()));
parameters.SetStringKey("headerBackgroundColor",
......@@ -194,8 +209,8 @@ std::string DiceWebSigninInterceptHandler::GetBodyTitle() {
return l10n_util::GetStringUTF8(
IDS_SIGNIN_DICE_WEB_INTERCEPT_CONSUMER_BUBBLE_TITLE);
case DiceWebSigninInterceptor::SigninInterceptionType::kProfileSwitch:
// TODO: use localized string once it's available.
return "Switch profile";
return l10n_util::GetStringUTF8(
IDS_SIGNIN_DICE_WEB_INTERCEPT_SWITCH_BUBBLE_TITLE);
}
}
......@@ -222,10 +237,9 @@ std::string DiceWebSigninInterceptHandler::GetBodyText() {
IDS_SIGNIN_DICE_WEB_INTERCEPT_CONSUMER_BUBBLE_DESC,
base::UTF8ToUTF16(intercepted_account().given_name));
case DiceWebSigninInterceptor::SigninInterceptionType::kProfileSwitch:
// TODO: use localized string once it's available.
return base::StringPrintf(
"This account is already signed in in a different profile. Would "
"you like to switch to %s's profile?",
intercepted_account().given_name.c_str());
return l10n_util::GetStringFUTF8(
IDS_SIGNIN_DICE_WEB_INTERCEPT_SWITCH_BUBBLE_DESC,
base::UTF8ToUTF16(intercepted_account().email),
base::UTF8ToUTF16(intercepted_account().given_name));
}
}
......@@ -8,10 +8,8 @@
#include "chrome/browser/profiles/profile_attributes_entry.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/webui_util.h"
#include "chrome/common/webui_url_constants.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_data_source.h"
#include "services/network/public/mojom/content_security_policy.mojom.h"
......@@ -32,17 +30,6 @@ DiceWebSigninInterceptUI::DiceWebSigninInterceptUI(content::WebUI* web_ui)
source->AddResourcePath("signin_shared_css.js", IDR_SIGNIN_SHARED_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.
source->OverrideContentSecurityPolicy(
network::mojom::CSPDirectiveName::ScriptSrc,
......
......@@ -35,6 +35,8 @@ suite('DiceWebSigninInterceptTest', function() {
headerText: 'header_text',
bodyTitle: 'body_title',
bodyText: 'body_text',
confirmButtonLabel: 'confirm_label',
cancelButtonLabel: 'cancel_label',
headerTextColor: 'rgba(255, 255, 255, 1)',
headerBackgroundColor: 'rgba(255, 0, 0, 1)',
interceptedAccount: {isManaged: false, pictureUrl: AVATAR_URL_1},
......@@ -55,13 +57,18 @@ suite('DiceWebSigninInterceptTest', function() {
* @param {string} expectedBodyText
*/
function checkTextValues(
expectedHeaderText, expectedBodyTitle, expectedBodyText) {
expectedHeaderText, expectedBodyTitle, expectedBodyText,
expectedConfirmLabel, expectedCancelLabel) {
const headerTextElement = app.$$('#headerText');
assertEquals(expectedHeaderText, headerTextElement.textContent);
const titleElement = app.$$('#title');
assertEquals(expectedBodyTitle, titleElement.textContent);
const contentsElement = app.$$('#contents');
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) {
......@@ -84,18 +91,24 @@ suite('DiceWebSigninInterceptTest', function() {
test('TextValues', function() {
// Initial values.
checkTextValues('header_text', 'body_title', 'body_text');
checkTextValues(
'header_text', 'body_title', 'body_text', 'confirm_label',
'cancel_label');
// Update the values.
fireParametersChanged({
headerText: 'new_header_text',
bodyTitle: 'new_body_title',
bodyText: 'new_body_text',
confirmButtonLabel: 'new_confirm_label',
cancelButtonLabel: 'new_cancel_label',
headerTextColor: 'rgba(255, 255, 255, 1)',
headerBackgroundColor: 'rgba(255, 0, 0, 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() {
......@@ -107,6 +120,8 @@ suite('DiceWebSigninInterceptTest', function() {
headerText: 'header_text',
bodyTitle: 'body_title',
bodyText: 'body_text',
confirmButtonLabel: 'confirm_label',
cancelButtonLabel: 'cancel_label',
headerTextColor: 'rgba(255, 255, 255, 1)',
headerBackgroundColor: 'rgba(255, 0, 0, 1)',
interceptedAccount: {isManaged: false, pictureUrl: AVATAR_URL_2},
......
......@@ -15,6 +15,8 @@ export class TestDiceWebSigninInterceptBrowserProxy extends TestBrowserProxy {
headerText: '',
bodyTitle: '',
bodyText: '',
cancelButtonLabel: '',
confirmButtonLabel: '',
headerTextColor: '',
headerBackgroundColor: '',
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