diff options
Diffstat (limited to 'chromium/chrome/browser/resources/settings/people_page')
57 files changed, 0 insertions, 9259 deletions
diff --git a/chromium/chrome/browser/resources/settings/people_page/account_manager.html b/chromium/chrome/browser/resources/settings/people_page/account_manager.html deleted file mode 100644 index f5d9d8bc29f..00000000000 --- a/chromium/chrome/browser/resources/settings/people_page/account_manager.html +++ /dev/null @@ -1,207 +0,0 @@ -<link rel="import" href="chrome://resources/html/polymer.html"> - -<link rel="import" href="chrome://resources/cr_elements/cr_action_menu/cr_action_menu.html"> -<link rel="import" href="chrome://resources/cr_elements/cr_button/cr_button.html"> -<link rel="import" href="chrome://resources/cr_elements/cr_icon_button/cr_icon_button.html"> -<link rel="import" href="chrome://resources/cr_elements/policy/cr_policy_indicator.html"> -<link rel="import" href="chrome://resources/cr_elements/policy/cr_tooltip_icon.html"> -<link rel="import" href="chrome://resources/html/i18n_behavior.html"> -<link rel="import" href="chrome://resources/html/icon.html"> -<link rel="import" href="chrome://resources/html/util.html"> -<link rel="import" href="chrome://resources/html/web_ui_listener_behavior.html"> -<link rel="import" href="chrome://resources/polymer/v1_0/iron-flex-layout/iron-flex-layout-classes.html"> -<link rel="import" href="../i18n_setup.html"> -<link rel="import" href="../route.html"> -<link rel="import" href="../settings_shared_css.html"> -<link rel="import" href="account_manager_browser_proxy.html"> - -<dom-module id="settings-account-manager"> - <template> - <style include="settings-shared iron-flex iron-flex-alignment"> - :host { - --add-account-margin-top: 16px; - } - - .profile-icon { - background: center / cover no-repeat; - border-radius: 20px; - flex-shrink: 0; - height: 40px; - width: 40px; - } - - .account-list-item { - padding-inline-end: 8px; - padding-inline-start: 0; - } - - .account-manager-description { - /* Up to 70 characters. */ - max-width: 35em; - } - - #outer { - margin-inline-end: var(--cr-section-padding); - margin-inline-start: 60px; - } - - .secondary-accounts-policy-indicator { - margin-inline-end: 12px; - } - - .settings-box.user-message { - align-items: flex-end; - } - - #account-list-header > h2 { - padding-bottom: 12px; - padding-top: 12px; - } - - cr-policy-indicator { - margin-inline-end: 1em; - margin-top: var(--add-account-margin-top); - } - - #add-account-button { - margin-bottom: 12px; - margin-top: 12px; - } - - #add-account-icon { - -webkit-mask-image: url(chrome://resources/images/add.svg); - background-color: currentColor; - height: 24px; - margin-inline-end: 0.5em; - width: 24px; - } - - .signed-out-text { - color: var(--google-red-600); - } - - .error-badge { - background: url(chrome://resources/images/error_badge.svg) - center / cover no-repeat; - display: block; - height: 20px; - left: 60%; - position: relative; - top: 60%; - width: 20px; - } - - :host-context([dir='rtl']) .error-badge { - left: auto; - right: 60%; - } - - .management-status { - color: var(--cr-secondary-text-color); - } - - .tooltip-primary-account { - margin-inline-end: 12px; - margin-inline-start: 12px; - } - </style> - - <div class="settings-box first"> - <span class="account-manager-description"> - $i18n{accountManagerDescription} - <a href="$i18nRaw{accountManagerLearnMoreUrl}" target="_blank"> - $i18n{learnMore} - </a> - </span> - </div> - - <div id="settings-box-user-message" class="settings-box first user-message" - hidden="[[isSecondaryGoogleAccountSigninAllowed_()]]"> - <cr-policy-pref-indicator class="secondary-accounts-policy-indicator" - pref= - "[[prefs.account_manager.secondary_google_account_signin_allowed]]"> - </cr-policy-pref-indicator> - <div id="user-message-text" class="secondary"> - [[getSecondaryAccountsDisabledUserMessage_()]] - </div> - </div> - - <div class="settings-box first"> - <div id="account-list-header" class="flex"> - <h2>$i18n{accountListHeader}</h2> - </div> - <cr-button disabled="[[!isSecondaryGoogleAccountSigninAllowed_()]]" - id="add-account-button" on-tap="addAccount_"> - <div id="add-account-icon"></div> - $i18n{addAccountLabel} - </cr-button> - </div> - - <div id="outer" class="layout vertical nowrap"> - <template is="dom-repeat" id="account-list" items="[[accounts_]]"> - <div class="settings-box account-list-item"> - - <div class="profile-icon" - style="background-image: [[getIconImageSet_(item.pic)]]"> - <template is="dom-if" if="[[!item.isSignedIn]]"> - <span class="error-badge"></span> - </template> - </div> - - <div class="middle two-line no-min-width"> - <div class="flex text-elide"> - <!-- If account is signed in, display the full name --> - <template is="dom-if" if="[[item.isSignedIn]]"> - <span>[[item.fullName]]</span> - </template> - <!-- Else, display a re-authentication message --> - <template is="dom-if" if="[[!item.isSignedIn]]"> - <span class="signed-out-text"> - [[getAccountManagerSignedOutName_(item.unmigrated)]] - </span> - </template> - - <div class="secondary">[[item.email]]</div> - </div> - </div> - - <template is="dom-if" - if="[[shouldShowReauthenticationButton_(item)]]"> - <cr-button title="[[getAccountManagerSignedOutTitle_(item)]]" - class="reauth-button" on-click="onReauthenticationTap_"> - [[getAccountManagerSignedOutLabel_(item.unmigrated)]] - </cr-button> - </template> - - <!-- If this is the Device Account, display the management status --> - <template is="dom-if" if="[[item.isDeviceAccount]]"> - <cr-tooltip-icon icon-class="cr:info-outline" - class="tooltip-primary-account" - tooltip-text="$i18n{accountManagerPrimaryAccountTooltip}" - icon-aria-label="$i18n{accountManagerPrimaryAccountTooltip}"> - </cr-tooltip-icon> - <span class="management-status"> - [[getManagementLabel_(item)]] - </span> - </template> - <!-- Else, display a hamburger menu for removing the account --> - <template is="dom-if" if="[[!item.isDeviceAccount]]"> - <cr-icon-button class="icon-more-vert" - title="[[getMoreActionsTitle_(item)]]" - on-click="onAccountActionsMenuButtonTap_"> - </cr-icon-button> - </template> - </div> - </template> - - <div class="clear settings-box"></div> - - <cr-action-menu> - <button class="dropdown-item" on-click="onRemoveAccountTap_"> - $i18n{removeAccountLabel} - </button> - </cr-action-menu> - </div> - </template> - <script src="account_manager.js"></script> -</dom-module> diff --git a/chromium/chrome/browser/resources/settings/people_page/account_manager.js b/chromium/chrome/browser/resources/settings/people_page/account_manager.js deleted file mode 100644 index e5cecdcd17f..00000000000 --- a/chromium/chrome/browser/resources/settings/people_page/account_manager.js +++ /dev/null @@ -1,217 +0,0 @@ -// 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 - * 'settings-account-manager' is the settings subpage containing controls to - * list, add and delete Secondary Google Accounts. - */ - -Polymer({ - is: 'settings-account-manager', - - behaviors: [ - I18nBehavior, - WebUIListenerBehavior, - settings.RouteObserverBehavior, - ], - - properties: { - /** - * List of Accounts. - * @type {!Array<settings.Account>} - */ - accounts_: { - type: Array, - value: function() { - return []; - }, - }, - - /** - * The targeted account for menu operations. - * @private {?settings.Account} - */ - actionMenuAccount_: Object, - }, - - /** @private {?settings.AccountManagerBrowserProxy} */ - browserProxy_: null, - - /** @override */ - attached: function() { - this.addWebUIListener('accounts-changed', this.refreshAccounts_.bind(this)); - }, - - /** @override */ - ready: function() { - this.browserProxy_ = settings.AccountManagerBrowserProxyImpl.getInstance(); - this.refreshAccounts_(); - }, - - /** - * @param {!settings.Route} newRoute - * @param {settings.Route} oldRoute - */ - currentRouteChanged: function(newRoute, oldRoute) { - if (newRoute == settings.routes.ACCOUNT_MANAGER) { - this.browserProxy_.showWelcomeDialogIfRequired(); - } - }, - - /** - * @return {boolean} True if secondary account sign-ins are allowed, false - * otherwise. - * @private - */ - isSecondaryGoogleAccountSigninAllowed_: function() { - return loadTimeData.getBoolean('secondaryGoogleAccountSigninAllowed'); - }, - - /** - * @return {string} 'Secondary Accounts disabled' message depending on - * account type - * @private - */ - getSecondaryAccountsDisabledUserMessage_: function() { - return loadTimeData.getBoolean('isChild') - ? this.i18n('accountManagerSecondaryAccountsDisabledChildText') - : this.i18n('accountManagerSecondaryAccountsDisabledText'); - }, - - /** - * @param {string} iconUrl - * @return {string} A CSS image-set for multiple scale factors. - * @private - */ - getIconImageSet_: function(iconUrl) { - return cr.icon.getImage(iconUrl); - }, - - /** - * @param {!Event} event - * @private - */ - addAccount_: function(event) { - this.browserProxy_.addAccount(); - }, - - /** - * @param {!settings.Account} account - * @return {boolean} True if the account reauthentication button should be - * shown, false otherwise. - * @private - */ - shouldShowReauthenticationButton_: function(account) { - // Device account re-authentication cannot be handled in-session, primarily - // because the user may have changed their password (leading to an LST - // invalidation) and we do not have a mechanism to change the cryptohome - // password in-session. - return !account.isDeviceAccount && !account.isSignedIn; - }, - - /** - * @param {!settings.Account} account - * @return {string} An appropriate management status label. e.g. - * "Primary account" for unmanaged accounts, "Managed by <Domain>" - * for Enterprise managed accounts etc. - * @private - */ - getManagementLabel_: function(account) { - if (account.organization) { - return this.i18n('accountManagerManagedLabel', account.organization); - } - - return this.i18n('accountManagerUnmanagedLabel'); - }, - - /** - * @param {boolean} unmigrated - * @private - */ - getAccountManagerSignedOutName_: function(unmigrated) { - return this.i18n(unmigrated ? 'accountManagerUnmigratedAccountName' - : 'accountManagerSignedOutAccountName'); - }, - - /** - * @param {boolean} unmigrated - * @private - */ - getAccountManagerSignedOutLabel_: function(unmigrated) { - return this.i18n(unmigrated ? 'accountManagerMigrationLabel' - : 'accountManagerReauthenticationLabel'); - }, - - - /** - * @param {!settings.Account} account - * @private - */ - getAccountManagerSignedOutTitle_: function(account) { - const label = account.unmigrated ? 'accountManagerMigrationTooltip' - : 'accountManagerReauthenticationTooltip'; - return loadTimeData.getStringF(label, account.email); - }, - - /** - * @param {!settings.Account} account - * @private - */ - getMoreActionsTitle_: function(account) { - return loadTimeData.getStringF('accountManagerMoreActionsTooltip', - account.email); - }, - - /** - * @param {!CustomEvent<!{model: !{item: !settings.Account}}>} event - * @private - */ - onReauthenticationTap_: function(event) { - if (event.model.item.unmigrated) { - this.browserProxy_.migrateAccount(event.model.item.email); - } else { - this.browserProxy_.reauthenticateAccount(event.model.item.email); - } - }, - - /** - * @private - */ - refreshAccounts_: function() { - this.browserProxy_.getAccounts().then(accounts => { - this.set('accounts_', accounts); - }); - }, - - /** - * Opens the Account actions menu. - * @param {!{model: !{item: settings.Account}, target: !Element}} event - * @private - */ - onAccountActionsMenuButtonTap_: function(event) { - this.actionMenuAccount_ = event.model.item; - /** @type {!CrActionMenuElement} */ (this.$$('cr-action-menu')) - .showAt(event.target); - }, - - /** - * Closes action menu and resets action menu model. - * @private - */ - closeActionMenu_: function() { - this.$$('cr-action-menu').close(); - this.actionMenuAccount_ = null; - }, - - /** - * Removes the account being pointed to by |this.actionMenuAccount_|. - * @private - */ - onRemoveAccountTap_: function() { - this.browserProxy_.removeAccount( - /** @type {?settings.Account} */ (this.actionMenuAccount_)); - this.closeActionMenu_(); - } -}); diff --git a/chromium/chrome/browser/resources/settings/people_page/account_manager_browser_proxy.html b/chromium/chrome/browser/resources/settings/people_page/account_manager_browser_proxy.html deleted file mode 100644 index 7228eadf8dc..00000000000 --- a/chromium/chrome/browser/resources/settings/people_page/account_manager_browser_proxy.html +++ /dev/null @@ -1 +0,0 @@ -<script src="account_manager_browser_proxy.js"></script> diff --git a/chromium/chrome/browser/resources/settings/people_page/account_manager_browser_proxy.js b/chromium/chrome/browser/resources/settings/people_page/account_manager_browser_proxy.js deleted file mode 100644 index b08b02268b5..00000000000 --- a/chromium/chrome/browser/resources/settings/people_page/account_manager_browser_proxy.js +++ /dev/null @@ -1,109 +0,0 @@ -// 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 from the "Google Accounts" subsection of - * the "People" section of Settings, to interact with the browser. Chrome OS - * only. - */ -cr.exportPath('settings'); - -/** - * Information for an account managed by Chrome OS AccountManager. - * @typedef {{ - * id: string, - * accountType: number, - * isDeviceAccount: boolean, - * isSignedIn: boolean, - * unmigrated: boolean, - * fullName: string, - * email: string, - * pic: string, - * organization: (string|undefined), - * }} - */ -settings.Account; - -cr.define('settings', function() { - /** @interface */ - class AccountManagerBrowserProxy { - /** - * Returns a Promise for the list of GAIA accounts held in AccountManager. - * @return {!Promise<!Array<settings.Account>>} - */ - getAccounts() {} - - /** - * Triggers the 'Add account' flow. - */ - addAccount() {} - - /** - * Triggers the re-authentication flow for the account pointed to by - * |account_email|. - * @param {string} account_email - */ - reauthenticateAccount(account_email) {} - - /** - * Triggers the migration dialog for the account pointed to by - * |account_email|. - * @param {string} account_email - */ - migrateAccount(account_email) {} - - /** - * Removes |account| from Account Manager. - * @param {?settings.Account} account - */ - removeAccount(account) {} - - /** - * Displays the Account Manager welcome dialog if required. - */ - showWelcomeDialogIfRequired() {} - } - - /** - * @implements {settings.AccountManagerBrowserProxy} - */ - class AccountManagerBrowserProxyImpl { - /** @override */ - getAccounts() { - return cr.sendWithPromise('getAccounts'); - } - - /** @override */ - addAccount() { - chrome.send('addAccount'); - } - - /** @override */ - reauthenticateAccount(account_email) { - chrome.send('reauthenticateAccount', [account_email]); - } - - /** @override */ - migrateAccount(account_email) { - chrome.send('migrateAccount', [account_email]); - } - - /** @override */ - removeAccount(account) { - chrome.send('removeAccount', [account]); - } - - /** @override */ - showWelcomeDialogIfRequired() { - chrome.send('showWelcomeDialogIfRequired'); - } - } - - cr.addSingletonGetter(AccountManagerBrowserProxyImpl); - - return { - AccountManagerBrowserProxy: AccountManagerBrowserProxy, - AccountManagerBrowserProxyImpl: AccountManagerBrowserProxyImpl, - }; -}); diff --git a/chromium/chrome/browser/resources/settings/people_page/change_picture.html b/chromium/chrome/browser/resources/settings/people_page/change_picture.html deleted file mode 100644 index 1dc7a5d0d42..00000000000 --- a/chromium/chrome/browser/resources/settings/people_page/change_picture.html +++ /dev/null @@ -1,118 +0,0 @@ -<link rel="import" href="chrome://resources/html/polymer.html"> - -<link rel="import" href="chrome://resources/cr_elements/chromeos/cr_picture/cr_picture_list.html"> -<link rel="import" href="chrome://resources/cr_elements/chromeos/cr_picture/cr_picture_pane.html"> -<link rel="import" href="chrome://resources/cr_elements/chromeos/cr_picture/cr_picture_types.html"> -<link rel="import" href="chrome://resources/html/i18n_behavior.html"> -<link rel="import" href="chrome://resources/html/util.html"> -<link rel="import" href="chrome://resources/html/web_ui_listener_behavior.html"> -<link rel="import" href="../i18n_setup.html"> -<link rel="import" href="../route.html"> -<link rel="import" href="../settings_shared_css.html"> -<link rel="import" href="change_picture_browser_proxy.html"> - -<dom-module id="settings-change-picture"> - <template> - <style> - :host { - --cr-toolbar-height: 56px; - /* #headerLine height + padding */ - --cr-settings-header-height: calc(62px + 1.34em); - --title-height: 2em; - --title-padding: 16px; - display: block; - min-height: 328px; - } - - #title { - height: var(--title-height); - margin-inline-start: 20px; - padding-top: var(--title-padding); - } - - #container { - align-items: flex-start; - display: flex; - margin-inline-start: 20px; - position: absolute; - top: calc(var(--cr-settings-header-height) + - var(--title-padding) + - var(--title-height)); - user-select: none; - } - - #picturePane { - --cr-picture-image-size: 192px; - flex-shrink: 0; - height: 288px; - margin-inline-end: 24px; - margin-top: 6px; - position: relative; - width: 288px; - } - - #authorCredit { - color: var(--paper-grey-500); - display: flex; - flex-direction: column; - margin-top: 20px; - } - - #pictureList { - /* TODO(reveman): Find a way to have height align to viewport - without using fixed position. */ - height: calc(100vh - - var(--cr-toolbar-height) - - var(--cr-settings-header-height) - - var(--title-padding) - - var(--title-height)); - margin-inline-end: 16px; - margin-top: 0; - min-height: 332px; - overflow-x: hidden; - overflow-y: auto; - position: relative; - } - - </style> - <div id="title">$i18n{changePicturePageDescription}</div> - <div id="container"> - <div> - <cr-picture-pane id="picturePane" - camera-present="[[cameraPresent_]]", - image-src="[[getImageSrc_(selectedItem_)]]" - image-type="[[getImageType_(selectedItem_)]]" - discard-image-label="$i18n{discardPhoto}" - preview-alt-text="$i18n{previewAltText}" - take-photo-label="$i18n{takePhoto}" - capture-video-label="$i18n{captureVideo}" - switch-mode-to-camera-label="$i18n{switchModeToCamera}" - switch-mode-to-video-label="$i18n{switchModeToVideo}" - camera-video-mode-enabled="[[cameraVideoModeEnabled_]]" - on-keys-pressed="onCameraPaneKeysPressed_"> - </cr-picture-pane> - <div id="authorCredit" - hidden="[[!isAuthorCreditShown_(selectedItem_)]]"> - [[getAuthorCredit_(selectedItem_, defaultImages_)]] - <a href="[[getAuthorWebsite_(selectedItem_, defaultImages_)]]" - target="_blank"> - [[getAuthorWebsite_(selectedItem_, defaultImages_)]] - </a> - </div> - </div> - <cr-picture-list id="pictureList" - hidden="[[!defaultImages_]]" - camera-present="[[cameraPresent_]]" - default-images="[[getDefaultImages_(defaultImages_, - firstDefaultImageIndex_)]]" - selected-item="{{selectedItem_}}" - choose-file-label="$i18n{chooseFile}" - old-image-label="$i18n{oldPhoto}" - profile-image-label="$i18n{profilePhoto}" - take-photo-label="$i18n{takePhoto}" - capture-video-label="$i18n{captureVideo}"> - </cr-picture-list> - </div> - </template> - <script src="change_picture.js"></script> -</dom-module> diff --git a/chromium/chrome/browser/resources/settings/people_page/change_picture.js b/chromium/chrome/browser/resources/settings/people_page/change_picture.js deleted file mode 100644 index 8dd70529250..00000000000 --- a/chromium/chrome/browser/resources/settings/people_page/change_picture.js +++ /dev/null @@ -1,334 +0,0 @@ -// Copyright 2015 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 - * 'settings-change-picture' is the settings subpage containing controls to - * edit a ChromeOS user's picture. - */ -Polymer({ - is: 'settings-change-picture', - - behaviors: [ - settings.RouteObserverBehavior, - I18nBehavior, - WebUIListenerBehavior, - ], - - properties: { - /** - * True if the user has a plugged-in webcam. - * @private {boolean} - */ - cameraPresent_: { - type: Boolean, - value: false, - }, - - /** - * The currently selected item. This property is bound to the iron-selector - * and never directly assigned. This may be undefined momentarily as - * the selection changes due to iron-selector implementation details. - * @private {?CrPicture.ImageElement} - */ - selectedItem_: { - type: Object, - value: null, - }, - - /** - * The active set of default user images. - * @private {?Array<!settings.DefaultImage>} - */ - defaultImages_: { - type: Object, - value: null, - }, - - /** - * The index of the first default image to use in the selection list. - * @private - */ - firstDefaultImageIndex_: Number, - - /** - * True when camera video mode is enabled. - * @private {boolean} - */ - cameraVideoModeEnabled_: { - type: Boolean, - value: function() { - return loadTimeData.getBoolean('changePictureVideoModeEnabled'); - }, - readOnly: true, - }, - }, - - listeners: { - 'discard-image': 'onDiscardImage_', - 'image-activate': 'onImageActivate_', - 'focus-action': 'onFocusAction_', - 'photo-taken': 'onPhotoTaken_', - 'switch-mode': 'onSwitchMode_', - }, - - /** @private {?settings.ChangePictureBrowserProxy} */ - browserProxy_: null, - - /** @private {?CrPictureListElement} */ - pictureList_: null, - - /** @private {boolean} */ - oldImagePending_: false, - - /** @override */ - ready: function() { - this.browserProxy_ = settings.ChangePictureBrowserProxyImpl.getInstance(); - this.pictureList_ = - /** @type {CrPictureListElement} */ (this.$.pictureList); - }, - - /** @override */ - attached: function() { - this.addWebUIListener( - 'default-images-changed', this.receiveDefaultImages_.bind(this)); - this.addWebUIListener( - 'selected-image-changed', this.receiveSelectedImage_.bind(this)); - this.addWebUIListener( - 'old-image-changed', this.receiveOldImage_.bind(this)); - this.addWebUIListener( - 'profile-image-changed', this.receiveProfileImage_.bind(this)); - this.addWebUIListener( - 'camera-presence-changed', this.receiveCameraPresence_.bind(this)); - }, - - - /** @protected */ - currentRouteChanged: function(newRoute) { - if (newRoute == settings.routes.CHANGE_PICTURE) { - this.browserProxy_.initialize(); - this.browserProxy_.requestSelectedImage(); - this.pictureList_.setFocus(); - } else { - // Ensure we deactivate the camera when we navigate away. - this.selectedItem_ = null; - } - }, - - /** - * Handler for the 'default-images-changed' event. - * @param {{first: number, images: !Array<!settings.DefaultImage>}} info - * @private - */ - receiveDefaultImages_: function(info) { - this.defaultImages_ = info.images; - this.firstDefaultImageIndex_ = info.first; - }, - - /** - * Handler for the 'selected-image-changed' event. Is only called with - * default images. - * @param {string} imageUrl - * @private - */ - receiveSelectedImage_: function(imageUrl) { - this.pictureList_.setSelectedImageUrl(imageUrl); - }, - - /** - * Handler for the 'old-image-changed' event. The Old image is any selected - * non-profile and non-default image. It can be from the camera, a file, or a - * deprecated default image. When this method is called, the Old image - * becomes the selected image. - * @param {!{url: string, index: number}} imageInfo - * @private - */ - receiveOldImage_: function(imageInfo) { - this.oldImagePending_ = false; - this.pictureList_.setOldImageUrl(imageInfo.url, imageInfo.index); - }, - - /** - * Handler for the 'profile-image-changed' event. - * @param {string} imageUrl - * @param {boolean} selected - * @private - */ - receiveProfileImage_: function(imageUrl, selected) { - this.pictureList_.setProfileImageUrl(imageUrl, selected); - }, - - /** - * Handler for the 'camera-presence-changed' event. - * @param {boolean} cameraPresent - * @private - */ - receiveCameraPresence_: function(cameraPresent) { - this.cameraPresent_ = cameraPresent; - }, - - /** - * Selects an image element. - * @param {!CrPicture.ImageElement} image - * @private - */ - selectImage_: function(image) { - switch (image.dataset.type) { - case CrPicture.SelectionTypes.CAMERA: - /** CrPicturePaneElement */ (this.$.picturePane).takePhoto(); - break; - case CrPicture.SelectionTypes.FILE: - this.browserProxy_.chooseFile(); - break; - case CrPicture.SelectionTypes.PROFILE: - this.browserProxy_.selectProfileImage(); - break; - case CrPicture.SelectionTypes.OLD: - const imageIndex = image.dataset.imageIndex; - if (imageIndex !== undefined && imageIndex >= 0 && image.src) { - this.browserProxy_.selectDefaultImage(image.dataset.url); - } else { - this.browserProxy_.selectOldImage(); - } - break; - case CrPicture.SelectionTypes.DEFAULT: - this.browserProxy_.selectDefaultImage(image.dataset.url); - break; - default: - assertNotReached('Selected unknown image type'); - } - }, - - /** - * Handler for when an image is activated. - * @param {!CustomEvent<!CrPicture.ImageElement>} event - * @private - */ - onImageActivate_: function(event) { - this.selectImage_(event.detail); - }, - - /** Focus the action button in the picture pane. */ - onFocusAction_: function() { - /** CrPicturePaneElement */ (this.$.picturePane).focusActionButton(); - }, - - /** - * @param {!CustomEvent<{photoDataUrl: string}>} event - * @private - */ - onPhotoTaken_: function(event) { - this.oldImagePending_ = true; - this.browserProxy_.photoTaken(event.detail.photoDataUrl); - this.pictureList_.setOldImageUrl(event.detail.photoDataUrl); - this.pictureList_.setFocus(); - announceAccessibleMessage( - loadTimeData.getString('photoCaptureAccessibleText')); - }, - - /** - * @param {!CustomEvent<boolean>} event - * @private - */ - onSwitchMode_: function(event) { - const videomode = event.detail; - announceAccessibleMessage(this.i18n( - videomode ? 'videoModeAccessibleText' : 'photoModeAccessibleText')); - }, - - /** - * Callback the iron-a11y-keys "keys-pressed" event bubbles up from the - * cr-camera-pane. - * @param {!CustomEvent<!{key: string, keyboardEvent: Object}>} event - * @private - */ - onCameraPaneKeysPressed_(event) { - this.$.pictureList.focus(); - this.$.pictureList.onKeysPressed(event); - }, - - /** @private */ - onDiscardImage_: function() { - // Prevent image from being discarded if old image is pending. - if (this.oldImagePending_) { - return; - } - this.pictureList_.setOldImageUrl(CrPicture.kDefaultImageUrl); - // Revert to profile image as we don't know what last used default image is. - this.browserProxy_.selectProfileImage(); - announceAccessibleMessage(this.i18n('photoDiscardAccessibleText')); - }, - - /** - * @param {CrPicture.ImageElement} selectedItem - * @return {string} - * @private - */ - getImageSrc_: function(selectedItem) { - return (selectedItem && selectedItem.dataset.url) || ''; - }, - - /** - * @param {CrPicture.ImageElement} selectedItem - * @return {string} - * @private - */ - getImageType_: function(selectedItem) { - return (selectedItem && selectedItem.dataset.type) || - CrPicture.SelectionTypes.NONE; - }, - - /** - * @param {!Array<!settings.DefaultImage>} defaultImages - * @param {number} firstDefaultImageIndex - * @return {!Array<!settings.DefaultImage>} - * @private - */ - getDefaultImages_(defaultImages, firstDefaultImageIndex) { - return defaultImages ? defaultImages.slice(firstDefaultImageIndex) : []; - }, - - /** - * @param {CrPicture.ImageElement} selectedItem - * @return {boolean} True if the author credit text is shown. - * @private - */ - isAuthorCreditShown_: function(selectedItem) { - return !!selectedItem && - (selectedItem.dataset.type == CrPicture.SelectionTypes.DEFAULT || - (selectedItem.dataset.imageIndex !== undefined && - selectedItem.dataset.imageIndex >= 0)); - }, - - /** - * @param {!CrPicture.ImageElement} selectedItem - * @param {!Array<!settings.DefaultImage>} defaultImages - * @return {string} The author name for the selected default image. An empty - * string is returned if there is no valid author name. - * @private - */ - getAuthorCredit_: function(selectedItem, defaultImages) { - const index = selectedItem ? selectedItem.dataset.imageIndex : undefined; - if (index === undefined || index < 0 || index >= defaultImages.length) { - return ''; - } - const author = defaultImages[index].author; - return author ? this.i18n('authorCreditText', author) : ''; - }, - - /** - * @param {!CrPicture.ImageElement} selectedItem - * @param {!Array<!settings.DefaultImage>} defaultImages - * @return {string} The author name for the selected default image. An empty - * string is returned if there is no valid author name. - * @private - */ - getAuthorWebsite_: function(selectedItem, defaultImages) { - const index = selectedItem ? selectedItem.dataset.imageIndex : undefined; - if (index === undefined || index < 0 || index >= defaultImages.length) { - return ''; - } - return defaultImages[index].website || ''; - }, -}); diff --git a/chromium/chrome/browser/resources/settings/people_page/change_picture_browser_proxy.html b/chromium/chrome/browser/resources/settings/people_page/change_picture_browser_proxy.html deleted file mode 100644 index 6a983e4ff9a..00000000000 --- a/chromium/chrome/browser/resources/settings/people_page/change_picture_browser_proxy.html +++ /dev/null @@ -1 +0,0 @@ -<script src="change_picture_browser_proxy.js"></script> diff --git a/chromium/chrome/browser/resources/settings/people_page/change_picture_browser_proxy.js b/chromium/chrome/browser/resources/settings/people_page/change_picture_browser_proxy.js deleted file mode 100644 index 3cd333e51bd..00000000000 --- a/chromium/chrome/browser/resources/settings/people_page/change_picture_browser_proxy.js +++ /dev/null @@ -1,119 +0,0 @@ -// Copyright 2016 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 from the "Change Picture" subpage of - * the People section to interact with the browser. ChromeOS only. - */ -cr.exportPath('settings'); - -/** - * An object describing a default image. - * @typedef {{ - * author: (string|undefined), - * index: number, - * title: (string|undefined), - * url: string, - * website: (string|undefined) - * }} - */ -settings.DefaultImage; - -cr.define('settings', function() { - /** @interface */ - class ChangePictureBrowserProxy { - /** - * Retrieves the initial set of default images, profile image, etc. As a - * response, the C++ sends these WebUIListener events: - * 'default-images-changed', 'profile-image-changed', 'old-image-changed', - * and 'selected-image-changed' - */ - initialize() {} - - /** - * Sets the user image to one of the default images. As a response, the C++ - * sends the 'default-images-changed' WebUIListener event. - * @param {string} imageUrl - */ - selectDefaultImage(imageUrl) {} - - /** - * Sets the user image to the 'old' image. As a response, the C++ sends the - * 'old-image-changed' WebUIListener event. - */ - selectOldImage() {} - - /** - * Sets the user image to the profile image. As a response, the C++ sends - * the 'profile-image-changed' WebUIListener event. - */ - selectProfileImage() {} - - /** - * Provides the taken photo as a data URL to the C++ and sets the user - * image to the 'old' image. As a response, the C++ sends the - * 'old-image-changed' WebUIListener event. - * @param {string} photoDataUrl - */ - photoTaken(photoDataUrl) {} - - /** - * Requests a file chooser to select a new user image. No response is - * expected. - */ - chooseFile() {} - - /** Requests the currently selected image. */ - requestSelectedImage() {} - } - - /** - * @implements {settings.ChangePictureBrowserProxy} - */ - class ChangePictureBrowserProxyImpl { - /** @override */ - initialize() { - chrome.send('onChangePicturePageInitialized'); - } - - /** @override */ - selectDefaultImage(imageUrl) { - chrome.send('selectImage', [imageUrl, 'default']); - } - - /** @override */ - selectOldImage() { - chrome.send('selectImage', ['', 'old']); - } - - /** @override */ - selectProfileImage() { - chrome.send('selectImage', ['', 'profile']); - } - - /** @override */ - photoTaken(photoDataUrl) { - chrome.send('photoTaken', [photoDataUrl]); - } - - /** @override */ - chooseFile() { - chrome.send('chooseFile'); - } - - /** @override */ - requestSelectedImage() { - chrome.send('requestSelectedImage'); - } - } - - // The singleton instance_ is replaced with a test version of this wrapper - // during testing. - cr.addSingletonGetter(ChangePictureBrowserProxyImpl); - - return { - ChangePictureBrowserProxy: ChangePictureBrowserProxy, - ChangePictureBrowserProxyImpl: ChangePictureBrowserProxyImpl, - }; -}); diff --git a/chromium/chrome/browser/resources/settings/people_page/fingerprint_browser_proxy.html b/chromium/chrome/browser/resources/settings/people_page/fingerprint_browser_proxy.html deleted file mode 100644 index 1e90fb88668..00000000000 --- a/chromium/chrome/browser/resources/settings/people_page/fingerprint_browser_proxy.html +++ /dev/null @@ -1 +0,0 @@ -<script src="fingerprint_browser_proxy.js"></script> diff --git a/chromium/chrome/browser/resources/settings/people_page/fingerprint_browser_proxy.js b/chromium/chrome/browser/resources/settings/people_page/fingerprint_browser_proxy.js deleted file mode 100644 index 8479d9ce8e1..00000000000 --- a/chromium/chrome/browser/resources/settings/people_page/fingerprint_browser_proxy.js +++ /dev/null @@ -1,165 +0,0 @@ -// Copyright 2017 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.exportPath('settings'); - -/** - * @enum {number} - * These values must be kept in sync with the values in - * third_party/cros_system_api/dbus/service_constants.h. - */ -settings.FingerprintResultType = { - SUCCESS: 0, - PARTIAL: 1, - INSUFFICIENT: 2, - SENSOR_DIRTY: 3, - TOO_SLOW: 4, - TOO_FAST: 5, - IMMOBILE: 6, -}; - -/** - * An object describing a attempt from the fingerprint hardware. The structure - * of this data must be kept in sync with C++ FingerprintHandler. - * @typedef {{ - * result: settings.FingerprintResultType, - * indexes: !Array<number>, - * }} - */ -settings.FingerprintAttempt; - -/** - * An object describing a scan from the fingerprint hardware. The structure of - * this data must be kept in sync with C++ FingerprintHandler. - * @typedef {{ - * result: settings.FingerprintResultType, - * isComplete: boolean, - * percentComplete: number, - * }} - */ -settings.FingerprintScan; - -/** - * An object describing the necessary info to display on the fingerprint - * settings. The structure of this data must be kept in sync with - * C++ FingerprintHandler. - * @typedef {{ - * fingerprintsList: !Array<string>, - * isMaxed: boolean, - * }} - */ -settings.FingerprintInfo; - -cr.define('settings', function() { - /** @interface */ - class FingerprintBrowserProxy { - /** - * @return {!Promise<!settings.FingerprintInfo>} - */ - getFingerprintsList() {} - - /** - * @return {!Promise<number>} - */ - getNumFingerprints() {} - - /** - * @param {string} authToken - */ - startEnroll(authToken) {} - - cancelCurrentEnroll() {} - - /** - * @param {number} index - * @return {!Promise<string>} - */ - getEnrollmentLabel(index) {} - - /** - * @param {number} index - * @return {!Promise<boolean>} - */ - removeEnrollment(index) {} - - /** - * @param {number} index - * @param {string} newLabel - * @return {!Promise<boolean>} - */ - changeEnrollmentLabel(index, newLabel) {} - - startAuthentication() {} - endCurrentAuthentication() {} - - /** - * TODO(sammiequon): Temporary function to let the handler know when a - * completed scan has been sent via click on the setup fingerprint dialog. - * Remove this when real scans are implemented. - */ - fakeScanComplete() {} - } - - /** - * @implements {settings.FingerprintBrowserProxy} - */ - class FingerprintBrowserProxyImpl { - /** @override */ - getFingerprintsList() { - return cr.sendWithPromise('getFingerprintsList'); - } - - /** @override */ - getNumFingerprints() { - return cr.sendWithPromise('getNumFingerprints'); - } - - /** @override */ - startEnroll(authToken) { - chrome.send('startEnroll', [authToken]); - } - - /** @override */ - cancelCurrentEnroll() { - chrome.send('cancelCurrentEnroll'); - } - - /** @override */ - getEnrollmentLabel(index) { - return cr.sendWithPromise('getEnrollmentLabel'); - } - - /** @override */ - removeEnrollment(index) { - return cr.sendWithPromise('removeEnrollment', index); - } - - /** @override */ - changeEnrollmentLabel(index, newLabel) { - return cr.sendWithPromise('changeEnrollmentLabel', index, newLabel); - } - - /** @override */ - startAuthentication() { - chrome.send('startAuthentication'); - } - - /** @override */ - endCurrentAuthentication() { - chrome.send('endCurrentAuthentication'); - } - - /** @override */ - fakeScanComplete() { - chrome.send('fakeScanComplete'); - } - } - - cr.addSingletonGetter(FingerprintBrowserProxyImpl); - - return { - FingerprintBrowserProxy: FingerprintBrowserProxy, - FingerprintBrowserProxyImpl: FingerprintBrowserProxyImpl, - }; -}); diff --git a/chromium/chrome/browser/resources/settings/people_page/fingerprint_list.html b/chromium/chrome/browser/resources/settings/people_page/fingerprint_list.html deleted file mode 100644 index 37db70a1b32..00000000000 --- a/chromium/chrome/browser/resources/settings/people_page/fingerprint_list.html +++ /dev/null @@ -1,82 +0,0 @@ -<link rel="import" href="chrome://resources/html/polymer.html"> - -<link rel="import" href="chrome://resources/cr_elements/cr_button/cr_button.html"> -<link rel="import" href="chrome://resources/cr_elements/cr_icon_button/cr_icon_button.html"> -<link rel="import" href="chrome://resources/cr_elements/cr_input/cr_input.html"> -<link rel="import" href="chrome://resources/cr_elements/icons.html"> -<link rel="import" href="chrome://resources/html/assert.html"> -<link rel="import" href="chrome://resources/html/cr/ui/focus_without_ink.html"> -<link rel="import" href="chrome://resources/html/i18n_behavior.html"> -<link rel="import" href="chrome://resources/html/web_ui_listener_behavior.html"> -<link rel="import" href="chrome://resources/polymer/v1_0/iron-icon/iron-icon.html"> -<link rel="import" href="chrome://resources/polymer/v1_0/iron-list/iron-list.html"> -<link rel="import" href="chrome://resources/polymer/v1_0/paper-ripple/paper-ripple.html"> -<link rel="import" href="fingerprint_browser_proxy.html"> -<link rel="import" href="setup_fingerprint_dialog.html"> -<link rel="import" href="../i18n_setup.html"> -<link rel="import" href="../route.html"> -<link rel="import" href="../settings_shared_css.html"> - -<dom-module id="settings-fingerprint-list"> - <template> - <style include="settings-shared"> - .add-link { - background-color: transparent; - color: var(--google-blue-500); - } - - .add-link[disabled] { - color: var(--google-grey-500); - } - - .body { - @apply --settings-list-frame-padding; - } - - .list-item { - background-color: white; - } - - cr-input { - --cr-input-error-display: none; - } - - paper-ripple { - color: var(--google-grey-refresh-700); - } - </style> - - <h2 class="settings-box">$i18n{lockScreenRegisteredFingerprints}</h2> - <div class="body layout vertical"> - <iron-list id="fingerprintsList" items="[[fingerprints_]]"> - <template> - <div class="list-item"> - <paper-ripple noink></paper-ripple> - <cr-input value="{{item}}" on-change="onFingerprintLabelChanged_"> - </cr-input> - <cr-icon-button class="icon-delete-gray" - on-click="onFingerprintDeleteTapped_" - aria-label$="[[getButtonAriaLabel_(item)]]"></cr-icon-button> - </div> - </template> - </iron-list> - <div class="continuation"> - <cr-button id="addFingerprint" class="add-link action-button" - on-click="openAddFingerprintDialog_"> - $i18n{lockScreenAddFingerprint} - </cr-button> - </div> - </div> - <i class="settings-box continuation">$i18n{lockScreenFingerprintWarning}</i> - - <template is="dom-if" if="[[showSetupFingerprintDialog_]]" restamp> - <settings-setup-fingerprint-dialog - auth-token="[[authToken]]" - on-add-fingerprint="updateFingerprintsList_" - on-close="onSetupFingerprintDialogClose_" - allow-add-another-finger="[[allowAddAnotherFinger_]]"> - </settings-setup-fingerprint-dialog> - </template> - </template> - <script src="fingerprint_list.js"></script> -</dom-module> diff --git a/chromium/chrome/browser/resources/settings/people_page/fingerprint_list.js b/chromium/chrome/browser/resources/settings/people_page/fingerprint_list.js deleted file mode 100644 index 657e219e3dd..00000000000 --- a/chromium/chrome/browser/resources/settings/people_page/fingerprint_list.js +++ /dev/null @@ -1,207 +0,0 @@ -// Copyright 2016 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. - -(function() { -'use strict'; - -/** - * The duration in ms of a background flash when a user touches the fingerprint - * sensor on this page. - * @type {number} - */ -const FLASH_DURATION_MS = 500; - -Polymer({ - is: 'settings-fingerprint-list', - - behaviors: [ - I18nBehavior, - WebUIListenerBehavior, - settings.RouteObserverBehavior, - ], - - properties: { - /** - * Authentication token provided by settings-people-page. - */ - authToken: { - type: String, - value: '', - }, - - /** - * The list of fingerprint objects. - * @private {!Array<string>} - */ - fingerprints_: { - type: Array, - value: function() { - return []; - } - }, - - /** @private */ - showSetupFingerprintDialog_: Boolean, - - /** - * Whether add another finger is allowed. - * @type {boolean} - * @private - */ - allowAddAnotherFinger_: { - type: Boolean, - value: true, - }, - }, - - /** @private {?settings.FingerprintBrowserProxy} */ - browserProxy_: null, - - /** @override */ - attached: function() { - this.addWebUIListener( - 'on-fingerprint-attempt-received', this.onAttemptReceived_.bind(this)); - this.addWebUIListener('on-screen-locked', this.onScreenLocked_.bind(this)); - this.browserProxy_ = settings.FingerprintBrowserProxyImpl.getInstance(); - this.browserProxy_.startAuthentication(); - this.updateFingerprintsList_(); - }, - - /** @override */ - detached: function() { - this.browserProxy_.endCurrentAuthentication(); - }, - - /** - * Overridden from settings.RouteObserverBehavior. - * @param {!settings.Route} newRoute - * @param {!settings.Route} oldRoute - * @protected - */ - currentRouteChanged: function(newRoute, oldRoute) { - if (newRoute != settings.routes.FINGERPRINT) { - if (this.browserProxy_) { - this.browserProxy_.endCurrentAuthentication(); - } - } else if (oldRoute == settings.routes.LOCK_SCREEN) { - // Start fingerprint authentication when going from LOCK_SCREEN to - // FINGERPRINT page. - this.browserProxy_.startAuthentication(); - } - }, - - /** - * Sends a ripple when the user taps the sensor with a registered fingerprint. - * @param {!settings.FingerprintAttempt} fingerprintAttempt - * @private - */ - onAttemptReceived_: function(fingerprintAttempt) { - /** @type {NodeList<!HTMLElement>} */ const listItems = - this.$.fingerprintsList.querySelectorAll('.list-item'); - /** @type {Array<number>} */ const filteredIndexes = - fingerprintAttempt.indexes.filter(function(index) { - return index >= 0 && index < listItems.length; - }); - - // Flash the background and produce a ripple for each list item that - // corresponds to the attempted finger. - filteredIndexes.forEach(function(index) { - const listItem = listItems[index]; - const ripple = listItem.querySelector('paper-ripple'); - - // Activate the ripple. - if (ripple) { - ripple.simulatedRipple(); - } - - // Flash the background. - listItem.animate( - [ - {backgroundColor: ['var(--google-grey-300)']}, - {backgroundColor: ['white']} - ], - FLASH_DURATION_MS); - }); - }, - - /** @private */ - updateFingerprintsList_: function() { - this.browserProxy_.getFingerprintsList().then( - this.onFingerprintsChanged_.bind(this)); - }, - - /** - * @param {!settings.FingerprintInfo} fingerprintInfo - * @private - */ - onFingerprintsChanged_: function(fingerprintInfo) { - // Update iron-list. - this.fingerprints_ = fingerprintInfo.fingerprintsList.slice(); - this.$$('.action-button').disabled = fingerprintInfo.isMaxed; - this.allowAddAnotherFinger_ = !fingerprintInfo.isMaxed; - }, - - /** - * Deletes a fingerprint from |fingerprints_|. - * @param {!{model: !{index: !number}}} e - * @private - */ - onFingerprintDeleteTapped_: function(e) { - this.browserProxy_.removeEnrollment(e.model.index).then(success => { - if (success) { - this.updateFingerprintsList_(); - } - }); - }, - - /** - * @param {!{model: !{index: !number, item: !string}}} e - * @private - */ - onFingerprintLabelChanged_: function(e) { - this.browserProxy_.changeEnrollmentLabel(e.model.index, e.model.item) - .then(success => { - if (success) { - this.updateFingerprintsList_(); - } - }); - }, - - /** - * Opens the setup fingerprint dialog. - * @private - */ - openAddFingerprintDialog_: function() { - this.showSetupFingerprintDialog_ = true; - }, - - /** @private */ - onSetupFingerprintDialogClose_: function() { - this.showSetupFingerprintDialog_ = false; - cr.ui.focusWithoutInk(assert(this.$$('#addFingerprint'))); - this.browserProxy_.startAuthentication(); - }, - - /** - * Close the setup fingerprint dialog when the screen is unlocked. - * @param {boolean} screenIsLocked - * @private - */ - onScreenLocked_: function(screenIsLocked) { - if (!screenIsLocked && - settings.getCurrentRoute() == settings.routes.FINGERPRINT) { - this.onSetupFingerprintDialogClose_(); - } - }, - - /** - * @param {string} item - * @return {string} - * @private - */ - getButtonAriaLabel_: function(item) { - return this.i18n('lockScreenDeleteFingerprintLabel', item); - }, -}); -})(); diff --git a/chromium/chrome/browser/resources/settings/people_page/import_data_browser_proxy.html b/chromium/chrome/browser/resources/settings/people_page/import_data_browser_proxy.html deleted file mode 100644 index d49dd93b022..00000000000 --- a/chromium/chrome/browser/resources/settings/people_page/import_data_browser_proxy.html +++ /dev/null @@ -1 +0,0 @@ -<script src="import_data_browser_proxy.js"></script> diff --git a/chromium/chrome/browser/resources/settings/people_page/import_data_browser_proxy.js b/chromium/chrome/browser/resources/settings/people_page/import_data_browser_proxy.js deleted file mode 100644 index 47c80a28a9d..00000000000 --- a/chromium/chrome/browser/resources/settings/people_page/import_data_browser_proxy.js +++ /dev/null @@ -1,87 +0,0 @@ -// Copyright 2016 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 from the the Import Data dialog to allow - * users to import data (like bookmarks) from other web browsers. - */ -cr.exportPath('settings'); - -/** - * An object describing a source browser profile that may be imported. - * The structure of this data must be kept in sync with C++ ImportDataHandler. - * @typedef {{ - * name: string, - * index: number, - * history: boolean, - * favorites: boolean, - * passwords: boolean, - * search: boolean, - * autofillFormData: boolean, - * }} - */ -settings.BrowserProfile; - -/** - * @enum {string} - * These string values must be kept in sync with the C++ ImportDataHandler. - */ -settings.ImportDataStatus = { - INITIAL: 'initial', - IN_PROGRESS: 'inProgress', - SUCCEEDED: 'succeeded', - FAILED: 'failed', -}; - -cr.define('settings', function() { - /** @interface */ - class ImportDataBrowserProxy { - /** - * Returns the source profiles available for importing from other browsers. - * @return {!Promise<!Array<!settings.BrowserProfile>>} - */ - initializeImportDialog() {} - - /** - * Starts importing data for the specified source browser profile. The C++ - * responds with the 'import-data-status-changed' WebUIListener event. - * @param {number} sourceBrowserProfileIndex - */ - importData(sourceBrowserProfileIndex) {} - - /** - * Prompts the user to choose a bookmarks file to import bookmarks from. - */ - importFromBookmarksFile() {} - } - - /** - * @implements {settings.ImportDataBrowserProxy} - */ - class ImportDataBrowserProxyImpl { - /** @override */ - initializeImportDialog() { - return cr.sendWithPromise('initializeImportDialog'); - } - - /** @override */ - importData(sourceBrowserProfileIndex) { - chrome.send('importData', [sourceBrowserProfileIndex]); - } - - /** @override */ - importFromBookmarksFile() { - chrome.send('importFromBookmarksFile'); - } - } - - // The singleton instance_ is replaced with a test version of this wrapper - // during testing. - cr.addSingletonGetter(ImportDataBrowserProxyImpl); - - return { - ImportDataBrowserProxy: ImportDataBrowserProxy, - ImportDataBrowserProxyImpl: ImportDataBrowserProxyImpl, - }; -}); diff --git a/chromium/chrome/browser/resources/settings/people_page/import_data_dialog.html b/chromium/chrome/browser/resources/settings/people_page/import_data_dialog.html deleted file mode 100644 index 9eb241a1aba..00000000000 --- a/chromium/chrome/browser/resources/settings/people_page/import_data_dialog.html +++ /dev/null @@ -1,130 +0,0 @@ -<link rel="import" href="chrome://resources/html/polymer.html"> - -<link rel="import" href="chrome://resources/cr_elements/cr_button/cr_button.html"> -<link rel="import" href="chrome://resources/cr_elements/cr_dialog/cr_dialog.html"> -<link rel="import" href="chrome://resources/html/i18n_behavior.html"> -<link rel="import" href="chrome://resources/cr_elements/md_select_css.html"> -<link rel="import" href="chrome://resources/html/web_ui_listener_behavior.html"> -<link rel="import" href="chrome://resources/polymer/v1_0/iron-icon/iron-icon.html"> -<link rel="import" href="chrome://resources/polymer/v1_0/paper-spinner/paper-spinner-lite.html"> -<link rel="import" href="../controls/settings_checkbox.html"> -<link rel="import" href="../controls/settings_toggle_button.html"> -<link rel="import" href="../i18n_setup.html"> -<link rel="import" href="../icons.html"> -<link rel="import" href="import_data_browser_proxy.html"> -<link rel="import" href="../prefs/prefs_behavior.html"> -<link rel="import" href="../settings_vars_css.html"> - -<dom-module id="settings-import-data-dialog"> - <template> - <style include="settings-shared md-select"> - .description { - align-items: center; - display: flex; - margin-top: 16px; - } - - paper-spinner-lite { - margin: 0 8px; - } - - #successIcon { - fill: var(--cr-checked-color); - height: 80px; - margin: auto; - width: 100%; - } - - /* Prevent focus-outline to be chopped by the bottom of dialog body. */ - .md-select { - margin-top: 2px; - } - - </style> - <cr-dialog id="dialog" close-text="$i18n{close}" - ignore-popstate> - <div slot="title">$i18n{importTitle}</div> - <div slot="body"> - <div hidden$="[[!hasImportStatus_( - importStatusEnum_.SUCCEEDED, importStatus_)]]"> - <iron-icon id="successIcon" icon="settings:check-circle"> - </iron-icon> - <div hidden$="[[!prefs.import_dialog_bookmarks.value]]"> - <div class="description">$i18n{importSuccess}</div> - <settings-toggle-button class="first" - label="$i18n{showBookmarksBar}" - pref="{{prefs.bookmark_bar.show_on_all_tabs}}"> - </settings-toggle-button> - </div> - </div> - - <div hidden$="[[hasImportStatus_( - importStatusEnum_.SUCCEEDED, importStatus_)]]"> - <select id="browserSelect" class="md-select" - aria-label="$i18n{importFromLabel}" - on-change="onBrowserProfileSelectionChange_"> - <template is="dom-repeat" items="[[browserProfiles_]]"> - <option value="[[item.index]]">[[item.name]]</option> - </template> - </select> - <div class="description">$i18n{importDescription}</div> - <settings-checkbox - hidden="[[!selected_.history]]" - pref="{{prefs.import_dialog_history}}" - label="$i18n{importHistory}"> - </settings-checkbox> - <settings-checkbox - hidden="[[!selected_.favorites]]" - pref="{{prefs.import_dialog_bookmarks}}" - label="$i18n{importFavorites}"> - </settings-checkbox> - <settings-checkbox - hidden="[[!selected_.passwords]]" - pref="{{prefs.import_dialog_saved_passwords}}" - label="$i18n{importPasswords}"> - </settings-checkbox> - <settings-checkbox - hidden="[[!selected_.search]]" - pref="{{prefs.import_dialog_search_engine}}" - label="$i18n{importSearch}"> - </settings-checkbox> - <settings-checkbox - hidden="[[!selected_.autofillFormData]]" - pref="{{prefs.import_dialog_autofill_form_data}}" - label="$i18n{importAutofillFormData}"> - </settings-checkbox> - </div> - </div> - <div slot="button-container"> - <paper-spinner-lite - active="[[hasImportStatus_( - importStatusEnum_.IN_PROGRESS, importStatus_)]]" - hidden="[[hasImportStatus_( - importStatusEnum_.SUCCEEDED, importStatus_)]]"> - </paper-spinner-lite> - <cr-button id="cancel" class="cancel-button" - hidden="[[hasImportStatus_( - importStatusEnum_.SUCCEEDED, importStatus_)]]" - disabled="[[hasImportStatus_( - importStatusEnum_.IN_PROGRESS, importStatus_)]]" - on-click="closeDialog_"> - $i18n{cancel} - </cr-button> - <cr-button id="import" class="action-button" - hidden="[[hasImportStatus_( - importStatusEnum_.SUCCEEDED, importStatus_)]]" - disabled="[[shouldDisableImport_( - importStatus_, noImportDataTypeSelected_)]]" - on-click="onActionButtonTap_"> - [[getActionButtonText_(selected_)]] - </cr-button> - - <cr-button id="done" class="action-button" - hidden$="[[!hasImportStatus_( - importStatusEnum_.SUCCEEDED, importStatus_)]]" - on-click="closeDialog_">$i18n{done}</cr-button> - </div> - </cr-dialog> - </template> - <script src="import_data_dialog.js"></script> -:</dom-module> diff --git a/chromium/chrome/browser/resources/settings/people_page/import_data_dialog.js b/chromium/chrome/browser/resources/settings/people_page/import_data_dialog.js deleted file mode 100644 index 4192db5cdfb..00000000000 --- a/chromium/chrome/browser/resources/settings/people_page/import_data_dialog.js +++ /dev/null @@ -1,144 +0,0 @@ -// Copyright 2016 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 'settings-import-data-dialog' is a component for importing - * bookmarks and other data from other sources. - */ -Polymer({ - is: 'settings-import-data-dialog', - - behaviors: [I18nBehavior, WebUIListenerBehavior, PrefsBehavior], - - properties: { - /** @private {!Array<!settings.BrowserProfile>} */ - browserProfiles_: Array, - - /** @private {!settings.BrowserProfile} */ - selected_: Object, - - /** - * Whether none of the import data categories is selected. - * @private - */ - noImportDataTypeSelected_: { - type: Boolean, - value: false, - }, - - /** @private */ - importStatus_: { - type: String, - value: settings.ImportDataStatus.INITIAL, - }, - - /** - * Mirroring the enum so that it can be used from HTML bindings. - * @private - */ - importStatusEnum_: { - type: Object, - value: settings.ImportDataStatus, - }, - }, - - observers: [ - 'prefsChanged_(selected_, prefs.*)', - ], - - /** @private {?settings.ImportDataBrowserProxy} */ - browserProxy_: null, - - /** @override */ - attached: function() { - this.browserProxy_ = settings.ImportDataBrowserProxyImpl.getInstance(); - this.browserProxy_.initializeImportDialog().then(data => { - this.browserProfiles_ = data; - this.selected_ = this.browserProfiles_[0]; - - // Show the dialog only after the browser profiles data is populated - // to avoid UI flicker. - this.$.dialog.showModal(); - }); - - this.addWebUIListener('import-data-status-changed', importStatus => { - this.importStatus_ = importStatus; - if (this.hasImportStatus_(settings.ImportDataStatus.FAILED)) { - this.closeDialog_(); - } - }); - }, - - /** @private */ - prefsChanged_: function() { - if (this.selected_ == undefined || this.prefs == undefined) { - return; - } - - this.noImportDataTypeSelected_ = - !(this.getPref('import_dialog_history').value && - this.selected_.history) && - !(this.getPref('import_dialog_bookmarks').value && - this.selected_.favorites) && - !(this.getPref('import_dialog_saved_passwords').value && - this.selected_.passwords) && - !(this.getPref('import_dialog_search_engine').value && - this.selected_.search) && - !(this.getPref('import_dialog_autofill_form_data').value && - this.selected_.autofillFormData); - }, - - /** - * @param {!settings.ImportDataStatus} status - * @return {boolean} Whether |status| is the current status. - * @private - */ - hasImportStatus_: function(status) { - return this.importStatus_ == status; - }, - - /** @private */ - isImportFromFileSelected_: function() { - // The last entry in |browserProfiles_| always refers to dummy profile for - // importing from a bookmarks file. - return this.selected_.index == this.browserProfiles_.length - 1; - }, - - /** - * @return {string} - * @private - */ - getActionButtonText_: function() { - return this.i18n( - this.isImportFromFileSelected_() ? 'importChooseFile' : 'importCommit'); - }, - - /** @private */ - onBrowserProfileSelectionChange_: function() { - this.selected_ = this.browserProfiles_[this.$.browserSelect.selectedIndex]; - }, - - /** @private */ - onActionButtonTap_: function() { - if (this.isImportFromFileSelected_()) { - this.browserProxy_.importFromBookmarksFile(); - } else { - this.browserProxy_.importData(this.$.browserSelect.selectedIndex); - } - }, - - /** @private */ - closeDialog_: function() { - this.$.dialog.close(); - }, - - /** - * @return {boolean} Whether the import button should be disabled. - * @private - */ - shouldDisableImport_: function() { - return this.hasImportStatus_(settings.ImportDataStatus.IN_PROGRESS) || - this.noImportDataTypeSelected_; - }, -}); diff --git a/chromium/chrome/browser/resources/settings/people_page/kerberos_accounts.html b/chromium/chrome/browser/resources/settings/people_page/kerberos_accounts.html deleted file mode 100644 index 66f41e87954..00000000000 --- a/chromium/chrome/browser/resources/settings/people_page/kerberos_accounts.html +++ /dev/null @@ -1,184 +0,0 @@ -<link rel="import" href="chrome://resources/html/polymer.html"> - -<link rel="import" href="chrome://resources/cr_elements/cr_action_menu/cr_action_menu.html"> -<link rel="import" href="chrome://resources/cr_elements/cr_button/cr_button.html"> -<link rel="import" href="chrome://resources/cr_elements/cr_icon_button/cr_icon_button.html"> -<link rel="import" href="chrome://resources/cr_elements/cr_toast/cr_toast.html"> -<link rel="import" href="chrome://resources/cr_elements/policy/cr_policy_indicator.html"> -<link rel="import" href="chrome://resources/html/icon.html"> -<link rel="import" href="chrome://resources/html/util.html"> -<link rel="import" href="chrome://resources/html/web_ui_listener_behavior.html"> -<link rel="import" href="chrome://resources/polymer/v1_0/iron-flex-layout/iron-flex-layout-classes.html"> -<link rel="import" href="../i18n_setup.html"> -<link rel="import" href="../route.html"> -<link rel="import" href="../settings_shared_css.html"> -<link rel="import" href="kerberos_accounts_browser_proxy.html"> -<link rel="import" href="kerberos_add_account_dialog.html"> - -<dom-module id="settings-kerberos-accounts"> - <template> - <style include="settings-shared iron-flex iron-flex-alignment"> - .account-icon { - background: center no-repeat; - border-radius: 20px; - flex-shrink: 0; - height: 40px; - width: 40px; - } - - #outer { - margin-inline-end: var(--cr-section-padding); - margin-inline-start: 60px; - } - - #account-list-header { - padding-bottom: 1em; - } - - .account-toolbar, - #remove-account-policy-indicator { - margin-inline-start: 1em; - } - - #add-account-policy-indicator { - margin-inline-end: 1em; - } - - #add-account-icon { - -webkit-mask-image: url(chrome://resources/images/add.svg); - background-color: currentColor; - height: 24px; - margin-inline-end: 0.5em; - width: 24px; - } - - #remove-account-container { - align-items: center; - display: flex; - } - - .error-badge { - left: 60%; - position: relative; - top: 60%; - } - - .warning { - color: red; - } - - :host-context([dir='rtl']) .error-badge { - left: auto; - right: 60%; - } - </style> - - <div class="settings-box first"> - <h2 class="first"> - <!-- Inner div needed to get spacing right in front of 'Learn more'. --> - <div inner-h-t-m-l="[[i18nAdvanced('kerberosAccountsDescription')]]"> - </div> - </h2> - </div> - - <div class="settings-box first"> - <div id="account-list-header" class="flex"> - <h2>$i18n{kerberosAccountsListHeader}</h2> - </div> - <template is="dom-if" if="[[!addAccountsAllowed_]]"> - <cr-policy-indicator id="add-account-policy-indicator" - indicator-type="userPolicy"> - </cr-policy-indicator> - </template> - <cr-button id="add-account-button" on-click="onAddAccountClick_" - disabled="[[!addAccountsAllowed_]]"> - <div id="add-account-icon"></div> - $i18n{kerberosAccountsAddAccountLabel} - </cr-button> - </div> - - <div id="outer" class="layout vertical nowrap"> - <template is="dom-repeat" id="account-list" items="[[accounts_]]"> - <div class="settings-box account-list-item"> - - <div class="account-icon" - style="background-image: [[getIconImageSet_(item.pic)]]"> - <img class="error-badge" hidden$="[[item.isSignedIn]]" - src="chrome://resources/images/error_badge.svg"> - </div> - - <div class="middle two-line no-min-width"> - <div class="flex text-elide"> - <span>[[item.principalName]]</span> - - <div class="secondary signed-in" hidden$="[[!item.isSignedIn]]"> - [[i18n('kerberosAccountsSignedIn', item.validForDuration)]] - </div> - <div class="secondary warning signed-out" - hidden$="[[item.isSignedIn]]"> - $i18n{kerberosAccountsSignedOut} - </div> - </div> - </div> - - <div class="secondary account-toolbar active-indicator" - hidden$="[[!item.isActive]]"> - $i18n{kerberosAccountsTicketActive} - </div> - - <cr-button class="account-toolbar reauth-button" - hidden$="[[item.isSignedIn]]" - on-click="onReauthenticationClick_"> - $i18n{kerberosAccountsReauthenticationLabel} - </cr-button> - - <template is="dom-if" if="[[item.isManaged]]"> - <cr-policy-indicator indicator-type="userPolicy" - class="account-toolbar account-policy-indicator"> - </cr-policy-indicator> - </template> - - <!-- Hamburger menu --> - <cr-icon-button class="icon-more-vert more-actions" - title="$i18n{moreActions}" - on-click="onAccountActionsMenuButtonClick_"> - </cr-icon-button> - </div> - </template> - - <div class="clear settings-box"></div> - - <cr-action-menu> - <button class="dropdown-item" on-click="onRefreshNowClick_"> - $i18n{kerberosAccountsRefreshNowLabel} - </button> - <button class="dropdown-item" on-click="onSetAsActiveAccountClick_"> - $i18n{kerberosAccountsSetAsActiveAccountLabel} - </button> - <button class="dropdown-item" on-click="onRemoveAccountClick_" - disabled="[[selectedAccount_.isManaged]]"> - <div id="remove-account-container"> - $i18n{kerberosAccountsRemoveAccountLabel} - <template is="dom-if" if="[[selectedAccount_.isManaged]]"> - <cr-policy-indicator id="remove-account-policy-indicator" - indicator-type="userPolicy"> - </cr-policy-indicator> - </template> - </div> - </button> - </cr-action-menu> - </div> - - <cr-toast id="account-toast" duration="3000"> - <!-- Gets displayed with black font without div and id :-/ --> - <div id="account-toast-label">[[accountToastText_]]</div> - </cr-toast> - - <template is="dom-if" if="[[showAddAccountDialog_]]" restamp> - <kerberos-add-account-dialog preset-account="[[selectedAccount_]]" - on-close="onAddAccountDialogClosed_"> - </kerberos-add-account-dialog> - </template> - </template> - <script src="kerberos_accounts.js"></script> -</dom-module>
\ No newline at end of file diff --git a/chromium/chrome/browser/resources/settings/people_page/kerberos_accounts.js b/chromium/chrome/browser/resources/settings/people_page/kerberos_accounts.js deleted file mode 100644 index 4f45f060ed1..00000000000 --- a/chromium/chrome/browser/resources/settings/people_page/kerberos_accounts.js +++ /dev/null @@ -1,201 +0,0 @@ -// 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. - -/** - * @fileoverview - * 'settings-kerberos-accounts' is the settings subpage containing controls to - * list, add and delete Kerberos Accounts. - */ - -'use strict'; - -Polymer({ - is: 'settings-kerberos-accounts', - - behaviors: [ - I18nBehavior, - WebUIListenerBehavior, - ], - - properties: { - /** - * List of Accounts. - * @private {!Array<!settings.KerberosAccount>} - */ - accounts_: { - type: Array, - value: function() { - return []; - }, - }, - - /** - * The targeted account for menu and other operations. - * @private {?settings.KerberosAccount} - */ - selectedAccount_: Object, - - /** @private */ - showAddAccountDialog_: Boolean, - - /** @private */ - addAccountsAllowed_: { - type: Boolean, - value: function() { - return loadTimeData.getBoolean('kerberosAddAccountsAllowed'); - }, - }, - - /** @private */ - accountToastText_: { - type: String, - value: '', - }, - }, - - /** @private {?settings.KerberosAccountsBrowserProxy} */ - browserProxy_: null, - - /** @override */ - attached: function() { - this.addWebUIListener( - 'kerberos-accounts-changed', this.refreshAccounts_.bind(this)); - }, - - /** @override */ - ready: function() { - this.browserProxy_ = - settings.KerberosAccountsBrowserProxyImpl.getInstance(); - - // Grab account list and - when done - pop up the reauthentication dialog if - // there is a kerberos_reauth param. - this.refreshAccounts_().then(() => { - const queryParams = settings.getQueryParameters(); - const reauthPrincipal = queryParams.get('kerberos_reauth'); - const reauthAccount = this.accounts_.find(account => { - return account.principalName == reauthPrincipal; - }); - if (reauthAccount) { - this.selectedAccount_ = reauthAccount; - this.showAddAccountDialog_ = true; - } - }); - }, - - /** - * @param {string} iconUrl - * @return {string} A CSS image-set for multiple scale factors. - * @private - */ - getIconImageSet_: function(iconUrl) { - return cr.icon.getImage(iconUrl); - }, - - /** - * @param {!Event} event - * @private - */ - onAddAccountClick_: function(event) { - this.selectedAccount_ = null; - this.showAddAccountDialog_ = true; - }, - - /** - * @param {!CustomEvent<!{model: !{item: !settings.Account}}>} event - * @private - */ - onReauthenticationClick_: function(event) { - this.selectedAccount_ = event.model.item; - this.showAddAccountDialog_ = true; - }, - - /** @private */ - onAddAccountDialogClosed_: function() { - if (this.$$('kerberos-add-account-dialog').accountWasRefreshed) { - this.showToast_('kerberosAccountsAccountRefreshedTip'); - } - - this.showAddAccountDialog_ = false; - - // In case it was opened by the 'Refresh now' action menu. - this.closeActionMenu_(); - }, - - /** - * @return {!Promise} - * @private - */ - refreshAccounts_: function() { - return this.browserProxy_.getAccounts().then(accounts => { - this.accounts_ = accounts; - }); - }, - - /** - * Opens the Account actions menu. - * @param {!{model: !{item: !settings.KerberosAccount}, target: !Element}} - * event - * @private - */ - onAccountActionsMenuButtonClick_: function(event) { - this.selectedAccount_ = event.model.item; - /** @type {!CrActionMenuElement} */ (this.$$('cr-action-menu')) - .showAt(event.target); - }, - - /** - * Closes action menu and resets action menu model. - * @private - */ - closeActionMenu_: function() { - this.$$('cr-action-menu').close(); - this.selectedAccount_ = null; - }, - - /** - * Removes |this.selectedAccount_|. - * @private - */ - onRemoveAccountClick_: function() { - this.browserProxy_ - .removeAccount( - /** @type {!settings.KerberosAccount} */ (this.selectedAccount_)) - .then(error => { - if (error == settings.KerberosErrorType.kNone) { - this.showToast_('kerberosAccountsAccountRemovedTip'); - } else { - console.error('Unexpected error removing account: ' + error); - } - }); - this.closeActionMenu_(); - }, - - /** - * Sets |this.selectedAccount_| as active Kerberos account. - * @private - */ - onSetAsActiveAccountClick_: function() { - this.browserProxy_.setAsActiveAccount( - /** @type {!settings.KerberosAccount} */ (this.selectedAccount_)); - this.closeActionMenu_(); - }, - - /** - * Opens the reauth dialog for |this.selectedAccount_|. - * @private - */ - onRefreshNowClick_: function() { - this.showAddAccountDialog_ = true; - }, - - /** - * Pops up a toast with localized text |label|. - * @param {string} label Name of the localized label string. - * @private - */ - showToast_: function(label) { - this.accountToastText_ = this.i18n(label); - this.$$('#account-toast').show(); - } -}); diff --git a/chromium/chrome/browser/resources/settings/people_page/kerberos_accounts_browser_proxy.html b/chromium/chrome/browser/resources/settings/people_page/kerberos_accounts_browser_proxy.html deleted file mode 100644 index c74b570b089..00000000000 --- a/chromium/chrome/browser/resources/settings/people_page/kerberos_accounts_browser_proxy.html +++ /dev/null @@ -1,2 +0,0 @@ -<link rel="import" href="chrome://resources/html/cr.html"> -<script src="kerberos_accounts_browser_proxy.js"></script>
\ No newline at end of file diff --git a/chromium/chrome/browser/resources/settings/people_page/kerberos_accounts_browser_proxy.js b/chromium/chrome/browser/resources/settings/people_page/kerberos_accounts_browser_proxy.js deleted file mode 100644 index 89d27cd38aa..00000000000 --- a/chromium/chrome/browser/resources/settings/people_page/kerberos_accounts_browser_proxy.js +++ /dev/null @@ -1,171 +0,0 @@ -// 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. - -/** - * @fileoverview A helper object used from the "Kerberos Accounts" subsection of - * the "People" section of Settings, to interact with the browser. Chrome OS - * only. - */ -cr.exportPath('settings'); - -/** - * Information for a Chrome OS Kerberos account. - * @typedef {{ - * principalName: string, - * config: string, - * isSignedIn: boolean, - * isActive: boolean, - * isManaged: boolean, - * passwordWasRemembered: boolean, - * pic: string, - * validForDuration: string - * }} - */ -settings.KerberosAccount; - -/** - * @typedef {{ - * error: !settings.KerberosErrorType, - * errorInfo: !{ - * code: !settings.KerberosConfigErrorCode, - * lineIndex: (number|undefined) - * } - * }} - */ -settings.ValidateKerberosConfigResult; - -cr.define('settings', function() { - /** - * @enum {number} - * These values must be kept in sync with the ErrorType enum in - * third_party/cros_system_api/dbus/kerberos/kerberos_service.proto. - */ - const KerberosErrorType = { - kNone: 0, - kUnknown: 1, - kDBusFailure: 2, - kNetworkProblem: 3, - kUnknownKrb5Error: 4, - kBadPrincipal: 5, - kBadPassword: 6, - kPasswordExpired: 7, - kPasswordRejected: 8, - kNoCredentialsCacheFound: 9, - kKerberosTicketExpired: 10, - kKdcDoesNotSupportEncryptionType: 11, - kContactingKdcFailed: 12, - kParseRequestFailed: 13, - kLocalIo: 14, - kUnknownPrincipalName: 15, - kDuplicatePrincipalName: 16, - kInProgress: 17, - kParsePrincipalFailed: 18, - kBadConfig: 19, - kJailFailure: 20, - }; - - /** - * @enum {number} - * Error codes for config validation. - * These values must be kept in sync with the KerberosConfigErrorCode enum in - * third_party/cros_system_api/dbus/kerberos/kerberos_service.proto. - */ - const KerberosConfigErrorCode = { - kNone: 0, - kSectionNestedInGroup: 1, - kSectionSyntax: 2, - kExpectedOpeningCurlyBrace: 3, - kExtraCurlyBrace: 4, - kRelationSyntax: 5, - kKeyNotSupported: 6, - kSectionNotSupported: 7, - kKrb5FailedToParse: 8, - }; - - /** @interface */ - class KerberosAccountsBrowserProxy { - /** - * Returns a Promise for the list of Kerberos accounts held in the kerberosd - * system daemon. - * @return {!Promise<!Array<!settings.KerberosAccount>>} - */ - getAccounts() {} - - /** - * Attempts to add a new (or update an existing) Kerberos account. - * @param {string} principalName Kerberos principal (user@realm.com). - * @param {string} password Account password. - * @param {boolean} rememberPassword Whether to store the password. - * @param {string} config Kerberos configuration. - * @param {boolean} allowExisting Whether existing accounts may be updated. - * @return {!Promise<!settings.KerberosErrorType>} - */ - addAccount( - principalName, password, rememberPassword, config, allowExisting) {} - - /** - * Removes |account| from the set of Kerberos accounts. - * @param {!settings.KerberosAccount} account - * @return {!Promise<!settings.KerberosErrorType>} - */ - removeAccount(account) {} - - /** - * Validates |krb5conf| by making sure that it does not contain syntax - * errors or disallowed configuration options. - * @param {string} krb5Conf Kerberos configuration data (krb5.conf) - * @return {!Promise<!settings.ValidateKerberosConfigResult>} - */ - validateConfig(krb5Conf) {} - - /** - * Sets |account| as currently active account. Kerberos credentials are - * consumed from this account. - * @param {!settings.KerberosAccount} account - */ - setAsActiveAccount(account) {} - } - - /** - * @implements {settings.KerberosAccountsBrowserProxy} - */ - class KerberosAccountsBrowserProxyImpl { - /** @override */ - getAccounts() { - return cr.sendWithPromise('getKerberosAccounts'); - } - - /** @override */ - addAccount( - principalName, password, rememberPassword, config, allowExisting) { - return cr.sendWithPromise( - 'addKerberosAccount', principalName, password, rememberPassword, - config, allowExisting); - } - - /** @override */ - removeAccount(account) { - return cr.sendWithPromise('removeKerberosAccount', account.principalName); - } - - /** @override */ - validateConfig(krb5conf) { - return cr.sendWithPromise('validateKerberosConfig', krb5conf); - } - - /** @override */ - setAsActiveAccount(account) { - chrome.send('setAsActiveKerberosAccount', [account.principalName]); - } - } - - cr.addSingletonGetter(KerberosAccountsBrowserProxyImpl); - - return { - KerberosErrorType: KerberosErrorType, - KerberosConfigErrorCode: KerberosConfigErrorCode, - KerberosAccountsBrowserProxy: KerberosAccountsBrowserProxy, - KerberosAccountsBrowserProxyImpl: KerberosAccountsBrowserProxyImpl, - }; -}); diff --git a/chromium/chrome/browser/resources/settings/people_page/kerberos_add_account_dialog.html b/chromium/chrome/browser/resources/settings/people_page/kerberos_add_account_dialog.html deleted file mode 100644 index 45f8f74a85a..00000000000 --- a/chromium/chrome/browser/resources/settings/people_page/kerberos_add_account_dialog.html +++ /dev/null @@ -1,168 +0,0 @@ -<link rel="import" href="chrome://resources/html/polymer.html"> - -<link rel="import" href="chrome://resources/cr_elements/cr_button/cr_button.html"> -<link rel="import" href="chrome://resources/cr_elements/cr_checkbox/cr_checkbox.html"> -<link rel="import" href="chrome://resources/cr_elements/cr_dialog/cr_dialog.html"> -<link rel="import" href="chrome://resources/cr_elements/cr_input/cr_input.html"> -<link rel="import" href="chrome://resources/cr_elements/icons.html"> -<link rel="import" href="chrome://resources/cr_elements/policy/cr_policy_indicator.html"> -<link rel="import" href="chrome://resources/cr_elements/shared_vars_css.html"> -<link rel="import" href="chrome://resources/html/action_link.html"> -<link rel="import" href="chrome://resources/html/i18n_behavior.html"> -<link rel="import" href="chrome://resources/html/load_time_data.html"> -<link rel="import" href="chrome://resources/html/web_ui_listener_behavior.html"> -<link rel="import" href="chrome://resources/polymer/v1_0/iron-icon/iron-icon.html"> -<link rel="import" href="../controls/settings_textarea.html"> -<link rel="import" href="../settings_shared_css.html"> -<link rel="import" href="kerberos_accounts_browser_proxy.html"> - -<dom-module id="kerberos-add-account-dialog"> - <template> - <style include="settings-shared action-link"> - #advancedConfigDesc { - align-items: center; - display: flex; - } - - #advancedConfigPolicyIndicator { - margin-inline-start: 1em; - } - - #credentials { - margin-top: 16px; - } - - #credentials > *:not(:last-child) { - margin-bottom: var(--cr-form-field-bottom-spacing); - } - - #general-error-container { - display: flex; - height: 56px; - } - - #config-error-container { - display: flex; - height: 40px; - margin-top: 16px; - } - - #general-error-message, - #config-error-message { - color: var(--settings-error-color); - } - - iron-icon[icon='cr:error'] { - fill: var(--settings-error-color); - margin-inline-end: 8px; - } - - #rememberPasswordContainer { - align-items: center; - display: flex; - margin-bottom: 32px; - } - - #rememberPassword { - margin-inline-end: 1em; - } - </style> - - <cr-dialog id="addDialog" hidden="[[showAdvancedConfig_]]"> - <div slot="title">[[title_]]</div> - - <div slot="body" spellcheck="false"> - <h2 class="start first"> - $i18n{addKerberosAccountDescription} - </h2> - - <div id="general-error-container" - hidden="[[!showError_(generalErrorText_)]]"> - <iron-icon id="error-icon" icon="cr:error"></iron-icon> - <div id="general-error-message">[[generalErrorText_]]</div> - </div> - - <div id="credentials"> - <cr-input id="username" label="$i18n{kerberosUsername}" - value="{{username_}}" invalid="[[showError_(usernameErrorText_)]]" - placeholder="user@example.com" - error-message="[[usernameErrorText_]]"> - </cr-input> - - <cr-input id="password" type="password" - label="$i18n{kerberosPassword}" value="{{password_}}" - invalid="[[showError_(passwordErrorText_)]]" - error-message="[[passwordErrorText_]]" - on-input="onPasswordInput_"> - </cr-input> - - <div id="rememberPasswordContainer"> - <cr-checkbox id="rememberPassword" checked="{{rememberPassword_}}" - disabled="[[!rememberPasswordEnabled_]]"> - $i18n{addKerberosAccountRememberPassword} - </cr-checkbox> - <template is="dom-if" if="[[!rememberPasswordEnabled_]]"> - <cr-policy-indicator id="rememberPasswordPolicyIndicator" - indicator-type="userPolicy"> - </cr-policy-indicator> - </template> - </div> - - <a is="action-link" id="advancedConfigButton" - on-click="onAdvancedConfigClick_"> - $i18n{kerberosAccountsAdvancedConfigLabel} - </a> - </div> - </div> - - <div slot="button-container"> - <cr-button class="cancel-button" on-click="onCancel_" id="cancel"> - $i18n{cancel} - </cr-button> - <cr-button class="action-button" on-click="onAdd_" - disabled="[[inProgress_]]"> - [[actionButtonLabel_]] - </cr-button> - </div> - </cr-dialog> - - <template is="dom-if" if="[[showAdvancedConfig_]]" restamp> - <cr-dialog id="advancedConfigDialog" on-close="onAdvancedConfigClose_"> - <div slot="title">$i18n{kerberosAdvancedConfigTitle}</div> - - <div slot="body"> - <h2 class="first" id="advancedConfigDesc"> - $i18n{kerberosAdvancedConfigDesc} - <template is="dom-if" if="[[isManaged_]]"> - <cr-policy-indicator id="advancedConfigPolicyIndicator" - indicator-type="userPolicy"> - </cr-policy-indicator> - </template> - </h2> - - <settings-textarea id="config" value="{{editableConfig_}}" rows=12 - spellcheck="false" disabled="[[isManaged_]]"> - </settings-textarea> - - <div id="config-error-container" - hidden="[[!showError_(configErrorText_)]]"> - <iron-icon id="error-icon" icon="cr:error"></iron-icon> - <div id="config-error-message">[[configErrorText_]]</div> - </div> - </div> - - <div slot="button-container"> - <cr-button class="cancel-button" - on-click="onAdvancedConfigCancel_"> - $i18n{cancel} - </cr-button> - <cr-button class="action-button" on-click="onAdvancedConfigSave_" - disabled="[[inProgress_]]"> - $i18n{save} - </cr-button> - </div> - </cr-dialog> - </template> - </template> - <script src="kerberos_add_account_dialog.js"></script> -</dom-module> diff --git a/chromium/chrome/browser/resources/settings/people_page/kerberos_add_account_dialog.js b/chromium/chrome/browser/resources/settings/people_page/kerberos_add_account_dialog.js deleted file mode 100644 index 5bb16f8daf9..00000000000 --- a/chromium/chrome/browser/resources/settings/people_page/kerberos_add_account_dialog.js +++ /dev/null @@ -1,421 +0,0 @@ -// 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. - -/** - * @fileoverview - * 'kerberos-add-account-dialog' is an element to add Kerberos accounts. - */ - -Polymer({ - is: 'kerberos-add-account-dialog', - - behaviors: [I18nBehavior], - - properties: { - /** - * If set, some fields are preset from this account (like username or - * whether to remember the password). - * @type {?settings.KerberosAccount} - */ - presetAccount: Object, - - /** - * Whether an existing |presetAccount| was successfully authenticated. - * Always false if |presetAccount| is null (new accounts). - */ - accountWasRefreshed: { - type: Boolean, - value: false, - }, - - /** @private */ - username_: { - type: String, - value: '', - }, - - /** @private */ - password_: { - type: String, - value: '', - }, - - /** - * Current configuration in the Advanced Config dialog. Propagates to - * |config| only if 'Save' button is pressed. - * @private {string} - */ - editableConfig_: { - type: String, - value: '', - }, - - /** @private */ - rememberPassword_: { - type: Boolean, - value: false, - }, - - /** @private */ - generalErrorText_: { - type: String, - value: '', - }, - - /** @private */ - usernameErrorText_: { - type: String, - value: '', - }, - - /** @private */ - passwordErrorText_: { - type: String, - value: '', - }, - - /** @private */ - configErrorText_: { - type: String, - value: '', - }, - - /** @private */ - inProgress_: { - type: Boolean, - value: false, - }, - - /** @private */ - isManaged_: { - type: Boolean, - value: false, - }, - - /** @private */ - showAdvancedConfig_: { - type: Boolean, - value: false, - }, - - /** @private */ - rememberPasswordEnabled_: { - type: Boolean, - value: function() { - return loadTimeData.getBoolean('kerberosRememberPasswordEnabled'); - }, - }, - }, - - /** @private {boolean} */ - useRememberedPassword_: false, - - /** @private {string} */ - config_: '', - - /** @private {string} */ - title_: '', - - /** @private {string} */ - actionButtonLabel_: '', - - /** @private {?settings.KerberosAccountsBrowserProxy} */ - browserProxy_: null, - - /** @override */ - created: function() { - this.browserProxy_ = - settings.KerberosAccountsBrowserProxyImpl.getInstance(); - }, - - /** @override */ - attached: function() { - this.$.addDialog.showModal(); - - if (this.presetAccount) { - // Refresh an existing account. - this.title_ = this.i18n('refreshKerberosAccount'); - this.actionButtonLabel_ = - this.i18n('addKerberosAccountRefreshButtonLabel'); - - // Preset username and make UI read-only. - // Note: At least the focus() part needs to be after showModal. - this.username_ = this.presetAccount.principalName; - this.isManaged_ = this.presetAccount.isManaged; - this.$.username.readonly = true; - this.$.password.focus(); - - if (this.presetAccount.passwordWasRemembered && - this.rememberPasswordEnabled_) { - // The daemon knows the user's password, so prefill the password field - // with some string (Chrome does not know the actual password for - // security reasons). If the user does not change it, an empty password - // is sent to the daemon, which is interpreted as "use remembered - // password". Also, keep remembering the password by default. - const FAKE_PASSWORD = 'xxxxxxxx'; - this.password_ = FAKE_PASSWORD; - this.rememberPassword_ = true; - this.useRememberedPassword_ = true; - } - - this.config_ = this.presetAccount.config; - } else { - // Add a new Kerberos account. - this.title_ = this.i18n('addKerberosAccount'); - this.actionButtonLabel_ = this.i18n('add'); - - // Set a default configuration. - this.config_ = loadTimeData.getString('defaultKerberosConfig'); - } - }, - - /** @private */ - onCancel_: function() { - this.$.addDialog.cancel(); - }, - - /** @private */ - onAdd_: function() { - assert(!this.inProgress_); - this.inProgress_ = true; - - // Keep the general error, wiping it might cause the error to disappear and - // immediately reappear, causing 2 resizings of the dialog. - this.usernameErrorText_ = ''; - this.passwordErrorText_ = ''; - - // An empty password triggers the Kerberos daemon to use the remembered one. - const passwordToSubmit = this.useRememberedPassword_ ? '' : this.password_; - - // For new accounts (no preset), bail if the account already exists. - const allowExisting = !!this.presetAccount; - - this.browserProxy_ - .addAccount( - this.username_, passwordToSubmit, this.rememberPassword_, - this.config_, allowExisting) - .then(error => { - this.inProgress_ = false; - - // Success case. Close dialog. - if (error == settings.KerberosErrorType.kNone) { - this.accountWasRefreshed = this.presetAccount != null; - this.$.addDialog.close(); - return; - } - - // Triggers the UI to update error messages. - this.updateErrorMessages_(error); - }); - }, - - /** @private */ - onPasswordInput_: function() { - // On first input, don't reuse the remembered password, but submit the - // changed one. - this.useRememberedPassword_ = false; - }, - - /** @private */ - onAdvancedConfigClick_: function() { - // Keep a copy of the config in case the user cancels. - this.editableConfig_ = this.config_; - this.showAdvancedConfig_ = true; - Polymer.dom.flush(); - this.$$('#advancedConfigDialog').showModal(); - }, - - /** @private */ - onAdvancedConfigCancel_: function() { - this.configErrorText_ = ''; - this.showAdvancedConfig_ = false; - this.$$('#advancedConfigDialog').cancel(); - }, - - /** @private */ - onAdvancedConfigSave_: function() { - assert(!this.inProgress_); - this.inProgress_ = true; - - this.browserProxy_.validateConfig(this.editableConfig_).then(result => { - this.inProgress_ = false; - - // Success case. Close dialog. - if (result.error == settings.KerberosErrorType.kNone) { - this.showAdvancedConfig_ = false; - this.config_ = this.editableConfig_; - this.configErrorText_ = ''; - this.$$('#advancedConfigDialog').close(); - return; - } - - // Triggers the UI to update error messages. - this.updateConfigErrorMessage_(result); - }); - }, - - onAdvancedConfigClose_: function(event) { - // Note: 'Esc' doesn't trigger onAdvancedConfigCancel_() and some tests - // that trigger onAdvancedConfigCancel_() don't trigger this for some - // reason, hence this is needed here and above. - this.showAdvancedConfig_ = false; - - // Since this is a sub-dialog, prevent event from bubbling up. Otherwise, - // it might cause the add-dialog to be closed. - event.stopPropagation(); - }, - - /** - * @param {!settings.KerberosErrorType} error Current error enum - * @private - */ - updateErrorMessages_: function(error) { - this.generalErrorText_ = ''; - this.usernameErrorText_ = ''; - this.passwordErrorText_ = ''; - - switch (error) { - case settings.KerberosErrorType.kNone: - break; - - case settings.KerberosErrorType.kNetworkProblem: - this.generalErrorText_ = this.i18n('kerberosErrorNetworkProblem'); - break; - case settings.KerberosErrorType.kParsePrincipalFailed: - this.usernameErrorText_ = this.i18n('kerberosErrorUsernameInvalid'); - break; - case settings.KerberosErrorType.kBadPrincipal: - this.usernameErrorText_ = this.i18n('kerberosErrorUsernameUnknown'); - break; - case settings.KerberosErrorType.kDuplicatePrincipalName: - this.usernameErrorText_ = - this.i18n('kerberosErrorDuplicatePrincipalName'); - break; - case settings.KerberosErrorType.kContactingKdcFailed: - this.usernameErrorText_ = this.i18n('kerberosErrorContactingServer'); - break; - - case settings.KerberosErrorType.kBadPassword: - this.passwordErrorText_ = this.i18n('kerberosErrorPasswordInvalid'); - break; - case settings.KerberosErrorType.kPasswordExpired: - this.passwordErrorText_ = this.i18n('kerberosErrorPasswordExpired'); - break; - - case settings.KerberosErrorType.kKdcDoesNotSupportEncryptionType: - this.generalErrorText_ = this.i18n('kerberosErrorKdcEncType'); - break; - default: - this.generalErrorText_ = - this.i18n('kerberosErrorGeneral', error.toString()); - } - }, - - /** - * @param {!settings.ValidateKerberosConfigResult} result Result from a - * validateKerberosConfig() call. - * @private - */ - updateConfigErrorMessage_: function(result) { - // There should be an error at this point. - assert(result.error != settings.KerberosErrorType.kNone); - - // Only handle kBadConfig here. Display generic error otherwise. Should only - // occur if something is wrong with D-Bus, but nothing user-induced. - if (result.error != settings.KerberosErrorType.kBadConfig) { - this.configErrorText_ = - this.i18n('kerberosErrorGeneral', result.error.toString()); - return; - } - - let errorLine = ''; - - // Don't fall for the classical blunder 0 == false. - if (result.errorInfo.lineIndex != undefined) { - const textArea = this.$$('#config').shadowRoot.querySelector('#input'); - errorLine = this.selectAndScrollTo_(textArea, result.errorInfo.lineIndex); - } - - // If kBadConfig, the error code should be set. - assert(result.errorInfo.code != settings.KerberosConfigErrorCode.kNone); - this.configErrorText_ = - this.getConfigErrorString_(result.errorInfo.code, errorLine); - }, - - /** - * @param {!settings.KerberosConfigErrorCode} code Error code - * @param {string} errorLine Line where the error occurred - * @return {string} Localized error string that corresponds to code - * @private - */ - getConfigErrorString_: function(code, errorLine) { - switch (code) { - case settings.KerberosConfigErrorCode.kSectionNestedInGroup: - return this.i18n('kerberosConfigErrorSectionNestedInGroup', errorLine); - case settings.KerberosConfigErrorCode.kSectionSyntax: - return this.i18n('kerberosConfigErrorSectionSyntax', errorLine); - case settings.KerberosConfigErrorCode.kExpectedOpeningCurlyBrace: - return this.i18n( - 'kerberosConfigErrorExpectedOpeningCurlyBrace', errorLine); - case settings.KerberosConfigErrorCode.kExtraCurlyBrace: - return this.i18n('kerberosConfigErrorExtraCurlyBrace', errorLine); - case settings.KerberosConfigErrorCode.kRelationSyntax: - return this.i18n('kerberosConfigErrorRelationSyntax', errorLine); - case settings.KerberosConfigErrorCode.kKeyNotSupported: - return this.i18n('kerberosConfigErrorKeyNotSupported', errorLine); - case settings.KerberosConfigErrorCode.kSectionNotSupported: - return this.i18n('kerberosConfigErrorSectionNotSupported', errorLine); - case settings.KerberosConfigErrorCode.kKrb5FailedToParse: - // Note: This error doesn't have an error line. - return this.i18n('kerberosConfigErrorKrb5FailedToParse'); - default: - assertNotReached(); - } - }, - - /** - * Selects a line in a text area and scrolls to it. - * @param {!Element} textArea A textarea element - * @param {number} lineIndex 0-based index of the line to select - * @return {string} The line at lineIndex. - * @private - */ - selectAndScrollTo_: function(textArea, lineIndex) { - const lines = textArea.value.split('\n'); - assert(lineIndex >= 0 && lineIndex < lines.length); - - // Compute selection position in characters. - let startPos = 0; - for (let i = 0; i < lineIndex; i++) { - startPos += lines[i].length + 1; - } - - // Ignore starting and trailing whitespace for the selection. - const trimmedLine = lines[lineIndex].trim(); - startPos += lines[lineIndex].indexOf(trimmedLine); - const endPos = startPos + trimmedLine.length; - - // Set selection. - textArea.focus(); - textArea.setSelectionRange(startPos, endPos); - - // Scroll to center the selected line. - const lineHeight = textArea.clientHeight / textArea.rows; - const firstLine = Math.max(0, lineIndex - textArea.rows / 2); - textArea.scrollTop = lineHeight * firstLine; - - return lines[lineIndex]; - }, - - /** - * Whether an error element should be shown. - * Note that !! is not supported in Polymer bindings. - * @param {?string} errorText Error text to be displayed. Empty if no error. - * @return {boolean} True iff errorText is not empty. - * @private - */ - showError_: function(errorText) { - return !!errorText; - } -});
\ No newline at end of file diff --git a/chromium/chrome/browser/resources/settings/people_page/lock_screen.html b/chromium/chrome/browser/resources/settings/people_page/lock_screen.html deleted file mode 100644 index 56fa177dc1d..00000000000 --- a/chromium/chrome/browser/resources/settings/people_page/lock_screen.html +++ /dev/null @@ -1,175 +0,0 @@ -<link rel="import" href="chrome://resources/html/polymer.html"> - -<link rel="import" href="chrome://resources/cr_components/chromeos/quick_unlock/lock_screen_constants.html"> -<link rel="import" href="chrome://resources/cr_elements/cr_button/cr_button.html"> -<link rel="import" href="chrome://resources/cr_elements/cr_radio_button/cr_radio_button.html"> -<link rel="import" href="chrome://resources/cr_elements/cr_radio_group/cr_radio_group.html"> -<link rel="import" href="chrome://resources/cr_elements/shared_vars_css.html"> -<link rel="import" href="chrome://resources/cr_elements/policy/cr_policy_indicator.html"> -<link rel="import" href="chrome://resources/html/assert.html"> -<link rel="import" href="chrome://resources/html/cr/ui/focus_without_ink.html"> -<link rel="import" href="chrome://resources/html/i18n_behavior.html"> -<link rel="import" href="chrome://resources/html/web_ui_listener_behavior.html"> -<link rel="import" href="../controls/settings_toggle_button.html"> -<link rel="import" href="fingerprint_browser_proxy.html"> -<link rel="import" href="lock_state_behavior.html"> -<link rel="import" href="lock_screen_password_prompt_dialog.html"> -<link rel="import" href="setup_pin_dialog.html"> -<link rel="import" href="../i18n_setup.html"> -<link rel="import" href="../prefs/prefs_behavior.html"> -<link rel="import" href="../prefs/prefs.html"> -<link rel="import" href="../route.html"> -<link rel="import" href="../settings_shared_css.html"> -<link rel="import" href="../settings_vars_css.html"> - -<dom-module id="settings-lock-screen"> - <template> - <style include="settings-shared"> - cr-policy-indicator { - margin-inline-start: auto; - /* Align the indicator with the h2 that it is associated with. */ - padding-bottom: 12px; - padding-top: 24px; - } - - #lockOptionsDiv { - display: block; - } - - #pinPasswordDiv { - display: flex; - } - - #pinPasswordLabel { - flex: 1; - } - - #pinPasswordLabel, - #pinPasswordSecondaryActionDiv { - margin: auto; - } - - .underbar { - border-bottom: var(--cr-separator-line); - } - - #unlockType[disabled] { - opacity: var(--settings-disabled-opacity); - pointer-events: none; - } - </style> - - <div> - <settings-toggle-button id="enableLockScreen" class="first" - pref="{{prefs.settings.enable_screen_lock}}" - on-settings-boolean-control-change="onScreenLockChange_" no-set-pref - label="$i18n{enableScreenlock}"> - </settings-toggle-button> - - <template is="dom-if" if="[[quickUnlockEnabled_]]"> - <div id="lockOptionsDiv"> - <div class="settings-box"> - <h2>[[selectLockScreenOptionsString(hasPinLogin)]]</h2> - <template is="dom-if" if="[[quickUnlockDisabledByPolicy_]]"> - <cr-policy-indicator indicator-type="userPolicy"> - </cr-policy-indicator> - </template> - </div> - <div class="list-frame" > - <cr-radio-group id="unlockType" - disabled$="[[quickUnlockDisabledByPolicy_]]" - selected="{{selectedUnlockType}}"> - <cr-radio-button name="password" class="list-item underbar"> - <div class="start"> - $i18n{lockScreenPasswordOnly} - </div> - </cr-radio-button> - <cr-radio-button name="pin+password" class="list-item"> - <div id="pinPasswordDiv"> - <div id="pinPasswordLabel"> - $i18n{lockScreenPinOrPassword} - </div> - <template is="dom-if" - if="[[showConfigurePinButton_(selectedUnlockType)]]"> - <div class="separator"></div> - <div id="pinPasswordSecondaryActionDiv" - class="secondary-action"> - <!-- Use stop-keyboard-event-propagation to prevent - triggering this when focused after closing the - dialog. --> - <cr-button id="setupPinButton" on-click="onConfigurePin_" - stop-keyboard-event-propagation> - [[getSetupPinText_(hasPin)]] - </cr-button> - </div> - </template> - </div> - </cr-radio-button> - </cr-radio-group> - </div> - </div> - </template> - - <template is="dom-if" if="[[lockScreenNotificationsEnabled_]]"> - <h2 class="settings-box"> - $i18n{lockScreenNotificationTitle} - </h2> - <div class="list-frame"> - <settings-radio-group - pref="{{prefs.ash.message_center.lock_screen_mode}}"> - <template is="dom-if" - if="[[lockScreenHideSensitiveNotificationSupported_]]"> - <cr-radio-button name="hideSensitive" class="list-item underbar" - pref="[[prefs.ash.message_center.lock_screen_mode]]" - label="$i18n{lockScreenNotificationHideSensitive}"> - </cr-radio-button> - </template> - <cr-radio-button name="show" class="list-item underbar" - pref="[[prefs.ash.message_center.lock_screen_mode]]" - label="$i18n{lockScreenNotificationShow}"> - </cr-radio-button> - <cr-radio-button name="hide" class="list-item" - pref="[[prefs.ash.message_center.lock_screen_mode]]" - label="$i18n{lockScreenNotificationHide}"> - </cr-radio-button> - </settings-radio-group> - </div> - </template> - - <template is="dom-if" if="[[fingerprintUnlockEnabled_]]"> - <div id="fingerprintDiv" class="settings-box two-line"> - <div class="start"> - $i18n{lockScreenEditFingerprints} - <div class="secondary" id="lockScreenEditFingerprintsSecondary"> - [[getDescriptionText_(numFingerprints_)]] - </div> - </div> - <div class="separator"></div> - <div class="secondary-action"> - <cr-button on-click="onEditFingerprints_" - aria-label="$i18n{lockScreenEditFingerprints}" - aria-descibedby="lockScreenEditFingerprintsSecondary"> - $i18n{lockScreenSetupFingerprintButton} - </cr-button> - </div> - </div> - </template> - - <template is="dom-if" if="[[showPasswordPromptDialog_]]" restamp> - <settings-lock-screen-password-prompt-dialog - id="lockScreenPasswordPrompt" - on-close="onPasswordPromptDialogClose_" set-modes="{{setModes_}}" - auth-token="{{authToken}}"> - </settings-lock-screen-password-prompt-dialog> - </template> - - <template is="dom-if" if="[[showSetupPinDialog_]]" restamp> - <settings-setup-pin-dialog id="setupPin" set-modes="[[setModes_]]" - on-close="onSetupPinDialogClose_"> - </settings-setup-pin-dialog> - </template> - </div> - </template> - - <script src="lock_screen.js"></script> -</dom-module> diff --git a/chromium/chrome/browser/resources/settings/people_page/lock_screen.js b/chromium/chrome/browser/resources/settings/people_page/lock_screen.js deleted file mode 100644 index f0584fee7e4..00000000000 --- a/chromium/chrome/browser/resources/settings/people_page/lock_screen.js +++ /dev/null @@ -1,322 +0,0 @@ -// Copyright 2016 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 - * 'settings-lock-screen' allows the user to change how they unlock their - * device. - * - * Example: - * - * <settings-lock-screen - * prefs="{{prefs}}"> - * </settings-lock-screen> - */ - -Polymer({ - is: 'settings-lock-screen', - - behaviors: [ - I18nBehavior, - LockStateBehavior, - WebUIListenerBehavior, - settings.RouteObserverBehavior, - ], - - properties: { - /** Preferences state. */ - prefs: {type: Object}, - - /** - * setModes_ is a partially applied function that stores the current auth - * token. It's defined only when the user has entered a valid password. - * @type {Object|undefined} - * @private - */ - setModes_: { - type: Object, - observer: 'onSetModesChanged_', - }, - - /** - * Authentication token provided by lock-screen-password-prompt-dialog. - */ - authToken: { - type: String, - value: '', - notify: true, - }, - - /** - * writeUma_ is a function that handles writing uma stats. It may be - * overridden for tests. - * - * @type {Function} - * @private - */ - writeUma_: { - type: Object, - value: function() { - return settings.recordLockScreenProgress; - }, - }, - - /** - * True if quick unlock settings should be displayed on this machine. - * @private - */ - quickUnlockEnabled_: { - type: Boolean, - value: function() { - return loadTimeData.getBoolean('quickUnlockEnabled'); - }, - readOnly: true, - }, - - /** - * True if quick unlock settings are disabled by policy. - * @private - */ - quickUnlockDisabledByPolicy_: { - type: Boolean, - value: function() { - return loadTimeData.getBoolean('quickUnlockDisabledByPolicy'); - }, - readOnly: true, - }, - - /** - * True if fingerprint unlock settings should be displayed on this machine. - * @private - */ - fingerprintUnlockEnabled_: { - type: Boolean, - value: function() { - return loadTimeData.getBoolean('fingerprintUnlockEnabled'); - }, - readOnly: true, - }, - - /** @private */ - numFingerprints_: { - type: Number, - value: 0, - }, - - /** - * Whether notifications on the lock screen are enable by the feature flag. - * @private - */ - lockScreenNotificationsEnabled_: { - type: Boolean, - value: function() { - return loadTimeData.getBoolean('lockScreenNotificationsEnabled'); - }, - readOnly: true, - }, - - /** - * Whether the "hide sensitive notification" option on the lock screen can - * be enable by the feature flag. - * @private - */ - lockScreenHideSensitiveNotificationSupported_: { - type: Boolean, - value: function() { - return loadTimeData.getBoolean( - 'lockScreenHideSensitiveNotificationsSupported'); - }, - readOnly: true, - }, - - /** @private */ - showPasswordPromptDialog_: Boolean, - - /** @private */ - showSetupPinDialog_: Boolean, - }, - - /** @private {?settings.FingerprintBrowserProxy} */ - fingerprintBrowserProxy_: null, - - /** selectedUnlockType is defined in LockStateBehavior. */ - observers: ['selectedUnlockTypeChanged_(selectedUnlockType)'], - - /** @override */ - attached: function() { - if (this.shouldAskForPassword_(settings.getCurrentRoute())) { - this.openPasswordPromptDialog_(); - } - - this.fingerprintBrowserProxy_ = - settings.FingerprintBrowserProxyImpl.getInstance(); - this.updateNumFingerprints_(); - }, - - /** - * Overridden from settings.RouteObserverBehavior. - * @param {!settings.Route} newRoute - * @param {!settings.Route} oldRoute - * @protected - */ - currentRouteChanged: function(newRoute, oldRoute) { - if (newRoute == settings.routes.LOCK_SCREEN) { - this.updateUnlockType(); - this.updateNumFingerprints_(); - } - - if (this.shouldAskForPassword_(newRoute)) { - this.openPasswordPromptDialog_(); - } else if ( - newRoute != settings.routes.FINGERPRINT && - oldRoute != settings.routes.FINGERPRINT) { - // If the user navigated away from the lock screen settings page they will - // have to re-enter their password. An exception is if they are navigating - // to or from the fingerprint subpage. - this.setModes_ = undefined; - } - }, - - /** - * @param {!Event} event - * @private - */ - onScreenLockChange_: function(event) { - const target = /** @type {!SettingsToggleButtonElement} */ (event.target); - if (!this.authToken) { - console.error('Screen lock changed with expired token.'); - target.checked = !target.checked; - return; - } - this.setLockScreenEnabled(this.authToken, target.checked); - }, - - /** - * Called when the unlock type has changed. - * @param {!string} selected The current unlock type. - * @private - */ - selectedUnlockTypeChanged_: function(selected) { - if (selected == LockScreenUnlockType.VALUE_PENDING) { - return; - } - - if (selected != LockScreenUnlockType.PIN_PASSWORD && this.setModes_) { - this.setModes_.call(null, [], [], function(result) { - assert(result, 'Failed to clear quick unlock modes'); - if (!result) { - console.error('Failed to clear quick unlock modes'); - } - }); - } - }, - - /** @private */ - onSetModesChanged_: function() { - if (this.shouldAskForPassword_(settings.getCurrentRoute())) { - this.showSetupPinDialog_ = false; - this.openPasswordPromptDialog_(); - } - }, - - /** @private */ - openPasswordPromptDialog_: function() { - this.showPasswordPromptDialog_ = true; - }, - - /** @private */ - onPasswordPromptDialogClose_: function() { - this.showPasswordPromptDialog_ = false; - if (!this.setModes_) { - settings.navigateToPreviousRoute(); - } else if (!this.$$('#unlockType').disabled) { - cr.ui.focusWithoutInk(assert(this.$$('#unlockType'))); - } else { - cr.ui.focusWithoutInk(assert(this.$$('#enableLockScreen'))); - } - }, - - /** - * @param {!Event} e - * @private - */ - onConfigurePin_: function(e) { - e.preventDefault(); - this.writeUma_(LockScreenProgress.CHOOSE_PIN_OR_PASSWORD); - this.showSetupPinDialog_ = true; - }, - - /** @private */ - onSetupPinDialogClose_: function() { - this.showSetupPinDialog_ = false; - cr.ui.focusWithoutInk(assert(this.$$('#setupPinButton'))); - }, - - /** - * Returns true if the setup pin section should be shown. - * @param {!string} selectedUnlockType The current unlock type. Used to let - * Polymer know about the dependency. - * @private - */ - showConfigurePinButton_: function(selectedUnlockType) { - return selectedUnlockType === LockScreenUnlockType.PIN_PASSWORD; - }, - - /** - * @param {boolean} hasPin - * @private - */ - getSetupPinText_: function(hasPin) { - if (hasPin) { - return this.i18n('lockScreenChangePinButton'); - } - return this.i18n('lockScreenSetupPinButton'); - }, - - /** @private */ - getDescriptionText_: function() { - if (this.numFingerprints_ > 0) { - return this.i18n( - 'lockScreenNumberFingerprints', this.numFingerprints_.toString()); - } - - return this.i18n('lockScreenEditFingerprintsDescription'); - }, - - /** @private */ - onEditFingerprints_: function() { - settings.navigateTo(settings.routes.FINGERPRINT); - }, - - /** - * @param {!settings.Route} route - * @return {boolean} Whether the password dialog should be shown. - * @private - */ - shouldAskForPassword_: function(route) { - return route == settings.routes.LOCK_SCREEN && !this.setModes_; - }, - - /** @private */ - updateNumFingerprints_: function() { - if (this.fingerprintUnlockEnabled_ && this.fingerprintBrowserProxy_) { - this.fingerprintBrowserProxy_.getNumFingerprints().then( - numFingerprints => { - this.numFingerprints_ = numFingerprints; - }); - } - }, - - /** - * Looks up the translation id, which depends on PIN login support. - * @param {boolean} hasPinLogin - * @private - */ - selectLockScreenOptionsString(hasPinLogin) { - if (hasPinLogin) { - return this.i18n('lockScreenOptionsLoginLock'); - } - return this.i18n('lockScreenOptionsLock'); - }, -}); diff --git a/chromium/chrome/browser/resources/settings/people_page/lock_screen_password_prompt_dialog.html b/chromium/chrome/browser/resources/settings/people_page/lock_screen_password_prompt_dialog.html deleted file mode 100644 index 086183af7b5..00000000000 --- a/chromium/chrome/browser/resources/settings/people_page/lock_screen_password_prompt_dialog.html +++ /dev/null @@ -1,16 +0,0 @@ -<link rel="import" href="chrome://resources/html/polymer.html"> - -<link rel="import" href="chrome://resources/cr_components/chromeos/quick_unlock/lock_screen_constants.html"> -<link rel="import" href="../controls/password_prompt_dialog.html"> -<link rel="import" href="lock_state_behavior.html"> - -<dom-module id="settings-lock-screen-password-prompt-dialog"> - <template> - <settings-password-prompt-dialog - id="passwordPrompt" - password-prompt-text="[[selectPasswordPromptEnterPasswordString_(hasPinLogin)]]" - auth-token="{{authToken}}"> - </settings-password-prompt-dialog> - </template> - <script src="lock_screen_password_prompt_dialog.js"></script> -</dom-module> diff --git a/chromium/chrome/browser/resources/settings/people_page/lock_screen_password_prompt_dialog.js b/chromium/chrome/browser/resources/settings/people_page/lock_screen_password_prompt_dialog.js deleted file mode 100644 index 0da0789b4b4..00000000000 --- a/chromium/chrome/browser/resources/settings/people_page/lock_screen_password_prompt_dialog.js +++ /dev/null @@ -1,120 +0,0 @@ -// Copyright 2016 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 - * - * 'settings-lock-screen-password-prompt-dialog' displays a password prompt to - * the user. Clients can determine if the user has authenticated if either the - * |authToken| string or |setModes| closure are present. - * - * The setModes binding is a wrapper around chrome.quickUnlockPrivate.setModes - * which has a prebound account password. The account password by itself is not - * available for other elements to access. - * - * Example: - * - * <settings-lock-screen-password-prompt-dialog - * id="lockScreenPasswordPrompt" - * set-modes="[[setModes]]"> - * </settings-lock-screen-password-prompt-dialog> - */ - -(function() { -'use strict'; - -Polymer({ - is: 'settings-lock-screen-password-prompt-dialog', - - behaviors: [ - LockStateBehavior, - ], - - properties: { - /** - * Authentication token returned by quickUnlockPrivate.getAuthToken. Should - * be passed to API calls which require authentication. - * @type {string} - */ - authToken: { - type: String, - notify: true, - observer: 'authTokenChanged_', - }, - - /** - * A wrapper around chrome.quickUnlockPrivate.setModes with the account - * password already supplied. If this is null, the authentication screen - * needs to be redisplayed. This property will be cleared after the timeout - * returned by quickUnlockPrivate.getAuthToken. - * @type {?Function} - */ - setModes: { - type: Object, - notify: true, - }, - - /** - * writeUma_ is a function that handles writing uma stats. It may be - * overridden for tests. - * - * @type {Function} - * @private - */ - writeUma_: { - type: Object, - value: function() { - return settings.recordLockScreenProgress; - } - }, - }, - - /** @override */ - attached: function() { - this.writeUma_(LockScreenProgress.START_SCREEN_LOCK); - }, - - /** - * Called when the authToken changes. If the authToken is valid, that - * indicates the user authenticated successfully. - * @param {String} authToken - * @private - */ - authTokenChanged_: function(authToken) { - if (!this.authToken) { - this.setModes = null; - return; - } - - // The user successfully authenticated. - this.writeUma_(LockScreenProgress.ENTER_PASSWORD_CORRECTLY); - - this.setModes = (modes, credentials, onComplete) => { - this.quickUnlockPrivate.setModes( - this.authToken, modes, credentials, () => { - let result = true; - if (chrome.runtime.lastError) { - console.error( - 'setModes failed: ' + chrome.runtime.lastError.message); - result = false; - } - onComplete(result); - }); - }; - }, - - /** - * Looks up the translation id, which depends on PIN login support. - * @param {boolean} hasPinLogin - * @return {string} - * @private - */ - selectPasswordPromptEnterPasswordString_: function(hasPinLogin) { - if (hasPinLogin) { - return this.i18n('passwordPromptEnterPasswordLoginLock'); - } - return this.i18n('passwordPromptEnterPasswordLock'); - }, -}); -})(); diff --git a/chromium/chrome/browser/resources/settings/people_page/lock_state_behavior.html b/chromium/chrome/browser/resources/settings/people_page/lock_state_behavior.html deleted file mode 100644 index 52dd5119bd0..00000000000 --- a/chromium/chrome/browser/resources/settings/people_page/lock_state_behavior.html +++ /dev/null @@ -1,7 +0,0 @@ -<link rel="import" href="chrome://resources/html/polymer.html"> - -<link rel="import" href="chrome://resources/html/i18n_behavior.html"> -<link rel="import" href="chrome://resources/html/web_ui_listener_behavior.html"> -<link rel="import" href="../i18n_setup.html"> - -<script src="lock_state_behavior.js"></script> diff --git a/chromium/chrome/browser/resources/settings/people_page/lock_state_behavior.js b/chromium/chrome/browser/resources/settings/people_page/lock_state_behavior.js deleted file mode 100644 index 8ef0b549f2f..00000000000 --- a/chromium/chrome/browser/resources/settings/people_page/lock_state_behavior.js +++ /dev/null @@ -1,123 +0,0 @@ -// Copyright 2016 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 - * Contains utilities that help identify the current way that the lock screen - * will be displayed. - */ - -/** @enum {string} */ -const LockScreenUnlockType = { - VALUE_PENDING: 'value_pending', - PASSWORD: 'password', - PIN_PASSWORD: 'pin+password' -}; - -/** - * Determining if the device supports PIN sign-in takes time, as it may require - * a cryptohome call. This means incorrect strings may be shown for a brief - * period, and updating them causes UI flicker. - * - * Cache the value since the behavior is instantiated multiple times. Caching - * is safe because PIN login support depends only on hardware capabilities. The - * value does not change after discovered. - * - * @type {boolean|undefined} - */ -let cachedHasPinLogin = undefined; - -/** @polymerBehavior */ -const LockStateBehaviorImpl = { - properties: { - /** - * The currently selected unlock type. - * @type {!LockScreenUnlockType} - */ - selectedUnlockType: - {type: String, notify: true, value: LockScreenUnlockType.VALUE_PENDING}, - - /** - * True/false if there is a PIN set; undefined if the computation is still - * pending. This is a separate value from selectedUnlockType because the UI - * can change the selectedUnlockType before setting up a PIN. - * @type {boolean|undefined} - */ - hasPin: {type: Boolean, notify: true}, - - /** - * True if the PIN backend supports signin. undefined iff the value is still - * resolving. - * @type {boolean|undefined} - */ - hasPinLogin: {type: Boolean, notify: true}, - - /** - * Interface for chrome.quickUnlockPrivate calls. May be overridden by - * tests. - * @type {QuickUnlockPrivate} - */ - quickUnlockPrivate: {type: Object, value: chrome.quickUnlockPrivate}, - }, - - /** @override */ - attached: function() { - this.boundOnActiveModesChanged_ = this.updateUnlockType.bind(this); - this.quickUnlockPrivate.onActiveModesChanged.addListener( - this.boundOnActiveModesChanged_); - - // See comment on |cachedHasPinLogin| declaration. - if (cachedHasPinLogin === undefined) { - this.addWebUIListener( - 'pin-login-available-changed', - this.handlePinLoginAvailableChanged_.bind(this)); - chrome.send('RequestPinLoginState'); - } else { - this.hasPinLogin = cachedHasPinLogin; - } - - this.updateUnlockType(); - }, - - /** @override */ - detached: function() { - this.quickUnlockPrivate.onActiveModesChanged.removeListener( - this.boundOnActiveModesChanged_); - }, - - /** - * Updates the selected unlock type radio group. This function will get called - * after preferences are initialized, after the quick unlock mode has been - * changed, and after the lockscreen preference has changed. - */ - updateUnlockType: function() { - this.quickUnlockPrivate.getActiveModes(modes => { - if (modes.includes(chrome.quickUnlockPrivate.QuickUnlockMode.PIN)) { - this.hasPin = true; - this.selectedUnlockType = LockScreenUnlockType.PIN_PASSWORD; - } else { - this.hasPin = false; - this.selectedUnlockType = LockScreenUnlockType.PASSWORD; - } - }); - }, - - /** Sets the lock screen enabled state. */ - setLockScreenEnabled(authToken, enabled) { - this.quickUnlockPrivate.setLockScreenEnabled(authToken, enabled); - }, - - /** - * Handler for when the pin login available state has been updated. - * @private - */ - handlePinLoginAvailableChanged_: function(isAvailable) { - this.hasPinLogin = isAvailable; - cachedHasPinLogin = this.hasPinLogin; - }, -}; - -/** @polymerBehavior */ -const LockStateBehavior = - [I18nBehavior, WebUIListenerBehavior, LockStateBehaviorImpl];
\ No newline at end of file diff --git a/chromium/chrome/browser/resources/settings/people_page/manage_profile.html b/chromium/chrome/browser/resources/settings/people_page/manage_profile.html deleted file mode 100644 index c2f444c6013..00000000000 --- a/chromium/chrome/browser/resources/settings/people_page/manage_profile.html +++ /dev/null @@ -1,46 +0,0 @@ -<link rel="import" href="chrome://resources/html/polymer.html"> - -<link rel="import" href="chrome://resources/cr_elements/cr_input/cr_input.html"> -<link rel="import" href="chrome://resources/cr_elements/cr_profile_avatar_selector/cr_profile_avatar_selector.html"> -<link rel="import" href="chrome://resources/cr_elements/cr_toggle/cr_toggle.html"> -<link rel="import" href="chrome://resources/html/web_ui_listener_behavior.html"> -<link rel="import" href="chrome://resources/polymer/v1_0/paper-styles/shadow.html"> -<link rel="import" href="../i18n_setup.html"> -<link rel="import" href="manage_profile_browser_proxy.html"> -<link rel="import" href="../route.html"> -<link rel="import" href="../settings_shared_css.html"> - -<dom-module id="settings-manage-profile"> - <template> - <style include="settings-shared"> - cr-input { - --cr-input-error-display: none; - } - - #selector { - margin: 16px 48px; - } - </style> - <div class="settings-box first"> - <cr-input id="name" value="[[profileName]]" pattern=".*\S.*" - on-change="onProfileNameChanged_" on-keydown="onProfileNameKeydown_" - disabled="[[isProfileNameDisabled_(syncStatus)]]" maxlength="500" - auto-validate required spellcheck="false"> - </cr-input> - </div> - <template is="dom-if" if="[[isProfileShortcutSettingVisible_]]"> - <div class="settings-box first"> - <div id="showShortcutLabel" class="start">$i18n{showShortcutLabel}</div> - <cr-toggle id="hasShortcutToggle" - checked="{{hasProfileShortcut_}}" - on-change="onHasProfileShortcutChange_" - aria-labelledby="showShortcutLabel"> - </cr-toggle> - </div> - </template> - <cr-profile-avatar-selector id="selector" avatars="[[availableIcons]]" - selected-avatar="{{profileAvatar_}}" ignore-modified-key-events> - </cr-profile-avatar-selector> - </template> - <script src="manage_profile.js"></script> -</dom-module> diff --git a/chromium/chrome/browser/resources/settings/people_page/manage_profile.js b/chromium/chrome/browser/resources/settings/people_page/manage_profile.js deleted file mode 100644 index 0f45b9044cf..00000000000 --- a/chromium/chrome/browser/resources/settings/people_page/manage_profile.js +++ /dev/null @@ -1,157 +0,0 @@ -// Copyright 2015 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 - * 'settings-manage-profile' is the settings subpage containing controls to - * edit a profile's name, icon, and desktop shortcut. - */ -Polymer({ - is: 'settings-manage-profile', - - behaviors: [WebUIListenerBehavior, settings.RouteObserverBehavior], - - properties: { - /** - * The newly selected avatar. Populated only if the user manually changes - * the avatar selection. The observer ensures that the changes are - * propagated to the C++. - * @private - */ - profileAvatar_: { - type: Object, - observer: 'profileAvatarChanged_', - }, - - /** - * The current profile name. - */ - profileName: String, - - /** - * True if the current profile has a shortcut. - */ - hasProfileShortcut_: Boolean, - - /** - * The available icons for selection. - * @type {!Array<!AvatarIcon>} - */ - availableIcons: { - type: Array, - value: function() { - return []; - }, - }, - - /** - * The current sync status. - * @type {?settings.SyncStatus} - */ - syncStatus: Object, - - /** - * True if the profile shortcuts feature is enabled. - */ - isProfileShortcutSettingVisible_: Boolean, - }, - - /** @private {?settings.ManageProfileBrowserProxy} */ - browserProxy_: null, - - /** @override */ - created: function() { - this.browserProxy_ = settings.ManageProfileBrowserProxyImpl.getInstance(); - }, - - /** @override */ - attached: function() { - const setIcons = icons => { - this.availableIcons = icons; - }; - - this.addWebUIListener('available-icons-changed', setIcons); - this.browserProxy_.getAvailableIcons().then(setIcons); - }, - - /** @protected */ - currentRouteChanged: function() { - if (settings.getCurrentRoute() == settings.routes.MANAGE_PROFILE) { - if (this.profileName) { - this.$.name.value = this.profileName; - } - if (loadTimeData.getBoolean('profileShortcutsEnabled')) { - this.browserProxy_.getProfileShortcutStatus().then(status => { - if (status == ProfileShortcutStatus.PROFILE_SHORTCUT_SETTING_HIDDEN) { - this.isProfileShortcutSettingVisible_ = false; - return; - } - - this.isProfileShortcutSettingVisible_ = true; - this.hasProfileShortcut_ = - status == ProfileShortcutStatus.PROFILE_SHORTCUT_FOUND; - }); - } - } - }, - - /** - * Handler for when the profile name field is changed, then blurred. - * @param {!Event} event - * @private - */ - onProfileNameChanged_: function(event) { - if (event.target.invalid) { - return; - } - - this.browserProxy_.setProfileName(event.target.value); - }, - - /** - * Handler for profile name keydowns. - * @param {!Event} event - * @private - */ - onProfileNameKeydown_: function(event) { - if (event.key == 'Escape') { - event.target.value = this.profileName; - event.target.blur(); - } - }, - - /** - * Handler for when the profile avatar is changed by the user. - * @private - */ - profileAvatarChanged_: function() { - if (this.profileAvatar_.isGaiaAvatar) { - this.browserProxy_.setProfileIconToGaiaAvatar(); - } else { - this.browserProxy_.setProfileIconToDefaultAvatar(this.profileAvatar_.url); - } - }, - - /** - * @param {?settings.SyncStatus} syncStatus - * @return {boolean} Whether the profile name field is disabled. - * @private - */ - isProfileNameDisabled_: function(syncStatus) { - return !!syncStatus.supervisedUser && !syncStatus.childUser; - }, - - /** - * Handler for when the profile shortcut toggle is changed. - * @param {!Event} event - * @private - */ - onHasProfileShortcutChange_: function(event) { - if (this.hasProfileShortcut_) { - this.browserProxy_.addProfileShortcut(); - } else { - this.browserProxy_.removeProfileShortcut(); - } - } -}); diff --git a/chromium/chrome/browser/resources/settings/people_page/manage_profile_browser_proxy.html b/chromium/chrome/browser/resources/settings/people_page/manage_profile_browser_proxy.html deleted file mode 100644 index 6e30760f0cd..00000000000 --- a/chromium/chrome/browser/resources/settings/people_page/manage_profile_browser_proxy.html +++ /dev/null @@ -1,2 +0,0 @@ -<link rel="import" href="chrome://resources/html/cr.html"> -<script src="manage_profile_browser_proxy.js"></script> diff --git a/chromium/chrome/browser/resources/settings/people_page/manage_profile_browser_proxy.js b/chromium/chrome/browser/resources/settings/people_page/manage_profile_browser_proxy.js deleted file mode 100644 index 4acf227e676..00000000000 --- a/chromium/chrome/browser/resources/settings/people_page/manage_profile_browser_proxy.js +++ /dev/null @@ -1,112 +0,0 @@ -// Copyright 2016 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 from the "Manage Profile" subpage of - * the People section to interact with the browser. Chrome Browser only. - */ - -/** - * Contains the possible profile shortcut statuses. These strings must be kept - * in sync with the C++ Manage Profile handler. - * @enum {string} - */ -const ProfileShortcutStatus = { - PROFILE_SHORTCUT_SETTING_HIDDEN: 'profileShortcutSettingHidden', - PROFILE_SHORTCUT_NOT_FOUND: 'profileShortcutNotFound', - PROFILE_SHORTCUT_FOUND: 'profileShortcutFound', -}; - -cr.define('settings', function() { - /** @interface */ - class ManageProfileBrowserProxy { - /** - * Gets the available profile icons to choose from. - * @return {!Promise<!Array<!AvatarIcon>>} - */ - getAvailableIcons() {} - - /** - * Sets the profile's icon to the GAIA avatar. - */ - setProfileIconToGaiaAvatar() {} - - /** - * Sets the profile's icon to one of the default avatars. - * @param {string} iconUrl The new profile URL. - */ - setProfileIconToDefaultAvatar(iconUrl) {} - - /** - * Sets the profile's name. - * @param {string} name The new profile name. - */ - setProfileName(name) {} - - /** - * Returns whether the current profile has a shortcut. - * @return {!Promise<ProfileShortcutStatus>} - */ - getProfileShortcutStatus() {} - - /** - * Adds a shortcut for the current profile. - */ - addProfileShortcut() {} - - /** - * Removes the shortcut of the current profile. - */ - removeProfileShortcut() {} - } - - /** - * @implements {settings.ManageProfileBrowserProxy} - */ - class ManageProfileBrowserProxyImpl { - /** @override */ - getAvailableIcons() { - return cr.sendWithPromise('getAvailableIcons'); - } - - /** @override */ - setProfileIconToGaiaAvatar() { - chrome.send('setProfileIconToGaiaAvatar'); - } - - /** @override */ - setProfileIconToDefaultAvatar(iconUrl) { - chrome.send('setProfileIconToDefaultAvatar', [iconUrl]); - } - - /** @override */ - setProfileName(name) { - chrome.send('setProfileName', [name]); - } - - /** @override */ - getProfileShortcutStatus() { - return cr.sendWithPromise('requestProfileShortcutStatus'); - } - - /** @override */ - addProfileShortcut() { - chrome.send('addProfileShortcut'); - } - - /** @override */ - removeProfileShortcut() { - chrome.send('removeProfileShortcut'); - } - } - - // The singleton instance_ is replaced with a test version of this wrapper - // during testing. - cr.addSingletonGetter(ManageProfileBrowserProxyImpl); - - return { - ManageProfileBrowserProxy: ManageProfileBrowserProxy, - ManageProfileBrowserProxyImpl: ManageProfileBrowserProxyImpl, - }; -}); diff --git a/chromium/chrome/browser/resources/settings/people_page/people_page.html b/chromium/chrome/browser/resources/settings/people_page/people_page.html deleted file mode 100644 index d6891e8da93..00000000000 --- a/chromium/chrome/browser/resources/settings/people_page/people_page.html +++ /dev/null @@ -1,428 +0,0 @@ -<link rel="import" href="chrome://resources/html/polymer.html"> - -<link rel="import" href="chrome://resources/cr_elements/cr_button/cr_button.html"> -<link rel="import" href="chrome://resources/cr_elements/cr_icon_button/cr_icon_button.html"> -<link rel="import" href="chrome://resources/cr_elements/cr_link_row/cr_link_row.html"> -<link rel="import" href="chrome://resources/cr_elements/icons.html"> -<link rel="import" href="chrome://resources/cr_elements/policy/cr_policy_indicator.html"> -<link rel="import" href="chrome://resources/cr_elements/shared_vars_css.html"> -<link rel="import" href="chrome://resources/html/assert.html"> -<link rel="import" href="chrome://resources/html/cr/ui/focus_without_ink.html"> -<link rel="import" href="chrome://resources/html/i18n_behavior.html"> -<link rel="import" href="chrome://resources/html/icon.html"> -<link rel="import" href="chrome://resources/html/util.html"> -<link rel="import" href="chrome://resources/html/web_ui_listener_behavior.html"> -<link rel="import" href="chrome://resources/polymer/v1_0/iron-flex-layout/iron-flex-layout-classes.html"> -<link rel="import" href="../controls/settings_toggle_button.html"> -<link rel="import" href="profile_info_browser_proxy.html"> -<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"> -<link rel="import" href="../settings_shared_css.html"> -<link rel="import" href="signout_dialog.html"> -<link rel="import" href="sync_controls.html"> - -<if expr="chromeos"> -<link rel="import" href="account_manager.html"> -<link rel="import" href="account_manager_browser_proxy.html"> -<link rel="import" href="change_picture.html"> -<link rel="import" href="chrome://resources/cr_elements/chromeos/cr_picture/cr_png_behavior.html"> -<link rel="import" href="fingerprint_list.html"> -<link rel="import" href="kerberos_accounts.html"> -<link rel="import" href="lock_screen.html"> -<link rel="import" href="lock_state_behavior.html"> -<link rel="import" href="users_page.html"> -<link rel="import" href="../parental_controls_page/parental_controls_page.html"> -</if> -<if expr="not chromeos"> -<link rel="import" href="chrome://resources/cr_elements/cr_toast/cr_toast.html"> -<link rel="import" href="sync_account_control.html"> -<link rel="import" href="import_data_dialog.html"> -<link rel="import" href="manage_profile.html"> -</if> - -<dom-module id="settings-people-page"> - <template> - <style include="settings-shared iron-flex"> - setting-box.middle { - /* Per spec, middle text is indented 20px in this section. */ - margin-inline-start: 20px; - } - - .sync-row { - align-items: center; - flex: auto; - } - - #profile-icon { - background: center / cover no-repeat; - border-radius: 20px; - flex-shrink: 0; - height: 40px; - width: 40px; - } - - #sync-status.no-error { - --cr-link-row-start-icon-color: var(--google-green-refresh-700); - } - - @media (prefers-color-scheme: dark) { - #sync-status.no-error { - --cr-link-row-start-icon-color: var(--google-green-refresh-300); - } - } - - #sync-setup { - --cr-secondary-text: { - color: var(--settings-error-color); - } - } - - #sync-status[actionable].auth-error { - --cr-link-row-start-icon-color: var(--google-blue-500); - } - - @media (prefers-color-scheme: dark) { - #sync-status[actionable].auth-error { - --cr-link-row-start-icon-color: var(--google-blue-refresh-300); - } - } - - #sync-status:not([actionable]) .subpage-arrow { - display: none; - } - - cr-link-row { - --cr-link-row-icon-width: 40px; - border-top: var(--cr-separator-line); - } - - #sync-status[actionable].sync-error { - --cr-link-row-start-icon-color: var(--settings-error-color); - --cr-secondary-text: { - color: var(--settings-error-color); - } - } - - .icon-container { - display: flex; - flex-shrink: 0; - justify-content: center; - width: 40px; - } - -<if expr="not chromeos"> - #toast { - left: 0; - z-index: 1; - } - - :host-context([dir='rtl']) #toast { - left: auto; - right: 0; - } - - settings-sync-account-control[showing-promo]::part(banner) { - /* Make the banner image stay within setting-section's card border - radius. */ - border-top-left-radius: var(--cr-card-border-radius); - border-top-right-radius: var(--cr-card-border-radius); - } - - settings-sync-account-control[showing-promo]::part(title) { - font-size: 1.1rem; - line-height: 1.625rem; - } -</if> - </style> - <settings-animated-pages id="pages" section="people" - focus-config="[[focusConfig_]]"> - <div route-path="default"> -<if expr="not chromeos"> - <template is="dom-if" if="[[shouldShowSyncAccountControl_(diceEnabled_, - syncStatus.syncSystemEnabled, syncStatus.signinAllowed)]]"> - <settings-sync-account-control - unified-consent-enabled="[[unifiedConsentEnabled_]]" - sync-status="[[syncStatus]]" - promo-label-with-account="$i18n{peopleSignInPrompt}" - promo-label-with-no-account="$i18n{peopleSignInPrompt}" - promo-secondary-label-with-account= - "$i18n{peopleSignInPromptSecondaryWithAccount}" - promo-secondary-label-with-no-account= - "$i18n{peopleSignInPromptSecondaryWithNoAccount}"> - </settings-sync-account-control> - </template> - <template is="dom-if" if="[[!diceEnabled_]]"> -</if> - <div id="picture-subpage-trigger" class="settings-box first two-line"> - <template is="dom-if" if="[[syncStatus]]"> - <div id="profile-icon" on-click="onProfileTap_" - actionable$="[[isProfileActionable_]]" - style="background-image: [[getIconImageSet_( - profileIconUrl_)]]"> - </div> - <div class="middle two-line no-min-width" - id="profile-row" - on-click="onProfileTap_" - actionable$="[[isProfileActionable_]]"> - <div class="flex text-elide settings-box-text"> - <span id="profile-name">[[profileName_]]</span> - <div class="secondary" hidden="[[!syncStatus.signedIn]]"> - [[syncStatus.signedInUsername]] - </div> - </div> -<if expr="not chromeos"> - <cr-icon-button class="subpage-arrow" - aria-label="$i18n{editPerson}" - aria-describedby="profile-name"></cr-icon-button> -</if> -<if expr="chromeos"> - <cr-icon-button class$="[[profileRowIconClass_]]" - id="profile-subpage-arrow" - hidden="[[!isProfileActionable_]]" - aria-label$="[[profileRowIconAriaLabel_]]" - aria-describedby="profile-name"></cr-icon-button> -</if> - </div> -<if expr="not chromeos"> - <template is="dom-if" if="[[showSignin_(syncStatus)]]"> - <div class="separator"></div> - <cr-button class="action-button" on-click="onSigninTap_" - disabled="[[syncStatus.firstSetupInProgress]]"> - $i18n{syncSignin} - </cr-button> - </template> - <template is="dom-if" if="[[syncStatus.signedIn]]"> - <div class="separator"></div> - <cr-button id="disconnectButton" on-click="onDisconnectTap_" - disabled="[[syncStatus.firstSetupInProgress]]"> - $i18n{syncDisconnect} - </cr-button> - </template> -</if> - </template> - </div> -<if expr="not chromeos"> - </template> <!-- if="[[!diceEnabled_]]" --> -</if> - - <template is="dom-if" if="[[!syncStatus.signedIn]]"> -<if expr="not chromeos"> - <template is="dom-if" if="[[!diceEnabled_]]"> -</if> - <div class="settings-box two-line" id="sync-overview" - hidden="[[!syncStatus.signinAllowed]]"> - <div class="start settings-box-text"> - $i18n{syncOverview} - <a target="_blank" href="$i18n{syncLearnMoreUrl}"> - $i18n{learnMore} - </a> - </div> - </div> -<if expr="not chromeos"> - </template> <!-- if="[[!diceEnabled_]]" --> -</if> - </template> - - <template is="dom-if" - if="[[isPreUnifiedConsentAdvancedSyncSettingsVisible_( - syncStatus, unifiedConsentEnabled_)]]"> - <cr-link-row id="sync-status" - class$="[[getSyncStatusClass_(syncStatus)]]" - label="$i18n{syncAndNonPersonalizedServices}" - sub-label="[[getSyncAndGoogleServicesSubtext_(syncStatus)]]" - on-click="onSyncTap_" start-icon="[[getSyncIcon_(syncStatus)]]" - actionable$="[[isSyncStatusActionable_(syncStatus)]]"> - </cr-link-row> - </template> - - <template is="dom-if" if="[[unifiedConsentEnabled_]]"> - <cr-link-row id="sync-setup" - label="$i18n{syncAndNonPersonalizedServices}" - sub-label="[[getSyncAndGoogleServicesSubtext_(syncStatus)]]" - on-click="onSyncTap_"> - </cr-link-row> - </template> - -<if expr="not chromeos"> - <template is="dom-if" if="[[diceEnabled_]]"> - <cr-link-row id="manage-google-account" - label="$i18n{manageGoogleAccount}" - hidden="[[!shouldShowGoogleAccount_]]" - on-click="openGoogleAccount_" external></cr-link-row> - - <div class="settings-box" id="edit-profile" on-click="onProfileTap_" - actionable> - <div class="start settings-box-text"> - $i18n{profileNameAndPicture} - </div> - <cr-icon-button class="subpage-arrow" - aria-label="$i18n{editPerson}"></cr-icon-button> - </div> - </template> -</if> - -<if expr="chromeos"> - <cr-link-row id="lock-screen-subpage-trigger" class="hr" - on-click="onConfigureLockTap_" - label="[[selectLockScreenTitleString(hasPinLogin)]]" - sub-label="[[getPasswordState_(hasPin, - prefs.settings.enable_screen_lock.value)]]" - hidden="[[!pageVisibility.people.lockScreen]]"></cr-link-row> - - <template is="dom-if" if="[[pageVisibility.people.googleAccounts]]"> - <cr-link-row id="account-manager-subpage-trigger" class="hr" - on-click="onAccountManagerTap_" - label="$i18n{accountManagerSubMenuLabel}"></cr-link-row> - </template> - <template is="dom-if" if="[[showParentalControls_]]"> - <settings-parental-controls-page> - </settings-parental-controls-page> - </template> - <cr-link-row id="manage-other-people-subpage-trigger" - label="$i18n{manageOtherPeople}" on-click="onManageOtherPeople_" - hidden="[[!pageVisibility.people.manageUsers]]"> - </cr-link-row> - - <template is="dom-if" if="[[pageVisibility.people.kerberosAccounts]]"> - <cr-link-row id="kerberos-accounts-subpage-trigger" class="hr" - on-click="onKerberosAccountsTap_" - label="$i18n{kerberosAccountsSubMenuLabel}"> - <cr-policy-indicator indicator-type="userPolicy"> - </cr-policy-indicator> - </cr-link-row> - </template> -</if> - -<if expr="not chromeos"> - <cr-link-row id="importDataDialogTrigger" - label="$i18n{importTitle}" - on-click="onImportDataTap_"></cr-link-row> -</if> - - </div> - <template is="dom-if" route-path="/syncSetup" - no-search="[[!isAdvancedSyncSettingsSearchable_( - syncStatus, unifiedConsentEnabled_)]]"> - <settings-subpage - associated-control="[[getAdvancedSyncSettingsAssociatedControl_( - unifiedConsentEnabled_)]]" - page-title="$i18n{syncPageTitle}" - learn-more-url="$i18n{syncAndGoogleServicesLearnMoreURL}" - no-search$="[[!isAdvancedSyncSettingsSearchable_(syncStatus, - unifiedConsentEnabled_)]]"> - <settings-sync-page -<if expr="not chromeos"> - dice-enabled="[[diceEnabled_]]" -</if> - unified-consent-enabled="[[unifiedConsentEnabled_]]" - sync-status="[[syncStatus]]" prefs="{{prefs}}" - page-visibility="[[pageVisibility.privacy]]"> - </settings-sync-page> - </settings-subpage> - </template> - - <template is="dom-if" if="[[unifiedConsentEnabled_]]"> - <template is="dom-if" route-path="/syncSetup/advanced"> - <settings-subpage page-title="$i18n{syncAdvancedPageTitle}" - associated-control="[[$$('#sync-setup')]]" - learn-more-url="$i18n{syncAndGoogleServicesLearnMoreURL}"> - <settings-sync-controls sync-status="[[syncStatus]]"> - </settings-sync-controls> - </settings-subpage> - </template> - </template> - -<if expr="chromeos"> - <template is="dom-if" if="[[pageVisibility.people.lockScreen]]"> - <template is="dom-if" route-path="/lockScreen"> - <settings-subpage - page-title="[[selectLockScreenTitleString(hasPinLogin)]]" - associated-control="[[$$('#lock-screen-subpage-trigger')]]"> - <settings-lock-screen - prefs="{{prefs}}" auth-token="{{authToken_}}"> - </settings-lock-screen> - </settings-subpage> - </template> - <template is="dom-if" if="[[fingerprintUnlockEnabled_]]"> - <template is="dom-if" route-path="/lockScreen/fingerprint" no-search> - <settings-subpage page-title="$i18n{lockScreenFingerprintTitle}"> - <settings-fingerprint-list auth-token="[[authToken_]]"> - </settings-fingerprint-list> - </settings-subpage> - </template> - </template> - </template> - <template is="dom-if" if="[[pageVisibility.people.manageUsers]]"> - <template is="dom-if" route-path="/accounts"> - <settings-subpage - associated-control= - "[[$$('#manage-other-people-subpage-trigger')]]" - page-title="$i18n{manageOtherPeople}"> - <settings-users-page prefs="{{prefs}}"> - </settings-users-page> - </settings-subpage> - </template> - </template> - <template is="dom-if" route-path="/changePicture"> - <settings-subpage - associated-control="[[$$('#picture-subpage-trigger')]]" - page-title="$i18n{changePictureTitle}"> - <settings-change-picture></settings-change-picture> - </settings-subpage> - </template> - <template is="dom-if" if="[[pageVisibility.people.googleAccounts]]"> - <template is="dom-if" route-path="/accountManager"> - <settings-subpage - associated-control="[[$$('#account-manager-subpage-trigger')]]" - page-title="$i18n{accountManagerPageTitle}"> - <settings-account-manager></settings-account-manager> - </settings-subpage> - </template> - </template> - <template is="dom-if" if="[[pageVisibility.people.kerberosAccounts]]"> - <template is="dom-if" route-path="/kerberosAccounts"> - <settings-subpage - associated-control="[[$$('#kerberos-accounts-subpage-trigger')]]" - page-title="$i18n{kerberosAccountsPageTitle}"> - <settings-kerberos-accounts></settings-kerberos-accounts> - </settings-subpage> - </template> - </template> -</if> -<if expr="not chromeos"> - <template is="dom-if" route-path="/manageProfile"> - <settings-subpage - associated-control="[[getEditPersonAssocControl_(diceEnabled_)]]" - page-title="$i18n{editPerson}"> - <settings-manage-profile profile-name="[[profileName_]]" - sync-status="[[syncStatus]]"> - </settings-manage-profile> - </settings-subpage> - </template> -</if> - </settings-animated-pages> - - <template is="dom-if" if="[[showSignoutDialog_]]" restamp> - <settings-signout-dialog sync-status="[[syncStatus]]" - on-close="onDisconnectDialogClosed_"> - </settings-signout-dialog> - </template> - - <template is="dom-if" if="[[showImportDataDialog_]]" restamp> - <settings-import-data-dialog prefs="{{prefs}}" - on-close="onImportDataDialogClosed_"> - </settings-import-data-dialog> - </template> -<if expr="not chromeos"> - <cr-toast duration="3000" id="toast"> - <span>$i18n{syncSettingsSavedToast}</span> - </cr-toast> -</if> - </template> - <script src="people_page.js"></script> -</dom-module> diff --git a/chromium/chrome/browser/resources/settings/people_page/people_page.js b/chromium/chrome/browser/resources/settings/people_page/people_page.js deleted file mode 100644 index ec7591d62f6..00000000000 --- a/chromium/chrome/browser/resources/settings/people_page/people_page.js +++ /dev/null @@ -1,699 +0,0 @@ -// Copyright 2015 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 - * 'settings-people-page' is the settings page containing sign-in settings. - */ -Polymer({ - is: 'settings-people-page', - - behaviors: [ - settings.RouteObserverBehavior, I18nBehavior, WebUIListenerBehavior, - // <if expr="chromeos"> - CrPngBehavior, LockStateBehavior, - // </if> - ], - - properties: { - /** - * Preferences state. - */ - prefs: { - type: Object, - notify: true, - }, - - // <if expr="not chromeos"> - /** - * This flag is used to conditionally show a set of new sign-in UIs to the - * profiles that have been migrated to be consistent with the web sign-ins. - * TODO(tangltom): In the future when all profiles are completely migrated, - * this should be removed, and UIs hidden behind it should become default. - * @private - */ - diceEnabled_: { - type: Boolean, - value: function() { - return loadTimeData.getBoolean('diceEnabled'); - }, - }, - // </if> - - /** - * This flag is used to conditionally show a set of sync UIs to the - * profiles that have been migrated to have a unified consent flow. - * TODO(tangltom): In the future when all profiles are completely migrated, - * this should be removed, and UIs hidden behind it should become default. - * @private - */ - unifiedConsentEnabled_: { - type: Boolean, - value: function() { - return loadTimeData.getBoolean('unifiedConsentEnabled'); - }, - }, - - // <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} - */ - syncStatus: Object, - - /** - * Dictionary defining page visibility. - * @type {!PageVisibility} - */ - pageVisibility: Object, - - /** - * Authentication token provided by settings-lock-screen. - * @private - */ - authToken_: { - type: String, - value: '', - }, - - /** - * The currently selected profile icon URL. May be a data URL. - * @private - */ - profileIconUrl_: String, - - /** - * Whether the profile row is clickable. The behavior depends on the - * platform. - * @private - */ - isProfileActionable_: { - type: Boolean, - value: function() { - if (!cr.isChromeOS) { - // Opens profile manager. - return true; - } - if (loadTimeData.getBoolean('showOSSettings')) { - // Pre-SplitSettings opens change picture. - return true; - } - // Post-SplitSettings links out to account manager if it is available. - return loadTimeData.getBoolean('isAccountManagerEnabled'); - }, - readOnly: true, - }, - - /** - * The current profile name. - * @private - */ - profileName_: String, - - // <if expr="chromeos"> - /** @private {string} */ - profileRowIconClass_: { - type: String, - value: function() { - if (loadTimeData.getBoolean('showOSSettings')) { - // Pre-SplitSettings links internally to the change picture subpage. - return 'subpage-arrow'; - } else { - // Post-SplitSettings links externally to account manager. If account - // manager isn't available the icon will be hidden. - return 'icon-external'; - } - }, - readOnly: true, - }, - - /** @private {string} */ - profileRowIconAriaLabel_: { - type: String, - value: function() { - if (loadTimeData.getBoolean('showOSSettings')) { - // Pre-SplitSettings. - return this.i18n('changePictureTitle'); - } else { - // Post-SplitSettings. If account manager isn't available the icon - // will be hidden so the label doesn't matter. - return this.i18n('accountManagerSubMenuLabel'); - } - }, - readOnly: true, - }, - // </if> - - // <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, - value: false, - }, - // </if> - - /** @private */ - showSignoutDialog_: Boolean, - - // <if expr="chromeos"> - /** - * True if fingerprint settings should be displayed on this machine. - * @private - */ - fingerprintUnlockEnabled_: { - type: Boolean, - value: function() { - return loadTimeData.getBoolean('fingerprintUnlockEnabled'); - }, - readOnly: true, - }, - - /** @private */ - showParentalControls_: { - type: Boolean, - value: function() { - return loadTimeData.valueExists('showParentalControls') && - loadTimeData.getBoolean('showParentalControls'); - }, - }, - // </if> - - /** @private {!Map<string, string>} */ - focusConfig_: { - type: Object, - value: function() { - const map = new Map(); - if (settings.routes.SYNC) { - map.set( - settings.routes.SYNC.path, - loadTimeData.getBoolean('unifiedConsentEnabled') ? - '#sync-setup' : - '#sync-status .subpage-arrow'); - } - // <if expr="not chromeos"> - if (settings.routes.MANAGE_PROFILE) { - map.set( - settings.routes.MANAGE_PROFILE.path, - loadTimeData.getBoolean('diceEnabled') ? - '#edit-profile .subpage-arrow' : - '#picture-subpage-trigger .subpage-arrow'); - } - // </if> - // <if expr="chromeos"> - if (settings.routes.CHANGE_PICTURE) { - map.set( - settings.routes.CHANGE_PICTURE.path, - '#picture-subpage-trigger .subpage-arrow'); - } - if (settings.routes.LOCK_SCREEN) { - map.set( - settings.routes.LOCK_SCREEN.path, '#lock-screen-subpage-trigger'); - } - if (settings.routes.ACCOUNTS) { - map.set( - settings.routes.ACCOUNTS.path, - '#manage-other-people-subpage-trigger'); - } - if (settings.routes.ACCOUNT_MANAGER) { - map.set( - settings.routes.ACCOUNT_MANAGER.path, - '#account-manager-subpage-trigger'); - } - if (settings.routes.KERBEROS_ACCOUNTS) { - map.set( - settings.routes.KERBEROS_ACCOUNTS.path, - '#kerberos-accounts-subpage-trigger'); - } - // </if> - return map; - }, - }, - }, - - /** @private {?settings.SyncBrowserProxy} */ - syncBrowserProxy_: null, - - /** @override */ - attached: function() { - let useProfileNameAndIcon = true; - // <if expr="chromeos"> - if (!loadTimeData.getBoolean('showOSSettings') && - loadTimeData.getBoolean('isAccountManagerEnabled')) { - // If this is SplitSettings and we have the Google Account manager, - // prefer the GAIA name and icon. - useProfileNameAndIcon = false; - this.addWebUIListener( - 'accounts-changed', this.updateAccounts_.bind(this)); - this.updateAccounts_(); - } - // </if> - if (useProfileNameAndIcon) { - settings.ProfileInfoBrowserProxyImpl.getInstance().getProfileInfo().then( - this.handleProfileInfo_.bind(this)); - this.addWebUIListener( - 'profile-info-changed', this.handleProfileInfo_.bind(this)); - } - - this.syncBrowserProxy_ = settings.SyncBrowserProxyImpl.getInstance(); - this.syncBrowserProxy_.getSyncStatus().then( - 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(); - }); - // </if> - }, - - /** @protected */ - currentRouteChanged: function() { - this.showImportDataDialog_ = - settings.getCurrentRoute() == settings.routes.IMPORT_DATA; - - if (settings.getCurrentRoute() == settings.routes.SIGN_OUT) { - // If the sync status has not been fetched yet, optimistically display - // the sign-out dialog. There is another check when the sync status is - // fetched. The dialog will be closed when the user is not signed in. - if (this.syncStatus && !this.syncStatus.signedIn) { - settings.navigateToPreviousRoute(); - } else { - this.showSignoutDialog_ = true; - } - } - }, - - /** - * @return {!Element} - * @private - */ - getEditPersonAssocControl_: function() { - return this.diceEnabled_ ? assert(this.$$('#edit-profile')) : - assert(this.$$('#picture-subpage-trigger')); - }, - - // <if expr="chromeos"> - /** @private */ - getPasswordState_: function(hasPin, enableScreenLock) { - if (!enableScreenLock) { - return this.i18n('lockScreenNone'); - } - if (hasPin) { - return this.i18n('lockScreenPinOrPassword'); - } - return this.i18n('lockScreenPasswordOnly'); - }, - // </if> - - /** - * @return {string} - * @private - */ - getSyncAndGoogleServicesSubtext_: function() { - if (this.syncStatus && this.syncStatus.hasError && - this.syncStatus.statusText) { - return this.syncStatus.statusText; - } - return ''; - }, - - /** - * Handler for when the profile's icon and name is updated. - * @private - * @param {!settings.ProfileInfo} info - */ - handleProfileInfo_: function(info) { - this.profileName_ = info.name; - /** - * Extract first frame from image by creating a single frame PNG using - * url as input if base64 encoded and potentially animated. - */ - // <if expr="chromeos"> - if (info.iconUrl.startsWith('data:image/png;base64')) { - this.profileIconUrl_ = - CrPngBehavior.convertImageSequenceToPng([info.iconUrl]); - return; - } - // </if> - - this.profileIconUrl_ = info.iconUrl; - }, - - // <if expr="chromeos"> - /** - * @private - * @suppress {checkTypes} The types only exists in Chrome OS builds, but - * Closure doesn't understand the <if> above. - */ - updateAccounts_: async function() { - const /** @type {!Array<{settings.Account}>} */ accounts = - await settings.AccountManagerBrowserProxyImpl.getInstance() - .getAccounts(); - // The user might not have any GAIA accounts (e.g. guest mode, Kerberos, - // Active Directory). In these cases the profile row is hidden, so there's - // nothing to do. - if (accounts.length == 0) { - return; - } - this.profileName_ = accounts[0].fullName; - this.profileIconUrl_ = accounts[0].pic; - }, - // </if> - - /** - * Handler for when the sync state is pushed from the browser. - * @param {?settings.SyncStatus} syncStatus - * @private - */ - handleSyncStatus_: function(syncStatus) { - // Sign-in impressions should be recorded only if the sign-in promo is - // shown. They should be recorder only once, the first time - // |this.syncStatus| is set. - const shouldRecordSigninImpression = - !this.syncStatus && syncStatus && this.showSignin_(syncStatus); - - this.syncStatus = syncStatus; - - if (shouldRecordSigninImpression && !this.shouldShowSyncAccountControl_()) { - // SyncAccountControl records the impressions user actions. - chrome.metricsPrivate.recordUserAction('Signin_Impression_FromSettings'); - } - }, - - // <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"> - if (loadTimeData.getBoolean('showOSSettings')) { - // Pre-SplitSettings. - settings.navigateTo(settings.routes.CHANGE_PICTURE); - } else if (loadTimeData.getBoolean('isAccountManagerEnabled')) { - // Post-SplitSettings. The browser C++ code loads OS settings in a window. - // Don't use window.open() because that creates an extra empty tab. - window.location.href = 'chrome://os-settings/accountManager'; - } - // </if> - // <if expr="not chromeos"> - settings.navigateTo(settings.routes.MANAGE_PROFILE); - // </if> - }, - - /** @private */ - onSigninTap_: function() { - this.syncBrowserProxy_.startSignIn(); - }, - - /** @private */ - onDisconnectDialogClosed_: function(e) { - this.showSignoutDialog_ = false; - // <if expr="not chromeos"> - if (!this.diceEnabled_) { - // If DICE-enabled, this button won't exist here. - cr.ui.focusWithoutInk(assert(this.$$('#disconnectButton'))); - } - // </if> - - // <if expr="chromeos"> - cr.ui.focusWithoutInk(assert(this.$$('#disconnectButton'))); - // </if> - - if (settings.getCurrentRoute() == settings.routes.SIGN_OUT) { - settings.navigateToPreviousRoute(); - } - }, - - /** @private */ - onDisconnectTap_: function() { - settings.navigateTo(settings.routes.SIGN_OUT); - }, - - /** @private */ - onSyncTap_: function() { - // When unified-consent is enabled, users can go to sync subpage regardless - // of sync status. - if (this.unifiedConsentEnabled_) { - settings.navigateTo(settings.routes.SYNC); - return; - } - - // TODO(crbug.com/862983): Remove this code once UnifiedConsent is rolled - // out to 100%. - assert(this.syncStatus.signedIn); - assert(this.syncStatus.syncSystemEnabled); - - if (!this.isSyncStatusActionable_(this.syncStatus)) { - return; - } - - switch (this.syncStatus.statusAction) { - case settings.StatusAction.REAUTHENTICATE: - this.syncBrowserProxy_.startSignIn(); - break; - case settings.StatusAction.SIGNOUT_AND_SIGNIN: - // <if expr="chromeos"> - this.syncBrowserProxy_.attemptUserExit(); - // </if> - // <if expr="not chromeos"> - if (this.syncStatus.domain) { - settings.navigateTo(settings.routes.SIGN_OUT); - } else { - // Silently sign the user out without deleting their profile and - // prompt them to sign back in. - this.syncBrowserProxy_.signOut(false); - this.syncBrowserProxy_.startSignIn(); - } - // </if> - break; - case settings.StatusAction.UPGRADE_CLIENT: - settings.navigateTo(settings.routes.ABOUT); - break; - case settings.StatusAction.ENTER_PASSPHRASE: - case settings.StatusAction.CONFIRM_SYNC_SETTINGS: - case settings.StatusAction.NO_ACTION: - default: - settings.navigateTo(settings.routes.SYNC); - } - }, - - // <if expr="chromeos"> - /** - * @param {!Event} e - * @private - */ - onConfigureLockTap_: function(e) { - // Navigating to the lock screen will always open the password prompt - // dialog, so prevent the end of the tap event to focus what is underneath - // it, which takes focus from the dialog. - e.preventDefault(); - settings.navigateTo(settings.routes.LOCK_SCREEN); - }, - - /** - * @param {!Event} e - * @private - */ - onAccountManagerTap_: function(e) { - settings.navigateTo(settings.routes.ACCOUNT_MANAGER); - }, - - /** - * @param {!Event} e - * @private - */ - onKerberosAccountsTap_: function(e) { - settings.navigateTo(settings.routes.KERBEROS_ACCOUNTS); - }, - - /** @private */ - onManageOtherPeople_: function() { - settings.navigateTo(settings.routes.ACCOUNTS); - }, - // </if> - - // <if expr="not chromeos"> - /** @private */ - onImportDataTap_: function() { - settings.navigateTo(settings.routes.IMPORT_DATA); - }, - - /** @private */ - onImportDataDialogClosed_: function() { - settings.navigateToPreviousRoute(); - cr.ui.focusWithoutInk(assert(this.$.importDataDialogTrigger)); - }, - - /** - * Open URL for managing your Google Account. - * @private - */ - openGoogleAccount_: function() { - settings.OpenWindowProxyImpl.getInstance().openURL( - loadTimeData.getString('googleAccountUrl')); - chrome.metricsPrivate.recordUserAction('ManageGoogleAccount_Clicked'); - }, - - /** - * @return {boolean} - * @private - */ - shouldShowSyncAccountControl_: function() { - if (this.syncStatus == undefined) { - return false; - } - - return this.diceEnabled_ && !!this.syncStatus.syncSystemEnabled && - !!this.syncStatus.signinAllowed; - }, - // </if> - - /** - * @private - * @param {?settings.SyncStatus} syncStatus - * @return {boolean} - */ - isPreUnifiedConsentAdvancedSyncSettingsVisible_: function(syncStatus) { - return !!syncStatus && !!syncStatus.signedIn && - !!syncStatus.syncSystemEnabled && !this.unifiedConsentEnabled_; - }, - - /** - * @private - * @param {?settings.SyncStatus} syncStatus - * @return {boolean} - */ - isAdvancedSyncSettingsSearchable_: function(syncStatus) { - return this.isPreUnifiedConsentAdvancedSyncSettingsVisible_(syncStatus) || - !!this.unifiedConsentEnabled_; - }, - - /** - * @private - * @return {Element|null} - */ - getAdvancedSyncSettingsAssociatedControl_: function() { - return this.unifiedConsentEnabled_ ? this.$$('#sync-setup') : - this.$$('#sync-status'); - }, - - /** - * @private - * @param {?settings.SyncStatus} syncStatus - * @return {boolean} Whether an action can be taken with the sync status. sync - * status is actionable if sync is not managed and if there is a sync - * error, there is an action associated with it. - */ - isSyncStatusActionable_: function(syncStatus) { - return !!syncStatus && !syncStatus.managed && - (!syncStatus.hasError || - syncStatus.statusAction != settings.StatusAction.NO_ACTION); - }, - - /** - * @private - * @param {?settings.SyncStatus} syncStatus - * @return {string} - */ - getSyncIcon_: function(syncStatus) { - if (!syncStatus) { - return ''; - } - - let syncIcon = 'cr:sync'; - - if (syncStatus.hasError) { - syncIcon = 'settings:sync-problem'; - } - - // Override the icon to the disabled icon if sync is managed. - if (syncStatus.managed || - syncStatus.statusAction == settings.StatusAction.REAUTHENTICATE) { - syncIcon = 'settings:sync-disabled'; - } - - return syncIcon; - }, - - /** - * @private - * @param {?settings.SyncStatus} syncStatus - * @return {string} The class name for the sync status row. - */ - getSyncStatusClass_: function(syncStatus) { - if (syncStatus && syncStatus.hasError) { - // Most of the time re-authenticate states are caused by intentional user - // action, so they will be displayed differently as other errors. - return syncStatus.statusAction == settings.StatusAction.REAUTHENTICATE ? - 'auth-error' : - 'sync-error'; - } - - return 'no-error'; - }, - - /** - * @param {string} iconUrl - * @return {string} A CSS image-set for multiple scale factors. - * @private - */ - getIconImageSet_: function(iconUrl) { - return cr.icon.getImage(iconUrl); - }, - - /** - * @param {!settings.SyncStatus} syncStatus - * @return {boolean} Whether to show the "Sign in to Chrome" button. - * @private - */ - showSignin_: function(syncStatus) { - return !!syncStatus.signinAllowed && !syncStatus.signedIn; - }, - - /** - * Looks up the translation id, which depends on PIN login support. - * @param {boolean} hasPinLogin - * @private - */ - selectLockScreenTitleString(hasPinLogin) { - if (hasPinLogin) { - return this.i18n('lockScreenTitleLoginLock'); - } - return this.i18n('lockScreenTitleLock'); - }, -}); diff --git a/chromium/chrome/browser/resources/settings/people_page/profile_info_browser_proxy.html b/chromium/chrome/browser/resources/settings/people_page/profile_info_browser_proxy.html deleted file mode 100644 index 76290dddea4..00000000000 --- a/chromium/chrome/browser/resources/settings/people_page/profile_info_browser_proxy.html +++ /dev/null @@ -1,2 +0,0 @@ -<link rel="import" href="chrome://resources/html/cr.html"> -<script src="profile_info_browser_proxy.js"></script> diff --git a/chromium/chrome/browser/resources/settings/people_page/profile_info_browser_proxy.js b/chromium/chrome/browser/resources/settings/people_page/profile_info_browser_proxy.js deleted file mode 100644 index 65808a60de6..00000000000 --- a/chromium/chrome/browser/resources/settings/people_page/profile_info_browser_proxy.js +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright 2016 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 from the the People section to get the - * profile info, which consists of the profile name and icon. Used for both - * Chrome browser and ChromeOS. - */ -cr.exportPath('settings'); - -/** - * An object describing the profile. - * @typedef {{ - * name: string, - * iconUrl: string - * }} - */ -settings.ProfileInfo; - -cr.define('settings', function() { - /** @interface */ - class ProfileInfoBrowserProxy { - /** - * Returns a Promise for the profile info. - * @return {!Promise<!settings.ProfileInfo>} - */ - getProfileInfo() {} - - /** - * Requests the profile stats count. The result is returned by the - * 'profile-stats-count-ready' WebUI listener event. - */ - getProfileStatsCount() {} - } - - /** - * @implements {ProfileInfoBrowserProxy} - */ - class ProfileInfoBrowserProxyImpl { - /** @override */ - getProfileInfo() { - return cr.sendWithPromise('getProfileInfo'); - } - - /** @override */ - getProfileStatsCount() { - chrome.send('getProfileStatsCount'); - } - } - - cr.addSingletonGetter(ProfileInfoBrowserProxyImpl); - - return { - ProfileInfoBrowserProxyImpl: ProfileInfoBrowserProxyImpl, - }; -}); diff --git a/chromium/chrome/browser/resources/settings/people_page/settings_icon_camera_alt.svg b/chromium/chrome/browser/resources/settings/people_page/settings_icon_camera_alt.svg deleted file mode 100644 index dbe522a6b85..00000000000 --- a/chromium/chrome/browser/resources/settings/people_page/settings_icon_camera_alt.svg +++ /dev/null @@ -1 +0,0 @@ -<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="#FFF"><circle cx="12" cy="12" r="3.2"/><path d="M9 2L7.17 4H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2h-3.17L15 2H9zm3 15c-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5-2.24 5-5 5z"/></svg>
\ No newline at end of file diff --git a/chromium/chrome/browser/resources/settings/people_page/setup_fingerprint_dialog.html b/chromium/chrome/browser/resources/settings/people_page/setup_fingerprint_dialog.html deleted file mode 100644 index 298e790f814..00000000000 --- a/chromium/chrome/browser/resources/settings/people_page/setup_fingerprint_dialog.html +++ /dev/null @@ -1,105 +0,0 @@ -<link rel="import" href="chrome://resources/html/polymer.html"> - -<link rel="import" href="chrome://resources/cr_elements/chromeos/cr_lottie/cr_lottie.html"> -<link rel="import" href="chrome://resources/cr_elements/cr_fingerprint/cr_fingerprint_progress_arc.html"> -<link rel="import" href="chrome://resources/cr_elements/cr_button/cr_button.html"> -<link rel="import" href="chrome://resources/cr_elements/cr_dialog/cr_dialog.html"> -<link rel="import" href="chrome://resources/cr_elements/icons.html"> -<link rel="import" href="chrome://resources/html/assert.html"> -<link rel="import" href="chrome://resources/html/i18n_behavior.html"> -<link rel="import" href="chrome://resources/html/web_ui_listener_behavior.html"> -<link rel="import" href="chrome://resources/polymer/v1_0/iron-icon/iron-icon.html"> -<link rel="import" href="chrome://resources/polymer/v1_0/iron-iconset-svg/iron-iconset-svg.html"> -<link rel="import" href="../icons.html"> -<link rel="import" href="../settings_shared_css.html"> -<link rel="import" href="fingerprint_browser_proxy.html"> - -<dom-module id="settings-setup-fingerprint-dialog"> - <template> - <style include="settings-shared"> - #dialog::part(dialog) { - min-width: 500px; - width: 500px; - } - - .fingerprint-scanner-laptop-bottom-right { - background: - url(chrome://theme/IDR_LOGIN_FINGERPRINT_SCANNER_LAPTOP_BOTTOM_RIGHT_ANIMATION); - } - - .fingerprint-scanner-laptop-top-right { - background: - url(chrome://theme/IDR_LOGIN_FINGERPRINT_SCANNER_LAPTOP_TOP_RIGHT_ANIMATION); - } - - #scannerLocation { - background-position: center; - background-repeat: no-repeat; - background-size: 298px 205px; - height: 240px; - } - - #scannerLocationLottie { - height: 220px; - padding: 10px 0; - } - - #messageDiv { - height: 20px; - } - - /* Use this instead of hidden so that the dialog does not resize when the - message appears or disappears. */ - #messageDiv[invisible] { - visibility: hidden; - } - - #closeButton { - margin-inline-start: 5px; - } - </style> - - <cr-dialog id="dialog" on-close="close" - close-text="$i18n{close}"> - <div slot="title">$i18n{configureFingerprintTitle}</div> - <div slot="body"> - <div id="messageDiv" - invisible$="[[!getInstructionMessage_(step_, problemMessage_)]]" - aria-live="polite"> - <span>[[getInstructionMessage_(step_, problemMessage_)]]</span> - </div> - <template is="dom-if" if="[[shouldUseLottieAnimation_]]"> - <div id="scannerLocationLottie" - hidden="[[!showScannerLocation_(step_)]]" aria-live="polite" - aria-label="$i18n{configureFingerprintScannerStepAriaLabel}"> - <cr-lottie animation-url="finger_print.json" autoplay> - </cr-lottie> - </div> - </template> - <template is="dom-if" if="[[!shouldUseLottieAnimation_]]"> - <div id="scannerLocation" hidden="[[!showScannerLocation_(step_)]]" - class$="[[fingerprintScannerAnimationClass_]]" - aria-label="$i18n{configureFingerprintScannerStepAriaLabel}" - aria-live="polite" > - </div> - </template> - <cr-fingerprint-progress-arc id="arc" circle-radius="100" - hidden="[[!showArc_(step_)]]"> - </cr-fingerprint-progress-arc> - </div> - <div slot="button-container"> - <cr-button id="addAnotherButton" on-click="onAddAnotherFingerprint_" - hidden$="[[hideAddAnother_(step_, allowAddAnotherFinger)]]"> - $i18n{configureFingerprintAddAnotherButton} - </cr-button> - - <cr-button id="closeButton" - class$="[[getCloseButtonClass_(step_)]]" on-click="onClose_"> - [[getCloseButtonText_(step_)]] - </cr-button> - </div> - </cr-dialog> - </template> - - <script src="setup_fingerprint_dialog.js"></script> -</dom-module> diff --git a/chromium/chrome/browser/resources/settings/people_page/setup_fingerprint_dialog.js b/chromium/chrome/browser/resources/settings/people_page/setup_fingerprint_dialog.js deleted file mode 100644 index d0d6d0ec42b..00000000000 --- a/chromium/chrome/browser/resources/settings/people_page/setup_fingerprint_dialog.js +++ /dev/null @@ -1,370 +0,0 @@ -// Copyright 2017 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.exportPath('settings'); - -/** - * The steps in the fingerprint setup flow. - * @enum {number} - */ -settings.FingerprintSetupStep = { - LOCATE_SCANNER: 1, // The user needs to locate the scanner. - MOVE_FINGER: 2, // The user needs to move finger around the scanner. - READY: 3 // The scanner has read the fingerprint successfully. -}; - -/** - * Fingerprint sensor locations corresponding to the FingerprintLocation - * enumerators in - * /chrome/browser/chromeos/login/quick_unlock/quick_unlock_utils.h - * @enum {number} - */ -settings.FingerprintLocation = { - TABLET_POWER_BUTTON: 0, - KEYBOARD_TOP_RIGHT: 1, - KEYBOARD_BOTTOM_RIGHT: 2, -}; - -(function() { - -/** - * The amount of milliseconds after a successful but not completed scan before a - * message shows up telling the user to scan their finger again. - * @type {number} - */ -const SHOW_TAP_SENSOR_MESSAGE_DELAY_MS = 2000; - -Polymer({ - is: 'settings-setup-fingerprint-dialog', - - behaviors: [I18nBehavior, WebUIListenerBehavior], - - properties: { - /** - * Whether add another finger is allowed. - * @type {boolean} - */ - allowAddAnotherFinger: { - type: Boolean, - value: true, - }, - - /** - * Authentication token provided by settings-fingerprint-list - */ - authToken: { - type: String, - value: '', - }, - /** - * The problem message to display. - * @private - */ - problemMessage_: { - type: String, - value: '', - }, - - /** - * The setup phase we are on. - * @type {!settings.FingerprintSetupStep} - * @private - */ - step_: {type: Number, value: settings.FingerprintSetupStep.LOCATE_SCANNER}, - - /** - * The percentage of completion that has been received during setup. - * This is used to approximate the progress of the setup. - * The value within [0, 100] represents the percent of enrollment - * completion. - * @type {number} - * @private - */ - percentComplete_: { - type: Number, - value: 0, - observer: 'onProgressChanged_', - }, - - /** - * This is used to display right animation for fingerprint sensor. - * @private {string} - */ - fingerprintScannerAnimationClass_: { - type: String, - value: function() { - if (!loadTimeData.getBoolean('fingerprintUnlockEnabled')) { - return ''; - } - const fingerprintLocation = - loadTimeData.getInteger('fingerprintReaderLocation'); - switch (fingerprintLocation) { - case settings.FingerprintLocation.TABLET_POWER_BUTTON: - return ''; - case settings.FingerprintLocation.KEYBOARD_TOP_RIGHT: - return 'fingerprint-scanner-laptop-top-right'; - case settings.FingerprintLocation.KEYBOARD_BOTTOM_RIGHT: - return 'fingerprint-scanner-laptop-bottom-right'; - } - assertNotReached(); - }, - readOnly: true, - }, - - /** - * True lottie animation file should be used instead of a png animation - * image sequence. - * @private {boolean} - */ - shouldUseLottieAnimation_: { - type: Boolean, - value: function() { - if (!loadTimeData.getBoolean('fingerprintUnlockEnabled')) { - return false; - } - - const fingerprintLocation = - loadTimeData.getInteger('fingerprintReaderLocation'); - const isTabletPowerButton = - settings.FingerprintLocation.TABLET_POWER_BUTTON == - fingerprintLocation; - return isTabletPowerButton; - }, - readOnly: true, - } - }, - - /** - * A message shows after the user has not scanned a finger during setup. This - * is the set timeout id. - * @type {number} - * @private - */ - tapSensorMessageTimeoutId_: 0, - - /** @private {?settings.FingerprintBrowserProxy}*/ - browserProxy_: null, - - /** @override */ - attached: function() { - this.addWebUIListener( - 'on-fingerprint-scan-received', this.onScanReceived_.bind(this)); - this.browserProxy_ = settings.FingerprintBrowserProxyImpl.getInstance(); - - this.$.arc.reset(); - this.browserProxy_.startEnroll(this.authToken); - this.$.dialog.showModal(); - }, - - /** - * Closes the dialog. - */ - close: function() { - if (this.$.dialog.open) { - this.$.dialog.close(); - } - - // Note: Reset resets |step_| back to the default, so handle anything that - // checks |step_| before resetting. - if (this.step_ != settings.FingerprintSetupStep.READY) { - this.browserProxy_.cancelCurrentEnroll(); - } - - this.reset_(); - }, - - /** private */ - clearSensorMessageTimeout_: function() { - if (this.tapSensorMessageTimeoutId_ != 0) { - clearTimeout(this.tapSensorMessageTimeoutId_); - this.tapSensorMessageTimeoutId_ = 0; - } - }, - - /** - * Resets the dialog to its start state. Call this when the dialog gets - * closed. - * @private - */ - reset_: function() { - this.step_ = settings.FingerprintSetupStep.LOCATE_SCANNER; - this.percentComplete_ = 0; - this.clearSensorMessageTimeout_(); - }, - - /** - * Closes the dialog. - * @private - */ - onClose_: function() { - if (this.$.dialog.open) { - this.$.dialog.close(); - } - }, - - /** - * Advances steps, shows problems and animates the progress as needed based on - * scan results. - * @param {!settings.FingerprintScan} scan - * @private - */ - onScanReceived_: function(scan) { - switch (this.step_) { - case settings.FingerprintSetupStep.LOCATE_SCANNER: - this.$.arc.reset(); - this.step_ = settings.FingerprintSetupStep.MOVE_FINGER; - this.percentComplete_ = scan.percentComplete; - this.setProblem_(scan.result); - break; - case settings.FingerprintSetupStep.MOVE_FINGER: - if (scan.isComplete) { - this.problemMessage_ = ''; - this.step_ = settings.FingerprintSetupStep.READY; - this.clearSensorMessageTimeout_(); - this.fire('add-fingerprint'); - } else { - this.setProblem_(scan.result); - } - this.percentComplete_ = scan.percentComplete; - break; - case settings.FingerprintSetupStep.READY: - break; - default: - assertNotReached(); - break; - } - }, - - /** - * Sets the instructions based on which phase of the fingerprint setup we are - * on. - * @param {!settings.FingerprintSetupStep} step The current step the - * fingerprint setup is on. - * @param {string} problemMessage Message for the scan result. - * @private - */ - getInstructionMessage_: function(step, problemMessage) { - switch (step) { - case settings.FingerprintSetupStep.LOCATE_SCANNER: - return this.i18n('configureFingerprintInstructionLocateScannerStep'); - case settings.FingerprintSetupStep.MOVE_FINGER: - return problemMessage; - case settings.FingerprintSetupStep.READY: - return this.i18n('configureFingerprintInstructionReadyStep'); - } - assertNotReached(); - }, - - /** - * Set the problem message based on the result from the fingerprint scanner. - * @param {!settings.FingerprintResultType} scanResult The result the - * fingerprint scanner gives. - * @private - */ - setProblem_: function(scanResult) { - this.clearSensorMessageTimeout_(); - switch (scanResult) { - case settings.FingerprintResultType.SUCCESS: - this.problemMessage_ = ''; - this.tapSensorMessageTimeoutId_ = setTimeout(() => { - this.problemMessage_ = this.i18n('configureFingerprintLiftFinger'); - }, SHOW_TAP_SENSOR_MESSAGE_DELAY_MS); - break; - case settings.FingerprintResultType.PARTIAL: - case settings.FingerprintResultType.INSUFFICIENT: - case settings.FingerprintResultType.SENSOR_DIRTY: - case settings.FingerprintResultType.TOO_SLOW: - case settings.FingerprintResultType.TOO_FAST: - this.problemMessage_ = this.i18n('configureFingerprintTryAgain'); - break; - case settings.FingerprintResultType.IMMOBILE: - this.problemMessage_ = this.i18n('configureFingerprintImmobile'); - break; - default: - assertNotReached(); - break; - } - }, - - /** - * Displays the text of the close button based on which phase of the - * fingerprint setup we are on. - * @param {!settings.FingerprintSetupStep} step The current step the - * fingerprint setup is on. - * @private - */ - getCloseButtonText_: function(step) { - if (step == settings.FingerprintSetupStep.READY) { - return this.i18n('done'); - } - - return this.i18n('cancel'); - }, - - /** - * @param {!settings.FingerprintSetupStep} step - * @private - */ - getCloseButtonClass_: function(step) { - if (step == settings.FingerprintSetupStep.READY) { - return 'action-button'; - } - - return 'cancel-button'; - }, - - /** - * @param {!settings.FingerprintSetupStep} step - * @param {boolean} allowAddAnotherFinger - * @private - */ - hideAddAnother_: function(step, allowAddAnotherFinger) { - return step != settings.FingerprintSetupStep.READY || - !allowAddAnotherFinger; - }, - - /** - * Enrolls the finished fingerprint and sets the dialog back to step one to - * prepare to enroll another fingerprint. - * @private - */ - onAddAnotherFingerprint_: function() { - this.reset_(); - this.$.arc.reset(); - this.step_ = settings.FingerprintSetupStep.MOVE_FINGER; - this.browserProxy_.startEnroll(this.authToken); - }, - - /** - * Whether scanner location should be shown at the current step. - * @private - */ - showScannerLocation_: function() { - return this.step_ == settings.FingerprintSetupStep.LOCATE_SCANNER; - }, - - /** - * Whether fingerprint progress circle should be shown at the current step. - * @private - */ - showArc_: function() { - return this.step_ == settings.FingerprintSetupStep.MOVE_FINGER || - this.step_ == settings.FingerprintSetupStep.READY; - }, - - /** - * Observer for percentComplete_. - * @private - */ - onProgressChanged_: function(newValue, oldValue) { - // Start a new enrollment, so reset all enrollment related states. - if (newValue === 0) { - this.$.arc.reset(); - return; - } - - this.$.arc.setProgress(oldValue, newValue, newValue === 100); - }, -}); -})(); diff --git a/chromium/chrome/browser/resources/settings/people_page/setup_pin_dialog.html b/chromium/chrome/browser/resources/settings/people_page/setup_pin_dialog.html deleted file mode 100644 index 093bace2c14..00000000000 --- a/chromium/chrome/browser/resources/settings/people_page/setup_pin_dialog.html +++ /dev/null @@ -1,53 +0,0 @@ -<link rel="import" href="chrome://resources/html/polymer.html"> - -<link rel="import" href="chrome://resources/cr_components/chromeos/quick_unlock/setup_pin_keyboard.html"> -<link rel="import" href="chrome://resources/cr_elements/cr_button/cr_button.html"> -<link rel="import" href="chrome://resources/cr_elements/cr_dialog/cr_dialog.html"> -<link rel="import" href="chrome://resources/html/assert.html"> -<link rel="import" href="chrome://resources/html/i18n_behavior.html"> -<link rel="import" href="../i18n_setup.html"> -<link rel="import" href="../settings_shared_css.html"> - -<dom-module id="settings-setup-pin-dialog"> - <template> - <style include="settings-shared"> - #pinKeyboardDiv { - justify-content: center; - }; - - #pinKeyboard { - --cr-input-placeholder-letter-spacing: normal; - } - </style> - <cr-dialog id="dialog" on-close="close" - close-text="$i18n{close}"> - <div slot="title">[[getTitleMessage_(isConfirmStep_)]]</div> - <div slot="body"> - <!-- PIN keyboard --> - <div id="pinKeyboardDiv" class="settings-box continuation"> - <setup-pin-keyboard id="pinKeyboard" - enable-submit="{{enableSubmit_}}" - is-confirm-step="{{isConfirmStep_}}" - on-pin-submit="onPinSubmit_" - on-set-pin-done="onSetPinDone_" - set-modes="{{setModes}}" - quick-unlock-private="[[quickUnlockPrivate]]" - write-uma="[[writeUma_]]" - enable-placeholder> - </setup-pin-keyboard> - </div> - </div> - <div slot="button-container"> - <cr-button class="cancel-button" on-click="onCancelTap_"> - $i18n{cancel} - </cr-button> - <cr-button class="action-button" on-click="onPinSubmit_" - disabled$="[[!enableSubmit_]]"> - <span>[[getContinueMessage_(isConfirmStep_)]]</span> - </cr-button> - </div> - </cr-dialog> - </template> - - <script src="setup_pin_dialog.js"></script> -</dom-module> diff --git a/chromium/chrome/browser/resources/settings/people_page/setup_pin_dialog.js b/chromium/chrome/browser/resources/settings/people_page/setup_pin_dialog.js deleted file mode 100644 index 83e44e8ed17..00000000000 --- a/chromium/chrome/browser/resources/settings/people_page/setup_pin_dialog.js +++ /dev/null @@ -1,121 +0,0 @@ -// Copyright 2016 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 - * 'settings-setup-pin-dialog' is the settings page for choosing a PIN. - * - * Example: - * * <settings-setup-pin-dialog set-modes="[[quickUnlockSetModes]]"> - * </settings-setup-pin-dialog> - */ - -(function() { -'use strict'; - -Polymer({ - is: 'settings-setup-pin-dialog', - - behaviors: [I18nBehavior], - - properties: { - /** - * Reflects property set in password_prompt_dialog.js. - * @type {?Object} - */ - setModes: { - type: Object, - notify: true, - }, - - /** - * Should the step-specific submit button be displayed? - * @private - */ - enableSubmit_: Boolean, - - /** - * The current step/subpage we are on. - * @private - */ - isConfirmStep_: {type: Boolean, value: false}, - - /** - * Interface for chrome.quickUnlockPrivate calls. May be overridden by - * tests. - * @private - */ - quickUnlockPrivate: {type: Object, value: chrome.quickUnlockPrivate}, - - /** - * writeUma is a function that handles writing uma stats. It may be - * overridden for tests. - * - * @type {Function} - * @private - */ - writeUma_: { - type: Object, - value: function() { - return () => {}; - } - }, - }, - - /** @override */ - attached: function() { - this.$.dialog.showModal(); - this.$.pinKeyboard.focus(); - }, - - close: function() { - if (this.$.dialog.open) { - this.$.dialog.close(); - } - - this.$.pinKeyboard.resetState(); - }, - - - /** @private */ - onCancelTap_: function() { - this.$.pinKeyboard.resetState(); - this.$.dialog.close(); - }, - - /** @private */ - onPinSubmit_: function() { - this.$.pinKeyboard.doSubmit(); - }, - - - /** @private */ - onSetPinDone_: function() { - if (this.$.dialog.open) { - this.$.dialog.close(); - } - }, - - /** - * @private - * @param {boolean} isConfirmStep - * @return {string} - */ - getTitleMessage_: function(isConfirmStep) { - return this.i18n( - isConfirmStep ? 'configurePinConfirmPinTitle' : - 'configurePinChoosePinTitle'); - }, - - /** - * @private - * @param {boolean} isConfirmStep - * @return {string} - */ - getContinueMessage_: function(isConfirmStep) { - return this.i18n(isConfirmStep ? 'confirm' : 'continue'); - }, -}); - -})(); diff --git a/chromium/chrome/browser/resources/settings/people_page/signout_dialog.html b/chromium/chrome/browser/resources/settings/people_page/signout_dialog.html deleted file mode 100644 index 74a1ee48418..00000000000 --- a/chromium/chrome/browser/resources/settings/people_page/signout_dialog.html +++ /dev/null @@ -1,84 +0,0 @@ -<link rel="import" href="chrome://resources/html/polymer.html"> - -<link rel="import" href="chrome://resources/cr_elements/cr_button/cr_button.html"> -<link rel="import" href="chrome://resources/cr_elements/cr_checkbox/cr_checkbox.html"> -<link rel="import" href="chrome://resources/cr_elements/cr_dialog/cr_dialog.html"> -<link rel="import" href="chrome://resources/cr_elements/cr_expand_button/cr_expand_button.html"> -<link rel="import" href="chrome://resources/cr_elements/shared_vars_css.html"> -<link rel="import" href="chrome://resources/polymer/v1_0/iron-collapse/iron-collapse.html"> -<link rel="import" href="profile_info_browser_proxy.html"> -<link rel="import" href="sync_browser_proxy.html"> -<link rel="import" href="../settings_shared_css.html"> - -<dom-module id="settings-signout-dialog"> - <template> - <style include="settings-shared"> - #dialog [slot=footer] .settings-box { - --cr-section-padding: 0; - } - - .delete-profile-warning { - padding-bottom: 10px; - padding-inline-end: var(--cr-section-padding); - /* In order to line up with the checkbox text. */ - padding-inline-start: var(--cr-section-indent-padding); - padding-top: 10px; - } - - #wideFooter { - /* Override the cr-dialog footer padding. */ - padding: 16px 0; - } - - #dialog-body { - /* Add space for the link focus ring. See https://crbug.com/916939. */ - padding-bottom: 2px; - } - </style> - - <cr-dialog id="dialog" ignore-enter-key close-text="$i18n{close}"> - <div slot="title">$i18n{syncDisconnectTitle}</div> - <div id="dialog-body" slot="body"> - <div inner-h-t-m-l="[[ - getDisconnectExplanationHtml_(syncStatus.domain)]]"> - </div> - </div> - <div slot="button-container"> - <cr-button id="disconnectCancel" class="cancel-button" - on-click="onDisconnectCancel_" > - $i18n{cancel} - </cr-button> - <cr-button id="disconnectConfirm" class="action-button" - hidden="[[syncStatus.domain]]" on-click="onDisconnectConfirm_"> - $i18n{syncDisconnect} - </cr-button> - <cr-button id="disconnectManagedProfileConfirm" - class="action-button" hidden="[[!syncStatus.domain]]" - on-click="onDisconnectConfirm_"> - $i18n{syncDisconnectConfirm} - </cr-button> - </div> -<if expr="(not chromeos and is_posix) or is_win or is_macosx"> - <template is="dom-if" if="[[!syncStatus.domain]]"> - <div id="wideFooter" slot="footer"> - <div class="settings-box first"> - <cr-checkbox id="deleteProfile" class="start" - checked="{{deleteProfile_}}"> - $i18n{syncDisconnectDeleteProfile} - </cr-checkbox> - <cr-expand-button expanded="{{deleteProfileWarningVisible_}}" - alt="$i18n{deleteProfileWarningExpandA11yLabel}"> - </cr-expand-button> - </div> - <iron-collapse opened="[[deleteProfileWarningVisible_]]"> - <div class="delete-profile-warning"> - [[deleteProfileWarning_]] - </div> - </iron-collapse> - </div> - </template> -</if> - </cr-dialog> - </template> - <script src="signout_dialog.js"></script> -</dom-module> diff --git a/chromium/chrome/browser/resources/settings/people_page/signout_dialog.js b/chromium/chrome/browser/resources/settings/people_page/signout_dialog.js deleted file mode 100644 index e9ea0fe55e2..00000000000 --- a/chromium/chrome/browser/resources/settings/people_page/signout_dialog.js +++ /dev/null @@ -1,121 +0,0 @@ -// 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 'settings-signout-dialog' is a dialog that allows the - * user to turn off sync and sign out of Chromium. - */ -Polymer({ - is: 'settings-signout-dialog', - - behaviors: [WebUIListenerBehavior], - - properties: { - /** - * The current sync status, supplied by the parent. - * @type {?settings.SyncStatus} - */ - syncStatus: { - type: Object, - observer: 'syncStatusChanged_', - }, - - /** - * True if the checkbox to delete the profile has been checked. - * @private - */ - deleteProfile_: Boolean, - - /** - * True if the profile deletion warning is visible. - * @private - */ - deleteProfileWarningVisible_: Boolean, - - /** - * The profile deletion warning. The message indicates the number of - * profile stats that will be deleted if a non-zero count for the profile - * stats is returned from the browser. - * @private - */ - deleteProfileWarning_: String, - }, - - /** @override */ - attached: function() { - this.addWebUIListener( - 'profile-stats-count-ready', this.handleProfileStatsCount_.bind(this)); - // <if expr="not chromeos"> - settings.ProfileInfoBrowserProxyImpl.getInstance().getProfileStatsCount(); - // </if> - this.async(() => { - this.$.dialog.showModal(); - }); - }, - - /** - * Returns true when the user selected 'Confirm'. - * @return {boolean} - */ - wasConfirmed: function() { - return this.$.dialog.getNative().returnValue == 'success'; - }, - - /** - * Handler for when the profile stats count is pushed from the browser. - * @param {number} count - * @private - */ - handleProfileStatsCount_: function(count) { - const username = this.syncStatus.signedInUsername || ''; - if (count == 0) { - this.deleteProfileWarning_ = loadTimeData.getStringF( - 'deleteProfileWarningWithoutCounts', username); - } else if (count == 1) { - this.deleteProfileWarning_ = loadTimeData.getStringF( - 'deleteProfileWarningWithCountsSingular', username); - } else { - this.deleteProfileWarning_ = loadTimeData.getStringF( - 'deleteProfileWarningWithCountsPlural', count, username); - } - }, - - /** - * Polymer observer for syncStatus. - * @private - */ - syncStatusChanged_: function() { - if (!this.syncStatus.signedIn && this.$.dialog.open) { - this.$.dialog.close(); - } - }, - - /** - * @private - * @param {string} domain - * @return {string} - */ - getDisconnectExplanationHtml_: function(domain) { - // <if expr="not chromeos"> - if (domain) { - return loadTimeData.getStringF( - 'syncDisconnectManagedProfileExplanation', - '<span id="managed-by-domain-name">' + domain + '</span>'); - } - // </if> - return loadTimeData.getString('syncDisconnectExplanation'); - }, - - /** @private */ - onDisconnectCancel_: function() { - this.$.dialog.cancel(); - }, - - /** @private */ - onDisconnectConfirm_: function() { - this.$.dialog.close(); - const deleteProfile = !!this.syncStatus.domain || this.deleteProfile_; - settings.SyncBrowserProxyImpl.getInstance().signOut(deleteProfile); - }, -}); diff --git a/chromium/chrome/browser/resources/settings/people_page/sync_account_control.html b/chromium/chrome/browser/resources/settings/people_page/sync_account_control.html deleted file mode 100644 index e299214c6b6..00000000000 --- a/chromium/chrome/browser/resources/settings/people_page/sync_account_control.html +++ /dev/null @@ -1,245 +0,0 @@ -<link rel="import" href="chrome://resources/html/polymer.html"> - -<link rel="import" href="chrome://resources/cr_elements/cr_action_menu/cr_action_menu.html"> -<link rel="import" href="chrome://resources/cr_elements/cr_button/cr_button.html"> -<link rel="import" href="chrome://resources/cr_elements/cr_icon_button/cr_icon_button.html"> -<link rel="import" href="chrome://resources/cr_elements/icons.html"> -<link rel="import" href="chrome://resources/cr_elements/shared_vars_css.html"> -<link rel="import" href="chrome://resources/html/web_ui_listener_behavior.html"> -<link rel="import" href="chrome://resources/polymer/v1_0/iron-icon/iron-icon.html"> -<link rel="import" href="profile_info_browser_proxy.html"> -<link rel="import" href="sync_browser_proxy.html"> -<link rel="import" href="../i18n_setup.html"> -<link rel="import" href="../icons.html"> -<link rel="import" href="../route.html"> -<link rel="import" href="../settings_shared_css.html"> - -<dom-module id="settings-sync-account-control"> - <template> - <style include="settings-shared"> - :host { - --shown-avatar-size: 40px; - --sync-icon-border-size: 2px; - --sync-icon-size: 16px; - } - - setting-box.middle { - /* Per spec, middle text is indented 20px in this section. */ - margin-inline-start: 20px; - } - - .account-icon { - border-radius: 20px; - flex-shrink: 0; - height: var(--shown-avatar-size); - width: var(--shown-avatar-size); - } - - .account-icon.small { - height: 20px; - width: 20px; - } - - #menu .dropdown-item { - padding: 12px; - } - - #menu .dropdown-item span { - margin-inline-start: 8px; - } - - .flex { - display: flex; - flex: 1; - flex-direction: column; - } - - #avatar-container { - height: var(--shown-avatar-size); - position: relative; - } - - #sync-icon-container { - align-items: center; - background: var(--google-green-700); - border: var(--sync-icon-border-size) solid white; - border-radius: 50%; - display: flex; - height: var(--sync-icon-size); - position: absolute; - right: -6px; - top: calc(var(--shown-avatar-size) - var(--sync-icon-size) - - var(--sync-icon-border-size)); - width: var(--sync-icon-size); - } - - :host-context([dir='rtl']) #sync-icon-container { - left: -6px; - right: initial; - } - - @media (prefers-color-scheme: dark) { - #sync-icon-container { - background: var(--google-green-refresh-300); - border-color: var(--google-grey-900); - } - } - - #sync-icon-container.sync-problem { - background: var(--settings-error-color); - } - - #sync-icon-container.sync-paused { - background: var(--google-blue-500); - } - - @media (prefers-color-scheme: dark) { - #sync-icon-container.sync-paused { - background: var(--google-blue-refresh-300); - } - } - - #sync-icon-container.sync-disabled { - background: var(--google-grey-400); - } - - @media (prefers-color-scheme: dark) { - #sync-icon-container.sync-disabled { - background: var(--google-grey-refresh-500); - } - } - - #sync-icon-container iron-icon { - fill: white; /* Same in light and dark modes. */ - height: 12px; - margin: auto; - width: 12px; - } - - #sign-in { - margin: auto 8px; - min-width: 100px; - } - - #banner { - background: url(../images/sync_banner.svg) no-repeat; - background-size: 100% auto; - display: none; - padding-top: calc(120 / 680 * 100%); /* Keep background ratio. */ - } - - @media (prefers-color-scheme: dark) { - #banner { - background-image: url(../images/sync_banner_dark.svg); - } - } - - :host([showing-promo]) #banner { - display: block; - } - </style> - <div id="banner" hidden="[[syncStatus.signedIn]]" part="banner"></div> - <div class$="settings-box first - [[getPromoHeaderClass_(subLabel_)]]" - id="promo-header" hidden="[[syncStatus.signedIn]]"> - <div class="start settings-box-text"> - <div id="promo-title" part="title"> - [[getLabel_(promoLabelWithAccount, - promoLabelWithNoAccount, shownAccount_)]] - </div> - <div class="secondary">[[subLabel_]]</div> - </div> - <cr-button class="action-button" on-click="onSigninTap_" - disabled="[[syncStatus.firstSetupInProgress]]" id="sign-in" - hidden="[[shouldShowAvatarRow_]]"> - $i18n{peopleSignIn} - </cr-button> - </div> - <template is="dom-if" if="[[shouldShowAvatarRow_]]"> - <div class="settings-box first two-line" id="avatar-row"> - <div id="avatar-container"> - <img class="account-icon" alt="" - src="[[getAccountImageSrc_(shownAccount_.avatarImage)]]"> - <div id="sync-icon-container" hidden="[[!syncStatus.signedIn]]" - class$="[[getSyncIconStyle_( - syncStatus.hasError, syncStatus.statusAction, - syncStatus.disabled)]]"> - <iron-icon icon$="[[getSyncIcon_( - syncStatus.hasError, syncStatus.statusAction, - syncStatus.disabled)]]"></iron-icon> - </div> - </div> - <div class="middle two-line no-min-width"> - <div class="flex text-elide settings-box-text" id="user-info"> - <span> - [[getAvatarRowTitle_(shownAccount_.fullName, - '$i18nPolymer{syncNotWorking}', '$i18nPolymer{syncPaused}', - '$i18nPolymer{syncDisabled}', syncStatus.hasError, - syncStatus.statusAction, syncStatus.disabled)]] - </span> - <div class="secondary"> - [[getAccountLabel_( - '$i18nPolymer{syncingTo}', shownAccount_.email, - syncStatus.hasError, syncStatus.signedIn, - syncStatus.disabled, syncStatus.firstSetupInProgress, - unifiedConsentEnabled)]] - </div> - </div> - </div> - <cr-icon-button class="icon-arrow-dropdown" - hidden="[[syncStatus.signedIn]]" on-click="onMenuButtonTap_" - id="dropdown-arrow" aria-label="$i18n{useAnotherAccount}"> - </cr-icon-button> - <div class="separator" hidden="[[syncStatus.signedIn]]"></div> - <cr-button id="sync-button" class="action-button" - hidden="[[syncStatus.signedIn]]" on-click="onSyncButtonTap_" - disabled="[[syncStatus.firstSetupInProgress]]"> - $i18n{peopleSignIn} - </cr-button> - <cr-button id="turn-off" - hidden="[[!shouldShowTurnOffButton_(syncStatus.signedIn, - showSetupButtons_)]]" - on-click="onTurnOffButtonTap_" - disabled="[[syncStatus.firstSetupInProgress]]"> - $i18n{turnOffSync} - </cr-button> - <cr-button id="sync-error-button" class="action-button" - hidden="[[!shouldShowErrorActionButton_(syncStatus, - showSetupButtons_)]]" - on-click="onErrorButtonTap_" - disabled="[[syncStatus.firstSetupInProgress]]"> - [[syncStatus.statusActionText]] - </cr-button> - <div id="setup-buttons" hidden="[[!showSetupButtons_]]"> - <cr-button on-click="onSetupCancel_">$i18n{cancel}</cr-button> - <cr-button class="action-button" on-click="onSetupConfirm_"> - $i18n{confirm} - </cr-button> - </div> - </div> - <template is="dom-if" if="[[!syncStatus.signedIn]]" restamp> - <cr-action-menu id="menu" auto-reposition> - <template is="dom-repeat" items="[[storedAccounts_]]"> - <button class="dropdown-item" on-click="onAccountTap_"> - <img class="account-icon small" alt="" - src="[[getAccountImageSrc_(item.avatarImage)]]"> - <span>[[item.email]]</span> - </button> - </template> - <button class="dropdown-item" on-click="onSigninTap_" - disabled="[[syncStatus.firstSetupInProgress]]" id="sign-in-item"> - <img class="account-icon small" alt="" - src="chrome://theme/IDR_PROFILE_AVATAR_PLACEHOLDER_LARGE"> - <span>$i18n{useAnotherAccount}</span> - </button> - <button class="dropdown-item" on-click="onSignoutTap_" - disabled="[[syncStatus.firstSetupInProgress]]" id="sign-out-item"> - <iron-icon icon="settings:exit-to-app"></iron-icon> - <span>$i18n{peopleSignOut}</span> - </button> - </cr-action-menu> - </template> - </template> - </template> - <script src="sync_account_control.js"></script> -</dom-module> diff --git a/chromium/chrome/browser/resources/settings/people_page/sync_account_control.js b/chromium/chrome/browser/resources/settings/people_page/sync_account_control.js deleted file mode 100644 index eb455364aff..00000000000 --- a/chromium/chrome/browser/resources/settings/people_page/sync_account_control.js +++ /dev/null @@ -1,471 +0,0 @@ -// 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 - * 'settings-sync-account-section' is the settings page containing sign-in - * settings. - */ -cr.exportPath('settings'); - -/** @const {number} */ -settings.MAX_SIGNIN_PROMO_IMPRESSION = 10; - -Polymer({ - is: 'settings-sync-account-control', - behaviors: [WebUIListenerBehavior], - properties: { - /** - * The current sync status, supplied by parent element. - * @type {!settings.SyncStatus} - */ - syncStatus: Object, - - // String to be used as a title when the promo has an account. - promoLabelWithAccount: String, - - // String to be used as title of the promo has no account. - promoLabelWithNoAccount: String, - - // String to be used as a subtitle when the promo has an account. - promoSecondaryLabelWithAccount: String, - - // String to be used as subtitle of the promo has no account. - promoSecondaryLabelWithNoAccount: String, - - /** - * Proxy variable for syncStatus.signedIn to shield observer from being - * triggered multiple times whenever syncStatus changes. - * @private {boolean} - */ - signedIn_: { - type: Boolean, - computed: 'computeSignedIn_(syncStatus.signedIn)', - observer: 'onSignedInChanged_', - }, - - /** @private {!Array<!settings.StoredAccount>} */ - storedAccounts_: Object, - - /** @private {?settings.StoredAccount} */ - shownAccount_: Object, - - showingPromo: { - type: Boolean, - value: false, - reflectToAttribute: true, - }, - - // This property should be set by the parent only and should not change - // after the element is created. - embeddedInSubpage: { - type: Boolean, - reflectToAttribute: true, - }, - - // This property should be set by the parent only and should not change - // after the element is created. - hideButtons: { - type: Boolean, - value: false, - reflectToAttribute: true, - }, - - /** @private {boolean} */ - shouldShowAvatarRow_: { - type: Boolean, - value: false, - computed: 'computeShouldShowAvatarRow_(storedAccounts_, syncStatus,' + - 'storedAccounts_.length, syncStatus.signedIn)', - observer: 'onShouldShowAvatarRowChange_', - }, - - /** @private */ - subLabel_: { - type: String, - computed: 'computeSubLabel_(promoSecondaryLabelWithAccount,' + - 'promoSecondaryLabelWithNoAccount, shownAccount_)', - }, - - unifiedConsentEnabled: Boolean, - - /** @private */ - showSetupButtons_: { - type: Boolean, - computed: 'computeShowSetupButtons_(unifiedConsentEnabled,' + - 'hideButtons, syncStatus.firstSetupInProgress)', - }, - }, - - observers: [ - 'onShownAccountShouldChange_(storedAccounts_, syncStatus)', - ], - - /** @private {?settings.SyncBrowserProxy} */ - syncBrowserProxy_: null, - - created: function() { - this.syncBrowserProxy_ = settings.SyncBrowserProxyImpl.getInstance(); - }, - - /** @override */ - attached: function() { - this.syncBrowserProxy_.getStoredAccounts().then( - this.handleStoredAccounts_.bind(this)); - this.addWebUIListener( - 'stored-accounts-updated', this.handleStoredAccounts_.bind(this)); - }, - - /** - * Records the following user actions: - * - Signin_Impression_FromSettings and - * - Signin_ImpressionWithAccount_FromSettings - * - Signin_ImpressionWithNoAccount_FromSettings - * @private - */ - recordImpressionUserActions_: function() { - assert(!this.syncStatus.signedIn); - assert(this.shownAccount_ !== undefined); - - chrome.metricsPrivate.recordUserAction('Signin_Impression_FromSettings'); - if (this.shownAccount_) { - chrome.metricsPrivate.recordUserAction( - 'Signin_ImpressionWithAccount_FromSettings'); - } else { - chrome.metricsPrivate.recordUserAction( - 'Signin_ImpressionWithNoAccount_FromSettings'); - } - }, - - /** - * @return {boolean} - * @private - */ - computeSignedIn_: function() { - return !!this.syncStatus && !!this.syncStatus.signedIn; - }, - - /** @private */ - onSignedInChanged_: function() { - if (this.embeddedInSubpage) { - this.showingPromo = true; - return; - } - - if (!this.showingPromo && !this.syncStatus.signedIn && - this.syncBrowserProxy_.getPromoImpressionCount() < - settings.MAX_SIGNIN_PROMO_IMPRESSION) { - this.showingPromo = true; - this.syncBrowserProxy_.incrementPromoImpressionCount(); - } else { - // Turn off the promo if the user is signed in. - this.showingPromo = false; - } - if (!this.syncStatus.signedIn && this.shownAccount_ !== undefined) { - this.recordImpressionUserActions_(); - } - }, - - /** - * @param {string} labelWithAccount - * @param {string} labelWithNoAccount - * @return {string} - * @private - */ - getLabel_: function(labelWithAccount, labelWithNoAccount) { - return this.shownAccount_ ? labelWithAccount : labelWithNoAccount; - }, - - /** - * @return {string} - * @private - */ - computeSubLabel_: function() { - return this.getLabel_(this.promoSecondaryLabelWithAccount, - this.promoSecondaryLabelWithNoAccount); - }, - - /** - * @return {string} - * @private - */ - getPromoHeaderClass_: function() { - return this.subLabel_ ? 'two-line' : ''; - }, - - /** - * @param {string} label - * @param {string} name - * @return {string} - * @private - */ - getSubstituteLabel_: function(label, name) { - return loadTimeData.substituteString(label, name); - }, - - /** - * @param {string} label - * @param {string} account - * @return {string} - * @private - */ - getAccountLabel_: function(label, account) { - if (this.unifiedConsentEnabled && this.syncStatus.firstSetupInProgress) { - return this.syncStatus.statusText || account; - } - return this.syncStatus.signedIn && !this.syncStatus.hasError && - !this.syncStatus.disabled ? - loadTimeData.substituteString(label, account) : - account; - }, - - /** - * @param {?string} image - * @return {string} - * @private - */ - getAccountImageSrc_: function(image) { - // image can be undefined if the account has not set an avatar photo. - return image || 'chrome://theme/IDR_PROFILE_AVATAR_PLACEHOLDER_LARGE'; - }, - - /** - * Returns the class of the sync icon. - * @return {string} - * @private - */ - getSyncIconStyle_: function() { - if (this.syncStatus.hasUnrecoverableError) { - return 'sync-problem'; - } - if (this.syncStatus.hasError) { - return this.syncStatus.statusAction == - settings.StatusAction.REAUTHENTICATE ? - 'sync-paused' : - 'sync-problem'; - } - if (this.syncStatus.disabled) { - return 'sync-disabled'; - } - return 'sync'; - }, - - /** - * Returned value must match one of iron-icon's settings:(*) icon name. - * @return {string} - * @private - */ - getSyncIcon_: function() { - switch (this.getSyncIconStyle_()) { - case 'sync-problem': - return 'settings:sync-problem'; - case 'sync-paused': - return 'settings:sync-disabled'; - default: - return 'cr:sync'; - } - }, - - /** - * @return {string} - * @private - */ - getAvatarRowTitle_: function( - accountName, syncErrorLabel, authErrorLabel, disabledLabel) { - switch (this.getSyncIconStyle_()) { - case 'sync-problem': - return syncErrorLabel; - case 'sync-paused': - return authErrorLabel; - case 'sync-disabled': - return disabledLabel; - default: - return accountName; - } - }, - - /** - * @return {boolean} - * @private - */ - shouldShowTurnOffButton_: function() { - return !this.hideButtons && !this.showSetupButtons_ && - !!this.syncStatus.signedIn; - }, - - /** - * @return {boolean} - * @private - */ - shouldShowErrorActionButton_: function() { - if (this.embeddedInSubpage && - this.syncStatus.statusAction == - settings.StatusAction.ENTER_PASSPHRASE) { - // In a subpage the passphrase button is not required. - return false; - } - return !this.hideButtons && !this.showSetupButtons_ && - !!this.syncStatus.signedIn && !!this.syncStatus.hasError && - this.syncStatus.statusAction != settings.StatusAction.NO_ACTION; - }, - - /** - * @param {!Array<!settings.StoredAccount>} accounts - * @private - */ - handleStoredAccounts_: function(accounts) { - this.storedAccounts_ = accounts; - }, - - /** - * @return {boolean} - * @private - */ - computeShouldShowAvatarRow_: function() { - if (this.storedAccounts_ === undefined || this.syncStatus === undefined) { - return false; - } - - return this.syncStatus.signedIn || this.storedAccounts_.length > 0; - }, - - /** @private */ - onErrorButtonTap_: function() { - switch (this.syncStatus.statusAction) { - case settings.StatusAction.REAUTHENTICATE: - this.syncBrowserProxy_.startSignIn(); - break; - case settings.StatusAction.SIGNOUT_AND_SIGNIN: - if (this.syncStatus.domain) { - settings.navigateTo(settings.routes.SIGN_OUT); - } else { - // Silently sign the user out without deleting their profile and - // prompt them to sign back in. - this.syncBrowserProxy_.signOut(false); - this.syncBrowserProxy_.startSignIn(); - } - break; - case settings.StatusAction.UPGRADE_CLIENT: - settings.navigateTo(settings.routes.ABOUT); - break; - case settings.StatusAction.ENTER_PASSPHRASE: - case settings.StatusAction.CONFIRM_SYNC_SETTINGS: - default: - settings.navigateTo(settings.routes.SYNC); - } - }, - - /** @private */ - onSigninTap_: function() { - this.syncBrowserProxy_.startSignIn(); - // Need to close here since one menu item also triggers this function. - if (this.$$('#menu')) { - /** @type {!CrActionMenuElement} */ (this.$$('#menu')).close(); - } - }, - - /** @private */ - onSignoutTap_: function() { - this.syncBrowserProxy_.signOut(false /* deleteProfile */); - /** @type {!CrActionMenuElement} */ (this.$$('#menu')).close(); - }, - - /** @private */ - onSyncButtonTap_: function() { - assert(this.shownAccount_); - assert(this.storedAccounts_.length > 0); - const isDefaultPromoAccount = - (this.shownAccount_.email == this.storedAccounts_[0].email); - - this.syncBrowserProxy_.startSyncingWithEmail( - this.shownAccount_.email, isDefaultPromoAccount); - }, - - /** @private */ - onTurnOffButtonTap_: function() { - /* This will route to people_page's disconnect dialog. */ - settings.navigateTo(settings.routes.SIGN_OUT); - }, - - /** @private */ - onMenuButtonTap_: function() { - const actionMenu = - /** @type {!CrActionMenuElement} */ (this.$$('#menu')); - actionMenu.showAt(assert(this.$$('#dropdown-arrow'))); - }, - - /** @private */ - onShouldShowAvatarRowChange_: function() { - // Close dropdown when avatar-row hides, so if it appears again, the menu - // won't be open by default. - const actionMenu = this.$$('#menu'); - if (!this.shouldShowAvatarRow_ && actionMenu && actionMenu.open) { - actionMenu.close(); - } - }, - - /** - * @param {!{model: - * !{item: !settings.StoredAccount}, - * }} e - * @private - */ - onAccountTap_: function(e) { - this.shownAccount_ = e.model.item; - /** @type {!CrActionMenuElement} */ (this.$$('#menu')).close(); - }, - - /** @private */ - onShownAccountShouldChange_: function() { - if (this.storedAccounts_ === undefined || this.syncStatus === undefined) { - return; - } - - if (this.syncStatus.signedIn) { - for (let i = 0; i < this.storedAccounts_.length; i++) { - if (this.storedAccounts_[i].email == this.syncStatus.signedInUsername) { - this.shownAccount_ = this.storedAccounts_[i]; - return; - } - } - } else { - const firstStoredAccount = - (this.storedAccounts_.length > 0) ? this.storedAccounts_[0] : null; - - // Sign-in impressions should be recorded in the following cases: - // 1. When the promo is first shown, i.e. when |shownAccount_| is - // initialized; - // 2. When the impression account state changes, i.e. promo impression - // state changes (WithAccount -> WithNoAccount) or - // (WithNoAccount -> WithAccount). - const shouldRecordImpression = (this.shownAccount_ === undefined) || - (!this.shownAccount_ && firstStoredAccount) || - (this.shownAccount_ && !firstStoredAccount); - - this.shownAccount_ = firstStoredAccount; - - if (shouldRecordImpression) { - this.recordImpressionUserActions_(); - } - } - }, - - /** - * @return {boolean} - * @private - */ - computeShowSetupButtons_: function() { - return !this.hideButtons && !!this.unifiedConsentEnabled && - !!this.syncStatus.firstSetupInProgress; - }, - - /** @private */ - onSetupCancel_: function() { - this.fire('sync-setup-done', false); - }, - - /** @private */ - onSetupConfirm_: function() { - this.fire('sync-setup-done', true); - }, -}); diff --git a/chromium/chrome/browser/resources/settings/people_page/sync_browser_proxy.html b/chromium/chrome/browser/resources/settings/people_page/sync_browser_proxy.html deleted file mode 100644 index 1770408e3bc..00000000000 --- a/chromium/chrome/browser/resources/settings/people_page/sync_browser_proxy.html +++ /dev/null @@ -1,3 +0,0 @@ -<link rel="import" href="../i18n_setup.html"> -<link rel="import" href="chrome://resources/html/cr.html"> -<script src="sync_browser_proxy.js"></script> diff --git a/chromium/chrome/browser/resources/settings/people_page/sync_browser_proxy.js b/chromium/chrome/browser/resources/settings/people_page/sync_browser_proxy.js deleted file mode 100644 index 340398c2a47..00000000000 --- a/chromium/chrome/browser/resources/settings/people_page/sync_browser_proxy.js +++ /dev/null @@ -1,324 +0,0 @@ -// Copyright 2016 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 from the the People section to get the - * status of the sync backend and user preferences on what data to sync. Used - * for both Chrome browser and ChromeOS. - */ -cr.exportPath('settings'); - -/** - * @typedef {{fullName: (string|undefined), - * givenName: (string|undefined), - * email: string, - * avatarImage: (string|undefined)}} - * @see chrome/browser/ui/webui/settings/people_handler.cc - */ -settings.StoredAccount; - -/** - * @typedef {{childUser: (boolean|undefined), - * disabled: (boolean|undefined), - * domain: (string|undefined), - * hasError: (boolean|undefined), - * hasUnrecoverableError: (boolean|undefined), - * managed: (boolean|undefined), - * firstSetupInProgress: (boolean|undefined), - * signedIn: (boolean|undefined), - * signedInUsername: (string|undefined), - * signinAllowed: (boolean|undefined), - * statusAction: (!settings.StatusAction), - * statusActionText: (string|undefined), - * statusText: (string|undefined), - * supervisedUser: (boolean|undefined), - * syncSystemEnabled: (boolean|undefined)}} - * @see chrome/browser/ui/webui/settings/people_handler.cc - */ -settings.SyncStatus; - - -/** - * Must be kept in sync with the return values of getSyncErrorAction in - * chrome/browser/ui/webui/settings/people_handler.cc - * @enum {string} - */ -settings.StatusAction = { - NO_ACTION: 'noAction', // No action to take. - REAUTHENTICATE: 'reauthenticate', // User needs to reauthenticate. - SIGNOUT_AND_SIGNIN: - 'signOutAndSignIn', // User needs to sign out and sign in. - UPGRADE_CLIENT: 'upgradeClient', // User needs to upgrade the client. - ENTER_PASSPHRASE: 'enterPassphrase', // User needs to enter passphrase. - CONFIRM_SYNC_SETTINGS: - 'confirmSyncSettings', // User needs to confirm sync settings. -}; - -/** - * The state of sync. This is the data structure sent back and forth between - * C++ and JS. Its naming and structure is not optimal, but changing it would - * require changes to the C++ handler, which is already functional. - * @typedef {{ - * appsEnforced: boolean, - * appsRegistered: boolean, - * appsSynced: boolean, - * autofillEnforced: boolean, - * autofillRegistered: boolean, - * autofillSynced: boolean, - * bookmarksEnforced: boolean, - * bookmarksRegistered: boolean, - * bookmarksSynced: boolean, - * encryptAllData: boolean, - * encryptAllDataAllowed: boolean, - * enterPassphraseBody: (string|undefined), - * extensionsEnforced: boolean, - * extensionsRegistered: boolean, - * extensionsSynced: boolean, - * fullEncryptionBody: string, - * passphrase: (string|undefined), - * passphraseRequired: boolean, - * passwordsEnforced: boolean, - * passwordsRegistered: boolean, - * passwordsSynced: boolean, - * paymentsIntegrationEnabled: boolean, - * preferencesEnforced: boolean, - * preferencesRegistered: boolean, - * preferencesSynced: boolean, - * setNewPassphrase: (boolean|undefined), - * syncAllDataTypes: boolean, - * tabsEnforced: boolean, - * tabsRegistered: boolean, - * tabsSynced: boolean, - * themesEnforced: boolean, - * themesRegistered: boolean, - * themesSynced: boolean, - * typedUrlsEnforced: boolean, - * typedUrlsRegistered: boolean, - * typedUrlsSynced: boolean, - * wifiConfigurationsEnforced: boolean, - * wifiConfigurationsRegistered: boolean, - * wifiConfigurationsSynced: boolean, - * }} - */ -settings.SyncPrefs; - -/** - * @enum {string} - */ -settings.PageStatus = { - SPINNER: 'spinner', // Before the page has loaded. - CONFIGURE: 'configure', // Preferences ready to be configured. - TIMEOUT: 'timeout', // Preferences loading has timed out. - DONE: 'done', // Sync subpage can be closed now. - PASSPHRASE_FAILED: 'passphraseFailed', // Error in the passphrase. -}; - -cr.define('settings', function() { - /** - * Key to be used with localStorage. - * @type {string} - */ - const PROMO_IMPRESSION_COUNT_KEY = 'signin-promo-count'; - - /** @interface */ - class SyncBrowserProxy { - // <if expr="not chromeos"> - /** - * Starts the signin process for the user. Does nothing if the user is - * already signed in. - */ - startSignIn() {} - - /** - * Signs out the signed-in user. - * @param {boolean} deleteProfile - */ - signOut(deleteProfile) {} - - /** - * Invalidates the Sync token without signing the user out. - */ - pauseSync() {} - - /** - * @return {number} the number of times the sync account promo was shown. - */ - getPromoImpressionCount() {} - - /** - * Increment the number of times the sync account promo was shown. - */ - incrementPromoImpressionCount() {} - - // </if> - - // <if expr="chromeos"> - /** - * Signs the user out. - */ - attemptUserExit() {} - - // </if> - - /** - * Gets the current sync status. - * @return {!Promise<!settings.SyncStatus>} - */ - getSyncStatus() {} - - /** - * Gets a list of stored accounts. - * @return {!Promise<!Array<!settings.StoredAccount>>} - */ - getStoredAccounts() {} - - /** - * Function to invoke when the sync page has been navigated to. This - * registers the UI as the "active" sync UI so that if the user tries to - * open another sync UI, this one will be shown instead. - */ - didNavigateToSyncPage() {} - - /** - * Function to invoke when leaving the sync page so that the C++ layer can - * be notified that the sync UI is no longer open. - * @param {boolean} didAbort - */ - didNavigateAwayFromSyncPage(didAbort) {} - - /** - * Sets which types of data to sync. - * @param {!settings.SyncPrefs} syncPrefs - * @return {!Promise<!settings.PageStatus>} - */ - setSyncDatatypes(syncPrefs) {} - - /** - * Sets the sync encryption options. - * @param {!settings.SyncPrefs} syncPrefs - * @return {!Promise<!settings.PageStatus>} - */ - setSyncEncryption(syncPrefs) {} - - /** - * Start syncing with an account, specified by its email. - * |isDefaultPromoAccount| is true if |email| is the email of the default - * account displayed in the promo. - * @param {string} email - * @param {boolean} isDefaultPromoAccount - */ - startSyncingWithEmail(email, isDefaultPromoAccount) {} - - /** - * Opens the Google Activity Controls url in a new tab. - */ - openActivityControlsUrl() {} - - /** - * Function to dispatch event sync-prefs-changed even without a change. - * This is used to decide whether we should show the link to password - * manager in passwords section on page load. - */ - sendSyncPrefsChanged() {} - } - - /** - * @implements {settings.SyncBrowserProxy} - */ - class SyncBrowserProxyImpl { - // <if expr="not chromeos"> - /** @override */ - startSignIn() { - chrome.send('SyncSetupStartSignIn'); - } - - /** @override */ - signOut(deleteProfile) { - chrome.send('SyncSetupSignout', [deleteProfile]); - } - - /** @override */ - pauseSync() { - chrome.send('SyncSetupPauseSync'); - } - - /** @override */ - getPromoImpressionCount() { - return parseInt( - window.localStorage.getItem(PROMO_IMPRESSION_COUNT_KEY), 10) || - 0; - } - - /** @override */ - incrementPromoImpressionCount() { - window.localStorage.setItem( - PROMO_IMPRESSION_COUNT_KEY, - (this.getPromoImpressionCount() + 1).toString()); - } - - // </if> - // <if expr="chromeos"> - /** @override */ - attemptUserExit() { - return chrome.send('AttemptUserExit'); - } - // </if> - - /** @override */ - getSyncStatus() { - return cr.sendWithPromise('SyncSetupGetSyncStatus'); - } - - /** @override */ - getStoredAccounts() { - return cr.sendWithPromise('SyncSetupGetStoredAccounts'); - } - - /** @override */ - didNavigateToSyncPage() { - chrome.send('SyncSetupShowSetupUI'); - } - - /** @override */ - didNavigateAwayFromSyncPage(didAbort) { - chrome.send('SyncSetupDidClosePage', [didAbort]); - } - - /** @override */ - setSyncDatatypes(syncPrefs) { - return cr.sendWithPromise( - 'SyncSetupSetDatatypes', JSON.stringify(syncPrefs)); - } - - /** @override */ - setSyncEncryption(syncPrefs) { - return cr.sendWithPromise( - 'SyncSetupSetEncryption', JSON.stringify(syncPrefs)); - } - - /** @override */ - startSyncingWithEmail(email, isDefaultPromoAccount) { - chrome.send( - 'SyncSetupStartSyncingWithEmail', [email, isDefaultPromoAccount]); - } - - /** @override */ - openActivityControlsUrl() { - chrome.metricsPrivate.recordUserAction( - 'Signin_AccountSettings_GoogleActivityControlsClicked'); - } - - /** @override */ - sendSyncPrefsChanged() { - chrome.send('SyncPrefsDispatch'); - } - } - - cr.addSingletonGetter(SyncBrowserProxyImpl); - - return { - SyncBrowserProxy: SyncBrowserProxy, - SyncBrowserProxyImpl: SyncBrowserProxyImpl, - }; -}); diff --git a/chromium/chrome/browser/resources/settings/people_page/sync_controls.html b/chromium/chrome/browser/resources/settings/people_page/sync_controls.html deleted file mode 100644 index 85151dcf0e4..00000000000 --- a/chromium/chrome/browser/resources/settings/people_page/sync_controls.html +++ /dev/null @@ -1,185 +0,0 @@ -<link rel="import" href="chrome://resources/html/polymer.html"> - -<link rel="import" href="chrome://resources/html/util.html"> -<link rel="import" href="chrome://resources/html/web_ui_listener_behavior.html"> -<link rel="import" href="chrome://resources/cr_elements/cr_toggle/cr_toggle.html"> -<link rel="import" href="chrome://resources/cr_elements/shared_vars_css.html"> -<link rel="import" href="sync_browser_proxy.html"> -<link rel="import" href="../route.html"> -<link rel="import" href="../settings_shared_css.html"> - -<dom-module id="settings-sync-controls"> - <template> - <style include="settings-shared"> - #sync-data-types .list-item:not([hidden]) ~ .list-item:not([hidden]) { - border-top: var(--cr-separator-line); - } - - .list-item { - display: flex; - } - - .list-item > div { - flex: 1; - } - </style> - <div class="settings-box first"> - <div id="syncEverythingCheckboxLabel" class="start"> - $i18n{syncEverythingCheckboxLabel} - </div> - <cr-toggle id="syncAllDataTypesControl" - checked="{{syncPrefs.syncAllDataTypes}}" - on-change="onSyncAllDataTypesChanged_" - aria-labelledby="syncEverythingCheckboxLabel"> - </cr-toggle> - </div> - - <div class="list-frame" id="sync-data-types"> - <div class="list-item" hidden="[[!syncPrefs.appsRegistered]]"> - <div id="appCheckboxLabel"> - $i18n{appCheckboxLabel} - </div> - <cr-toggle checked="{{syncPrefs.appsSynced}}" - on-change="onSingleSyncDataTypeChanged_" - disabled="[[shouldSyncCheckboxBeDisabled_( - syncPrefs.syncAllDataTypes, syncPrefs.appsEnforced)]]" - aria-labelledby="appCheckboxLabel"> - </cr-toggle> - </div> - - <div class="list-item" hidden="[[!syncPrefs.bookmarksRegistered]]"> - <div id="bookmarksCheckboxLabel"> - $i18n{bookmarksCheckboxLabel} - </div> - <cr-toggle checked="{{syncPrefs.bookmarksSynced}}" - on-change="onSingleSyncDataTypeChanged_" - disabled="[[shouldSyncCheckboxBeDisabled_( - syncPrefs.syncAllDataTypes, syncPrefs.bookmarksEnforced)]]" - aria-labelledby="bookmarksCheckboxLabel"> - </cr-toggle> - </div> - - <div class="list-item" hidden="[[!syncPrefs.extensionsRegistered]]"> - <div id="extensionsCheckboxLabel"> - $i18n{extensionsCheckboxLabel} - </div> - <cr-toggle checked="{{syncPrefs.extensionsSynced}}" - on-change="onSingleSyncDataTypeChanged_" - disabled="[[shouldSyncCheckboxBeDisabled_( - syncPrefs.syncAllDataTypes, syncPrefs.extensionsEnforced)]]" - aria-labelledby="extensionsCheckboxLabel"> - </cr-toggle> - </div> - - <div class="list-item" hidden="[[!syncPrefs.typedUrlsRegistered]]"> - <div id="historyCheckboxLabel"> - $i18n{historyCheckboxLabel} - </div> - <!-- TypedUrls has a special on-change handler to deal with user - events. --> - <cr-toggle id="historyToggle" - checked="{{syncPrefs.typedUrlsSynced}}" - on-change="onTypedUrlsDataTypeChanged_" - disabled="[[shouldSyncCheckboxBeDisabled_( - syncPrefs.syncAllDataTypes, syncPrefs.typedUrlsEnforced)]]" - aria-labelledby="historyCheckboxLabel"> - </cr-toggle> - </div> - - <div class="list-item" hidden="[[!syncPrefs.preferencesRegistered]]"> - <div id="settingsCheckboxLabel"> - $i18n{settingsCheckboxLabel} - </div> - <cr-toggle checked="{{syncPrefs.preferencesSynced}}" - on-change="onSingleSyncDataTypeChanged_" - disabled="[[shouldSyncCheckboxBeDisabled_( - syncPrefs.syncAllDataTypes, - syncPrefs.preferencesEnforced)]]" - aria-labelledby="settingsCheckboxLabel"> - </cr-toggle> - </div> - - <div class="list-item" hidden="[[!syncPrefs.themesRegistered]]"> - <div id="themesAndWallpapersCheckboxLabel"> - $i18n{themesAndWallpapersCheckboxLabel} - </div> - <cr-toggle checked="{{syncPrefs.themesSynced}}" - on-change="onSingleSyncDataTypeChanged_" - disabled="[[shouldSyncCheckboxBeDisabled_( - syncPrefs.syncAllDataTypes, syncPrefs.themesEnforced)]]" - aria-labelledby="themesAndWallpapersCheckboxLabel"> - </cr-toggle> - </div> - - <div class="list-item" hidden="[[!syncPrefs.tabsRegistered]]"> - <div id="openTabsCheckboxLabel"> - $i18n{openTabsCheckboxLabel} - </div> - <cr-toggle checked="{{syncPrefs.tabsSynced}}" - on-change="onSingleSyncDataTypeChanged_" - disabled="[[shouldSyncCheckboxBeDisabled_( - syncPrefs.syncAllDataTypes, syncPrefs.tabsEnforced)]]" - aria-labelledby="openTabsCheckboxLabel"> - </cr-toggle> - </div> - - <div class="list-item" hidden="[[!syncPrefs.passwordsRegistered]]"> - <div id="passwordsCheckboxLabel"> - $i18n{passwordsCheckboxLabel} - </div> - <cr-toggle checked="{{syncPrefs.passwordsSynced}}" - on-change="onSingleSyncDataTypeChanged_" - disabled="[[shouldSyncCheckboxBeDisabled_( - syncPrefs.syncAllDataTypes, syncPrefs.passwordsEnforced)]]" - aria-labelledby="passwordsCheckboxLabel"> - </cr-toggle> - </div> - -<if expr="chromeos"> - <div class="list-item" - hidden="[[!syncPrefs.wifiConfigurationsRegistered]]"> - <div id="wifiConfigurationsCheckboxLabel"> - $i18n{wifiConfigurationsCheckboxLabel} - </div> - <cr-toggle checked="{{syncPrefs.wifiConfigurationsSynced}}" - on-change="onSingleSyncDataTypeChanged_" - disabled="[[shouldSyncCheckboxBeDisabled_( - syncPrefs.syncAllDataTypes, - syncPrefs.wifiConfigurationsEnforced)]]" - aria-labelledby="wifiConfigurationsCheckboxLabel"> - </cr-toggle> - </div> -</if> - - <div class="list-item" hidden="[[!syncPrefs.autofillRegistered]]"> - <div id="autofillCheckboxLabel"> - $i18n{autofillCheckboxLabel} - </div> - <!-- Autofill has a special on-change handler to deal with - Payments integration. --> - <cr-toggle checked="{{syncPrefs.autofillSynced}}" - on-change="onAutofillDataTypeChanged_" - disabled="[[shouldSyncCheckboxBeDisabled_( - syncPrefs.syncAllDataTypes, syncPrefs.autofillEnforced)]]" - aria-labelledby="autofillCheckboxLabel"> - </cr-toggle> - </div> - - <div class="list-item" hidden="[[!syncPrefs.autofillRegistered]]"> - <!-- The Payments integration checkbox is a special case in many - ways. It's visible only if autofill is registered. It's - disabled and unchecked if autofill is unchecked.--> - <div> - $i18n{enablePaymentsIntegrationCheckboxLabel} - </div> - <cr-toggle checked="{{syncPrefs.paymentsIntegrationEnabled}}" - on-change="onSingleSyncDataTypeChanged_" - disabled="[[shouldPaymentsCheckboxBeDisabled_( - syncPrefs.syncAllDataTypes, syncPrefs.autofillSynced)]]" - aria-label="$i18n{enablePaymentsIntegrationCheckboxLabel}"> - </cr-toggle> - </div> - </div> - </template> - <script src="sync_controls.js"></script> -</dom-module> diff --git a/chromium/chrome/browser/resources/settings/people_page/sync_controls.js b/chromium/chrome/browser/resources/settings/people_page/sync_controls.js deleted file mode 100644 index 452cc5eeaad..00000000000 --- a/chromium/chrome/browser/resources/settings/people_page/sync_controls.js +++ /dev/null @@ -1,197 +0,0 @@ -// 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. - -(function() { - -/** - * Names of the individual data type properties to be cached from - * settings.SyncPrefs when the user checks 'Sync All'. - * @type {!Array<string>} - */ -const SyncPrefsIndividualDataTypes = [ - 'appsSynced', - 'extensionsSynced', - 'preferencesSynced', - 'autofillSynced', - 'typedUrlsSynced', - 'themesSynced', - 'bookmarksSynced', - 'passwordsSynced', - 'tabsSynced', - 'paymentsIntegrationEnabled', -]; - -/** - * @fileoverview - * 'settings-sync-controls' contains all sync data type controls. - */ -Polymer({ - is: 'settings-sync-controls', - - behaviors: [WebUIListenerBehavior], - - properties: { - hidden: { - type: Boolean, - value: false, - computed: 'syncControlsHidden_(' + - 'syncStatus.signedIn, syncStatus.disabled, syncStatus.hasError)', - reflectToAttribute: true, - }, - - /** - * The current sync preferences, supplied by SyncBrowserProxy. - * @type {settings.SyncPrefs|undefined} - */ - syncPrefs: Object, - - /** - * The current sync status, supplied by the parent. - * @type {settings.SyncStatus} - */ - syncStatus: { - type: Object, - observer: 'syncStatusChanged_', - }, - }, - - /** @private {?settings.SyncBrowserProxy} */ - browserProxy_: null, - - /** - * Caches the individually selected synced data types. This is used to - * be able to restore the selections after checking and unchecking Sync All. - * @private {?Object} - */ - cachedSyncPrefs_: null, - - /** @override */ - created: function() { - this.browserProxy_ = settings.SyncBrowserProxyImpl.getInstance(); - }, - - /** @override */ - attached: function() { - this.addWebUIListener( - 'sync-prefs-changed', this.handleSyncPrefsChanged_.bind(this)); - - if (settings.getCurrentRoute() == settings.routes.SYNC_ADVANCED) { - this.browserProxy_.didNavigateToSyncPage(); - } - }, - - /** - * Handler for when the sync preferences are updated. - * @private - */ - handleSyncPrefsChanged_: function(syncPrefs) { - this.syncPrefs = syncPrefs; - - // If autofill is not registered or synced, force Payments integration off. - if (!this.syncPrefs.autofillRegistered || !this.syncPrefs.autofillSynced) { - this.set('syncPrefs.paymentsIntegrationEnabled', false); - } - }, - - /** - * Handler for when the sync all data types checkbox is changed. - * @param {!Event} event - * @private - */ - onSyncAllDataTypesChanged_: function(event) { - if (event.target.checked) { - this.set('syncPrefs.syncAllDataTypes', true); - - // Cache the previously selected preference before checking every box. - this.cachedSyncPrefs_ = {}; - for (const dataType of SyncPrefsIndividualDataTypes) { - // These are all booleans, so this shallow copy is sufficient. - this.cachedSyncPrefs_[dataType] = this.syncPrefs[dataType]; - - this.set(['syncPrefs', dataType], true); - } - } else if (this.cachedSyncPrefs_) { - // Restore the previously selected preference. - for (const dataType of SyncPrefsIndividualDataTypes) { - this.set(['syncPrefs', dataType], this.cachedSyncPrefs_[dataType]); - } - } - - this.onSingleSyncDataTypeChanged_(); - }, - - /** - * Handler for when any sync data type checkbox is changed (except autofill). - * @private - */ - onSingleSyncDataTypeChanged_: function() { - assert(this.syncPrefs); - this.browserProxy_.setSyncDatatypes(this.syncPrefs); - }, - - /** - * Handler for when the autofill data type checkbox is changed. - * @private - */ - onAutofillDataTypeChanged_: function() { - this.set( - 'syncPrefs.paymentsIntegrationEnabled', this.syncPrefs.autofillSynced); - - this.onSingleSyncDataTypeChanged_(); - }, - - /** - * Handler for when the autofill data type checkbox is changed. - * @private - */ - onTypedUrlsDataTypeChanged_: function() { - this.onSingleSyncDataTypeChanged_(); - }, - - /** - * @param {boolean} syncAllDataTypes - * @param {boolean} enforced - * @return {boolean} Whether the sync checkbox should be disabled. - */ - shouldSyncCheckboxBeDisabled_: function(syncAllDataTypes, enforced) { - return syncAllDataTypes || enforced; - }, - - /** - * @param {boolean} syncAllDataTypes - * @param {boolean} autofillSynced - * @return {boolean} Whether the sync checkbox should be disabled. - */ - shouldPaymentsCheckboxBeDisabled_: function( - syncAllDataTypes, autofillSynced) { - return syncAllDataTypes || !autofillSynced; - }, - - /** @private */ - syncStatusChanged_: function() { - if (settings.getCurrentRoute() == settings.routes.SYNC_ADVANCED && - this.syncControlsHidden_()) { - settings.navigateTo(settings.routes.SYNC); - } - }, - - /** - * @return {boolean} Whether the sync controls are hidden. - * @private - */ - syncControlsHidden_: function() { - if (!this.syncStatus) { - // Show sync controls by default. - return false; - } - - if (!this.syncStatus.signedIn || this.syncStatus.disabled) { - return true; - } - - return !!this.syncStatus.hasError && - this.syncStatus.statusAction !== settings.StatusAction.ENTER_PASSPHRASE; - }, -}); -})(); diff --git a/chromium/chrome/browser/resources/settings/people_page/sync_page.html b/chromium/chrome/browser/resources/settings/people_page/sync_page.html deleted file mode 100644 index 51b1cf194c8..00000000000 --- a/chromium/chrome/browser/resources/settings/people_page/sync_page.html +++ /dev/null @@ -1,362 +0,0 @@ -<link rel="import" href="chrome://resources/html/polymer.html"> - -<link rel="import" href="chrome://resources/html/i18n_behavior.html"> -<link rel="import" href="chrome://resources/html/util.html"> -<link rel="import" href="chrome://resources/html/web_ui_listener_behavior.html"> -<link rel="import" href="chrome://resources/cr_elements/cr_dialog/cr_dialog.html"> -<link rel="import" href="chrome://resources/cr_elements/cr_button/cr_button.html"> -<link rel="import" href="chrome://resources/cr_elements/cr_icon_button/cr_icon_button.html"> -<link rel="import" href="chrome://resources/cr_elements/cr_input/cr_input.html"> -<link rel="import" href="chrome://resources/cr_elements/cr_radio_button/cr_radio_button.html"> -<link rel="import" href="chrome://resources/cr_elements/cr_radio_group/cr_radio_group.html"> -<link rel="import" href="chrome://resources/cr_elements/icons.html"> -<link rel="import" href="chrome://resources/cr_elements/shared_style_css.html"> -<link rel="import" href="chrome://resources/cr_elements/shared_vars_css.html"> -<link rel="import" href="chrome://resources/polymer/v1_0/iron-flex-layout/iron-flex-layout-classes.html"> -<link rel="import" href="sync_browser_proxy.html"> -<link rel="import" href="sync_controls.html"> -<link rel="import" href="../privacy_page/personalization_options.html"> -<link rel="import" href="../route.html"> -<link rel="import" href="../settings_shared_css.html"> -<link rel="import" href="../settings_vars_css.html"> - -<if expr="not chromeos"> -<link rel="import" href="sync_account_control.html"> -<link rel="import" href="chrome://resources/cr_elements/cr_toast/cr_toast.html"> -</if> - -<dom-module id="settings-sync-page"> - <template> - <style include="cr-shared-style settings-shared iron-flex"> - #sync-separator { - border-bottom: var(--cr-separator-line); - } - - #create-password-box { - /* In order to line up with the encryption radio box text. */ - margin-inline-start: var(--cr-section-indent-width); - } - - #create-password-box { - margin-bottom: 1em; - } - - #create-password-box .list-item { - margin-bottom: var(--cr-form-field-bottom-spacing); - } - - cr-input { - --cr-input-width: var(--settings-input-max-width); - } - - #existingPassphrase { - border-bottom: var(--cr-separator-line); - border-top: var(--cr-separator-line); - /* This particular list frame is not indented. */ - padding-inline-start: var(--cr-section-padding); - } - - #submitExistingPassphrase { - /* The submit button for the existing passphrase is on the same line. */ - margin-inline-start: 16px; - } - - #passphraseRecoverHint { - align-items: center; - } - - #other-sync-items { - padding-bottom: 8px; - } - - #other-sync-items > .list-item:not(.first) { - border-top: var(--cr-separator-line); - } - - .passphrase-reset-icon { - margin-inline-end: 8px; - } - - #disabled-by-admin-icon { - text-align: center; - width: 40px; - } - -<if expr="not chromeos"> - #toast { - left: 0; - z-index: 1; - } - - :host-context([dir='rtl']) #toast { - left: auto; - right: 0; - } -</if> - </style> -<if expr="not chromeos"> - <template is="dom-if" if="[[shouldShowSyncAccountControl_( - unifiedConsentEnabled, syncStatus.syncSystemEnabled, - syncStatus.signinAllowed)]]"> - <settings-sync-account-control embedded-in-subpage - unified-consent-enabled="[[unifiedConsentEnabled]]" - sync-status="[[syncStatus]]" - promo-label-with-account= - "$i18n{peopleSignInPromptSecondaryWithAccount}" - promo-label-with-no-account= - "$i18n{peopleSignInPromptSecondaryWithNoAccount}" - on-sync-setup-done="onSyncSetupDone_"> - </settings-sync-account-control> - </template> -</if> - <div class="settings-box first" hidden="[[!syncDisabledByAdmin_]]"> - <iron-icon id="disabled-by-admin-icon" icon="cr20:domain"></iron-icon> - <div class="middle settings-box-text"> - $i18n{syncDisabledByAdministrator} - </div> - </div> - - <template is="dom-if" if="[[shouldShowExistingPassphraseBelowAccount_( - unifiedConsentEnabled, syncPrefs.passphraseRequired)]]" - on-dom-change="focusPassphraseInput_"> - <div id="existingPassphrase" class="list-frame"> - <div id="existingPassphraseTitle" class="list-item"> - <div class="start settings-box-text"> - <div>$i18n{existingPassphraseTitle}</div> - <div class="secondary" - inner-h-t-m-l="[[syncPrefs.enterPassphraseBody]]"> - </div> - </div> - </div> - <div id="existingPassphraseContainer" class="list-item"> - <cr-input id="existingPassphraseInput" type="password" - value="{{existingPassphrase_}}" - placeholder="$i18n{passphrasePlaceholder}" - error-message="$i18n{incorrectPassphraseError}" - on-keypress="onSubmitExistingPassphraseTap_"> - <cr-button id="submitExistingPassphrase" slot="suffix" - on-click="onSubmitExistingPassphraseTap_" - class="action-button" disabled="[[!existingPassphrase_]]"> - $i18n{submitPassphraseButton} - </cr-button> - </cr-input> - </div> - <div id="passphraseRecoverHint" class="list-item"> - <div class="settings-box-text">$i18nRaw{passphraseRecover}</div> - </div> - </div> - </template> - - <div id="sync-separator" hidden="[[!syncSectionDisabled_]]"></div> - - <div id="sync-section" hidden="[[syncSectionDisabled_]]"> - <div class="settings-box first" hidden="[[!unifiedConsentEnabled]]"> - <h2 class="cr-title-text start">$i18n{sync}</h2> - </div> - - <div id="[[pages_.SPINNER]]" class="settings-box first settings-box-text" - hidden$="[[!isStatus_(pages_.SPINNER, pageStatus_)]]"> - $i18n{syncLoading} - </div> - <div id="[[pages_.TIMEOUT]]" class="settings-box first settings-box-text" - hidden$="[[!isStatus_(pages_.TIMEOUT, pageStatus_)]]"> - $i18n{syncTimeout} - </div> - <div id="[[pages_.CONFIGURE]]" - hidden$="[[!isStatus_(pages_.CONFIGURE, pageStatus_)]]"> - <!-- TODO(http://crbug.com/862983) Remove this section once the Unified - Consent feature is launched. --> - <template is="dom-if" if="[[shouldShowExistingPassphraseInSyncSection_( - unifiedConsentEnabled, syncPrefs.passphraseRequired)]]" - on-dom-change="focusPassphraseInput_"> - <div id="existingPassphrase" class="list-frame"> - <div class="list-item"> - <div class="settings-box-text" - inner-h-t-m-l="[[syncPrefs.enterPassphraseBody]]"> - </div> - </div> - <div id="existingPassphraseContainer" class="list-item"> - <cr-input id="existingPassphraseInput" type="password" - value="{{existingPassphrase_}}" - placeholder="$i18n{passphrasePlaceholder}" - error-message="$i18n{incorrectPassphraseError}" - on-keypress="onSubmitExistingPassphraseTap_"> - <cr-button id="submitExistingPassphrase" slot="suffix" - on-click="onSubmitExistingPassphraseTap_" - class="action-button" disabled="[[!existingPassphrase_]]"> - $i18n{submitPassphraseButton} - </cr-button> - </cr-input> - </div> - <div id="passphraseRecoverHint" class="list-item"> - <span>$i18nRaw{passphraseRecover}</span> - </div> - </div> - </template> - - <template is="dom-if" if="[[!unifiedConsentEnabled]]"> - <settings-sync-controls sync-status="[[syncStatus]]"> - </settings-sync-controls> - </template> - - <div id="other-sync-items" - class$="[[getListFrameClass_(unifiedConsentEnabled)]]"> - - <template is="dom-if" if="[[unifiedConsentEnabled]]"> - <div id="sync-advanced-row" class="list-item first" - on-click="onSyncAdvancedTap_" actionable> - <div class="start"> - $i18n{syncAdvancedPageTitle} - </div> - <cr-icon-button class="subpage-arrow" - aria-label="$i18n{syncAdvancedPageTitle}"></cr-icon-button> - </div> - </template> - - <template is="dom-if" - if="[[shouldShowDriveSuggest_(unifiedConsentEnabled)]]" restamp> - <settings-toggle-button - class$="[[getListItemClass_(unifiedConsentEnabled)]]" - pref="{{prefs.documentsuggest.enabled}}" - label="$i18n{driveSuggestPref}" - sub-label="$i18n{driveSuggestPrefDesc}"> - </settings-toggle-button> - </template> - - <a class$="inherit-color no-outline - [[getListItemClass_(unifiedConsentEnabled)]]" tabindex="-1" - target="_blank" href="$i18n{activityControlsUrl}" - on-click="onActivityControlsTap_"> - <div class="start settings-box-text"> - $i18n{personalizeGoogleServicesTitle} - </div> - <cr-icon-button actionable class="icon-external"></cr-icon-button> - </a> - - <a id="syncDashboardLink" - class$="inherit-color no-outline - [[getListItemClass_(unifiedConsentEnabled)]]" - tabindex="-1" target="_blank" href="$i18n{syncDashboardUrl}" - hidden="[[syncStatus.supervisedUser]]"> - <div class="start settings-box-text"> - $i18n{manageSyncedDataTitle} - </div> - <cr-icon-button actionable class="icon-external"></cr-icon-button> - </a> - - <div id="encryptionDescription" - hidden="[[syncPrefs.passphraseRequired]]" - class$="single-column settings-box-text - [[getPassphraseHintLines_(syncPrefs.encryptAllData)]] - [[getListItemClass_(unifiedConsentEnabled)]]"> - $i18n{encryptionOptionsTitle} - <div class="secondary"> - $i18n{syncDataEncryptedText} - <div hidden="[[!syncPrefs.encryptAllData]]"> - <iron-icon icon="cr:info-outline" - class="passphrase-reset-icon"> - </iron-icon> - $i18nRaw{passphraseResetHintEncryption} - </div> - </div> - </div> - - <div id="encryptionRadioGroupContainer" class="list-frame" - hidden="[[syncPrefs.passphraseRequired]]"> - <cr-radio-group - id="encryptionRadioGroup" - selected="[[selectedEncryptionRadio_(syncPrefs)]]" - on-selected-changed="onEncryptionRadioSelectionChanged_" - disabled$="[[disableEncryptionOptions_]]"> - <cr-radio-button name="encrypt-with-google" class="list-item" - aria-label="$i18n{encryptWithGoogleCredentialsLabel}" - disabled$="[[disableEncryptionOptions_]]"> - $i18n{encryptWithGoogleCredentialsLabel} - </cr-radio-button> - <cr-radio-button name="encrypt-with-passphrase" class="list-item" - disabled$="[[disableEncryptionOptions_]]"> - <span hidden="[[!syncPrefs.fullEncryptionBody]]"> - [[syncPrefs.fullEncryptionBody]] - </span> - <span on-click="onLearnMoreTap_" - hidden="[[syncPrefs.fullEncryptionBody]]"> - $i18nRaw{encryptWithSyncPassphraseLabel} - </span> - </cr-radio-button> - </cr-radio-group> - </div> - - <template is="dom-if" if="[[creatingNewPassphrase_]]"> - <div class="list-frame"> - <div id="create-password-box" - on-keypress="onSaveNewPassphraseTap_"> - <div class="list-item"> - <span>$i18nRaw{passphraseExplanationText}</span> - </div> - <cr-input id="passphraseInput" type="password" - value="{{passphrase_}}" - placeholder="$i18n{passphrasePlaceholder}" - error-message="$i18n{emptyPassphraseError}"> - </cr-input> - <cr-input id="passphraseConfirmationInput" type="password" - value="{{confirmation_}}" - placeholder="$i18n{passphraseConfirmationPlaceholder}" - error-message="$i18n{mismatchedPassphraseError}"> - </cr-input> - <cr-button id="saveNewPassphrase" - on-click="onSaveNewPassphraseTap_" class="action-button" - disabled="[[!isSaveNewPassphraseEnabled_(passphrase_, - confirmation_)]]"> - $i18n{save} - </cr-button> - </div> - </div> - </template> - - </div> - </div> - </div> - - <template is="dom-if" if="[[unifiedConsentEnabled]]"> - <div class="settings-box first"> - <h2 class="cr-title-text"> - $i18n{nonPersonalizedServicesSectionLabel} - </h2> - </div> - <settings-personalization-options class="list-frame" prefs="{{prefs}}" - page-visibility="[[pageVisibility]]" sync-status="[[syncStatus]]" - unified-consent-enabled="[[unifiedConsentEnabled]]"> - </settings-personalization-options> - </template> - -<if expr="not chromeos"> - <template is="dom-if" if="[[showSetupCancelDialog_]]" restamp> - <cr-dialog id="setupCancelDialog" on-close="onSetupCancelDialogClose_" - ignore-popstate> - <div slot="title">$i18n{syncSetupCancelDialogTitle}</div> - <div slot="body">$i18n{syncSetupCancelDialogBody}</div> - <div slot="button-container"> - <cr-button class="cancel-button" - on-click="onSetupCancelDialogBack_"> - $i18n{back} - </cr-button> - <cr-button class="action-button" - on-click="onSetupCancelDialogConfirm_"> - $i18n{cancelSync} - </cr-button> - </div> - </cr-dialog> - </template> - - <template is="dom-if" if="[[!unifiedConsentEnabled]]"> - <cr-toast id="toast" open="[[syncStatus.firstSetupInProgress]]"> - <div>$i18n{syncWillStart}</div> - <cr-button on-click="onSyncSetupCancel_"> - $i18n{cancelSync} - </cr-button> - </cr-toast> - </template> -</if> - </template> - <script src="sync_page.js"></script> -</dom-module> diff --git a/chromium/chrome/browser/resources/settings/people_page/sync_page.js b/chromium/chrome/browser/resources/settings/people_page/sync_page.js deleted file mode 100644 index e65b7efd44b..00000000000 --- a/chromium/chrome/browser/resources/settings/people_page/sync_page.js +++ /dev/null @@ -1,710 +0,0 @@ -// Copyright 2015 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. - -(function() { - -/** - * Names of the radio buttons which allow the user to choose their encryption - * mechanism. - * @enum {string} - */ -const RadioButtonNames = { - ENCRYPT_WITH_GOOGLE: 'encrypt-with-google', - ENCRYPT_WITH_PASSPHRASE: 'encrypt-with-passphrase', -}; - -/** - * @fileoverview - * 'settings-sync-page' is the settings page containing sync settings. - */ -Polymer({ - is: 'settings-sync-page', - - behaviors: [ - WebUIListenerBehavior, - settings.RouteObserverBehavior, - ], - - properties: { - /** - * Preferences state. - */ - prefs: { - type: Object, - notify: true, - }, - - /** @private */ - pages_: { - type: Object, - value: settings.PageStatus, - readOnly: true, - }, - - /** - * The current page status. Defaults to |CONFIGURE| such that the searching - * algorithm can search useful content when the page is not visible to the - * user. - * @private {?settings.PageStatus} - */ - pageStatus_: { - type: String, - value: settings.PageStatus.CONFIGURE, - }, - - /** - * Dictionary defining page visibility. - * @type {!PrivacyPageVisibility} - */ - pageVisibility: Object, - - /** - * The current sync preferences, supplied by SyncBrowserProxy. - * @type {settings.SyncPrefs|undefined} - */ - syncPrefs: { - type: Object, - }, - - /** @type {settings.SyncStatus} */ - syncStatus: { - type: Object, - }, - - /** - * Whether the "create passphrase" inputs should be shown. These inputs - * give the user the opportunity to use a custom passphrase instead of - * authenticating with their Google credentials. - * @private - */ - creatingNewPassphrase_: { - type: Boolean, - value: false, - }, - - /** - * The passphrase input field value. - * @private - */ - passphrase_: { - type: String, - value: '', - }, - - /** - * The passphrase confirmation input field value. - * @private - */ - confirmation_: { - type: String, - value: '', - }, - - /** - * The existing passphrase input field value. - * @private - */ - existingPassphrase_: { - type: String, - value: '', - }, - - /** @private */ - signedIn_: { - type: Boolean, - value: true, - computed: 'computeSignedIn_(syncStatus.signedIn)', - }, - - /** @private */ - syncDisabledByAdmin_: { - type: Boolean, - value: false, - computed: 'computeSyncDisabledByAdmin_(syncStatus.managed)', - }, - - /** @private */ - syncSectionDisabled_: { - type: Boolean, - value: false, - computed: 'computeSyncSectionDisabled_(' + - 'unifiedConsentEnabled, syncStatus.signedIn, syncStatus.disabled, ' + - 'syncStatus.hasError, syncStatus.statusAction)', - }, - - // <if expr="not chromeos"> - diceEnabled: Boolean, - // </if> - - unifiedConsentEnabled: { - type: Boolean, - observer: 'initializeDidAbort_', - }, - - /** @private */ - showSetupCancelDialog_: { - type: Boolean, - value: false, - }, - - disableEncryptionOptions_: { - type: Boolean, - computed: 'computeDisableEncryptionOptions_(' + - 'syncPrefs, syncStatus)', - }, - }, - - /** @private {?settings.SyncBrowserProxy} */ - browserProxy_: null, - - /** - * If unified consent is enabled, the beforeunload callback is used to - * show the 'Leave site' dialog. This makes sure that the user has the chance - * to go back and confirm the sync opt-in before leaving. - * - * If unified consent is disabled, the beforeunload callback is used - * to confirm the sync setup before leaving the opt-in flow. - * - * This property is non-null if the user is currently navigated on the sync - * settings route. - * - * @private {?Function} - */ - beforeunloadCallback_: null, - - /** - * If unified consent is enabled, the unload callback is used to cancel the - * sync setup when the user hits the browser back button after arriving on the - * page. - * Note: Cases like closing the tab or reloading don't need to be handled, - * because they are already caught in |PeopleHandler::~PeopleHandler| - * from the C++ code. - * - * @private {?Function} - */ - unloadCallback_: null, - - /** - * Whether the initial layout for collapsible sections has been computed. It - * is computed only once, the first time the sync status is updated. - * @private {boolean} - */ - collapsibleSectionsInitialized_: false, - - /** - * Whether the user decided to abort sync. When unified consent is enabled, - * this is initialized to true. - * @private {boolean} - */ - didAbort_: false, - - /** - * Whether the user confirmed the cancellation of sync. - * @private {boolean} - */ - setupCancelConfirmed_: false, - - /** @override */ - created: function() { - this.browserProxy_ = settings.SyncBrowserProxyImpl.getInstance(); - }, - - /** @override */ - attached: function() { - this.addWebUIListener( - 'page-status-changed', this.handlePageStatusChanged_.bind(this)); - this.addWebUIListener( - 'sync-prefs-changed', this.handleSyncPrefsChanged_.bind(this)); - - if (settings.getCurrentRoute() == settings.routes.SYNC) { - this.onNavigateToPage_(); - } - }, - - /** @override */ - detached: function() { - if (settings.routes.SYNC.contains(settings.getCurrentRoute())) { - this.onNavigateAwayFromPage_(); - } - - if (this.beforeunloadCallback_) { - window.removeEventListener('beforeunload', this.beforeunloadCallback_); - this.beforeunloadCallback_ = null; - } - if (this.unloadCallback_) { - window.removeEventListener('unload', this.unloadCallback_); - this.unloadCallback_ = null; - } - }, - - /** - * @return {boolean} - * @private - */ - computeSignedIn_: function() { - return !!this.syncStatus.signedIn; - }, - - /** - * @return {boolean} - * @private - */ - computeSyncSectionDisabled_: function() { - return !!this.unifiedConsentEnabled && this.syncStatus !== undefined && - (!this.syncStatus.signedIn || !!this.syncStatus.disabled || - (!!this.syncStatus.hasError && - this.syncStatus.statusAction !== - settings.StatusAction.ENTER_PASSPHRASE)); - }, - - /** - * @return {boolean} - * @private - */ - computeSyncDisabledByAdmin_: function() { - return this.syncStatus != undefined && !!this.syncStatus.managed; - }, - - /** @private */ - onSetupCancelDialogBack_: function() { - this.$$('#setupCancelDialog').cancel(); - chrome.metricsPrivate.recordUserAction( - 'Signin_Signin_CancelCancelAdvancedSyncSettings'); - }, - - /** @private */ - onSetupCancelDialogConfirm_: function() { - this.setupCancelConfirmed_ = true; - this.$$('#setupCancelDialog').close(); - settings.navigateTo(settings.routes.BASIC); - chrome.metricsPrivate.recordUserAction( - 'Signin_Signin_ConfirmCancelAdvancedSyncSettings'); - }, - - /** @private */ - onSetupCancelDialogClose_: function() { - this.showSetupCancelDialog_ = false; - }, - - /** @protected */ - currentRouteChanged: function() { - if (settings.getCurrentRoute() == settings.routes.SYNC) { - this.onNavigateToPage_(); - return; - } - - if (settings.routes.SYNC.contains(settings.getCurrentRoute())) { - return; - } - - const searchParams = settings.getQueryParameters().get('search'); - if (searchParams) { - // User navigated away via searching. Cancel sync without showing - // confirmation dialog. - this.onNavigateAwayFromPage_(); - return; - } - - const userActionCancelsSetup = this.syncStatus && - this.syncStatus.firstSetupInProgress && this.didAbort_; - if (this.unifiedConsentEnabled && userActionCancelsSetup && - !this.setupCancelConfirmed_) { - chrome.metricsPrivate.recordUserAction( - 'Signin_Signin_BackOnAdvancedSyncSettings'); - // Show the 'Cancel sync?' dialog. - // Yield so that other |currentRouteChanged| observers are called, - // before triggering another navigation (and another round of observers - // firing). Triggering navigation from within an observer leads to some - // undefined behavior and runtime errors. - requestAnimationFrame(() => { - settings.navigateTo(settings.routes.SYNC); - this.showSetupCancelDialog_ = true; - // Flush to make sure that the setup cancel dialog is attached. - Polymer.dom.flush(); - this.$$('#setupCancelDialog').showModal(); - }); - return; - } - - // Reset variable. - this.setupCancelConfirmed_ = false; - - this.onNavigateAwayFromPage_(); - }, - - /** - * @param {!settings.PageStatus} expectedPageStatus - * @return {boolean} - * @private - */ - isStatus_: function(expectedPageStatus) { - return expectedPageStatus == this.pageStatus_; - }, - - /** @private */ - onNavigateToPage_: function() { - assert(settings.getCurrentRoute() == settings.routes.SYNC); - - if (this.beforeunloadCallback_) { - return; - } - - this.collapsibleSectionsInitialized_ = false; - - // Display loading page until the settings have been retrieved. - this.pageStatus_ = settings.PageStatus.SPINNER; - - this.browserProxy_.didNavigateToSyncPage(); - - if (this.unifiedConsentEnabled) { - this.beforeunloadCallback_ = event => { - // When the user tries to leave the sync setup, show the 'Leave site' - // dialog. - if (this.unifiedConsentEnabled && this.syncStatus && - this.syncStatus.firstSetupInProgress) { - event.preventDefault(); - event.returnValue = ''; - - chrome.metricsPrivate.recordUserAction( - 'Signin_Signin_AbortAdvancedSyncSettings'); - } - }; - window.addEventListener('beforeunload', this.beforeunloadCallback_); - - this.unloadCallback_ = this.onNavigateAwayFromPage_.bind(this); - window.addEventListener('unload', this.unloadCallback_); - } else { - this.beforeunloadCallback_ = this.onNavigateAwayFromPage_.bind(this); - window.addEventListener('beforeunload', this.beforeunloadCallback_); - } - }, - - /** @private */ - onNavigateAwayFromPage_: function() { - if (!this.beforeunloadCallback_) { - return; - } - - // Reset the status to CONFIGURE such that the searching algorithm can - // search useful content when the page is not visible to the user. - this.pageStatus_ = settings.PageStatus.CONFIGURE; - - this.browserProxy_.didNavigateAwayFromSyncPage(this.didAbort_); - this.initializeDidAbort_(); - - window.removeEventListener('beforeunload', this.beforeunloadCallback_); - this.beforeunloadCallback_ = null; - - if (this.unloadCallback_) { - window.removeEventListener('unload', this.unloadCallback_); - this.unloadCallback_ = null; - } - }, - - /** - * Handler for when the sync preferences are updated. - * @private - */ - handleSyncPrefsChanged_: function(syncPrefs) { - this.syncPrefs = syncPrefs; - this.pageStatus_ = settings.PageStatus.CONFIGURE; - - // Hide the new passphrase box if (a) full data encryption is enabled, - // (b) encrypting all data is not allowed (so far, only applies to - // supervised accounts), or (c) the user is a supervised account. - if (this.syncPrefs.encryptAllData || - !this.syncPrefs.encryptAllDataAllowed || - (this.syncStatus && this.syncStatus.supervisedUser)) { - this.creatingNewPassphrase_ = false; - } - }, - - /** @private */ - onActivityControlsTap_: function() { - this.browserProxy_.openActivityControlsUrl(); - }, - - /** - * @param {string} passphrase The passphrase input field value - * @param {string} confirmation The passphrase confirmation input field value. - * @return {boolean} Whether the passphrase save button should be enabled. - * @private - */ - isSaveNewPassphraseEnabled_: function(passphrase, confirmation) { - return passphrase !== '' && confirmation !== ''; - }, - - /** - * Sends the newly created custom sync passphrase to the browser. - * @private - * @param {!Event} e - */ - onSaveNewPassphraseTap_: function(e) { - assert(this.creatingNewPassphrase_); - - // Ignore events on irrelevant elements or with irrelevant keys. - if (e.target.tagName != 'CR-BUTTON' && e.target.tagName != 'CR-INPUT') { - return; - } - if (e.type == 'keypress' && e.key != 'Enter') { - return; - } - - // If a new password has been entered but it is invalid, do not send the - // sync state to the API. - if (!this.validateCreatedPassphrases_()) { - return; - } - - this.syncPrefs.encryptAllData = true; - this.syncPrefs.setNewPassphrase = true; - this.syncPrefs.passphrase = this.passphrase_; - - this.browserProxy_.setSyncEncryption(this.syncPrefs) - .then(this.handlePageStatusChanged_.bind(this)); - }, - - /** - * Sends the user-entered existing password to re-enable sync. - * @private - * @param {!Event} e - */ - onSubmitExistingPassphraseTap_: function(e) { - if (e.type == 'keypress' && e.key != 'Enter') { - return; - } - - assert(!this.creatingNewPassphrase_); - - this.syncPrefs.setNewPassphrase = false; - - this.syncPrefs.passphrase = this.existingPassphrase_; - this.existingPassphrase_ = ''; - - this.browserProxy_.setSyncEncryption(this.syncPrefs) - .then(this.handlePageStatusChanged_.bind(this)); - }, - - /** - * Called when the page status updates. - * @param {!settings.PageStatus} pageStatus - * @private - */ - handlePageStatusChanged_: function(pageStatus) { - switch (pageStatus) { - case settings.PageStatus.SPINNER: - case settings.PageStatus.TIMEOUT: - case settings.PageStatus.CONFIGURE: - this.pageStatus_ = pageStatus; - return; - case settings.PageStatus.DONE: - if (settings.getCurrentRoute() == settings.routes.SYNC) { - settings.navigateTo(settings.routes.PEOPLE); - } - return; - case settings.PageStatus.PASSPHRASE_FAILED: - if (this.pageStatus_ == this.pages_.CONFIGURE && this.syncPrefs && - this.syncPrefs.passphraseRequired) { - const passphraseInput = /** @type {!CrInputElement} */ ( - this.$$('#existingPassphraseInput')); - passphraseInput.invalid = true; - passphraseInput.focusInput(); - } - return; - } - - assertNotReached(); - }, - - /** - * Called when the encryption - * @param {!Event} event - * @private - */ - onEncryptionRadioSelectionChanged_: function(event) { - this.creatingNewPassphrase_ = - event.detail.value == RadioButtonNames.ENCRYPT_WITH_PASSPHRASE; - }, - - /** - * Computed binding returning the selected encryption radio button. - * @private - */ - selectedEncryptionRadio_: function() { - return this.syncPrefs.encryptAllData || this.creatingNewPassphrase_ ? - RadioButtonNames.ENCRYPT_WITH_PASSPHRASE : - RadioButtonNames.ENCRYPT_WITH_GOOGLE; - }, - - /** - * Checks the supplied passphrases to ensure that they are not empty and that - * they match each other. Additionally, displays error UI if they are invalid. - * @return {boolean} Whether the check was successful (i.e., that the - * passphrases were valid). - * @private - */ - validateCreatedPassphrases_: function() { - const emptyPassphrase = !this.passphrase_; - const mismatchedPassphrase = this.passphrase_ != this.confirmation_; - - this.$$('#passphraseInput').invalid = emptyPassphrase; - this.$$('#passphraseConfirmationInput').invalid = - !emptyPassphrase && mismatchedPassphrase; - - return !emptyPassphrase && !mismatchedPassphrase; - }, - - /** - * @param {!Event} event - * @private - */ - onLearnMoreTap_: function(event) { - if (event.target.tagName == 'A') { - // Stop the propagation of events, so that clicking on links inside - // checkboxes or radio buttons won't change the value. - event.stopPropagation(); - } - }, - - /** - * When unified-consent enabled, the non-toggle items on the bottom of sync - * section should be wrapped with 'list-frame' in order to be indented - * correctly. - * @return {string} - * @private - */ - getListFrameClass_: function() { - return this.unifiedConsentEnabled ? 'list-frame' : ''; - }, - - /** - * When unified-consent enabled, the non-toggle items on the bottom of sync - * section will be wrapped with 'list-frame', and should have the 'list-item' - * instead of 'settings-box' in order to be indented correctly. - * @return {string} - * @private - */ - getListItemClass_: function() { - return this.unifiedConsentEnabled ? 'list-item' : 'settings-box'; - }, - - /** - * When there is a sync passphrase, some items have an additional line for the - * passphrase reset hint, making them three lines rather than two. - * @return {string} - * @private - */ - getPassphraseHintLines_: function() { - return this.syncPrefs.encryptAllData ? 'three-line' : 'two-line'; - }, - - // <if expr="not chromeos"> - /** - * @return {boolean} - * @private - */ - shouldShowSyncAccountControl_: function() { - return !!this.unifiedConsentEnabled && this.syncStatus !== undefined && - !!this.syncStatus.syncSystemEnabled && !!this.syncStatus.signinAllowed; - }, - // </if> - - /** - * @return {boolean} - * @private - */ - shouldShowExistingPassphraseBelowAccount_: function() { - return !!this.unifiedConsentEnabled && this.syncPrefs !== undefined && - !!this.syncPrefs.passphraseRequired; - }, - - /** - * @return {boolean} - * @private - */ - shouldShowExistingPassphraseInSyncSection_: function() { - return !this.unifiedConsentEnabled && this.syncPrefs !== undefined && - !!this.syncPrefs.passphraseRequired; - }, - - /** - * Whether we should disable the radio buttons that allow choosing the - * encryption options for Sync. - * We disable the buttons if: - * (a) full data encryption is enabled, or, - * (b) full data encryption is not allowed (so far, only applies to - * supervised accounts), or, - * (c) the user is a supervised account. - * @return {boolean} - * @private - */ - computeDisableEncryptionOptions_: function() { - return !!( - (this.syncPrefs && - (this.syncPrefs.encryptAllData || - !this.syncPrefs.encryptAllDataAllowed)) || - (this.syncStatus && this.syncStatus.supervisedUser)); - }, - - /** @private */ - onSyncAdvancedTap_: function() { - settings.navigateTo(settings.routes.SYNC_ADVANCED); - }, - - /** - * @return {boolean} - * @private - */ - shouldShowDriveSuggest_: function() { - return loadTimeData.getBoolean('driveSuggestAvailable') && - !this.unifiedConsentEnabled; - }, - - /** - * Used when unified consent is disabled. - * @private - */ - onSyncSetupCancel_: function() { - this.didAbort_ = true; - settings.navigateTo(settings.routes.BASIC); - }, - - /** @private */ - initializeDidAbort_: function() { - this.didAbort_ = !!this.unifiedConsentEnabled; - }, - - /** - * @param {!CustomEvent<boolean>} e The event passed from - * settings-sync-account-control. - * @private - */ - onSyncSetupDone_: function(e) { - if (e.detail) { - this.didAbort_ = false; - chrome.metricsPrivate.recordUserAction( - 'Signin_Signin_ConfirmAdvancedSyncSettings'); - } else { - this.setupCancelConfirmed_ = true; - chrome.metricsPrivate.recordUserAction( - 'Signin_Signin_CancelAdvancedSyncSettings'); - } - settings.navigateTo(settings.routes.BASIC); - }, - - /** - * Focuses the passphrase input element if it is available and the page is - * visible. - * @private - */ - focusPassphraseInput_: function() { - const passphraseInput = - /** @type {!CrInputElement} */ (this.$$('#existingPassphraseInput')); - if (passphraseInput && settings.getCurrentRoute() == settings.routes.SYNC) { - passphraseInput.focus(); - } - }, -}); - -})(); diff --git a/chromium/chrome/browser/resources/settings/people_page/user_list.html b/chromium/chrome/browser/resources/settings/people_page/user_list.html deleted file mode 100644 index dbc871abac2..00000000000 --- a/chromium/chrome/browser/resources/settings/people_page/user_list.html +++ /dev/null @@ -1,67 +0,0 @@ -<link rel="import" href="chrome://resources/html/polymer.html"> - -<link rel="import" href="chrome://resources/cr_elements/cr_icon_button/cr_icon_button.html"> -<link rel="import" href="chrome://resources/cr_elements/cr_scrollable_behavior.html"> -<link rel="import" href="chrome://resources/cr_elements/icons.html"> -<link rel="import" href="chrome://resources/cr_elements/shared_vars_css.html"> -<link rel="import" href="chrome://resources/html/i18n_behavior.html"> -<link rel="import" href="chrome://resources/polymer/v1_0/iron-flex-layout/iron-flex-layout-classes.html"> -<link rel="import" href="../route.html"> -<link rel="import" href="../settings_shared_css.html"> -<link rel="import" href="../settings_vars_css.html"> - -<dom-module id="settings-user-list"> - <template> - <style include="settings-shared iron-flex"> - .user-list { - /* 4 users (the extra 1px is to account for the border-bottom) */ - max-height: calc(4 * (var(--settings-row-two-line-min-height) + 1px)); - overflow-y: auto; - } - - .user { - border-bottom: var(--cr-separator-line); - } - - .user-icon { - background-position: center; - background-repeat: no-repeat; - background-size: cover; - border-radius: 20px; - flex-shrink: 0; - height: 40px; - width: 40px; - } - - .user-info { - padding-inline-start: 20px; - } - - :host([disabled]) .user-list { - opacity: var(--cr-disabled-opacity); - overflow: auto; - } - </style> - <div class="user-list" scrollable> - <template is="dom-repeat" items="[[users_]]"> - <div class="user layout horizontal center two-line"> - <img class="user-icon" src="[[getProfilePictureUrl_(item)]]"> - <div class="flex layout vertical user-info no-min-width"> - <div class="text-elide" title="[[getTooltip_(item)]]"> - [[getUserName_(item)]] - </div> - <div class="secondary text-elide" title="[[item.displayEmail]]" - hidden$="[[!shouldShowEmail_(item)]]"> - [[item.displayEmail]] - </div> - </div> - <cr-icon-button class="icon-clear" - hidden="[[shouldHideCloseButton_(disabled, item.isOwner)]]" - title="$i18n{removeUserTooltip}" on-click="removeUser_"> - </cr-icon-button> - </div> - </template> - </div> - </template> - <script src="user_list.js"></script> -</dom-module> diff --git a/chromium/chrome/browser/resources/settings/people_page/user_list.js b/chromium/chrome/browser/resources/settings/people_page/user_list.js deleted file mode 100644 index 066f71f607c..00000000000 --- a/chromium/chrome/browser/resources/settings/people_page/user_list.js +++ /dev/null @@ -1,136 +0,0 @@ -// Copyright 2015 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 - * 'settings-user-list' shows a list of users whitelisted on this Chrome OS - * device. - * - * Example: - * - * <settings-user-list prefs="{{prefs}}"> - * </settings-user-list> - */ -Polymer({ - is: 'settings-user-list', - - behaviors: [ - CrScrollableBehavior, - I18nBehavior, - settings.RouteObserverBehavior, - ], - - properties: { - /** - * Current list of whitelisted users. - * @private {!Array<!chrome.usersPrivate.User>} - */ - users_: { - type: Array, - value: function() { - return []; - }, - notify: true - }, - - /** - * Whether the user list is disabled, i.e. that no modifications can be - * made. - * @type {boolean} - */ - disabled: { - type: Boolean, - value: false, - reflectToAttribute: true, - } - }, - - /** @override */ - ready: function() { - chrome.settingsPrivate.onPrefsChanged.addListener(prefs => { - prefs.forEach(function(pref) { - if (pref.key == 'cros.accounts.users') { - chrome.usersPrivate.getWhitelistedUsers(users => { - this.setUsers_(users); - }); - } - }, this); - }); - }, - - /** @protected */ - currentRouteChanged: function() { - if (settings.getCurrentRoute() == settings.routes.ACCOUNTS) { - chrome.usersPrivate.getWhitelistedUsers(users => { - this.setUsers_(users); - }); - } - }, - - /** - * @param {!chrome.usersPrivate.User} user - * @return {string} - * @private - */ - getUserName_: function(user) { - return user.isOwner ? this.i18n('deviceOwnerLabel', user.name) : user.name; - }, - - /** - * Helper function that sorts and sets the given list of whitelisted users. - * @param {!Array<!chrome.usersPrivate.User>} users List of whitelisted users. - */ - setUsers_: function(users) { - this.users_ = users; - this.users_.sort(function(a, b) { - if (a.isOwner != b.isOwner) { - return b.isOwner ? 1 : -1; - } else { - return -1; - } - }); - this.requestUpdateScroll(); - }, - - /** - * @private - * @param {!{model: !{item: !chrome.usersPrivate.User}}} e - */ - removeUser_: function(e) { - chrome.usersPrivate.removeWhitelistedUser( - e.model.item.email, /* callback */ function() {}); - }, - - /** @private */ - shouldHideCloseButton_: function(disabled, isUserOwner) { - return disabled || isUserOwner; - }, - - /** - * @param {chrome.usersPrivate.User} user - * @private - */ - getProfilePictureUrl_: function(user) { - return 'chrome://userimage/' + user.email + '?id=' + Date.now() + - '&frame=0'; - }, - - /** - * @param {chrome.usersPrivate.User} user - * @private - */ - shouldShowEmail_: function(user) { - return !user.isSupervised && user.name != user.displayEmail; - }, - - /** - * Use this function to prevent tooltips from displaying for user names. We - * only want to display tooltips for email addresses. - * @param {chrome.usersPrivate.User} user - * @private - */ - getTooltip_: function(user) { - return !this.shouldShowEmail_(user) ? user.displayEmail : ''; - }, -}); diff --git a/chromium/chrome/browser/resources/settings/people_page/users_add_user_dialog.html b/chromium/chrome/browser/resources/settings/people_page/users_add_user_dialog.html deleted file mode 100644 index cbcbc0b24d5..00000000000 --- a/chromium/chrome/browser/resources/settings/people_page/users_add_user_dialog.html +++ /dev/null @@ -1,38 +0,0 @@ -<link rel="import" href="chrome://resources/html/polymer.html"> - -<link rel="import" href="chrome://resources/cr_elements/cr_button/cr_button.html"> -<link rel="import" href="chrome://resources/cr_elements/cr_dialog/cr_dialog.html"> -<link rel="import" href="chrome://resources/cr_elements/cr_input/cr_input.html"> -<link rel="import" href="chrome://resources/html/assert.html"> -<link rel="import" href="../settings_shared_css.html"> -<link rel="import" href="../settings_vars_css.html"> - -<dom-module id="settings-users-add-user-dialog"> - <template> - <style include="settings-shared"> - cr-dialog::part(dialog) { - width: 320px; - } - </style> - <cr-dialog id="dialog" close-text="$i18n{close}"> - <div slot="title">$i18n{addUsers}</div> - <div slot="body"> - <cr-input id="addUserInput" label="$i18n{addUsersEmail}" - invalid="[[shouldShowError_(errorCode_)]]" - on-value-changed="onInput_" - error-message="[[getErrorString_(errorCode_)]]" autofocus> - </cr-input> - </div> - <div slot="button-container"> - <cr-button class="cancel-button" on-click="onCancelTap_"> - $i18n{cancel} - </cr-button> - <cr-button on-click="addUser_" class="action-button" - disabled$="[[!canAddUser_(isEmail_, isEmpty_)]]"> - $i18n{add} - </cr-button> - </div> - </cr-dialog> - </template> - <script src="users_add_user_dialog.js"></script> -</dom-module> diff --git a/chromium/chrome/browser/resources/settings/people_page/users_add_user_dialog.js b/chromium/chrome/browser/resources/settings/people_page/users_add_user_dialog.js deleted file mode 100644 index a68a908b4b6..00000000000 --- a/chromium/chrome/browser/resources/settings/people_page/users_add_user_dialog.js +++ /dev/null @@ -1,159 +0,0 @@ -// Copyright 2016 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 - * 'settings-users-add-user-dialog' is the dialog shown for adding new allowed - * users to a ChromeOS device. - */ -(function() { - -/** - * Regular expression for adding a user where the string provided is just - * the part before the "@". - * Email alias only, assuming it's a gmail address. - * e.g. 'john' - * @type {!RegExp} - */ -const NAME_ONLY_REGEX = - new RegExp('^\\s*([\\w\\.!#\\$%&\'\\*\\+-\\/=\\?\\^`\\{\\|\\}~]+)\\s*$'); - -/** - * Regular expression for adding a user where the string provided is a full - * email address. - * e.g. 'john@chromium.org' - * @type {!RegExp} - */ -const EMAIL_REGEX = new RegExp( - '^\\s*([\\w\\.!#\\$%&\'\\*\\+-\\/=\\?\\^`\\{\\|\\}~]+)@' + - '([A-Za-z0-9\-]{2,63}\\..+)\\s*$'); - -/** @enum {number} */ -const UserAddError = { - NO_ERROR: 0, - INVALID_EMAIL: 1, - USER_EXISTS: 2, -}; - -Polymer({ - is: 'settings-users-add-user-dialog', - - behaviors: [I18nBehavior], - - properties: { - /** @private */ - errorCode_: { - type: Number, - value: UserAddError.NO_ERROR, - }, - - /** @private */ - isEmail_: { - type: Boolean, - value: false, - }, - - /** @private */ - isEmpty_: { - type: Boolean, - value: true, - }, - }, - - usersPrivate_: chrome.usersPrivate, - - open: function() { - this.$.addUserInput.value = ''; - this.onInput_(); - this.$.dialog.showModal(); - // Set to valid initially since the user has not typed anything yet. - this.$.addUserInput.invalid = false; - }, - - /** @private */ - addUser_: function() { - // May be submitted by the Enter key even if the input value is invalid. - if (this.$.addUserInput.disabled) { - return; - } - - const input = this.$.addUserInput.value; - - const nameOnlyMatches = NAME_ONLY_REGEX.exec(input); - let userEmail; - if (nameOnlyMatches) { - userEmail = nameOnlyMatches[1] + '@gmail.com'; - } else { - const emailMatches = EMAIL_REGEX.exec(input); - // Assuming the input validated, one of these two must match. - assert(emailMatches); - userEmail = emailMatches[1] + '@' + emailMatches[2]; - } - - this.usersPrivate_.isWhitelistedUser(userEmail, doesUserExist => { - if (doesUserExist) { - // This user email had been saved previously - this.errorCode_ = UserAddError.USER_EXISTS; - return; - } - - this.$.dialog.close(); - this.usersPrivate_.addWhitelistedUser( - userEmail, - /* callback */ function(success) {}); - - this.$.addUserInput.value = ''; - }); - }, - - /** - * @return {boolean} - * @private - */ - canAddUser_: function() { - return this.isEmail_ && !this.isEmpty_; - }, - - /** @private */ - onCancelTap_: function() { - this.$.dialog.cancel(); - }, - - /** @private */ - onInput_: function() { - const input = this.$.addUserInput.value; - this.isEmail_ = NAME_ONLY_REGEX.test(input) || EMAIL_REGEX.test(input); - this.isEmpty_ = input.length == 0; - - if (!this.isEmail_ && !this.isEmpty_) { - this.errorCode_ = UserAddError.INVALID_EMAIL; - return; - } - - this.errorCode_ = UserAddError.NO_ERROR; - }, - - /** - * @private - * @return {boolean} - */ - shouldShowError_: function() { - return this.errorCode_ != UserAddError.NO_ERROR; - }, - - /** - * @private - * @return {string} - */ - getErrorString_: function(errorCode_) { - if (errorCode_ == UserAddError.USER_EXISTS) { - return this.i18n('userExistsError'); - } - //TODO errorString for UserAddError.INVALID_EMAIL crbug/1007481 - - return ''; - }, -}); - -})(); diff --git a/chromium/chrome/browser/resources/settings/people_page/users_page.html b/chromium/chrome/browser/resources/settings/people_page/users_page.html deleted file mode 100644 index 3b94c83970a..00000000000 --- a/chromium/chrome/browser/resources/settings/people_page/users_page.html +++ /dev/null @@ -1,76 +0,0 @@ -<link rel="import" href="chrome://resources/html/polymer.html"> - -<link rel="import" href="chrome://resources/cr_elements/shared_vars_css.html"> -<link rel="import" href="chrome://resources/cr_elements/action_link_css.html"> -<link rel="import" href="chrome://resources/html/action_link.html"> -<link rel="import" href="chrome://resources/html/assert.html"> -<link rel="import" href="chrome://resources/html/cr/ui/focus_without_ink.html"> -<link rel="import" href="../controls/settings_toggle_button.html"> -<link rel="import" href="../settings_shared_css.html"> -<link rel="import" href="user_list.html"> -<link rel="import" href="users_add_user_dialog.html"> - -<dom-module id="settings-users-page"> - <template> - <style include="settings-shared action-link"> - .settings-box:first-of-type { - border-top: none; - } - - #add-user-button { - /* Add user button must be lined up with the start of users' names. */ - margin-inline-start: var(--cr-section-indent-padding); - } - - .block { - display: block; - } - - #header { - padding-inline-start: 20px; - } - </style> - <div class="settings-box" hidden$="[[!isWhitelistManaged_]]"> - $i18n{settingsManagedLabel} - </div> - <div class="settings-box" - hidden$="[[shouldHideModifiedByOwnerLabel_( - isWhitelistManaged_, isOwner_)]]"> - $i18n{usersModifiedByOwnerLabel} - </div> - <settings-toggle-button class="first" - pref="{{prefs.cros.accounts.allowBWSI}}" - label="$i18n{guestBrowsingLabel}" - disabled="[[isEditingDisabled_(isOwner_, isWhitelistManaged_)]]"> - </settings-toggle-button> - <settings-toggle-button class="continuation" - pref="{{prefs.cros.accounts.showUserNamesOnSignIn}}" - label="$i18n{showOnSigninLabel}" - disabled="[[isEditingDisabled_(isOwner_, isWhitelistManaged_)]]"> - </settings-toggle-button> - <settings-toggle-button class="continuation" - pref="{{prefs.cros.accounts.allowGuest}}" - id="restrictSignIn" - label="$i18n{restrictSigninLabel}" - disabled="[[isEditingDisabled_(isOwner_, isWhitelistManaged_)]]" - inverted> - </settings-toggle-button> - <template is="dom-if" - if="[[isEditingUsersEnabled_(isOwner_, isWhitelistManaged_, - prefs.cros.accounts.allowGuest.value, isChild_)]]"> - <div class="list-frame" > - <settings-user-list prefs="[[prefs]]"> - </settings-user-list> - <div id="add-user-button" class="list-item"> - <a is="action-link" class="list-button" on-click="openAddUserDialog_"> - $i18n{addUsers} - </a> - </div> - </div> - </template> - <settings-users-add-user-dialog id="addUserDialog" - on-close="onAddUserDialogClose_"> - </settings-users-add-user-dialog> - </template> - <script src="users_page.js"></script> -</dom-module> diff --git a/chromium/chrome/browser/resources/settings/people_page/users_page.js b/chromium/chrome/browser/resources/settings/people_page/users_page.js deleted file mode 100644 index 4a3ff206056..00000000000 --- a/chromium/chrome/browser/resources/settings/people_page/users_page.js +++ /dev/null @@ -1,95 +0,0 @@ -// Copyright 2015 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 - * 'settings-users-page' is the settings page for managing user accounts on - * the device. - */ -Polymer({ - is: 'settings-users-page', - - properties: { - /** - * Preferences state. - */ - prefs: { - type: Object, - notify: true, - }, - - /** @private */ - isOwner_: { - type: Boolean, - value: true, - }, - - /** @private */ - isWhitelistManaged_: { - type: Boolean, - value: false, - }, - - /** @private */ - isChild_: { - type: Boolean, - value: function() { - return loadTimeData.getBoolean('isSupervised'); - }, - }, - }, - - /** @override */ - created: function() { - chrome.usersPrivate.getCurrentUser(user => { - this.isOwner_ = user.isOwner; - }); - - chrome.usersPrivate.isWhitelistManaged(isWhitelistManaged => { - this.isWhitelistManaged_ = isWhitelistManaged; - }); - }, - - /** - * @param {!Event} e - * @private - */ - openAddUserDialog_: function(e) { - e.preventDefault(); - this.$.addUserDialog.open(); - }, - - /** @private */ - onAddUserDialogClose_: function() { - cr.ui.focusWithoutInk(assert(this.$$('#add-user-button a'))); - }, - - /** - * @param {boolean} isOwner - * @param {boolean} isWhitelistManaged - * @private - * @return {boolean} - */ - isEditingDisabled_: function(isOwner, isWhitelistManaged) { - return !isOwner || isWhitelistManaged; - }, - - /** - * @param {boolean} isOwner - * @param {boolean} isWhitelistManaged - * @param {boolean} allowGuest - * @param {boolean} isChild - * @private - * @return {boolean} - */ - isEditingUsersEnabled_: function( - isOwner, isWhitelistManaged, allowGuest, isChild) { - return isOwner && !isWhitelistManaged && !allowGuest && !isChild; - }, - - /** @return {boolean} */ - shouldHideModifiedByOwnerLabel_: function() { - return this.isWhitelistManaged_ || this.isOwner_; - }, -}); |