Skip to content

Commit

Permalink
[CrOS Cellular] Add UI for powerwash dialog eSIM warning.
Browse files Browse the repository at this point in the history
Add UI to <os-settings-powerwash-dialog> that displays a warning if
the user has installed eSIM profiles and shows a list of the profiles.
Contains a 'Continue' button that does not contain any business logic,
which will be added in a follow-up CL.

This is a follow-up CL from crrev.com/c/2875853.

Screenshot:
https://screenshot.googleplex.com/hJRAxFY5Cw9ebbY.png

Mocks:
https://carbon.googleplex.com/cros-ux/pages/lte-setup/settings-approach#366c05a9-5037-4406-ad43-ee889e29cece

Bug: 1196511
Change-Id: I6f481bb3f111fdebf73d7eae49509026c0e15ffb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2877774
Commit-Queue: Gordon Seto <gordonseto@google.com>
Reviewed-by: Regan Hsu <hsuregan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#880602}
  • Loading branch information
Gordon Seto authored and Chromium LUCI CQ committed May 7, 2021
1 parent aa20bd2 commit 00116dc
Show file tree
Hide file tree
Showing 17 changed files with 290 additions and 30 deletions.
18 changes: 18 additions & 0 deletions chrome/app/os_settings_strings.grdp
Expand Up @@ -3126,12 +3126,30 @@ Press an assigned switch to remove assignment.
<message name="IDS_SETTINGS_FACTORY_RESET_WARNING" desc="Warning text in the 'Factory Reset' window">
A restart is required before your device can be reset with Powerwash. <ph name="LINK_BEGIN">&lt;a&gt;</ph>Learn more<ph name="LINK_END">&lt;/a&gt;</ph>
</message>
<message name="IDS_SETTINGS_FACTORY_RESET_ESIM_WARNING_TITLE" desc="Name of the 'Factory reset' window">
Remove eSIM profiles before Powerwash
</message>
<message name="IDS_SETTINGS_FACTORY_RESET_ESIM_WARNING" desc="Warning text in the 'Factory Reset' window informing the user that the eSIM profiles they have installed won't be removed by a factory reset. Contains a url to the mobile data subpage.">
Powerwashing your device won't remove your eSIM profiles. Go to <ph name="LINK_BEGIN">&lt;a&gt;</ph>Mobile Settings<ph name="LINK_END">&lt;/a&gt;</ph> to manually remove these profiles.
</message>
<message name="IDS_SETTINGS_FACTORY_RESET_ESIM_LIST_TITLE" desc="Title for the list showing installed eSIM profiles in the 'Factory Reset' window.">
Active profiles
</message>
<message name="IDS_SETTINGS_FACTORY_RESET_ESIM_LIST_ITEM_TITLE" desc="Label for an eSIM profile shown in the 'Factory Reset' window displaying its name and provider.">
<ph name="NETWORK_NAME">$1<ex>My Verizon eSIM</ex></ph> - <ph name="SPAN_START">&lt;span id="providerName"&gt;</ph><ph name="CARRIER_NAME">$2<ex>Verizon Wireless</ex></ph><ph name="SPAN_END">&lt;/span&gt;</ph>
</message>
<message name="IDS_SETTINGS_FACTORY_RESET_ESIM_WARNING_CHECKBOX_LABEL" desc="Label for checkbox in the 'Factory Reset' window that confirms that the user is aware that the eSIM profiles they have installed won't be removed by a factory reset.">
I understand that installed eSIM profiles will not be removed by Powerwash
</message>
<message name="IDS_SETTINGS_FACTORY_RESET_BUTTON_LABEL" desc="Label for the factory reset button.">
Reset
</message>
<message name="IDS_SETTINGS_FACTORY_RESET_BUTTON_ROLE" desc="A label to be read aloud by screen readers when the Reset button is focused. This button initiates the device factory reset flow.">
Reset Button
</message>
<message name="IDS_SETTINGS_FACTORY_CONTINUE_BUTTON_LABEL" desc="Label for the button that navigates from the eSIM warning to the 'Factory Reset' UI.">
Continue
</message>

