Commit b1a37811 authored by Anastasiia N's avatar Anastasiia N Committed by Commit Bot

Migrate resources/chromeos/account_manager/ to Polymer 3

resources/chromeos/account_manager/ folder contains the following pages,
which are opened from the different dialogs:
- account_manager_welcome ("Sign in changed" welcome page)
- account_migration_welcome ("Update your account" page)
- account_manager_error ("Cannot add account" error page)

Bug: 1111846
Change-Id: I60b3806b4651842ccc587851f2a948c3cd25acf0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2352882
Commit-Queue: Anastasiia N <anastasiian@chromium.org>
Reviewed-by: default avatarRebekah Potter <rbpotter@chromium.org>
Cr-Commit-Position: refs/heads/master@{#800070}
parent 7bacea5b
...@@ -5931,6 +5931,7 @@ grit("resources") { ...@@ -5931,6 +5931,7 @@ grit("resources") {
} }
if (is_chromeos) { if (is_chromeos) {
deps += [ deps += [
"//chrome/browser/resources/chromeos/account_manager:web_components",
"//chrome/browser/resources/chromeos/account_manager/components:web_components", "//chrome/browser/resources/chromeos/account_manager/components:web_components",
"//chrome/browser/resources/chromeos/crostini_installer:polymer3_elements", "//chrome/browser/resources/chromeos/crostini_installer:polymer3_elements",
"//chrome/browser/resources/chromeos/crostini_upgrader:polymer3_elements", "//chrome/browser/resources/chromeos/crostini_upgrader:polymer3_elements",
......
...@@ -235,15 +235,14 @@ ...@@ -235,15 +235,14 @@
<!-- Chrome OS Account Manager resources --> <!-- Chrome OS Account Manager resources -->
<include name="IDR_ACCOUNT_MANAGER_COMPONENTS_ERROR_SCREEN_JS" file="${root_gen_dir}\chrome\browser\resources\chromeos\account_manager\components\error_screen.js" use_base_dir="false" type ="BINDATA"/> <include name="IDR_ACCOUNT_MANAGER_COMPONENTS_ERROR_SCREEN_JS" file="${root_gen_dir}\chrome\browser\resources\chromeos\account_manager\components\error_screen.js" use_base_dir="false" type ="BINDATA"/>
<include name="IDR_ACCOUNT_MANAGER_SHARED_CSS" file="resources\chromeos\account_manager\account_manager_shared.css" type="BINDATA" /> <include name="IDR_ACCOUNT_MANAGER_SHARED_CSS_JS" file="${root_gen_dir}\chrome\browser\resources\chromeos\account_manager\account_manager_shared_css.js" use_base_dir="false" type ="BINDATA" />
<include name="IDR_ACCOUNT_MANAGER_WELCOME_HTML" file="resources\chromeos\account_manager\account_manager_welcome.html" allowexternalscript="true" type="BINDATA" preprocess="true"/> <include name="IDR_ACCOUNT_MANAGER_WELCOME_HTML" file="resources\chromeos\account_manager\account_manager_welcome.html" allowexternalscript="true" type="BINDATA" preprocess="true"/>
<include name="IDR_ACCOUNT_MANAGER_WELCOME_JS" file="resources\chromeos\account_manager\account_manager_welcome.js" type="BINDATA" /> <include name="IDR_ACCOUNT_MANAGER_WELCOME_APP_JS" file="${root_gen_dir}\chrome\browser\resources\chromeos\account_manager\account_manager_welcome_app.js" use_base_dir="false" preprocess="true" type="BINDATA" />
<include name="IDR_ACCOUNT_MIGRATION_WELCOME_HTML" file="resources\chromeos\account_manager\account_migration_welcome.html" flattenhtml="true" allowexternalscript="true" type="BINDATA" /> <include name="IDR_ACCOUNT_MIGRATION_WELCOME_HTML" file="resources\chromeos\account_manager\account_migration_welcome.html" flattenhtml="true" allowexternalscript="true" type="BINDATA" />
<include name="IDR_ACCOUNT_MIGRATION_WELCOME_JS" file="resources\chromeos\account_manager\account_migration_welcome.js" flattenhtml="true" type="BINDATA" /> <include name="IDR_ACCOUNT_MIGRATION_WELCOME_APP_JS" file="${root_gen_dir}\chrome\browser\resources\chromeos\account_manager\account_migration_welcome_app.js" use_base_dir="false" preprocess="true" type="BINDATA" />
<include name="IDR_ACCOUNT_MANAGER_BROWSER_PROXY_HTML" file="resources\chromeos\account_manager\account_manager_browser_proxy.html" type="BINDATA" />
<include name="IDR_ACCOUNT_MANAGER_BROWSER_PROXY_JS" file="resources\chromeos\account_manager\account_manager_browser_proxy.js" type="BINDATA" /> <include name="IDR_ACCOUNT_MANAGER_BROWSER_PROXY_JS" file="resources\chromeos\account_manager\account_manager_browser_proxy.js" type="BINDATA" />
<include name="IDR_ACCOUNT_MANAGER_ERROR_HTML" file="resources\chromeos\account_manager\account_manager_error.html" allowexternalscript="true" type="BINDATA" preprocess="true"/> <include name="IDR_ACCOUNT_MANAGER_ERROR_HTML" file="resources\chromeos\account_manager\account_manager_error.html" allowexternalscript="true" type="BINDATA" preprocess="true"/>
<include name="IDR_ACCOUNT_MANAGER_ERROR_JS" file="resources\chromeos\account_manager\account_manager_error.js" type="BINDATA" /> <include name="IDR_ACCOUNT_MANAGER_ERROR_APP_JS" file="${root_gen_dir}\chrome\browser\resources\chromeos\account_manager\account_manager_error_app.js" use_base_dir="false" preprocess="true" type="BINDATA" />
<if expr="_google_chrome"> <if expr="_google_chrome">
<include name="IDR_ACCOUNT_MANAGER_WELCOME_1X_PNG" file="resources\chromeos\account_manager\account_manager_welcome_1x.png" type="BINDATA" compress="gzip" /> <include name="IDR_ACCOUNT_MANAGER_WELCOME_1X_PNG" file="resources\chromeos\account_manager\account_manager_welcome_1x.png" type="BINDATA" compress="gzip" />
<include name="IDR_ACCOUNT_MANAGER_WELCOME_2X_PNG" file="resources\chromeos\account_manager\account_manager_welcome_2x.png" type="BINDATA" compress="gzip" /> <include name="IDR_ACCOUNT_MANAGER_WELCOME_2X_PNG" file="resources\chromeos\account_manager\account_manager_welcome_2x.png" type="BINDATA" compress="gzip" />
......
...@@ -40,6 +40,7 @@ group("closure_compile") { ...@@ -40,6 +40,7 @@ group("closure_compile") {
"accessibility/braille_ime:closure_compile", "accessibility/braille_ime:closure_compile",
"accessibility/select_to_speak:closure_compile", "accessibility/select_to_speak:closure_compile",
"accessibility/switch_access:closure_compile", "accessibility/switch_access:closure_compile",
"account_manager:closure_compile",
"account_manager/components:closure_compile", "account_manager/components:closure_compile",
"add_supervision:closure_compile", "add_supervision:closure_compile",
"bluetooth_pairing_dialog:closure_compile", "bluetooth_pairing_dialog:closure_compile",
......
# Copyright 2020 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.
import("//third_party/closure_compiler/compile_js.gni")
import("//tools/polymer/html_to_js.gni")
js_type_check("closure_compile") {
is_polymer3 = true
deps = [
":account_manager_browser_proxy",
":account_manager_error_app",
":account_manager_welcome_app",
":account_migration_welcome_app",
]
}
js_library("account_manager_welcome_app") {
deps = [
":account_manager_browser_proxy",
"//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled",
]
}
js_library("account_migration_welcome_app") {
deps = [
":account_manager_browser_proxy",
"//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled",
"//ui/webui/resources/js:assert.m",
"//ui/webui/resources/js:load_time_data.m",
]
}
js_library("account_manager_error_app") {
deps = [
":account_manager_browser_proxy",
"//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled",
"//ui/webui/resources/js:assert.m",
"//ui/webui/resources/js:load_time_data.m",
]
}
js_library("account_manager_browser_proxy") {
deps = [ "//ui/webui/resources/js:cr.m" ]
externs_list = [ "$externs_path/chrome_send.js" ]
}
html_to_js("web_components") {
js_files = [
"account_manager_shared_css.js",
"account_manager_welcome_app.js",
"account_migration_welcome_app.js",
"account_manager_error_app.js",
]
}
<link rel="import" href="chrome://resources/html/assert.html">
<link rel="import" href="chrome://resources/html/cr.html">
<script src="account_manager_browser_proxy.js"></script>
...@@ -2,12 +2,14 @@ ...@@ -2,12 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
import {addSingletonGetter} from 'chrome://resources/js/cr.m.js';
/** /**
* @fileoverview Functions for Account manager screens. * @fileoverview Functions for Account manager screens.
*/ */
cr.define('account_manager', function() {
/** @interface */ /** @interface */
class AccountManagerBrowserProxy { export class AccountManagerBrowserProxy {
/** /**
* Triggers the re-authentication flow for the account pointed to by * Triggers the re-authentication flow for the account pointed to by
* |account_email|. * |account_email|.
...@@ -19,12 +21,12 @@ cr.define('account_manager', function() { ...@@ -19,12 +21,12 @@ cr.define('account_manager', function() {
* Closes the dialog. * Closes the dialog.
*/ */
closeDialog() {} closeDialog() {}
} }
/** /**
* @implements {account_manager.AccountManagerBrowserProxy} * @implements {AccountManagerBrowserProxy}
*/ */
class AccountManagerBrowserProxyImpl { export class AccountManagerBrowserProxyImpl {
/** @override */ /** @override */
reauthenticateAccount(account_email) { reauthenticateAccount(account_email) {
chrome.send('reauthenticateAccount', [account_email]); chrome.send('reauthenticateAccount', [account_email]);
...@@ -34,12 +36,6 @@ cr.define('account_manager', function() { ...@@ -34,12 +36,6 @@ cr.define('account_manager', function() {
closeDialog() { closeDialog() {
chrome.send('closeDialog'); chrome.send('closeDialog');
} }
} }
cr.addSingletonGetter(AccountManagerBrowserProxyImpl);
return { addSingletonGetter(AccountManagerBrowserProxyImpl);
AccountManagerBrowserProxy: AccountManagerBrowserProxy,
AccountManagerBrowserProxyImpl: AccountManagerBrowserProxyImpl,
};
});
...@@ -2,58 +2,19 @@ ...@@ -2,58 +2,19 @@
<html dir="$i18n{textdirection}" lang="$i18n{language}"> <html dir="$i18n{textdirection}" lang="$i18n{language}">
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<link rel="import" href="chrome://resources/html/polymer.html"> <!-- document title is set by account_manager_error_app.js -->
<link rel="import" href="chrome://resources/cr_elements/cr_button/cr_button.html">
<link rel="import" href="chrome://resources/cr_elements/shared_style_css.html">
<link rel="import" href="chrome://resources/html/assert.html">
<link rel="import" href="chrome://resources/html/i18n_behavior.html">
<link rel="import" href="account_manager_browser_proxy.html">
<link rel="stylesheet" href="chrome://resources/css/chrome_shared.css">
<link rel="stylesheet" href="chrome://resources/css/text_defaults_md.css">
<script src="chrome://resources/js/cr.js"></script>
<script src="chrome://resources/js/load_time_data.js"></script>
<script src="chrome://resources/js/util.js"></script>
<script src="strings.js"></script>
<script src="account_manager_error.js"></script>
<style> <style>
html,
body { body {
height: 100%; height: 100%;
margin: 0; margin: 0;
width: 100%;
} }
</style> </style>
</head> </head>
<body> <body>
<dom-module id="account-manager-error">
<template>
<style include="cr-shared-style">
<include src="account_manager_shared.css">
</style>
<div id="content">
<div class="main-container">
<if expr="_google_chrome">
<img id="google-logo" src="../googleg.svg" alt="">
</if>
<h1>[[errorTitle_]]</h1>
<p>[[errorMessage_]]</p>
<div class="image-container">
<template is="dom-if" if="[[imageUrl_]]">
<img class="main-image" src="[[imageUrl_]]" alt="">
</template>
</div>
</div>
<div class="button-container">
<cr-button id="ok-button" class="action-button"
on-click="closeDialog_">
$i18n{okButton}
</cr-button>
</div>
</div>
</template>
</dom-module>
<account-manager-error></account-manager-error> <account-manager-error></account-manager-error>
<link rel="stylesheet" href="chrome://resources/css/text_defaults_md.css">
<script type="module" src="account_manager_error_app.js"></script>
</body> </body>
</html> </html>
// Copyright (c) 2019 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.
cr.define('account_manager_error', function() {
'use strict';
/**
* Keep in sync with
* chrome/browser/ui/webui/signin/inline_login_handler_dialog_chromeos.cc
* @enum {number}
*/
const AccountManagerErrorType = {
SECONDARY_ACCOUNTS_DISABLED: 0,
CHILD_USER_ARC_DISABLED: 1,
};
Polymer({
is: 'account-manager-error',
behaviors: [
I18nBehavior,
],
properties: {
errorTitle_: {
type: String,
value: '',
},
errorMessage_: {
type: String,
value: '',
},
imageUrl_: {
type: String,
value: '',
},
},
/** @override */
ready() {
const errorType = this.getErrorType_();
if (errorType === AccountManagerErrorType.CHILD_USER_ARC_DISABLED) {
this.errorTitle_ = this.i18n('childUserArcDisabledErrorTitle');
this.errorMessage_ = this.i18n('childUserArcDisabledErrorMessage');
this.imageUrl_ = 'family_link_logo.svg';
} else {
this.errorTitle_ = this.i18n('secondaryAccountsDisabledErrorTitle');
this.errorMessage_ = this.i18n('secondaryAccountsDisabledErrorMessage');
}
document.title = this.errorTitle_;
},
/**
* @returns {number}
*/
getErrorType_() {
const dialogArgs = chrome.getVariableValue('dialogArguments');
assert(dialogArgs);
const args = JSON.parse(dialogArgs);
assert(args);
assert(Number.isInteger(args.errorType));
return args.errorType;
},
closeDialog_() {
account_manager.AccountManagerBrowserProxyImpl.getInstance()
.closeDialog();
},
});
});
<style include="shared-css">
.main-image {
height: 256px;
width: 256px;
}
</style>
<div class="content">
<div class="main-container">
<if expr="_google_chrome">
<img class="google-logo" src="../googleg.svg" alt="">
</if>
<h1>[[errorTitle_]]</h1>
<p>[[errorMessage_]]</p>
<div class="image-container">
<img hidden$="[[!imageUrl_]]" class="main-image" src="[[imageUrl_]]"
alt="">
</div>
</div>
<div class="button-container">
<cr-button id="ok-button" class="action-button" on-click="closeDialog_">
$i18n{okButton}
</cr-button>
</div>
</div>
// Copyright 2020 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.
import 'chrome://resources/cr_elements/cr_button/cr_button.m.js';
import './strings.m.js';
import './account_manager_shared_css.js';
import {assert} from 'chrome://resources/js/assert.m.js';
import {loadTimeData} from 'chrome://resources/js/load_time_data.m.js';
import {html, Polymer} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js';
import {AccountManagerBrowserProxyImpl} from './account_manager_browser_proxy.js';
/**
* Keep in sync with
* chrome/browser/ui/webui/signin/inline_login_dialog_chromeos.cc
* @enum {number}
*/
const AccountManagerErrorType = {
SECONDARY_ACCOUNTS_DISABLED: 0,
CHILD_USER_ARC_DISABLED: 1,
};
/**
* @typedef {{
* errorType: number,
* }}
*/
let DialogArgs;
Polymer({
is: 'account-manager-error',
_template: html`{__html_template__}`,
properties: {
/** @private */
errorTitle_: {
type: String,
value: '',
},
/** @private */
errorMessage_: {
type: String,
value: '',
},
/** @private */
imageUrl_: {
type: String,
value: '',
},
},
/** @override */
ready() {
const errorType = this.getErrorType_();
if (errorType === AccountManagerErrorType.CHILD_USER_ARC_DISABLED) {
this.errorTitle_ =
loadTimeData.getString('childUserArcDisabledErrorTitle');
this.errorMessage_ =
loadTimeData.getString('childUserArcDisabledErrorMessage');
this.imageUrl_ = 'family_link_logo.svg';
} else {
this.errorTitle_ =
loadTimeData.getString('secondaryAccountsDisabledErrorTitle');
this.errorMessage_ =
loadTimeData.getString('secondaryAccountsDisabledErrorMessage');
}
document.title = this.errorTitle_;
},
/**
* @return {AccountManagerErrorType}
* @private
*/
getErrorType_() {
const dialogArgs = chrome.getVariableValue('dialogArguments');
assert(dialogArgs);
const args = /** @type {DialogArgs} */ (JSON.parse(dialogArgs));
assert(args);
assert(Number.isInteger(args.errorType));
return /** @type {AccountManagerErrorType} */ (args.errorType);
},
/** @private */
closeDialog_() {
AccountManagerBrowserProxyImpl.getInstance().closeDialog();
},
});
/* Copyright 2019 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. */
h1 {
font-size: 2em;
font-weight: normal;
margin-bottom: 16px;
margin-top: 28px;
}
p {
line-height: 1.5;
white-space: pre-line;
}
a {
color: var(--cr-link-color);
text-decoration: none;
}
#content {
display: flex;
flex-direction: column;
height: calc(100% - 61px);
padding-bottom: 32px;
padding-inline-end: 0;
padding-inline-start: 0;
padding-top: 29px; /* 64px - 35px(dialog top border size) */
}
#google-logo {
height: 32px;
width: 32px;
}
#welcome-image {
width: 338px;
}
.image-container {
align-items: center;
display: flex;
flex-grow: 1;
justify-content: center;
width: 100%;
}
.main-image {
height: 256px;
width: 256px;
}
.main-container {
display: flex;
flex-direction: column;
flex-grow: 1;
padding-inline-end: 64px;
padding-inline-start: 64px;
}
.button-container {
display: flex;
justify-content: flex-end;
padding-inline-end: 32px;
padding-inline-start: 32px;
}
<template>
<style include="cr-shared-style">
h1 {
font-size: 2em;
font-weight: normal;
margin-bottom: 16px;
margin-top: 28px;
}
p {
line-height: 1.5;
white-space: pre-line;
}
a {
color: var(--cr-link-color);
text-decoration: none;
}
.content {
display: flex;
flex-direction: column;
height: calc(100% - 61px);
padding-bottom: 32px;
padding-inline-end: 0;
padding-inline-start: 0;
padding-top: 29px; /* 64px - 35px(dialog top border size) */
}
.google-logo {
height: 32px;
width: 32px;
}
.image-container {
align-items: center;
display: flex;
flex-grow: 1;
justify-content: center;
width: 100%;
}
.main-container {
display: flex;
flex-direction: column;
flex-grow: 1;
padding-inline-end: 64px;
padding-inline-start: 64px;
}
.button-container {
display: flex;
justify-content: flex-end;
padding-inline-end: 32px;
padding-inline-start: 32px;
}
</style>
</template>
// Copyright 2020 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.
import 'chrome://resources/cr_elements/shared_style_css.m.js';
import 'chrome://resources/cr_elements/shared_vars_css.m.js';
const template = document.createElement('template');
template.innerHTML = `
<dom-module id="shared-css">{__html_template__}</dom-module>
`;
document.body.appendChild(template.content.cloneNode(true));
<!doctype html> <!doctype html>
<html dir="$i18n{textdirection}" lang="$i18n{language}"> <html dir="$i18n{textdirection}" lang="$i18n{language}">
<head> <head>
<title>$i18n{welcomeTitle}</title>
<meta charset="utf-8"> <meta charset="utf-8">
<link rel="import" href="chrome://resources/html/polymer.html"> <title>$i18n{welcomeTitle}</title>
<link rel="import" href="chrome://resources/cr_elements/cr_button/cr_button.html">
<link rel="import" href="chrome://resources/cr_elements/shared_style_css.html">
<link rel="import" href="account_manager_browser_proxy.html">
<link rel="stylesheet" href="chrome://resources/css/chrome_shared.css">
<link rel="stylesheet" href="chrome://resources/css/text_defaults_md.css">
<script src="chrome://resources/js/cr.js"></script>
<script src="strings.js"></script>
<script src="account_manager_welcome.js"></script>
<style> <style>
html,
body { body {
height: 100%; height: 100%;
margin: 0; margin: 0;
width: 100%;
} }
</style> </style>
</head> </head>
<body> <body>
<dom-module id="account-manager-welcome">
<template>
<style include="cr-shared-style">
<include src="account_manager_shared.css">
</style>
<div id="content">
<div class="main-container">
<if expr="_google_chrome">
<img id="google-logo" src="../googleg.svg" alt="">
</if>
<h1>$i18n{welcomeTitle}</h1>
<p>$i18nRaw{welcomeMessage}</p>
<div class="image-container">
<if expr="_google_chrome">
<img id="welcome-image" alt=""
srcset="account_manager_welcome_1x.png 1x,
account_manager_welcome_2x.png 2x">
</if>
</div>
</div>
<div class="button-container">
<cr-button id="ok-button" class="action-button"
on-click="closeDialog_">
$i18n{okButton}
</cr-button>
</div>
</div>
</template>
</dom-module>
<account-manager-welcome></account-manager-welcome> <account-manager-welcome></account-manager-welcome>
<link rel="stylesheet" href="chrome://resources/css/text_defaults_md.css">
<script type="module" src="account_manager_welcome_app.js"></script>
</body> </body>
</html> </html>
// Copyright (c) 2019 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.
cr.define('account_manager_welcome', function() {
'use strict';
Polymer({
is: 'account-manager-welcome',
/** @private */
closeDialog_() {
account_manager.AccountManagerBrowserProxyImpl.getInstance()
.closeDialog();
},
});
});
<style include="shared-css">
.welcome-image {
width: 338px;
}
</style>
<div class="content">
<div class="main-container">
<if expr="_google_chrome">
<img class="google-logo" src="../googleg.svg" alt="">
</if>
<h1>$i18n{welcomeTitle}</h1>
<p>$i18nRaw{welcomeMessage}</p>
<div class="image-container">
<if expr="_google_chrome">
<img class="welcome-image" alt=""
srcset="account_manager_welcome_1x.png 1x,
account_manager_welcome_2x.png 2x">
</if>
</div>
</div>
<div class="button-container">
<cr-button class="action-button" on-click="closeDialog_">
$i18n{okButton}
</cr-button>
</div>
</div>
// Copyright 2020 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.
import 'chrome://resources/cr_elements/cr_button/cr_button.m.js';
import './account_manager_shared_css.js';
import {html, Polymer} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js';
import {AccountManagerBrowserProxyImpl} from './account_manager_browser_proxy.js';
Polymer({
is: 'account-manager-welcome',
_template: html`{__html_template__}`,
/** @private */
closeDialog_() {
AccountManagerBrowserProxyImpl.getInstance().closeDialog();
},
});
<!doctype html> <!doctype html>
<html dir="$i18n{textdirection}" lang="$i18n{language}"> <html dir="$i18n{textdirection}" lang="$i18n{language}">
<head> <head>
<title>$i18n{welcomePageTitle}</title>
<meta charset="utf-8"> <meta charset="utf-8">
<link rel="import" href="chrome://resources/html/polymer.html"> <title>$i18n{welcomePageTitle}</title>
<link rel="import" href="chrome://resources/cr_elements/cr_button/cr_button.html">
<link rel="import" href="chrome://resources/cr_elements/shared_style_css.html">
<link rel="import" href="chrome://resources/html/assert.html">
<link rel="import" href="chrome://resources/html/i18n_behavior.html">
<link rel="import" href="account_manager_browser_proxy.html">
<link rel="stylesheet" href="chrome://resources/css/chrome_shared.css">
<link rel="stylesheet" href="chrome://resources/css/text_defaults_md.css">
<script src="chrome://resources/js/load_time_data.js"></script>
<script src="chrome://resources/js/cr.js"></script>
<script src="strings.js"></script>
<script src="account_migration_welcome.js"></script>
<style> <style>
html,
body { body {
height: 100%; height: 100%;
margin: 0; margin: 0;
width: 100%;
} }
</style> </style>
</head> </head>
<body> <body>
<dom-module id="account-migration-welcome">
<template>
<style include="cr-shared-style">
<include src="account_manager_shared.css">
</style>
<div id="content">
<div class="main-container">
<if expr="_google_chrome">
<img id="google-logo" src="../googleg.svg" alt="">
</if>
<h1>[[title_]]</h1>
<p inner-h-t-m-l="[[body_]]"></p>
<div class="image-container">
<if expr="_google_chrome">
<img id="welcome-image" alt=""
srcset="account_manager_welcome_1x.png 1x,
account_manager_welcome_2x.png 2x">
</if>
</div>
</div>
<div class="button-container">
<cr-button id="cancel-button" class="cancel-button"
on-click="closeDialog_">
$i18n{cancelButton}
</cr-button>
<cr-button id="migrate-button" class="action-button"
on-click="reauthenticateAccount_">
$i18n{migrateButton}
</cr-button>
</div>
</div>
</template>
</dom-module>
<account-migration-welcome></account-migration-welcome> <account-migration-welcome></account-migration-welcome>
<link rel="stylesheet" href="chrome://resources/css/text_defaults_md.css">
<script type="module" src="account_migration_welcome_app.js"></script>
</body> </body>
</html> </html>
// Copyright 2019 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.
cr.define('account_migration_welcome', function() {
'use strict';
Polymer({
is: 'account-migration-welcome',
behaviors: [
I18nBehavior,
],
properties: {
title_: {
type: String,
value: '',
},
body_: {
type: String,
value: '',
},
},
/** @private {String} */
userEmail_: String,
/** @private {AccountManagerBrowserProxy} */
browserProxy_: Object,
/** @override */
ready() {
this.browserProxy_ =
account_manager.AccountManagerBrowserProxyImpl.getInstance();
const dialogArgs = chrome.getVariableValue('dialogArguments');
if (!dialogArgs) {
// Only if the user navigates to the URL
// chrome://account-migration-welcome to debug.
console.warn('No arguments were provided to the dialog.');
return;
}
const args = JSON.parse(dialogArgs);
assert(args);
assert(args.email);
this.userEmail_ = args.email;
this.title_ = loadTimeData.getStringF('welcomeTitle', this.userEmail_);
this.body_ = this.getWelcomeMessage_();
},
/** @private */
getWelcomeMessage_() {
const validNodeFn = (node, value) => node.tagName === 'A';
return this.i18nAdvanced('welcomeMessage', {
substitutions: [
this.userEmail_, loadTimeData.getString('accountManagerLearnMoreUrl')
],
attrs: {'id': validNodeFn, 'href': validNodeFn}
});
},
/** @private */
closeDialog_() {
this.browserProxy_.closeDialog();
},
/** @private */
reauthenticateAccount_() {
this.browserProxy_.reauthenticateAccount(this.userEmail_);
},
});
});
<style include="shared-css">
.welcome-image {
width: 338px;
}
</style>
<div class="content">
<div class="main-container">
<if expr="_google_chrome">
<img class="google-logo" src="../googleg.svg" alt="">
</if>
<h1>[[title_]]</h1>
<p inner-h-t-m-l="[[body_]]"></p>
<div class="image-container">
<if expr="_google_chrome">
<img class="welcome-image" alt=""
srcset="account_manager_welcome_1x.png 1x,
account_manager_welcome_2x.png 2x">
</if>
</div>
</div>
<div class="button-container">
<cr-button id="cancel-button" class="cancel-button"
on-click="closeDialog_">
$i18n{cancelButton}
</cr-button>
<cr-button id="migrate-button" class="action-button"
on-click="reauthenticateAccount_">
$i18n{migrateButton}
</cr-button>
</div>
</div>
// Copyright 2020 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.
import 'chrome://resources/cr_elements/cr_button/cr_button.m.js';
import './strings.m.js';
import './account_manager_shared_css.js';
import {assert} from 'chrome://resources/js/assert.m.js';
import {loadTimeData} from 'chrome://resources/js/load_time_data.m.js';
import {html, Polymer} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js';
import {AccountManagerBrowserProxy, AccountManagerBrowserProxyImpl} from './account_manager_browser_proxy.js';
Polymer({
is: 'account-migration-welcome',
_template: html`{__html_template__}`,
properties: {
/** @private */
title_: {
type: String,
value: '',
},
/** @private */
body_: {
type: String,
value: '',
},
},
/** @type {string} */
userEmail_: '',
/** @type {?AccountManagerBrowserProxy} */
browserProxy_: null,
/** @override */
ready() {
this.browserProxy_ = AccountManagerBrowserProxyImpl.getInstance();
const dialogArgs = chrome.getVariableValue('dialogArguments');
if (!dialogArgs) {
// Only if the user navigates to the URL
// chrome://account-migration-welcome to debug.
console.warn('No arguments were provided to the dialog.');
return;
}
const args = JSON.parse(dialogArgs);
assert(args);
assert(args.email);
this.userEmail_ = args.email;
this.title_ = loadTimeData.getStringF('welcomeTitle', this.userEmail_);
this.body_ = loadTimeData.getStringF(
'welcomeMessage', this.userEmail_,
loadTimeData.getString('accountManagerLearnMoreUrl'));
},
/** @private */
closeDialog_() {
this.browserProxy_.closeDialog();
},
/** @private */
reauthenticateAccount_() {
this.browserProxy_.reauthenticateAccount(this.userEmail_);
},
});
...@@ -28,6 +28,7 @@ AccountManagerErrorUI::AccountManagerErrorUI(content::WebUI* web_ui) ...@@ -28,6 +28,7 @@ AccountManagerErrorUI::AccountManagerErrorUI(content::WebUI* web_ui)
html_source->DisableTrustedTypesCSP(); html_source->DisableTrustedTypesCSP();
html_source->UseStringsJs(); html_source->UseStringsJs();
html_source->EnableReplaceI18nInJS();
html_source->AddLocalizedString( html_source->AddLocalizedString(
"secondaryAccountsDisabledErrorTitle", "secondaryAccountsDisabledErrorTitle",
...@@ -53,14 +54,12 @@ AccountManagerErrorUI::AccountManagerErrorUI(content::WebUI* web_ui) ...@@ -53,14 +54,12 @@ AccountManagerErrorUI::AccountManagerErrorUI(content::WebUI* web_ui)
IDR_FAMILY_LINK_LOGO_SVG); IDR_FAMILY_LINK_LOGO_SVG);
// Add required resources. // Add required resources.
html_source->AddResourcePath("account_manager_shared.css", html_source->AddResourcePath("account_manager_shared_css.js",
IDR_ACCOUNT_MANAGER_SHARED_CSS); IDR_ACCOUNT_MANAGER_SHARED_CSS_JS);
html_source->AddResourcePath("account_manager_browser_proxy.html",
IDR_ACCOUNT_MANAGER_BROWSER_PROXY_HTML);
html_source->AddResourcePath("account_manager_browser_proxy.js", html_source->AddResourcePath("account_manager_browser_proxy.js",
IDR_ACCOUNT_MANAGER_BROWSER_PROXY_JS); IDR_ACCOUNT_MANAGER_BROWSER_PROXY_JS);
html_source->AddResourcePath("account_manager_error.js", html_source->AddResourcePath("account_manager_error_app.js",
IDR_ACCOUNT_MANAGER_ERROR_JS); IDR_ACCOUNT_MANAGER_ERROR_APP_JS);
html_source->SetDefaultResource(IDR_ACCOUNT_MANAGER_ERROR_HTML); html_source->SetDefaultResource(IDR_ACCOUNT_MANAGER_ERROR_HTML);
......
...@@ -30,6 +30,7 @@ AccountManagerWelcomeUI::AccountManagerWelcomeUI(content::WebUI* web_ui) ...@@ -30,6 +30,7 @@ AccountManagerWelcomeUI::AccountManagerWelcomeUI(content::WebUI* web_ui)
html_source->DisableTrustedTypesCSP(); html_source->DisableTrustedTypesCSP();
html_source->UseStringsJs(); html_source->UseStringsJs();
html_source->EnableReplaceI18nInJS();
// Add localized strings. // Add localized strings.
html_source->AddLocalizedString("welcomeTitle", html_source->AddLocalizedString("welcomeTitle",
...@@ -43,12 +44,10 @@ AccountManagerWelcomeUI::AccountManagerWelcomeUI(content::WebUI* web_ui) ...@@ -43,12 +44,10 @@ AccountManagerWelcomeUI::AccountManagerWelcomeUI(content::WebUI* web_ui)
IDS_ACCOUNT_MANAGER_WELCOME_BUTTON); IDS_ACCOUNT_MANAGER_WELCOME_BUTTON);
// Add required resources. // Add required resources.
html_source->AddResourcePath("account_manager_shared.css", html_source->AddResourcePath("account_manager_welcome_app.js",
IDR_ACCOUNT_MANAGER_SHARED_CSS); IDR_ACCOUNT_MANAGER_WELCOME_APP_JS);
html_source->AddResourcePath("account_manager_welcome.js", html_source->AddResourcePath("account_manager_shared_css.js",
IDR_ACCOUNT_MANAGER_WELCOME_JS); IDR_ACCOUNT_MANAGER_SHARED_CSS_JS);
html_source->AddResourcePath("account_manager_browser_proxy.html",
IDR_ACCOUNT_MANAGER_BROWSER_PROXY_HTML);
html_source->AddResourcePath("account_manager_browser_proxy.js", html_source->AddResourcePath("account_manager_browser_proxy.js",
IDR_ACCOUNT_MANAGER_BROWSER_PROXY_JS); IDR_ACCOUNT_MANAGER_BROWSER_PROXY_JS);
#if BUILDFLAG(GOOGLE_CHROME_BRANDING) #if BUILDFLAG(GOOGLE_CHROME_BRANDING)
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include "content/public/browser/web_ui_data_source.h" #include "content/public/browser/web_ui_data_source.h"
#include "net/base/url_util.h" #include "net/base/url_util.h"
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
#include "ui/resources/grit/webui_resources.h"
#include "ui/strings/grit/ui_strings.h" #include "ui/strings/grit/ui_strings.h"
#include "ui/web_dialogs/web_dialog_delegate.h" #include "ui/web_dialogs/web_dialog_delegate.h"
...@@ -77,10 +78,13 @@ AccountMigrationWelcomeUI::AccountMigrationWelcomeUI(content::WebUI* web_ui) ...@@ -77,10 +78,13 @@ AccountMigrationWelcomeUI::AccountMigrationWelcomeUI(content::WebUI* web_ui)
: ui::WebDialogUI(web_ui) { : ui::WebDialogUI(web_ui) {
content::WebUIDataSource* html_source = content::WebUIDataSource::Create( content::WebUIDataSource* html_source = content::WebUIDataSource::Create(
chrome::kChromeUIAccountMigrationWelcomeHost); chrome::kChromeUIAccountMigrationWelcomeHost);
html_source->OverrideContentSecurityPolicy(
network::mojom::CSPDirectiveName::ScriptSrc,
"script-src chrome://resources chrome://test 'self';");
html_source->DisableTrustedTypesCSP(); html_source->DisableTrustedTypesCSP();
html_source->UseStringsJs(); html_source->UseStringsJs();
html_source->EnableReplaceI18nInJS();
// Add localized strings. // Add localized strings.
html_source->AddLocalizedString("welcomePageTitle", html_source->AddLocalizedString("welcomePageTitle",
...@@ -96,12 +100,10 @@ AccountMigrationWelcomeUI::AccountMigrationWelcomeUI(content::WebUI* web_ui) ...@@ -96,12 +100,10 @@ AccountMigrationWelcomeUI::AccountMigrationWelcomeUI(content::WebUI* web_ui)
chrome::kAccountManagerLearnMoreURL); chrome::kAccountManagerLearnMoreURL);
// Add required resources. // Add required resources.
html_source->AddResourcePath("account_manager_shared.css", html_source->AddResourcePath("account_migration_welcome_app.js",
IDR_ACCOUNT_MANAGER_SHARED_CSS); IDR_ACCOUNT_MIGRATION_WELCOME_APP_JS);
html_source->AddResourcePath("account_migration_welcome.js", html_source->AddResourcePath("account_manager_shared_css.js",
IDR_ACCOUNT_MIGRATION_WELCOME_JS); IDR_ACCOUNT_MANAGER_SHARED_CSS_JS);
html_source->AddResourcePath("account_manager_browser_proxy.html",
IDR_ACCOUNT_MANAGER_BROWSER_PROXY_HTML);
html_source->AddResourcePath("account_manager_browser_proxy.js", html_source->AddResourcePath("account_manager_browser_proxy.js",
IDR_ACCOUNT_MANAGER_BROWSER_PROXY_JS); IDR_ACCOUNT_MANAGER_BROWSER_PROXY_JS);
#if BUILDFLAG(GOOGLE_CHROME_BRANDING) #if BUILDFLAG(GOOGLE_CHROME_BRANDING)
...@@ -112,6 +114,8 @@ AccountMigrationWelcomeUI::AccountMigrationWelcomeUI(content::WebUI* web_ui) ...@@ -112,6 +114,8 @@ AccountMigrationWelcomeUI::AccountMigrationWelcomeUI(content::WebUI* web_ui)
html_source->AddResourcePath("googleg.svg", html_source->AddResourcePath("googleg.svg",
IDR_ACCOUNT_MANAGER_WELCOME_GOOGLE_LOGO_SVG); IDR_ACCOUNT_MANAGER_WELCOME_GOOGLE_LOGO_SVG);
#endif #endif
html_source->AddResourcePath("test_loader.js", IDR_WEBUI_JS_TEST_LOADER);
html_source->AddResourcePath("test_loader.html", IDR_WEBUI_HTML_TEST_LOADER);
html_source->SetDefaultResource(IDR_ACCOUNT_MIGRATION_WELCOME_HTML); html_source->SetDefaultResource(IDR_ACCOUNT_MIGRATION_WELCOME_HTML);
web_ui->AddMessageHandler(std::make_unique<MigrationMessageHandler>( web_ui->AddMessageHandler(std::make_unique<MigrationMessageHandler>(
......
...@@ -424,7 +424,10 @@ group("closure_compile") { ...@@ -424,7 +424,10 @@ group("closure_compile") {
# TODO(crbug.com/1000989): Add page specific targets here. # TODO(crbug.com/1000989): Add page specific targets here.
] ]
if (is_chromeos) { if (is_chromeos) {
deps += [ "chromeos/gaia_action_buttons:closure_compile" ] deps += [
"chromeos/account_manager:closure_compile",
"chromeos/gaia_action_buttons:closure_compile",
]
} }
if (enable_tab_search) { if (enable_tab_search) {
deps += [ "tab_search/test:closure_compile" ] deps += [ "tab_search/test:closure_compile" ]
......
# Copyright 2020 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.
import("//third_party/closure_compiler/compile_js.gni")
js_type_check("closure_compile") {
is_polymer3 = true
closure_flags = default_closure_args + [
"browser_resolver_prefix_replacements=\"chrome://account-migration-welcome/=../../chrome/browser/resources/chromeos/account_manager/\"",
"js_module_root=../../chrome/test/data/webui/",
"js_module_root=./gen/chrome/test/data/webui/",
]
deps = [
":account_migration_welcome_test",
":test_account_manager_browser_proxy",
]
}
js_library("account_migration_welcome_test") {
deps = [
":test_account_manager_browser_proxy",
"../..:chai_assert",
"//chrome/browser/resources/chromeos/account_manager:account_migration_welcome_app",
"//ui/webui/resources/js:assert.m",
]
externs_list = [ "$externs_path/mocha-2.5.js" ]
}
js_library("test_account_manager_browser_proxy") {
deps = [
"../..:test_browser_proxy.m",
"//chrome/browser/resources/chromeos/account_manager:account_manager_browser_proxy",
]
}
...@@ -4,32 +4,35 @@ ...@@ -4,32 +4,35 @@
/** @fileoverview Runs UI tests for account manager dialogs. */ /** @fileoverview Runs UI tests for account manager dialogs. */
// Polymer BrowserTest fixture.
GEN_INCLUDE(['//chrome/test/data/webui/polymer_browser_test_base.js']); GEN_INCLUDE(['//chrome/test/data/webui/polymer_browser_test_base.js']);
GEN('#include "content/public/test/browser_test.h"'); GEN('#include "content/public/test/browser_test.h"');
/** // eslint-disable-next-line no-var
* @constructor var AccountMigrationWelcomeTest = class extends PolymerTest {
* @extends {PolymerTest}
*/
function AccountManagerBrowserTest() {}
AccountManagerBrowserTest.prototype = {
__proto__: PolymerTest.prototype,
/** @override */ /** @override */
browsePreload: 'chrome://account-migration-welcome/', get browsePreload() {
return 'chrome://account-migration-welcome/test_loader.html?module=chromeos/account_manager/account_migration_welcome_test.js';
}
/** @override */ /** @override */
extraLibraries: [ get extraLibraries() {
...PolymerTest.prototype.extraLibraries, return [
'../../test_browser_proxy.js', '//third_party/mocha/mocha.js',
'test_account_manager_browser_proxy.js', '//chrome/test/data/webui/mocha_adapter.js',
'account_migration_welcome_test.js', ];
], }
}; };
TEST_F('AccountManagerBrowserTest', 'AccountMigrationWelcomeTests', () => { TEST_F('AccountMigrationWelcomeTest', 'CloseDialog', () => {
account_manager.account_migration_welcome_tests.registerTests(); this.runMochaTest(
mocha.run(); account_migration_welcome_test.suiteName,
account_migration_welcome_test.TestNames.CloseDialog);
});
TEST_F('AccountMigrationWelcomeTest', 'MigrateAccount', () => {
this.runMochaTest(
account_migration_welcome_test.suiteName,
account_migration_welcome_test.TestNames.MigrateAccount);
}); });
...@@ -2,52 +2,57 @@ ...@@ -2,52 +2,57 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
cr.define('account_manager.account_migration_welcome_tests', () => { import 'chrome://account-migration-welcome/account_migration_welcome_app.js';
function registerTests() {
suite('AccountMigrationWelcomeTests', () => { import {AccountManagerBrowserProxyImpl} from 'chrome://account-migration-welcome/account_manager_browser_proxy.js';
import {assert} from 'chrome://resources/js/assert.m.js';
import {flush} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js';
import {assertEquals} from '../../chai_assert.js';
import {TestAccountManagerBrowserProxy} from './test_account_manager_browser_proxy.js';
window.account_migration_welcome_test = {};
const account_migration_welcome_test = window.account_migration_welcome_test;
account_migration_welcome_test.suiteName = 'AccountMigrationWelcomeTest';
/** @enum {string} */
account_migration_welcome_test.TestNames = {
CloseDialog: 'Close dialog when user clicks "cancel" button',
MigrateAccount: 'Reauthenticate account when user clicks "migrate" button',
};
suite(account_migration_welcome_test.suiteName, () => {
/** @type {string} */
const fakeEmail = 'user@example.com'; const fakeEmail = 'user@example.com';
/** @type {AccountMigrationWelcomeElement} */
let element = null; let element = null;
/** @type {TestAccountManagerBrowserProxy} */
let testBrowserProxy = null; let testBrowserProxy = null;
setup(() => { setup(() => {
document.body.innerHTML = '';
testBrowserProxy = new TestAccountManagerBrowserProxy(); testBrowserProxy = new TestAccountManagerBrowserProxy();
account_manager.AccountManagerBrowserProxyImpl.instance_ = AccountManagerBrowserProxyImpl.instance_ = testBrowserProxy;
testBrowserProxy; element = /** @type {AccountMigrationWelcomeElement} */ (
element = document.createElement('account-migration-welcome'); document.createElement('account-migration-welcome'));
document.body.appendChild(element); document.body.appendChild(element);
element.userEmail_ = fakeEmail; element.userEmail_ = fakeEmail;
Polymer.dom.flush(); flush();
}); });
teardown((done) => { test(assert(account_migration_welcome_test.TestNames.CloseDialog), () => {
element.remove(); const cancelButton = element.$['cancel-button'];
// Allow asynchronous tasks to finish.
setTimeout(done);
});
test('closeDialog is called when user clicks "cancel" button', () => {
const cancelButton = element.shadowRoot.querySelector('#cancel-button');
cancelButton.click(); cancelButton.click();
assertEquals(1, testBrowserProxy.getCallCount('closeDialog')); assertEquals(1, testBrowserProxy.getCallCount('closeDialog'));
}); });
test( test(assert(account_migration_welcome_test.TestNames.MigrateAccount), () => {
'reauthenticateAccount is called when user clicks "migrate" button', const migrateButton = element.$['migrate-button'];
() => {
const migrateButton =
element.shadowRoot.querySelector('#migrate-button');
migrateButton.click(); migrateButton.click();
assertEquals( assertEquals(1, testBrowserProxy.getCallCount('reauthenticateAccount'));
1, testBrowserProxy.getCallCount('reauthenticateAccount'));
testBrowserProxy.whenCalled('reauthenticateAccount').then(email => { testBrowserProxy.whenCalled('reauthenticateAccount').then(email => {
assertEquals(fakeEmail, email); assertEquals(fakeEmail, email);
}); });
}); });
});
}
return {
registerTests: registerTests,
};
}); });
...@@ -2,8 +2,12 @@ ...@@ -2,8 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
/** @implements {account_manager.AccountManagerBrowserProxy} */ import {AccountManagerBrowserProxy} from 'chrome://account-migration-welcome/account_manager_browser_proxy.js';
class TestAccountManagerBrowserProxy extends TestBrowserProxy {
import {TestBrowserProxy} from '../../test_browser_proxy.m.js';
/** @implements {AccountManagerBrowserProxy} */
export class TestAccountManagerBrowserProxy extends TestBrowserProxy {
constructor() { constructor() {
super([ super([
'closeDialog', 'closeDialog',
......
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