Commit aac2e189 authored by Scott Chen's avatar Scott Chen Committed by Commit Bot

NUX Onboarding: add email interstitial.

For signed-in new users, if they chose an email provider on a previous step,
they would be prompted by a page which will direct them to the selected
email provider url.

Change-Id: Iccf0f61c0548923f63e022e66e408bf3595d54f1
Reviewed-on: https://chromium-review.googlesource.com/c/1256213
Commit-Queue: Scott Chen <scottchen@chromium.org>
Reviewed-by: default avatarHector Carmona <hcarmona@chromium.org>
Cr-Commit-Position: refs/heads/master@{#601820}
parent 78d3f4d3
......@@ -15,12 +15,20 @@ group("closure_compile") {
js_type_check("welcome_files") {
deps = [
":email_interstitial",
":landing_view",
":signin_view",
":welcome_app",
]
}
js_library("email_interstitial") {
deps = [
":welcome_browser_proxy",
"./email/:nux_email_proxy",
]
}
js_library("landing_view") {
deps = [
":navigation_behavior",
......@@ -32,6 +40,7 @@ js_library("signin_view") {
deps = [
":navigation_behavior",
":welcome_browser_proxy",
"./email/:nux_email_proxy",
]
}
......
......@@ -12,24 +12,25 @@ js_type_check("closure_compile") {
}
js_library("nux_email") {
deps = [
"../shared:nux_types",
]
}
js_library("email_chooser") {
deps = [
":nux_email_proxy",
"../:navigation_behavior",
"../shared:nux_types",
"//third_party/polymer/v1_0/components-chromium/iron-a11y-announcer:iron-a11y-announcer-extracted",
"//ui/webui/resources/js:cr",
"//ui/webui/resources/js:i18n_behavior",
"//ui/webui/resources/js:load_time_data",
]
}
js_library("nux_email_proxy") {
deps = [
"../shared:nux_types",
"//ui/webui/resources/js:cr",
"//ui/webui/resources/js:load_time_data",
]
externs_list = [
"$externs_path/chrome_extensions.js",
......
......@@ -67,6 +67,9 @@ cr.define('nux', function() {
*/
getEmailList() {}
/** @return {number} */
getSavedProvider() {}
recordPageInitialized() {}
recordClickedOption() {}
......@@ -95,6 +98,9 @@ cr.define('nux', function() {
/** @private {string} */
this.lastPart = '';
/** @private {number} */
this.savedProvider_;
}
/** @override */
......@@ -118,6 +124,11 @@ cr.define('nux', function() {
return cr.sendWithPromise('getEmailList');
}
/** @override */
getSavedProvider() {
return this.savedProvider_;
}
/** @override */
recordPageInitialized() {
chrome.metricsPrivate.recordEnumerationValue(
......@@ -147,6 +158,7 @@ cr.define('nux', function() {
/** @override */
recordProviderSelected(providerId, length) {
this.savedProvider_ = providerId;
// TODO(hcarmona): get enum's max from loadTimeData instead, since length
// might not be accurate once we start localizing.
chrome.metricsPrivate.recordEnumerationValue(
......
<!doctype html>
<html dir="$i18n{textdirection}" lang="$i18n{language}">
<head>
<meta charset="utf-8">
<title>$i18n{headerText}</title>
<link rel="import" href="chrome://resources/html/polymer.html">
<link rel="import" href="chrome://resources/cr_elements/paper_button_style_css.html">
<link rel="import" href="chrome://resources/html/assert.html">
<link rel="import" href="chrome://resources/polymer/v1_0/paper-button/paper-button.html">
<link rel="import" href="welcome_browser_proxy.html">
<link rel="import" href="email/nux_email_proxy.html">
<link rel="stylesheet" href="chrome://resources/css/text_defaults_md.css">
<dom-module id="email-interstitial">
<template>
<style include="paper-button-style">
#container {
align-items: center;
display: flex;
flex-direction: column;
height: 100%;
justify-content: center;
margin: auto;
width: 800px;
}
h1 {
font-size: 4rem;
margin-bottom: 20px;
}
h2 {
color: darkgrey;
font-size: 1.5rem;
}
paper-button {
font-size: 1rem;
height: 2.5rem;
text-align: center;
white-space: nowrap;
width: 220px;
}
</style>
<!-- TODO(scottchen): localize -->
<div id="container">
<h1>TODO Continue to your email?</h1>
<paper-button class="action-button" on-click="onContinueClick_">
Continue
</paper-button>
<paper-button on-click="onNoThanksClick_">
No thanks
</paper-button>
</div>
</template>
<script src="email_interstitial.js"></script>
</dom-module>
</head>
<body>
<email-interstitial></email-interstitial>
</body>
</html>
\ No newline at end of file
// Copyright 2018 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 When user gets to chrome://welcome/email-interstitial, it will
* also have a ?provider=... url param. This value is an ID that should match
* one of the provider in the email list retrieved from the backend. If the user
* chooses the continue button, they should be directed to the landing page of
* that email provider.
*/
Polymer({
is: 'email-interstitial',
/** @private */
welcomeBrowserProxy_: null,
/** @override */
ready: function() {
this.welcomeBrowserProxy_ = welcome.WelcomeBrowserProxyImpl.getInstance();
},
/** @private */
onContinueClick_: function() {
const providerId =
(new URL(window.location.href)).searchParams.get('provider');
nux.NuxEmailProxyImpl.getInstance().getEmailList().then(list => {
for (let i = 0; i < list.length; i++) {
if (list[i].id == providerId) {
this.welcomeBrowserProxy_.goToURL(list[i].url);
return;
}
}
// It shouldn't be possible to go to a URL with a non-existent provider
// id.
assertNotReached();
});
},
/** @private */
onNoThanksClick_: function() {
this.welcomeBrowserProxy_.goToNewTabPage();
}
});
......@@ -12,6 +12,14 @@
</outputs>
<release seq="1">
<structures>
<structure name="IDR_WELCOME_ONBOARDING_WELCOME_EMAIL_INTERSTITIAL_HTML"
file="email_interstitial.html"
type="chrome_html"
preprocess="true"/>
<structure name="IDR_WELCOME_ONBOARDING_WELCOME_EMAIL_INTERSTITIAL_JS"
file="email_interstitial.js"
type="chrome_html"
preprocess="true"/>
<structure name="IDR_WELCOME_ONBOARDING_WELCOME_LANDING_VIEW_JS"
file="landing_view.js"
type="chrome_html"
......
......@@ -7,12 +7,28 @@ Polymer({
behaviors: [welcome.NavigationBehavior],
/** @private */
// TODO(scottchen): read this from a nux onboarding feature param via
// loadTimeData.
shouldShowEmailInterstitial_: true,
/**
* When the user clicks sign-in, check whether or not they previously
* selected an email provider they prefer to use. If so, direct them back to
* the email-interstitial page, otherwise let it direct to NTP.
* @private
*/
onSignInClick_: function() {
// TODO(scottchen): create a feature flag to direct part of the users to
// chrome://welcome/email-interstitial instead of NTP.
// TODO(scottchen): implement chrome://welcome/email-interstitial.
welcome.WelcomeBrowserProxyImpl.getInstance().handleActivateSignIn();
let redirectUrl = null;
const savedProvider =
nux.NuxEmailProxyImpl.getInstance().getSavedProvider();
if (savedProvider != undefined && this.shouldShowEmailInterstitial_) {
redirectUrl =
`chrome://welcome/email-interstitial?provider=${savedProvider}`;
}
welcome.WelcomeBrowserProxyImpl.getInstance().handleActivateSignIn(
redirectUrl);
},
/** @private */
......
......@@ -11,9 +11,13 @@ cr.define('welcome', function() {
/** @interface */
class WelcomeBrowserProxy {
/** @param {string=} redirectUrl the URL to go to, after signing in. */
/** @param {?string} redirectUrl the URL to go to, after signing in. */
handleActivateSignIn(redirectUrl) {}
goToNewTabPage() {}
/** @param {string} url */
goToURL(url) {}
}
/** @implements {welcome.WelcomeBrowserProxy} */
......@@ -25,7 +29,12 @@ cr.define('welcome', function() {
/** @override */
goToNewTabPage() {
window.location.replace('chrome://newtab');
window.location.assign('chrome://newtab');
}
/** @override */
goToURL(url) {
window.location.assign(url);
}
}
......
......@@ -19,6 +19,7 @@
#include "ui/base/page_transition_types.h"
const char kWelcomeReturningUserUrl[] = "chrome://welcome/returning-user";
const char kWelcomeEmailInterstitial[] = "chrome://welcome/email-interstitial";
WelcomeHandler::WelcomeHandler(content::WebUI* web_ui)
: profile_(Profile::FromWebUI(web_ui)),
......@@ -51,8 +52,11 @@ void WelcomeHandler::OnSyncConfirmationUIClosed(
// chrome://welcome/... after closing sync-confirmation UI. If current URL
// matches such a case, do not navigate away.
GURL current_url = web_ui()->GetWebContents()->GetVisibleURL();
if (current_url != kWelcomeReturningUserUrl)
if (current_url != kWelcomeReturningUserUrl &&
current_url.spec().find(kWelcomeEmailInterstitial) ==
std::string::npos) {
GoToNewTabPage();
}
}
}
......
......@@ -123,9 +123,16 @@ WelcomeUI::WelcomeUI(content::WebUI* web_ui, const GURL& url)
html_source->AddResourcePath(kOnboardingWelcomeResources[i].name,
kOnboardingWelcomeResources[i].value);
}
// chrome://welcome
html_source->SetDefaultResource(
IDR_WELCOME_ONBOARDING_WELCOME_WELCOME_HTML);
// chrome://welcome/email-interstitial
html_source->AddResourcePath(
"email-interstitial",
IDR_WELCOME_ONBOARDING_WELCOME_EMAIL_INTERSTITIAL_HTML);
html_source->AddResourcePath(
"images/background_svgs/blue_circle.svg",
IDR_WELCOME_ONBOARDING_WELCOME_IMAGES_BACKGROUND_SVGS_BLUE_CIRCLE_SVG);
......
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