<!-- Google Assistant Page (OS Settings)-->
<message name="IDS_SETTINGS_GOOGLE_ASSISTANT" desc="Name of the settings page for Google Assistant.">
Expand Down
@@ -0,0 +1 @@
058df431bbd66f8555111b31273a30386c05910c
@@ -0,0 +1 @@
058df431bbd66f8555111b31273a30386c05910c
@@ -0,0 +1 @@
058df431bbd66f8555111b31273a30386c05910c
@@ -0,0 +1 @@
058df431bbd66f8555111b31273a30386c05910c
@@ -0,0 +1 @@
058df431bbd66f8555111b31273a30386c05910c
@@ -0,0 +1 @@
058df431bbd66f8555111b31273a30386c05910c
1 change: 1 addition & 0 deletions chrome/browser/resources/settings/chromeos/BUILD.gn
Expand Up @@ -446,6 +446,7 @@ preprocess_if_expr("preprocess_gen_v3") {
"chromeos/os_privacy_page/peripheral_data_access_browser_proxy.m.js",
"chromeos/os_privacy_page/peripheral_data_access_protection_dialog.m.js",
"chromeos/os_reset_page/os_powerwash_dialog.js",
"chromeos/os_reset_page/os_powerwash_dialog_esim_item.js",
"chromeos/os_reset_page/os_reset_page.js",
"chromeos/os_route.m.js",
"chromeos/os_search_page/os_search_page.m.js",
Expand Down
1 change: 1 addition & 0 deletions chrome/browser/resources/settings/chromeos/lazy_load.js
Expand Up @@ -48,6 +48,7 @@ import './os_printing_page/os_printing_page.js';
import './os_privacy_page/os_privacy_page.m.js';
import './os_privacy_page/peripheral_data_access_protection_dialog.m.js';
import './os_reset_page/os_powerwash_dialog.js';
import './os_reset_page/os_powerwash_dialog_esim_item.js';
import './os_reset_page/os_reset_page.js';
import './os_files_page/smb_shares_page.m.js';

Expand Down
11 changes: 11 additions & 0 deletions chrome/browser/resources/settings/chromeos/os_reset_page/BUILD.gn
Expand Up @@ -11,21 +11,31 @@ js_type_check("closure_compile_module") {
is_polymer3 = true
deps = [
":os_powerwash_dialog",
":os_powerwash_dialog_esim_item",
":os_reset_browser_proxy",
":os_reset_page",
]
}

js_library("os_powerwash_dialog") {
deps = [
":os_powerwash_dialog_esim_item",
":os_reset_browser_proxy",
"..:metrics_recorder.m",
"../..:lifetime_browser_proxy",
"../localized_link:localized_link.m",
"//third_party/polymer/v3_0/components-chromium/iron-list:iron-list",
"//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled",
]
}

js_library("os_powerwash_dialog_esim_item") {
deps = [
"//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled",
"//ui/webui/resources/js:i18n_behavior.m",
]
}

js_library("os_reset_browser_proxy") {
deps = [
"//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled",
Expand All @@ -48,6 +58,7 @@ js_library("os_reset_page") {
html_to_js("web_components") {
js_files = [
"os_powerwash_dialog.js",
"os_powerwash_dialog_esim_item.js",
"os_reset_page.js",
]
}
@@ -1,27 +1,99 @@
<style include="settings-shared"></style>
<style include="settings-shared">
:host {
--cr-dialog-width: 400px;
}

:host cr-checkbox {
--cr-checkbox-label-color: var(--cr-secondary-text-color);
--cr-checkbox-label-padding-start: 12px;
--cr-checkbox-unchecked-box-color: #888888;
}

iron-list {
background-color: #E8EAED61;
border-radius: 4px;
margin-top: 8px;
padding-bottom: 8px;
}

os-settings-powerwash-dialog-esim-item {
height: 32px;
padding-inline-end: 16px;
padding-inline-start: 16px;
}

#profilesListContainer {
margin-bottom: 8px;
margin-top: 20px;
}

#profilesListTitle {
font-size: calc(14 / 13 * 100%);
}

#checkboxLabel {
margin-top: 16px;
}
</style>
<cr-dialog id="dialog" close-text="$i18n{close}"
ignore-enter-key>
<div slot="title">$i18n{powerwashDialogTitle}</div>
<div slot="body">
<!-- TODO(crbug.com/1196511): UI still in progress. -->
<template is="dom-if"
if="[[shouldShowESimWarning_(installedESimProfiles)]]">

</template>
<template is="dom-if"
if="[[!shouldShowESimWarning_(installedESimProfiles)]]">
<template is="dom-if" if="[[shouldShowESimWarning_]]">
<div slot="title">$i18n{powerwashDialogESimWarningTitle}</div>
<div slot="body">
<!-- TODO(crbug.com/1196511): Add link to mobile settings. -->
<settings-localized-link
localized-string="$i18n{powerwashDialogESimWarning}"
link-url="#">
</settings-localized-link>
<div id="profilesListContainer">
<div id="profilesListTitle">
$i18n{powerwashDialogESimListTitle}
</div>
<iron-list items="[[installedESimProfiles]]"
scroll-target="profilesListContainer"
role="listbox">
<template>
<os-settings-powerwash-dialog-esim-item
profile="[[item]]"
tabindex="0"
role="option">
</os-powerwash-dialog-esim-item>
</template>
</iron-list>
</div>
<cr-checkbox>
<div id="checkboxLabel">
$i18n{powerwashDialogESimWarningCheckbox}
</div>
</cr-checkbox>
</div>
</template>
<template is="dom-if" if="[[!shouldShowESimWarning_]]">
<div slot="title">$i18n{powerwashDialogTitle}</div>
<div slot="body">
<div id="powerwashContainer">
<settings-localized-link
localized-string="$i18n{powerwashDialogExplanation}"
link-url="$i18nRaw{powerwashLearnMoreUrl}">
</settings-localized-link>
</div>
</template>
</div>
</div>
</template>
<div slot="button-container">
<cr-button class="cancel-button" on-click="onCancelTap_"
id="cancel">$i18n{cancel}</cr-button>
<cr-button class="action-button" id="powerwash"
on-click="onRestartTap_">$i18n{powerwashDialogButton}</cr-button>
<template is="dom-if" if="[[!shouldShowESimWarning_]]">
<cr-button class="action-button" id="powerwash"
on-click="onRestartTap_">
$i18n{powerwashDialogButton}
</cr-button>
</template>
<template is="dom-if" if="[[shouldShowESimWarning_]]">
<!-- TODO(crbug.com/1196511): Add continue button logic. -->
<cr-button class="action-button" id="continue"
hidden="[[!shouldShowESimWarning_]]">
$i18n{powerwashContinue}
</cr-button>
</template>
</div>
</cr-dialog>
Expand Up @@ -8,9 +8,12 @@
* from the user for a device reset (aka powerwash).
*/
import '//resources/cr_elements/cr_button/cr_button.m.js';
import '//resources/cr_elements/cr_checkbox/cr_checkbox.m.js';
import '//resources/cr_elements/cr_dialog/cr_dialog.m.js';
import '//resources/polymer/v3_0/iron-list/iron-list.js';
import '../localized_link/localized_link.m.js';
import '../../settings_shared_css.js';
import './os_powerwash_dialog_esim_item.js';

import {afterNextRender, flush, html, Polymer, TemplateInstanceBase, Templatizer} from '//resources/polymer/v3_0/polymer/polymer_bundled.min.js';

Expand Down Expand Up @@ -39,6 +42,13 @@ Polymer({
return [];
},
},

/** @private */
shouldShowESimWarning_: {
type: Boolean,
value: false,
computed: 'computeShouldShowESimWarning_(installedESimProfiles)',
},
},

