Skip to content

Commit

Permalink
[Autofill Home] Show Google Account Link for Signed-In Users
Browse files Browse the repository at this point in the history
This change updates the people section to show a link to the Google
Account in case the current user is signed-in.

Bug: 907035
Change-Id: I51a5d4df2563a1c646377abba74d810f7a24a426
Reviewed-on: https://chromium-review.googlesource.com/c/1346049
Commit-Queue: Jan Wilken Dörrie <jdoerrie@chromium.org>
Reviewed-by: Demetrios Papadopoulos <dpapad@chromium.org>
Cr-Original-Commit-Position: refs/heads/master@{#612836}(cherry picked from commit 888f7df)
Reviewed-on: https://chromium-review.googlesource.com/c/1358639
Reviewed-by: Jan Wilken Dörrie <jdoerrie@chromium.org>
Cr-Commit-Position: refs/branch-heads/3626@{#17}
Cr-Branched-From: d897fb1-refs/heads/master@{#612437}
  • Loading branch information
jdoerrie committed Dec 3, 2018
1 parent 48dcf08 commit 03f0beb
Show file tree
Hide file tree
Showing 17 changed files with 192 additions and 64 deletions.
3 changes: 3 additions & 0 deletions chrome/app/settings_strings.grdp
Original file line number Diff line number Diff line change
Expand Up @@ -3614,6 +3614,9 @@
<message name="IDS_SETTINGS_SYNC_EVERYTHING_CHECKBOX_LABEL" desc="Label for the checkbox which causes all properties to be synced.">
Sync everything
</message>
<message name="IDS_SETTINGS_MANAGE_GOOGLE_ACCOUNT" desc="Label for the button that takes the user to the Google Account website.">
Manage your Google Account
</message>
<message name="IDS_SETTINGS_APPS_CHECKBOX_LABEL" desc="Label for the checkbox which enables or disables syncing apps between multiple browser instances.">
Apps
</message>
Expand Down
7 changes: 7 additions & 0 deletions chrome/browser/resources/settings/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ js_type_check("settings_resources") {
":focus_row_behavior",
":global_scroll_target_behavior",
":lifetime_browser_proxy",
":open_window_proxy",
":page_visibility",
":route",
":search_settings",
Expand Down Expand Up @@ -154,6 +155,12 @@ js_library("lifetime_browser_proxy") {
externs_list = [ "$externs_path/chrome_send.js" ]
}

js_library("open_window_proxy") {
deps = [
"//ui/webui/resources/js:cr",
]
}

js_library("route") {
deps = [
":page_visibility",
Expand Down
9 changes: 1 addition & 8 deletions chrome/browser/resources/settings/autofill_page/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import("//third_party/closure_compiler/compile_js.gni")
js_type_check("closure_compile") {
deps = [
":address_edit_dialog",
":autofill_browser_proxy",
":autofill_page",
":autofill_section",
":credit_card_edit_dialog",
Expand All @@ -20,18 +19,12 @@ js_type_check("closure_compile") {
]
}

js_library("autofill_browser_proxy") {
deps = [
"//ui/webui/resources/js:cr",
]
}

js_library("autofill_page") {
deps = [
":autofill_browser_proxy",
":autofill_section",
":passwords_section",
":payments_section",
"..:open_window_proxy",
"..:route",
"../prefs:prefs_behavior",
"../settings_page:settings_animated_pages",
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
<link rel="import" href="chrome://resources/cr_elements/cr_link_row/cr_link_row.html">
<link rel="import" href="chrome://resources/html/cr.html">
<link rel="import" href="chrome://resources/polymer/v1_0/neon-animation/neon-animatable.html">
<link rel="import" href="autofill_browser_proxy.html">
<link rel="import" href="autofill_section.html">
<link rel="import" href="passwords_section.html">
<link rel="import" href="payments_section.html">
<link rel="import" href="../prefs/prefs.html">
<link rel="import" href="../prefs/prefs_behavior.html">
<link rel="import" href="../open_window_proxy.html">
<link rel="import" href="../route.html">
<link rel="import" href="../settings_page/settings_animated_pages.html">
<link rel="import" href="../settings_page/settings_subpage.html">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ Polymer({
*/
onPasswordsClick_: function() {
loadTimeData.getBoolean('navigateToGooglePasswordManager') ?
settings.AutofillBrowserProxyImpl.getInstance().openURL(
settings.OpenWindowProxyImpl.getInstance().openURL(
loadTimeData.getString('googlePasswordManagerUrl')) :
settings.navigateTo(settings.routes.PASSWORDS);
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
<link rel="import" href="chrome://resources/html/cr.html">
<script src="autofill_browser_proxy.js"></script>
<script src="open_window_proxy.js"></script>
36 changes: 36 additions & 0 deletions chrome/browser/resources/settings/open_window_proxy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// 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 A helper object used to open a URL in a new tab.
* the browser.
*/

cr.exportPath('settings');

cr.define('settings', function() {
/** @interface */
class OpenWindowProxy {
/**
* Opens the specified URL in a new tab.
* @param {string} url
*/
openURL(url) {}
}

/** @implements {settings.OpenWindowProxy} */
class OpenWindowProxyImpl {
/** @override */
openURL(url) {
window.open(url);
}
}

cr.addSingletonGetter(OpenWindowProxyImpl);

return {
OpenWindowProxy: OpenWindowProxy,
OpenWindowProxyImpl: OpenWindowProxyImpl,
};
});
1 change: 1 addition & 0 deletions chrome/browser/resources/settings/people_page/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ js_library("people_page") {
":profile_info_browser_proxy",
":signout_dialog",
":sync_browser_proxy",
"..:open_window_proxy",
"..:page_visibility",
"..:route",
"../settings_page:settings_animated_pages",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<link rel="import" href="sync_browser_proxy.html">
<link rel="import" href="sync_page.html">
<link rel="import" href="../icons.html">
<link rel="import" href="../open_window_proxy.html">
<link rel="import" href="../route.html">
<link rel="import" href="../settings_page/settings_animated_pages.html">
<link rel="import" href="../settings_page/settings_subpage.html">
Expand Down Expand Up @@ -258,6 +259,11 @@

<if expr="not chromeos">
<template is="dom-if" if="[[diceEnabled_]]">
<cr-link-row id="manage-google-account"
label="$i18n{manageGoogleAccount}" icon-class="icon-external"
hidden="[[!shouldShowGoogleAccount_]]"
on-click="openGoogleAccount_"></cr-link-row>

<div class="settings-box" id="edit-profile" on-click="onProfileTap_"
actionable>
<div class="start">$i18n{profileNameAndPicture}</div>
Expand Down
46 changes: 46 additions & 0 deletions chrome/browser/resources/settings/people_page/people_page.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,14 @@ Polymer({
},
},

// <if expr="not chromeos">
/**
* Stored accounts to the system, supplied by SyncBrowserProxy.
* @type {?Array<!settings.StoredAccount>}
*/
storedAccounts: Object,
// </if>

/**
* The current sync status, supplied by SyncBrowserProxy.
* @type {?settings.SyncStatus}
Expand All @@ -80,6 +88,14 @@ Polymer({
profileName_: String,

// <if expr="not chromeos">
/** @private {boolean} */
shouldShowGoogleAccount_: {
type: Boolean,
value: false,
computed: 'computeShouldShowGoogleAccount_(storedAccounts, syncStatus,' +
'storedAccounts.length, syncStatus.signedIn, syncStatus.hasError)',
},

/** @private */
showImportDataDialog_: {
type: Boolean,
Expand Down Expand Up @@ -192,7 +208,14 @@ Polymer({
this.handleSyncStatus_.bind(this));
this.addWebUIListener(
'sync-status-changed', this.handleSyncStatus_.bind(this));

// <if expr="not chromeos">
const handleStoredAccounts = accounts => {
this.storedAccounts = accounts;
};
this.syncBrowserProxy_.getStoredAccounts().then(handleStoredAccounts);
this.addWebUIListener('stored-accounts-updated', handleStoredAccounts);

this.addWebUIListener('sync-settings-saved', () => {
/** @type {!CrToastElement} */ (this.$.toast).show();
});
Expand Down Expand Up @@ -278,6 +301,20 @@ Polymer({
}
},

// <if expr="not chromeos">
/**
* @return {boolean}
* @private
*/
computeShouldShowGoogleAccount_: function() {
if (this.storedAccounts === undefined || this.syncStatus === undefined)
return false;

return (this.storedAccounts.length > 0 || !!this.syncStatus.signedIn) &&
!this.syncStatus.hasError;
},
// </if>

/** @private */
onProfileTap_: function() {
// <if expr="chromeos">
Expand Down Expand Up @@ -417,6 +454,15 @@ Polymer({
cr.ui.focusWithoutInk(assert(this.$.importDataDialogTrigger));
},

/**
* Open URL for managing your Google Account.
* @private
*/
openGoogleAccount_: function() {
settings.OpenWindowProxyImpl.getInstance().openURL(
loadTimeData.getString('googleAccountUrl'));
},

/**
* @return {boolean}
* @private
Expand Down
12 changes: 6 additions & 6 deletions chrome/browser/resources/settings/settings_resources.grd
Original file line number Diff line number Diff line change
Expand Up @@ -691,12 +691,6 @@
<structure name="IDR_SETTINGS_MEDIA_PICKER_JS"
file="site_settings/media_picker.js"
type="chrome_html" />
<structure name="IDR_SETTINGS_AUTOFILL_BROWSER_PROXY_HTML"
file="autofill_page/autofill_browser_proxy.html"
type="chrome_html" />
<structure name="IDR_SETTINGS_AUTOFILL_BROWSER_PROXY_JS"
file="autofill_page/autofill_browser_proxy.js"
type="chrome_html" />
<structure name="IDR_SETTINGS_AUTOFILL_PAGE_HTML"
file="autofill_page/autofill_page.html"
type="chrome_html" />
Expand Down Expand Up @@ -943,6 +937,12 @@
<structure name="IDR_SETTINGS_LOCAL_DATA_BROWSER_PROXY_JS"
file="site_settings/local_data_browser_proxy.js"
type="chrome_html" />
<structure name="IDR_SETTINGS_OPEN_WINDOW_PROXY_HTML"
file="open_window_proxy.html"
type="chrome_html" />
<structure name="IDR_SETTINGS_OPEN_WINDOW_PROXY_JS"
file="open_window_proxy.js"
type="chrome_html" />
<structure name="IDR_SETTINGS_PAGE_VISIBILITY_HTML"
file="page_visibility.html"
type="chrome_html" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1740,6 +1740,7 @@ void AddPeopleStrings(content::WebUIDataSource* html_source, Profile* profile) {
{"syncTimeout", IDS_SETTINGS_SYNC_TIMEOUT},
{"syncEverythingCheckboxLabel",
IDS_SETTINGS_SYNC_EVERYTHING_CHECKBOX_LABEL},
{"manageGoogleAccount", IDS_SETTINGS_MANAGE_GOOGLE_ACCOUNT},
{"appCheckboxLabel", IDS_SETTINGS_APPS_CHECKBOX_LABEL},
{"extensionsCheckboxLabel", IDS_SETTINGS_EXTENSIONS_CHECKBOX_LABEL},
{"settingsCheckboxLabel", IDS_SETTINGS_SETTINGS_CHECKBOX_LABEL},
Expand Down Expand Up @@ -1870,6 +1871,8 @@ void AddPeopleStrings(content::WebUIDataSource* html_source, Profile* profile) {
html_source->AddString("activityControlsUrl",
chrome::kGoogleAccountActivityControlsURL);

html_source->AddString("googleAccountUrl", chrome::kGoogleAccountURL);

html_source->AddBoolean("profileShortcutsEnabled",
ProfileShortcutManager::IsFeatureEnabled());

Expand Down
2 changes: 2 additions & 0 deletions chrome/common/url_constants.cc
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ const char kExtensionInvalidRequestURL[] = "chrome-extension://invalid/";
const char kGoogleAccountActivityControlsURL[] =
"https://myaccount.google.com/activitycontrols/search";

const char kGoogleAccountURL[] = "https://myaccount.google.com";

const char kGooglePasswordManagerURL[] = "https://passwords.google.com";

const char kLearnMoreReportingURL[] =
Expand Down
3 changes: 3 additions & 0 deletions chrome/common/url_constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@ extern const char kExtensionInvalidRequestURL[];
// URL of the 'Activity controls' section of the privacy settings page.
extern const char kGoogleAccountActivityControlsURL[];

// URL of the Google Account.
extern const char kGoogleAccountURL[];

// URL of the Google Password Manager.
extern const char kGooglePasswordManagerURL[];

Expand Down
14 changes: 7 additions & 7 deletions chrome/test/data/webui/settings/autofill_page_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
// found in the LICENSE file.

cr.define('settings_autofill_page', function() {
/** @implements {settings.AutofillBrowserProxy} */
class TestAutofillBrowserProxy extends TestBrowserProxy {
/** @implements {settings.OpenWindowProxy} */
class TestOpenWindowProxy extends TestBrowserProxy {
constructor() {
super([
'openURL',
Expand All @@ -20,8 +20,8 @@ cr.define('settings_autofill_page', function() {
suite('PasswordsUITest', function() {
/** @type {SettingsAutofillPageElement} */
let autofillPage = null;
/** @type {settings.AutofillBrowserProxy} */
let browserProxy = null;
/** @type {settings.OpenWindowProxy} */
let openWindowProxy = null;

suiteSetup(function() {
// Forces navigation to Google Password Manager to be off by default.
Expand All @@ -31,8 +31,8 @@ cr.define('settings_autofill_page', function() {
});

setup(function() {
browserProxy = new TestAutofillBrowserProxy();
settings.AutofillBrowserProxyImpl.instance_ = browserProxy;
openWindowProxy = new TestOpenWindowProxy();
settings.OpenWindowProxyImpl.instance_ = openWindowProxy;

PolymerTest.clearBody();
autofillPage = document.createElement('settings-autofill-page');
Expand Down Expand Up @@ -67,7 +67,7 @@ cr.define('settings_autofill_page', function() {
autofillPage.$$('#passwordManagerButton').click();
Polymer.dom.flush();

return browserProxy.whenCalled('openURL').then(url => {
return openWindowProxy.whenCalled('openURL').then(url => {
assertEquals(googlePasswordManagerUrl, url);
});
});
Expand Down
Loading

0 comments on commit 03f0beb

Please sign in to comment.