/** @override */
Expand All @@ -63,7 +73,7 @@ Polymer({
* @return {boolean}
* @private
*/
shouldShowESimWarning_() {
computeShouldShowESimWarning_() {
return !!this.installedESimProfiles.length;
},
});
@@ -0,0 +1,13 @@
<style include="settings-shared">
div {
color: var(--cr-primary-text-color);
margin-top: 10px;
}

/* This id is in the string returned from getItemInnerHtml_() */
#providerName {
color: var(--google-grey-600);
}
</style>
<div inner-h-t-m-l="[[getItemInnerHtml_(profileProperties_)]]">
</div>
@@ -0,0 +1,99 @@
// Copyright 2021 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

/**
* @fileoverview
* 'os-settings-powerwash-dialog-esim-item' is an item showing details of an
* installed eSIM profile shown in a list in the device reset dialog.
*/
import '../../settings_shared_css.js';

import {I18nBehavior} from '//resources/js/i18n_behavior.m.js';
import {html, Polymer} from '//resources/polymer/v3_0/polymer/polymer_bundled.min.js';

Polymer({
_template: html`{__html_template__}`,
is: 'os-settings-powerwash-dialog-esim-item',

behaviors: [
I18nBehavior,
],

properties: {
/** @type {?chromeos.cellularSetup.mojom.ESimProfileRemote} */
profile: {
type: Object,
value: null,
observer: 'onProfileChanged_',
},

/**
* @type {?chromeos.cellularSetup.mojom.ESimProfileProperties}
* @private
*/
profileProperties_: {
type: Object,
value: null,
},
},

/** @private */
onProfileChanged_() {
if (!this.profile) {
this.profileProperties_ = null;
return;
}
this.profile.getProperties().then(response => {
this.profileProperties_ = response.properties;
});
},

/**
* @return {string}
* @private
*/
getItemInnerHtml_() {
if (!this.profileProperties_) {
return '';
}
const profileName = this.getProfileName_(this.profileProperties_);
const providerName = this.escapeHtml_(
String.fromCharCode(...this.profileProperties_.serviceProvider.data));
if (!providerName) {
return profileName;
}
return this.i18nAdvanced(
'powerwashDialogESimListItemTitle',
{attrs: ['id'], substitutions: [profileName, providerName]});
},

/**
* @param {chromeos.cellularSetup.mojom.ESimProfileProperties}
* profileProperties
* @return {string}
* @private
*/
getProfileName_(profileProperties) {
if (!profileProperties.nickname.data ||
!profileProperties.nickname.data.length) {
return this.escapeHtml_(
String.fromCharCode(...profileProperties.name.data));
}
return this.escapeHtml_(
String.fromCharCode(...profileProperties.nickname.data));
},

/**
* @param {string} string
* @return {string}
* @private
*/
escapeHtml_(string) {
return string.replace(/&/g, '&amp;')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
.replace(/"/g, '&quot;')
.replace(/'/g, '&#039;');
},
});
1 change: 1 addition & 0 deletions chrome/browser/resources/settings/chromeos/os_settings.gni
Expand Up @@ -308,6 +308,7 @@ os_settings_migrated_imports = [
"chrome/browser/resources/settings/chromeos/os_printing_page/cups_settings_add_printer_dialog.html",
"chrome/browser/resources/settings/chromeos/os_printing_page/os_printing_page.html",
"chrome/browser/resources/settings/chromeos/os_reset_page/os_powerwash_dialog.html",
"chrome/browser/resources/settings/chromeos/os_reset_page/os_powerwash_dialog_esim_item.html",
"chrome/browser/resources/settings/chromeos/os_reset_page/os_reset_browser_proxy.html",
"chrome/browser/resources/settings/chromeos/os_reset_page/os_reset_page.html",
"chrome/browser/resources/settings/chromeos/personalization_page/change_picture_browser_proxy.html",
Expand Down
10 changes: 10 additions & 0 deletions chrome/browser/ui/webui/settings/chromeos/reset_section.cc
Expand Up @@ -69,6 +69,16 @@ void ResetSection::AddLoadTimeData(content::WebUIDataSource* html_source) {
{"powerwashLearnMoreUrl", IDS_FACTORY_RESET_HELP_URL},
{"powerwashButtonRoleDescription",
IDS_SETTINGS_FACTORY_RESET_BUTTON_ROLE},
{"powerwashDialogESimWarningTitle",
IDS_SETTINGS_FACTORY_RESET_ESIM_WARNING_TITLE},
{"powerwashDialogESimWarning", IDS_SETTINGS_FACTORY_RESET_ESIM_WARNING},
{"powerwashDialogESimListTitle",
IDS_SETTINGS_FACTORY_RESET_ESIM_LIST_TITLE},
{"powerwashDialogESimListItemTitle",
IDS_SETTINGS_FACTORY_RESET_ESIM_LIST_ITEM_TITLE},
{"powerwashDialogESimWarningCheckbox",
IDS_SETTINGS_FACTORY_RESET_ESIM_WARNING_CHECKBOX_LABEL},
{"powerwashContinue", IDS_SETTINGS_FACTORY_CONTINUE_BUTTON_LABEL},
};
html_source->AddLocalizedStrings(kLocalizedStrings);

Expand Down

0 comments on commit 00116dc

Please sign in to comment.