diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2018-01-29 16:35:13 +0100 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2018-02-01 15:33:35 +0000 |
commit | c8c2d1901aec01e934adf561a9fdf0cc776cdef8 (patch) | |
tree | 9157c3d9815e5870799e070b113813bec53e0535 /chromium/chrome/browser/resources/settings | |
parent | abefd5095b41dac94ca451d784ab6e27372e981a (diff) |
BASELINE: Update Chromium to 64.0.3282.139
Change-Id: I1cae68fe9c94ff7608b26b8382fc19862cdb293a
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'chromium/chrome/browser/resources/settings')
114 files changed, 2414 insertions, 1638 deletions
diff --git a/chromium/chrome/browser/resources/settings/about_page/about_page.html b/chromium/chrome/browser/resources/settings/about_page/about_page.html index bc42399d48f..42a110c6acf 100644 --- a/chromium/chrome/browser/resources/settings/about_page/about_page.html +++ b/chromium/chrome/browser/resources/settings/about_page/about_page.html @@ -104,7 +104,8 @@ src="[[getIconSrc_(obsoleteSystemInfo_, currentUpdateStatusEvent_)]]"> </iron-icon> <div class="start padded"> - <div id="updateStatusMessage" hidden="[[!showUpdateStatus_]]" + <div id="updateStatusMessage" hidden="[[!showUpdateStatus_]]"> + <div <if expr="not chromeos"> inner-h-t-m-l="[[getUpdateStatusMessage_( currentUpdateStatusEvent_)]]"> @@ -113,6 +114,12 @@ inner-h-t-m-l="[[getUpdateStatusMessage_( currentUpdateStatusEvent_, targetChannel_)]]"> </if> + </div> + <a hidden$="[[!shouldShowLearnMoreLink_( + currentUpdateStatusEvent_)]]" target="_blank" + href="https://support.google.com/chrome?p=update_error"> + $i18n{learnMore} + </a> </div> <span id="deprecationWarning" hidden="[[!obsoleteSystemInfo_.obsolete]]"> diff --git a/chromium/chrome/browser/resources/settings/about_page/about_page.js b/chromium/chrome/browser/resources/settings/about_page/about_page.js index 5ddfb82ce1f..0ed1b715a19 100644 --- a/chromium/chrome/browser/resources/settings/about_page/about_page.js +++ b/chromium/chrome/browser/resources/settings/about_page/about_page.js @@ -283,6 +283,14 @@ Polymer({ }, /** + * @return {boolean} + * @private + */ + shouldShowLearnMoreLink_: function() { + return this.currentUpdateStatusEvent_.status == UpdateStatus.FAILED; + }, + + /** * @return {string} * @private */ diff --git a/chromium/chrome/browser/resources/settings/android_apps_page/android_apps_page.html b/chromium/chrome/browser/resources/settings/android_apps_page/android_apps_page.html index 0fed226e58a..a59514198c0 100644 --- a/chromium/chrome/browser/resources/settings/android_apps_page/android_apps_page.html +++ b/chromium/chrome/browser/resources/settings/android_apps_page/android_apps_page.html @@ -21,7 +21,8 @@ focus-config="[[focusConfig_]]"> <neon-animatable route-path="default"> <template is="dom-if" if="[[havePlayStoreApp]]" restamp> - <div id="android-apps" class="settings-box two-line first" actionable + <div id="android-apps" class="settings-box two-line first" + actionable$="[[androidAppsInfo.playStoreEnabled]]" on-tap="onSubpageTap_"> <div class="start"> $i18n{androidAppsPageLabel} diff --git a/chromium/chrome/browser/resources/settings/android_apps_page/android_apps_subpage.js b/chromium/chrome/browser/resources/settings/android_apps_page/android_apps_subpage.js index a0699eace97..9dee9d3149d 100644 --- a/chromium/chrome/browser/resources/settings/android_apps_page/android_apps_subpage.js +++ b/chromium/chrome/browser/resources/settings/android_apps_page/android_apps_subpage.js @@ -74,7 +74,7 @@ Polymer({ onConfirmDisableDialogConfirm_: function() { this.setPrefValue('arc.enabled', false); this.$.confirmDisableDialog.close(); - settings.navigateToPreviousRoute(); + // Sub-page will be closed in onAndroidAppsInfoUpdate_ call. }, /** diff --git a/chromium/chrome/browser/resources/settings/basic_page/basic_page.html b/chromium/chrome/browser/resources/settings/basic_page/basic_page.html index cb5157281cf..94029ec4769 100644 --- a/chromium/chrome/browser/resources/settings/basic_page/basic_page.html +++ b/chromium/chrome/browser/resources/settings/basic_page/basic_page.html @@ -27,7 +27,7 @@ <link rel="import" href="../default_browser_page/default_browser_page.html"> </if> -<if expr="is_win"> +<if expr="_google_chrome and is_win"> <link rel="import" href="../chrome_cleanup_page/chrome_cleanup_page.html"> </if> @@ -124,7 +124,7 @@ </settings-section> </template> </if> -<if expr="is_win"> +<if expr="_google_chrome and is_win"> <template is="dom-if" if="[[showChromeCleanup]]" restamp> <settings-section section="chromeCleanup"> <settings-chrome-cleanup-page></settings-chrome-cleanup-page> diff --git a/chromium/chrome/browser/resources/settings/basic_page/basic_page.js b/chromium/chrome/browser/resources/settings/basic_page/basic_page.js index 36b2b7f6423..8207b5b3880 100644 --- a/chromium/chrome/browser/resources/settings/basic_page/basic_page.js +++ b/chromium/chrome/browser/resources/settings/basic_page/basic_page.js @@ -29,13 +29,15 @@ Polymer({ /** @type {!AndroidAppsInfo|undefined} */ androidAppsInfo: Object, + // <if expr="_google_chrome and is_win"> showChromeCleanup: { type: Boolean, value: function() { - return loadTimeData.valueExists('chromeCleanupEnabled') && - loadTimeData.getBoolean('chromeCleanupEnabled'); + return loadTimeData.getBoolean('chromeCleanupEnabled') && + !loadTimeData.getBoolean('userInitiatedCleanupsEnabled'); }, }, + // </if> showChangePassword: { type: Boolean, @@ -108,7 +110,7 @@ Polymer({ attached: function() { this.currentRoute_ = settings.getCurrentRoute(); - // <if expr="is_win"> + // <if expr="_google_chrome and is_win"> this.addEventListener('chrome-cleanup-dismissed', () => { this.showChromeCleanup = false; }); diff --git a/chromium/chrome/browser/resources/settings/bluetooth_page/bluetooth_page.js b/chromium/chrome/browser/resources/settings/bluetooth_page/bluetooth_page.js index dd816a8810d..2a6445caf7c 100644 --- a/chromium/chrome/browser/resources/settings/bluetooth_page/bluetooth_page.js +++ b/chromium/chrome/browser/resources/settings/bluetooth_page/bluetooth_page.js @@ -206,10 +206,10 @@ Polymer({ this.bluetoothToggleDisabled_ = true; this.bluetoothPrivate.setAdapterState( {powered: this.bluetoothToggleState_}, () => { - if (chrome.runtime.lastError) { - console.error( - 'Error enabling bluetooth: ' + - chrome.runtime.lastError.message); + var error = chrome.runtime.lastError; + if (error && error != 'Error setting adapter properties: powered') { + console.error('Error enabling bluetooth: ' + error.message); + return; } this.setPrefValue( 'ash.user.bluetooth.adapter_enabled', diff --git a/chromium/chrome/browser/resources/settings/bluetooth_page/bluetooth_subpage.html b/chromium/chrome/browser/resources/settings/bluetooth_page/bluetooth_subpage.html index 7a782eeb0e5..e3fc960d500 100644 --- a/chromium/chrome/browser/resources/settings/bluetooth_page/bluetooth_subpage.html +++ b/chromium/chrome/browser/resources/settings/bluetooth_page/bluetooth_subpage.html @@ -39,7 +39,7 @@ } </style> - <div class="settings-box first"> + <div class="settings-box first" actionable on-tap="onEnableTap_"> <div id="onOff" class="start" on$="[[bluetoothToggleState]]"> [[getOnOffString_(bluetoothToggleState, '$i18nPolymer{deviceOn}', '$i18nPolymer{deviceOff}')]] @@ -47,7 +47,8 @@ <paper-toggle-button id="enableBluetooth" checked="{{bluetoothToggleState}}" disabled$="[[bluetoothToggleDisabled]]" - aria-label="$i18n{bluetoothToggleA11yLabel}"> + aria-label="$i18n{bluetoothToggleA11yLabel}" + on-tap="stopTap_"> </paper-toggle-button> </div> @@ -62,13 +63,12 @@ <div id="pairedContainer" class="container" scrollable on-device-event="onDeviceEvent_" hidden="[[!showDevices_(bluetoothToggleState, pairedDeviceList_)]]"> - <iron-list id="pairedDevices" class="vertical-list" preserve-focus - items="[[pairedDeviceList_]]" + <iron-list id="pairedDevices" preserve-focus items="[[pairedDeviceList_]]" selection-enabled selected-item="{{selectedPairedItem_}}" - scroll-target="pairedContainer"> + scroll-target="pairedContainer" class="cr-separators"> <template> <bluetooth-device-list-item actionable device="[[item]]" - tabindex$="[[tabIndex]]"> + first$="[[!index]]" tabindex$="[[tabIndex]]"> </bluetooth-device-list-item> </template> </iron-list> @@ -87,13 +87,13 @@ <div id="unpairedContainer" class="container" scrollable on-device-event="onDeviceEvent_" hidden="[[!showDevices_(bluetoothToggleState, unpairedDeviceList_)]]"> - <iron-list id="unpairedDevices" class="vertical-list" preserve-focus + <iron-list id="unpairedDevices" class="cr-separators" preserve-focus items="[[unpairedDeviceList_]]" selection-enabled selected-item="{{selectedUnpairedItem_}}" scroll-target="unpairedContainer"> <template> <bluetooth-device-list-item actionable device="[[item]]" - tabindex$="[[tabIndex]]"> + first$="[[!index]]" tabindex$="[[tabIndex]]"> </bluetooth-device-list-item> </template> </iron-list> @@ -102,7 +102,7 @@ <bluetooth-dialog id="deviceDialog" bluetooth="[[bluetooth]]" bluetooth-private="[[bluetoothPrivate]]" - title="$i18n{bluetoothPairDevicePageTitle}" + dialog-title="$i18n{bluetoothPairDevicePageTitle}" on-close="onDialogClose_" pairing-device="[[pairingDevice_]]"> </bluetooth-dialog> diff --git a/chromium/chrome/browser/resources/settings/bluetooth_page/bluetooth_subpage.js b/chromium/chrome/browser/resources/settings/bluetooth_page/bluetooth_subpage.js index 54876622ff1..89131bed6c2 100644 --- a/chromium/chrome/browser/resources/settings/bluetooth_page/bluetooth_subpage.js +++ b/chromium/chrome/browser/resources/settings/bluetooth_page/bluetooth_subpage.js @@ -3,6 +3,12 @@ // found in the LICENSE file. /** + * Maximum number of bluetooth devices shown in bluetooth subpage. + * @const {number} + */ +var MAX_NUMBER_DEVICE_SHOWN = 50; + +/** * @fileoverview * 'settings-bluetooth-subpage' is the settings subpage for managing bluetooth * properties and devices. @@ -128,6 +134,15 @@ Polymer({ type: Object, value: chrome.bluetoothPrivate, }, + + /** + * Update frequency of the bluetooth list. + * @type {number} + */ + listUpdateFrequencyMs: { + type: Number, + value: 1000, + }, }, observers: [ @@ -136,13 +151,27 @@ Polymer({ ], /** - * Listener for chrome.bluetooth.onBluetoothDeviceAdded/Changed events. + * Timer ID for bluetooth list update. + * @type {number|undefined} + * @private + */ + updateTimerId_: undefined, + + /** + * Listener for chrome.bluetooth.onBluetoothDeviceChanged events. * @type {?function(!chrome.bluetooth.Device)} * @private */ bluetoothDeviceUpdatedListener_: null, /** + * Listener for chrome.bluetooth.onBluetoothDeviceAdded events. + * @type {?function(!chrome.bluetooth.Device)} + * @private + */ + bluetoothDeviceAddedListener_: null, + + /** * Listener for chrome.bluetooth.onBluetoothDeviceRemoved events. * @type {?function(!chrome.bluetooth.Device)} * @private @@ -154,11 +183,14 @@ Polymer({ this.bluetoothDeviceUpdatedListener_ = this.bluetoothDeviceUpdatedListener_ || this.onBluetoothDeviceUpdated_.bind(this); - this.bluetooth.onDeviceAdded.addListener( - this.bluetoothDeviceUpdatedListener_); this.bluetooth.onDeviceChanged.addListener( this.bluetoothDeviceUpdatedListener_); + this.bluetoothDeviceAddedListener_ = this.bluetoothDeviceAddedListener_ || + this.onBluetoothDeviceAdded_.bind(this); + this.bluetooth.onDeviceAdded.addListener( + this.bluetoothDeviceAddedListener_); + this.bluetoothDeviceRemovedListener_ = this.bluetoothDeviceRemovedListener_ || this.onBluetoothDeviceRemoved_.bind(this); @@ -169,7 +201,7 @@ Polymer({ /** @override */ detached: function() { this.bluetooth.onDeviceAdded.removeListener( - assert(this.bluetoothDeviceUpdatedListener_)); + assert(this.bluetoothDeviceAddedListener_)); this.bluetooth.onDeviceChanged.removeListener( assert(this.bluetoothDeviceUpdatedListener_)); this.bluetooth.onDeviceRemoved.removeListener( @@ -204,7 +236,7 @@ Polymer({ return !!device.paired || !!device.connecting; }); this.unpairedDeviceList_ = this.deviceList_.filter(function(device) { - return !device.paired; + return !device.paired && !device.connecting; }); this.updateScrollableContents(); this.restoreScroll(this.$.unpairedDevices); @@ -243,13 +275,11 @@ Polymer({ this.deviceList_ = []; return; } - this.bluetooth.getDevices(devices => { - this.deviceList_ = devices; - }); + this.requestListUpdate_(); }, /** - * Process bluetooth.onDeviceAdded and onDeviceChanged events. + * Process onDeviceChanged events. * @param {!chrome.bluetooth.Device} device * @private */ @@ -262,11 +292,17 @@ Polymer({ var index = this.deviceList_.findIndex(function(device) { return device.address == address; }); - if (index >= 0) { + if (index >= 0) this.set('deviceList_.' + index, device); - return; - } - this.push('deviceList_', device); + }, + + /** + * Process bluetooth.onDeviceAdded events. + * @param {!chrome.bluetooth.Device} device + * @private + */ + onBluetoothDeviceAdded_: function(device) { + this.requestListUpdate_(); }, /** @@ -331,6 +367,23 @@ Polymer({ }, /** + * @param {!Event} event + * @private + */ + stopTap_: function(event) { + event.stopPropagation(); + }, + + /** + * @param {!Event} event + * @private + */ + onEnableTap_: function(event) { + this.bluetoothToggleState = !this.bluetoothToggleState; + event.stopPropagation(); + }, + + /** * @param {boolean} enabled * @param {string} onstr * @param {string} offstr @@ -436,4 +489,77 @@ Polymer({ if (device) device.focus(); }, + + /** + * Requests update for bluetooth list. + * @private + */ + requestListUpdate_: function() { + if (this.deviceList_.length == 0) { + // Update immediately for the initial device list. + this.bluetooth.getDevices(devices => { + this.populateDeviceList_(devices); + }); + return; + } + + // Return here because an update is already queued. + if (this.updateTimerId_ !== undefined) + return; + + // Call bluetooth.getDevices once per listUpdateFrequencyMs. + this.updateTimerId_ = window.setTimeout(() => { + if (settings.getCurrentRoute() != settings.routes.BLUETOOTH_DEVICES) { + this.stopListUpdate_(); + return; + } + + this.bluetooth.getDevices(devices => { + this.populateDeviceList_(devices); + }); + this.updateTimerId_ = undefined; + }, this.listUpdateFrequencyMs); + }, + + /** + * Stops update for bluetooth list. + * @private + */ + stopListUpdate_: function() { + if (this.updateTimerId_ !== undefined) { + window.clearTimeout(this.updateTimerId_); + this.updateTimerId_ = undefined; + } + }, + + /** + * Populate the device list from chrome.bluetooth.getDevices + * Limit the device number to MAX_NUMBER_DEVICE_SHOWN and + * prioritize paired/connecting devices over other devices. + * @param {!Array<!chrome.bluetooth.Device|undefined>} devices + * @private + */ + populateDeviceList_: function(devices) { + var tempList = []; + var i; + for (i = 0; i < devices.length; i++) { + if (tempList.length == MAX_NUMBER_DEVICE_SHOWN) + break; + + if (!!devices[i].paired || !!devices[i].connecting) { + tempList.push(devices[i]); + devices[i] = undefined; + } + } + + for (i = 0; i < devices.length; i++) { + if (tempList.length == MAX_NUMBER_DEVICE_SHOWN) + break; + + if (devices[i] !== undefined) + tempList.push(devices[i]); + } + + this.deviceList_ = tempList; + }, }); diff --git a/chromium/chrome/browser/resources/settings/chrome_cleanup_page/chrome_cleanup_page.html b/chromium/chrome/browser/resources/settings/chrome_cleanup_page/chrome_cleanup_page.html index d2c2fc0ae4f..955204ac45c 100644 --- a/chromium/chrome/browser/resources/settings/chrome_cleanup_page/chrome_cleanup_page.html +++ b/chromium/chrome/browser/resources/settings/chrome_cleanup_page/chrome_cleanup_page.html @@ -98,11 +98,12 @@ <span>[[title_]]</span> <template is="dom-if" if="[[showDetails_]]"> <!-- Force line break to display learn-more inlined with - chromeCleanupExplanation or with the title_ (if showDetails_ is - false) despite these two elements being on different lines. --> + chromeCleanupExplanationRemove or with the title_ (if + showDetails_ is false) despite these two elements being on + different lines. --> <div></div> <span class="secondary"> - $i18n{chromeCleanupExplanation} + $i18n{chromeCleanupExplanationRemove} </span> </template> <a id="learn-more" href="$i18n{chromeCleanupLearnMoreUrl}" diff --git a/chromium/chrome/browser/resources/settings/clear_browsing_data_dialog/clear_browsing_data_dialog_tabs.html b/chromium/chrome/browser/resources/settings/clear_browsing_data_dialog/clear_browsing_data_dialog_tabs.html index 502eac00064..d0b12514e16 100644 --- a/chromium/chrome/browser/resources/settings/clear_browsing_data_dialog/clear_browsing_data_dialog_tabs.html +++ b/chromium/chrome/browser/resources/settings/clear_browsing_data_dialog/clear_browsing_data_dialog_tabs.html @@ -104,7 +104,6 @@ } .time-range-select { - -webkit-margin-start: 0.5em; /* Adjust for md-select-underline and 1px additional bottom padding * to keep md-select's text (without the underline) aligned with * neighboring text that does not have an underline. */ diff --git a/chromium/chrome/browser/resources/settings/controls/compiled_resources2.gyp b/chromium/chrome/browser/resources/settings/controls/compiled_resources2.gyp index 518172c836e..32dadfbdef9 100644 --- a/chromium/chrome/browser/resources/settings/controls/compiled_resources2.gyp +++ b/chromium/chrome/browser/resources/settings/controls/compiled_resources2.gyp @@ -101,6 +101,7 @@ { 'target_name': 'settings_toggle_button', 'dependencies': [ + '<(DEPTH)/ui/webui/resources/cr_elements/cr_toggle/compiled_resources2.gyp:cr_toggle', 'settings_boolean_control_behavior', ], 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'], diff --git a/chromium/chrome/browser/resources/settings/controls/settings_toggle_button.html b/chromium/chrome/browser/resources/settings/controls/settings_toggle_button.html index 3e6a81d6d48..7cdb86fdff3 100644 --- a/chromium/chrome/browser/resources/settings/controls/settings_toggle_button.html +++ b/chromium/chrome/browser/resources/settings/controls/settings_toggle_button.html @@ -1,7 +1,7 @@ <link rel="import" href="chrome://resources/html/polymer.html"> +<link rel="import" href="chrome://resources/cr_elements/cr_toggle/cr_toggle.html"> <link rel="import" href="chrome://resources/cr_elements/policy/cr_policy_pref_indicator.html"> -<link rel="import" href="chrome://resources/polymer/v1_0/paper-toggle-button/paper-toggle-button.html"> <link rel="import" href="chrome://resources/polymer/v1_0/iron-flex-layout/iron-flex-layout-classes.html"> <link rel="import" href="settings_boolean_control_behavior.html"> <link rel="import" href="../settings_shared_css.html"> @@ -62,13 +62,12 @@ <cr-policy-pref-indicator pref="[[pref]]" icon-aria-label="[[label]]"> </cr-policy-pref-indicator> </template> - <paper-toggle-button id="control" checked="{{checked}}" - on-change="notifyChangedByUserInteraction" + <cr-toggle id="control" checked="{{checked}}" + on-change="onChange_" aria-label$="[[getAriaLabel_(label, ariaLabel)]]" - aria-describedby="subLabel" on-up="resetTrackLock_" - disabled="[[controlDisabled_(disabled, pref)]]" - on-tap="onToggleTap_"> - </paper-toggle-button> + aria-describedby="subLabel" + disabled="[[controlDisabled_(disabled, pref)]]"> + </cr-toggle> </div> </template> <script src="settings_toggle_button.js"></script> diff --git a/chromium/chrome/browser/resources/settings/controls/settings_toggle_button.js b/chromium/chrome/browser/resources/settings/controls/settings_toggle_button.js index 96c789995a9..b4e7c83d4b3 100644 --- a/chromium/chrome/browser/resources/settings/controls/settings_toggle_button.js +++ b/chromium/chrome/browser/resources/settings/controls/settings_toggle_button.js @@ -58,17 +58,6 @@ Polymer({ return this.label || this.ariaLabel; }, - /** - * Handle taps directly on the toggle (see: onLabelWrapperTap_ for non-toggle - * taps). - * @param {!Event} e - * @private - */ - onToggleTap_: function(e) { - // Stop the event from propagating to avoid firing two 'changed' events. - e.stopPropagation(); - }, - /** @private */ onDisableOrPrefChange_: function() { if (this.controlDisabled_()) { @@ -79,28 +68,34 @@ Polymer({ }, /** - * Handle non-toggle button taps (see: onToggleTap_ for toggle taps). + * Handles non cr-toggle button taps (cr-toggle handles its own tap events + * which don't bubble). * @param {!Event} e * @private */ onHostTap_: function(e) { - // Stop the event from propagating to avoid firing two 'changed' events. e.stopPropagation(); if (this.controlDisabled_()) return; + // Ignore this |tap| event, if the interaction sequence + // (pointerdown+pointerup) began within the cr-toggle itself. + if (/** @type {!CrToggleElement} */ (this.$.control) + .shouldIgnoreHostTap(e)) { + return; + } + this.checked = !this.checked; this.notifyChangedByUserInteraction(); this.fire('change'); }, /** - * TODO(scottchen): temporary fix until polymer gesture bug resolved. See: - * https://github.com/PolymerElements/paper-slider/issues/186 + * @param {!CustomEvent} e * @private */ - resetTrackLock_: function() { - // Run tap.reset in next run-loop to avoid reversing the current tap event. - setTimeout(() => Polymer.Gestures.gestures.tap.reset()); + onChange_: function(e) { + this.checked = /** @type {boolean} */ (e.detail); + this.notifyChangedByUserInteraction(); }, }); diff --git a/chromium/chrome/browser/resources/settings/date_time_page/compiled_resources2.gyp b/chromium/chrome/browser/resources/settings/date_time_page/compiled_resources2.gyp index 0da9b331bfe..ad752f8f355 100644 --- a/chromium/chrome/browser/resources/settings/date_time_page/compiled_resources2.gyp +++ b/chromium/chrome/browser/resources/settings/date_time_page/compiled_resources2.gyp @@ -6,13 +6,46 @@ { 'target_name': 'date_time_page', 'dependencies': [ - '../controls/compiled_resources2.gyp:settings_dropdown_menu', + '../compiled_resources2.gyp:route', '../prefs/compiled_resources2.gyp:prefs_behavior', '../prefs/compiled_resources2.gyp:prefs_types', '<(DEPTH)/ui/webui/resources/cr_elements/policy/compiled_resources2.gyp:cr_policy_indicator_behavior', '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr', + '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:i18n_behavior', '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:load_time_data', '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:web_ui_listener_behavior', + 'date_time_types', + 'timezone_selector', + 'timezone_subpage', + ], + 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'], + }, + { + 'target_name': 'date_time_types', + 'dependencies': [ + '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr', + ], + 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'], + }, + { + 'target_name': 'timezone_selector', + 'dependencies': [ + '../controls/compiled_resources2.gyp:settings_dropdown_menu', + '../prefs/compiled_resources2.gyp:prefs_behavior', + '../prefs/compiled_resources2.gyp:prefs_types', + '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr', + '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:i18n_behavior', + 'date_time_types', + ], + 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'], + }, + { + 'target_name': 'timezone_subpage', + 'dependencies': [ + '../prefs/compiled_resources2.gyp:prefs_behavior', + '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr', + 'date_time_types', + 'timezone_selector', ], 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'], }, diff --git a/chromium/chrome/browser/resources/settings/date_time_page/date_time_page.html b/chromium/chrome/browser/resources/settings/date_time_page/date_time_page.html index 0b573e387a1..d946c09c440 100644 --- a/chromium/chrome/browser/resources/settings/date_time_page/date_time_page.html +++ b/chromium/chrome/browser/resources/settings/date_time_page/date_time_page.html @@ -1,16 +1,21 @@ <link rel="import" href="chrome://resources/html/polymer.html"> +<link rel="import" href="chrome://resources/cr_elements/cr_toggle/cr_toggle.html"> +<link rel="import" href="chrome://resources/cr_elements/policy/cr_policy_indicator.html"> <link rel="import" href="chrome://resources/html/cr.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/cr_elements/policy/cr_policy_indicator.html"> <link rel="import" href="chrome://resources/polymer/v1_0/paper-icon-button/paper-icon-button-light.html"> -<link rel="import" href="chrome://resources/polymer/v1_0/paper-toggle-button/paper-toggle-button.html"> -<link rel="import" href="../controls/settings_dropdown_menu.html"> <link rel="import" href="../controls/settings_toggle_button.html"> <link rel="import" href="../i18n_setup.html"> <link rel="import" href="../prefs/prefs_behavior.html"> <link rel="import" href="../prefs/prefs_types.html"> +<link rel="import" href="../route.html"> +<link rel="import" href="../settings_page/settings_subpage.html"> <link rel="import" href="../settings_shared_css.html"> +<link rel="import" href="date_time_types.html"> +<link rel="import" href="timezone_selector.html"> +<link rel="import" href="timezone_subpage.html"> <dom-module id="settings-date-time-page"> <template> @@ -19,11 +24,14 @@ padding: 0; } - settings-dropdown-menu { - --md-select-width: 400px; + #timeZoneButton { + display: flex; + flex-direction: column; + justify-content: center; + width: 100%; } - paper-toggle-button { + cr-toggle { -webkit-margin-start: var(--settings-control-label-spacing); } @@ -31,76 +39,90 @@ -webkit-margin-start: var(--settings-controlled-by-spacing); } </style> - <div class="settings-box first"> - <div id="timezoneGeolocateToggleLabel" class="start"> - $i18n{timeZoneGeolocation} - </div> - <template is="dom-if" restamp - if="[[!prefs.cros.flags.per_user_timezone_enabled.value]]"> - <template is="dom-if" if="[[hasTimeZoneAutoDetectPolicy_]]" restamp> - <cr-policy-indicator indicator-type="devicePolicy" - icon-aria-label="$i18n{timeZoneGeolocation}"> - </cr-policy-indicator> - </template> - <paper-toggle-button - id="timeZoneAutoDetect" - aria-labelledby="timezoneGeolocateToggleLabel" - checked="[[timeZoneAutoDetect_]]" - disabled="[[hasTimeZoneAutoDetectPolicy_]]" - on-change="onTimeZoneAutoDetectChange_"> - </paper-toggle-button> - </template> - <template is="dom-if" restamp - if="[[prefs.cros.flags.per_user_timezone_enabled.value]]"> - <settings-toggle-button class="first" - pref="{{prefs.settings.resolve_timezone_by_geolocation}}" - id="timeZoneAutoDetect" - aria-label="$i18n{timeZoneGeolocation}"> - </settings-toggle-button> - </template> - </div> - <div class="settings-box continuation embedded"> - <template is="dom-if" restamp - if="[[!prefs.cros.flags.per_user_timezone_enabled.value]]"> - <settings-dropdown-menu pref="{{prefs.cros.system.timezone}}" - label="$i18n{timeZone}" - menu-options="[[timeZoneList_]]" - disabled="[[timeZoneAutoDetect_]]"> - </settings-dropdown-menu> - </template> - <template is="dom-if" restamp - if="[[prefs.cros.flags.per_user_timezone_enabled.value]]"> - <template is="dom-if" if="[[!isUserTimeZoneSelectorHidden_( - prefs.settings.timezone, - prefs.settings.resolve_timezone_by_geolocation.value)]]" restamp> - <settings-dropdown-menu id="userTimeZoneSelector" - pref="{{prefs.settings.timezone}}" - label="$i18n{timeZone}" - menu-options="[[timeZoneList_]]"> - </settings-dropdown-menu> + <settings-animated-pages id="pages" section="dateTime" + focus-config="[[focusConfig_]]"> + <neon-animatable id="main" route-path="default"> + <template is="dom-if" + if="[[!prefs.cros.flags.fine_grained_time_zone_detection_enabled.value]]" + restamp> + <div class="settings-box first"> + <div id="timezoneGeolocateToggleLabel" class="start"> + $i18n{timeZoneGeolocation} + </div> + <template is="dom-if" + if="[[hasTimeZoneAutoDetectPolicyRestriction_]]" restamp> + <cr-policy-indicator indicator-type="devicePolicy" + icon-aria-label="$i18n{timeZoneGeolocation}"> + </cr-policy-indicator> + </template> + <cr-toggle + id="timeZoneAutoDetect" + aria-label="$i18n{timeZoneGeolocation}" + checked="[[timeZoneAutoDetect_]]" + disabled="[[hasTimeZoneAutoDetectPolicyRestriction_]]" + on-change="onTimeZoneAutoDetectChange_"> + </cr-toggle> + </div> </template> - <template is="dom-if" if="[[isUserTimeZoneSelectorHidden_( - prefs.settings.timezone, - prefs.settings.resolve_timezone_by_geolocation.value)]]" restamp> - <settings-dropdown-menu id="systemTimezoneSelector" - pref="{{prefs.cros.system.timezone}}" - label="$i18n{timeZone}" - menu-options="[[timeZoneList_]]" - disabled> - </settings-dropdown-menu> + <template is="dom-if" + if="[[prefs.cros.flags.fine_grained_time_zone_detection_enabled.value]]" + restamp> + <div id="timeZoneSettingsTrigger" class="settings-box first" + on-tap="onTimeZoneSettings_" actionable> + <div id="timeZoneButton" class="two-line"> + $i18n{timeZoneButton} + <div class="secondary"> + <div hidden="[[timeZoneAutoDetect_]]"> + [[activeTimeZoneDisplayName]] + </div> + <div hidden="[[!timeZoneAutoDetect_]]"> + [[getTimeZoneAutoDetectMethodDisplayName_( + timeZoneAutoDetectMethod_)]] + </div> + </div> + </div> + <template is="dom-if" + if="[[hasTimeZoneAutoDetectPolicyRestriction_]]" restamp> + <cr-policy-indicator indicator-type="devicePolicy" + icon-aria-label="$i18n{timeZoneGeolocation}" + hidden="[[!hasTimeZoneAutoDetectPolicyRestriction_]]"> + </cr-policy-indicator> + </template> + <button class="subpage-arrow" + disabled="[[hasTimeZoneAutoDetectPolicyRestriction_]]" + is="paper-icon-button-light" + aria-label="$i18n{timeZoneButton}"></button> + </div> </template> + <div class="settings-box continuation embedded" + hidden="[[prefs.cros.flags.fine_grained_time_zone_detection_enabled.value]]"> + <timezone-selector prefs="{{prefs}}" + time-zone-auto-detect="[[timeZoneAutoDetect_]]" + active-time-zone-display-name="{{activeTimeZoneDisplayName}}"> + </timezone-selector> + </div> + <settings-toggle-button + pref="{{prefs.settings.clock.use_24hour_clock}}" + label="$i18n{use24HourClock}"> + </settings-toggle-button> + <div class="settings-box" id="setDateTime" actionable + on-tap="onSetDateTimeTap_" hidden$="[[!canSetDateTime_]]"> + <div class="start">$i18n{setDateTime}</div> + <button class="subpage-arrow" is="paper-icon-button-light" + aria-label="$i18n{setDateTime}"></button> + </div> + </neon-animatable> + <template is="dom-if" route-path="/dateTime/timeZone"> + <settings-subpage data-route="DATETIME_TIMEZONE_SUBPAGE" + associated-control="[[$$('#timeZoneSettingsTrigger')]]" + page-title="$i18n{timeZoneSubpageTitle}"> + <timezone-subpage id="timezoneSubpage" prefs="{{prefs}}" + time-zone-auto-detect="[[timeZoneAutoDetect_]]" + active-time-zone-display-name="{{activeTimeZoneDisplayName}}"> + </timezone-subpage> + </settings-subpage> </template> - </div> - <settings-toggle-button - pref="{{prefs.settings.clock.use_24hour_clock}}" - label="$i18n{use24HourClock}"> - </settings-toggle-button> - <div class="settings-box" id="setDateTime" actionable - on-tap="onSetDateTimeTap_" hidden$="[[!canSetDateTime_]]"> - <div class="start">$i18n{setDateTime}</div> - <button class="subpage-arrow" is="paper-icon-button-light" - aria-label="$i18n{setDateTime}"></button> - </div> + </settings-animated-pages> </template> <script src="date_time_page.js"></script> </dom-module> diff --git a/chromium/chrome/browser/resources/settings/date_time_page/date_time_page.js b/chromium/chrome/browser/resources/settings/date_time_page/date_time_page.js index ef378947636..09badd25ad5 100644 --- a/chromium/chrome/browser/resources/settings/date_time_page/date_time_page.js +++ b/chromium/chrome/browser/resources/settings/date_time_page/date_time_page.js @@ -8,36 +8,24 @@ * settings. */ -cr.exportPath('settings'); - -/** - * Describes the status of the auto-detect policy. - * @enum {number} - */ -settings.TimeZoneAutoDetectPolicy = { - NONE: 0, - FORCED_ON: 1, - FORCED_OFF: 2, -}; - Polymer({ is: 'settings-date-time-page', - behaviors: [PrefsBehavior, WebUIListenerBehavior], + behaviors: [I18nBehavior, PrefsBehavior, WebUIListenerBehavior], properties: { /** - * The time zone auto-detect policy. - * @private {settings.TimeZoneAutoDetectPolicy} + * The effective policy restriction on time zone automatic detection. + * @private {settings.TimeZoneAutoDetectPolicyRestriction} */ - timeZoneAutoDetectPolicy_: { - type: Boolean, + timeZoneAutoDetectPolicyRestriction_: { + type: Number, value: function() { if (!loadTimeData.valueExists('timeZoneAutoDetectValueFromPolicy')) - return settings.TimeZoneAutoDetectPolicy.NONE; + return settings.TimeZoneAutoDetectPolicyRestriction.NONE; return loadTimeData.getBoolean('timeZoneAutoDetectValueFromPolicy') ? - settings.TimeZoneAutoDetectPolicy.FORCED_ON : - settings.TimeZoneAutoDetectPolicy.FORCED_OFF; + settings.TimeZoneAutoDetectPolicyRestriction.FORCED_ON : + settings.TimeZoneAutoDetectPolicyRestriction.FORCED_OFF; }, }, @@ -45,37 +33,32 @@ Polymer({ * Whether a policy controls the time zone auto-detect setting. * @private */ - hasTimeZoneAutoDetectPolicy_: { + hasTimeZoneAutoDetectPolicyRestriction_: { type: Boolean, - computed: - 'computeHasTimeZoneAutoDetectPolicy_(timeZoneAutoDetectPolicy_)', + computed: 'computeHasTimeZoneAutoDetectPolicy_(' + + 'timeZoneAutoDetectPolicyRestriction_)', }, /** - * The effective time zone auto-detect setting. + * The effective time zone auto-detect enabled/disabled status. * @private */ timeZoneAutoDetect_: { type: Boolean, computed: 'computeTimeZoneAutoDetect_(' + - 'timeZoneAutoDetectPolicy_,' + - 'prefs.settings.resolve_timezone_by_geolocation.value)', + 'timeZoneAutoDetectPolicyRestriction_,' + + 'prefs.settings.resolve_timezone_by_geolocation_method.value)', }, /** - * Initialized with the current time zone so the menu displays the - * correct value. The full option list is fetched lazily if necessary by - * maybeGetTimeZoneList_. - * @private {!DropdownMenuOptionList} + * The effective time zone auto-detect method. + * @private {settings.TimeZoneAutoDetectMethod} */ - timeZoneList_: { - type: Array, - value: function() { - return [{ - name: loadTimeData.getString('timeZoneName'), - value: loadTimeData.getString('timeZoneID'), - }]; - }, + timeZoneAutoDetectMethod_: { + type: Number, + computed: 'computeTimeZoneAutoDetectMethod_(' + + 'hasTimeZoneAutoDetectPolicyRestriction_,' + + 'prefs.settings.resolve_timezone_by_geolocation_method.value)', }, /** @@ -87,14 +70,29 @@ Polymer({ type: Boolean, value: false, }, - }, - observers: [ - 'maybeGetTimeZoneListPerUser_(' + - 'prefs.settings.timezone.value, timeZoneAutoDetect_)', - 'maybeGetTimeZoneListPerSystem_(' + - 'prefs.cros.system.timezone.value, timeZoneAutoDetect_)', - ], + /** + * This is used to get current time zone display name from + * <timezone-selector> via bi-directional binding. + */ + activeTimeZoneDisplayName: { + type: String, + value: loadTimeData.getString('timeZoneName'), + }, + + /** @private {!Map<string, string>} */ + focusConfig_: { + type: Object, + value: function() { + var map = new Map(); + if (settings.routes.DATETIME_TIMEZONE_SUBPAGE) + map.set( + settings.routes.DATETIME_TIMEZONE_SUBPAGE.path, + '#timeZoneSettingsTrigger .subpage-arrow'); + return map; + }, + }, + }, /** @override */ attached: function() { @@ -105,7 +103,6 @@ Polymer({ 'can-set-date-time-changed', this.onCanSetDateTimeChanged_.bind(this)); chrome.send('dateTimePageReady'); - this.maybeGetTimeZoneList_(); }, /** @@ -116,11 +113,12 @@ Polymer({ */ onTimeZoneAutoDetectPolicyChanged_: function(managed, valueFromPolicy) { if (managed) { - this.timeZoneAutoDetectPolicy_ = valueFromPolicy ? - settings.TimeZoneAutoDetectPolicy.FORCED_ON : - settings.TimeZoneAutoDetectPolicy.FORCED_OFF; + this.timeZoneAutoDetectPolicyRestriction_ = valueFromPolicy ? + settings.TimeZoneAutoDetectPolicyRestriction.FORCED_ON : + settings.TimeZoneAutoDetectPolicyRestriction.FORCED_OFF; } else { - this.timeZoneAutoDetectPolicy_ = settings.TimeZoneAutoDetectPolicy.NONE; + this.timeZoneAutoDetectPolicyRestriction_ = + settings.TimeZoneAutoDetectPolicyRestriction.NONE; } }, @@ -138,7 +136,9 @@ Polymer({ */ onTimeZoneAutoDetectChange_: function(e) { this.setPrefValue( - 'settings.resolve_timezone_by_geolocation', e.target.checked); + 'settings.resolve_timezone_by_geolocation_method', + e.target.checked ? settings.TimeZoneAutoDetectMethod.IP_ONLY : + settings.TimeZoneAutoDetectMethod.DISABLED); }, /** @private */ @@ -147,106 +147,100 @@ Polymer({ }, /** - * @param {settings.TimeZoneAutoDetectPolicy} timeZoneAutoDetectPolicy + * @param {settings.TimeZoneAutoDetectPolicyRestriction} policyValue * @return {boolean} * @private */ - computeHasTimeZoneAutoDetectPolicy_: function(timeZoneAutoDetectPolicy) { - return timeZoneAutoDetectPolicy != settings.TimeZoneAutoDetectPolicy.NONE; + computeHasTimeZoneAutoDetectPolicy_: function(policyValue) { + return policyValue != settings.TimeZoneAutoDetectPolicyRestriction.NONE; }, /** - * @param {settings.TimeZoneAutoDetectPolicy} timeZoneAutoDetectPolicy - * @param {boolean} prefValue Value of the geolocation pref. + * @param {settings.TimeZoneAutoDetectPolicyRestriction} policyValue + * @param {settings.TimeZoneAutoDetectMethod} prefValue + * prefs.settings.resolve_timezone_by_geolocation_method.value * @return {boolean} Whether time zone auto-detect is enabled. * @private */ - computeTimeZoneAutoDetect_: function(timeZoneAutoDetectPolicy, prefValue) { - switch (timeZoneAutoDetectPolicy) { - case settings.TimeZoneAutoDetectPolicy.NONE: - return prefValue; - case settings.TimeZoneAutoDetectPolicy.FORCED_ON: + computeTimeZoneAutoDetect_: function(policyValue, prefValue) { + switch (policyValue) { + case settings.TimeZoneAutoDetectPolicyRestriction.NONE: + return prefValue != settings.TimeZoneAutoDetectMethod.DISABLED; + case settings.TimeZoneAutoDetectPolicyRestriction.FORCED_ON: return true; - case settings.TimeZoneAutoDetectPolicy.FORCED_OFF: + case settings.TimeZoneAutoDetectPolicyRestriction.FORCED_OFF: return false; default: - assertNotReached(); + console.error('Unknown policy value "' + policyValue + '".'); + return false; } }, /** - * Fetches the list of time zones if necessary. - * @param {boolean=} perUserTimeZoneMode Expected value of per-user time zone. + * Computes effective time zone detection method. + * @param {Boolean} hasTimeZoneAutoDetectPolicyRestriction + * this.hasTimeZoneAutoDetectPolicyRestriction_ + * @param {settings.TimeZoneAutoDetectMethod} prefResolveValue + * prefs.settings.resolve_timezone_by_geolocation_method.value + * @return {settings.TimeZoneAutoDetectMethod} * @private */ - maybeGetTimeZoneList_: function(perUserTimeZoneMode) { - if (typeof(perUserTimeZoneMode) !== 'undefined') { - /* This method is called as observer. Skip if if current mode does not - * match expected. - */ - if (perUserTimeZoneMode != - this.getPref('cros.flags.per_user_timezone_enabled').value) { - return; + computeTimeZoneAutoDetectMethod_: function( + hasTimeZoneAutoDetectPolicyRestriction, prefResolveValue) { + if (hasTimeZoneAutoDetectPolicyRestriction) { + // timeZoneAutoDetectPolicyRestriction_ actually depends on several time + // policies and chrome flags. So we ignore real policy value if it is + // disabled. + if (this.timeZoneAutoDetectPolicyRestriction_ == + settings.TimeZoneAutoDetectPolicyRestriction.FORCED_OFF) { + return settings.TimeZoneAutoDetectMethod.DISABLED; } - } - // Only fetch the list once. - if (this.timeZoneList_.length > 1 || !CrSettingsPrefs.isInitialized) - return; - - // If auto-detect is enabled, we only need the current time zone. - if (this.timeZoneAutoDetect_) { - var isPerUserTimezone = - this.getPref('cros.flags.per_user_timezone_enabled').value; - if (this.timeZoneList_[0].value == - (isPerUserTimezone ? this.getPref('settings.timezone').value : - this.getPref('cros.system.timezone').value)) { - return; + + var policyValue = /** @type{settings.SystemTimezoneProto} */ ( + this.getPref('settings.resolve_device_timezone_by_geolocation_policy') + .value); + + switch (policyValue) { + case settings.SystemTimezoneProto.USERS_DECIDE: + console.error('Unexpected policy value "' + policyValue + '".'); + return settings.TimeZoneAutoDetectMethod.DISABLED; + case settings.SystemTimezoneProto.DISABLED: + return settings.TimeZoneAutoDetectMethod.DISABLED; + case settings.SystemTimezoneProto.IP_ONLY: + return settings.TimeZoneAutoDetectMethod.IP_ONLY; + case settings.SystemTimezoneProto.SEND_WIFI_ACCESS_POINTS: + return settings.TimeZoneAutoDetectMethod.SEND_WIFI_ACCESS_POINTS; + case settings.SystemTimezoneProto.SEND_ALL_LOCATION_INFO: + return settings.TimeZoneAutoDetectMethod.SEND_ALL_LOCATION_INFO; + default: + return settings.TimeZoneAutoDetectMethod.DISABLED; } } - - cr.sendWithPromise('getTimeZones').then(this.setTimeZoneList_.bind(this)); - }, - - /** - * Prefs observer for Per-user time zone enabled mode. - * @private - */ - maybeGetTimeZoneListPerUser_: function() { - this.maybeGetTimeZoneList_(true); + return prefResolveValue; }, /** - * Prefs observer for Per-user time zone disabled mode. + * Returns display name of the given time zone detection method. + * @param {settings.TimeZoneAutoDetectMethod} method + * this.timeZoneAutoDetectMethod_ value. + * @return {string} * @private */ - maybeGetTimeZoneListPerSystem_: function() { - this.maybeGetTimeZoneList_(false); + getTimeZoneAutoDetectMethodDisplayName_: function(method) { + var id = ([ + 'setTimeZoneAutomaticallyDisabled', + 'setTimeZoneAutomaticallyIpOnlyDefault', + 'setTimeZoneAutomaticallyWithWiFiAccessPointsData', + 'setTimeZoneAutomaticallyWithAllLocationInfo' + ])[method]; + if (id) + return this.i18n(id); + + return ''; }, - /** - * Converts the C++ response into an array of menu options. - * @param {!Array<!Array<string>>} timeZones C++ time zones response. - * @private - */ - setTimeZoneList_: function(timeZones) { - this.timeZoneList_ = timeZones.map(function(timeZonePair) { - return { - name: timeZonePair[1], - value: timeZonePair[0], - }; - }); - }, - - /** - * Computes visibility of user timezone preference. - * @param {?chrome.settingsPrivate.PrefObject} prefUserTimezone - * pref.settings.timezone - * @param {boolean} prefResolveValue - * prefs.settings.resolve_timezone_by_geolocation.value - * @private - */ - isUserTimeZoneSelectorHidden_: function(prefUserTimezone, prefResolveValue) { - return (prefUserTimezone && prefUserTimezone.controlledBy != null) || - prefResolveValue; + onTimeZoneSettings_: function() { + // TODO(alemate): revise this once UI mocks are finished. + settings.navigateTo(settings.routes.DATETIME_TIMEZONE_SUBPAGE); }, }); diff --git a/chromium/chrome/browser/resources/settings/date_time_page/date_time_types.html b/chromium/chrome/browser/resources/settings/date_time_page/date_time_types.html new file mode 100644 index 00000000000..b3ecb802c52 --- /dev/null +++ b/chromium/chrome/browser/resources/settings/date_time_page/date_time_types.html @@ -0,0 +1,2 @@ +<link rel="import" href="chrome://resources/html/cr.html"> +<script src="date_time_types.js"></script> diff --git a/chromium/chrome/browser/resources/settings/date_time_page/date_time_types.js b/chromium/chrome/browser/resources/settings/date_time_page/date_time_types.js new file mode 100644 index 00000000000..241d9b21e0c --- /dev/null +++ b/chromium/chrome/browser/resources/settings/date_time_page/date_time_types.js @@ -0,0 +1,48 @@ +// 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. + +/** + * @fileoverview + * This defines some types for settings-date-time-page. + */ + +cr.exportPath('settings'); + +/** + * Describes the effective policy restriction on time zone automatic detection. + * @enum {number} + */ +settings.TimeZoneAutoDetectPolicyRestriction = { + NONE: 0, + FORCED_ON: 1, + FORCED_OFF: 2, +}; + +/** + * Describes values of prefs.settings.resolve_timezone_by_geolocation_method. + * Must be kept in sync with TimeZoneResolverManager::TimeZoneResolveMethod + * enum. + * @enum {number} + */ +settings.TimeZoneAutoDetectMethod = { + DISABLED: 0, + IP_ONLY: 1, + SEND_WIFI_ACCESS_POINTS: 2, + SEND_ALL_LOCATION_INFO: 3 +}; + +/** + * Describes values of prefs.settings. + * resolve_device_timezone_by_geolocation_policy + * Must be kept in sync with enterprise_management::SystemTimezoneProto + * enum. + * @enum {number} + */ +settings.SystemTimezoneProto = { + USERS_DECIDE: 0, + DISABLED: 1, + IP_ONLY: 2, + SEND_WIFI_ACCESS_POINTS: 3, + SEND_ALL_LOCATION_INFO: 4, +}; diff --git a/chromium/chrome/browser/resources/settings/date_time_page/timezone_selector.html b/chromium/chrome/browser/resources/settings/date_time_page/timezone_selector.html new file mode 100644 index 00000000000..10e03126f46 --- /dev/null +++ b/chromium/chrome/browser/resources/settings/date_time_page/timezone_selector.html @@ -0,0 +1,52 @@ +<link rel="import" href="chrome://resources/html/polymer.html"> + +<link rel="import" href="chrome://resources/html/i18n_behavior.html"> +<link rel="import" href="../controls/settings_dropdown_menu.html"> +<link rel="import" href="../i18n_setup.html"> +<link rel="import" href="../prefs/prefs_behavior.html"> +<link rel="import" href="../prefs/prefs_types.html"> +<link rel="import" href="../settings_shared_css.html"> +<link rel="import" href="date_time_types.html"> + +<dom-module id="timezone-selector"> + <template> + <style include="settings-shared"> + settings-dropdown-menu { + --md-select-width: 400px; + } + </style> + <template is="dom-if" restamp + if="[[!prefs.cros.flags.per_user_timezone_enabled.value]]"> + <settings-dropdown-menu pref="{{prefs.cros.system.timezone}}" + label="$i18n{timeZoneColon}" + menu-options="[[timeZoneList_]]" + disabled="[[timeZoneAutoDetect]]"> + </settings-dropdown-menu> + </template> + <template is="dom-if" restamp + if="[[prefs.cros.flags.per_user_timezone_enabled.value]]"> + <template is="dom-if" if="[[!isUserTimeZoneSelectorHidden_( + prefs.settings.timezone, + prefs.settings.resolve_timezone_by_geolocation_method.value)]]" + restamp> + <settings-dropdown-menu id="userTimeZoneSelector" + pref="{{prefs.settings.timezone}}" + label="$i18n{timeZoneColon}" + menu-options="[[timeZoneList_]]"> + </settings-dropdown-menu> + </template> + <template is="dom-if" if="[[isUserTimeZoneSelectorHidden_( + prefs.settings.timezone, + prefs.settings.resolve_timezone_by_geolocation_method.value)]]" + restamp> + <settings-dropdown-menu id="systemTimezoneSelector" + pref="{{prefs.cros.system.timezone}}" + label="$i18n{timeZoneColon}" + menu-options="[[timeZoneList_]]" + disabled> + </settings-dropdown-menu> + </template> + </template> + </template> + <script src="timezone_selector.js"></script> +</dom-module> diff --git a/chromium/chrome/browser/resources/settings/date_time_page/timezone_selector.js b/chromium/chrome/browser/resources/settings/date_time_page/timezone_selector.js new file mode 100644 index 00000000000..e6559db6fbd --- /dev/null +++ b/chromium/chrome/browser/resources/settings/date_time_page/timezone_selector.js @@ -0,0 +1,153 @@ +// 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. + +/** + * @fileoverview 'timezone-selector' is the time zone selector dropdown. + */ +(function() { +'use strict'; + +Polymer({ + is: 'timezone-selector', + + behaviors: [I18nBehavior, PrefsBehavior], + + properties: { + /** + * If time zone auto detectoin is enabled. + */ + timeZoneAutoDetect: Boolean, + + /** + * This stores active time zone display name to be used in other UI + * via bi-directional binding. + */ + activeTimeZoneDisplayName: { + type: String, + notify: true, + }, + + /** + * Initialized with the current time zone so the menu displays the + * correct value. The full option list is fetched lazily if necessary by + * maybeGetTimeZoneList_. + * @private {!DropdownMenuOptionList} + */ + timeZoneList_: { + type: Array, + value: function() { + return [{ + name: loadTimeData.getString('timeZoneName'), + value: loadTimeData.getString('timeZoneID'), + }]; + }, + }, + }, + + observers: [ + 'maybeGetTimeZoneListPerUser_(' + + 'prefs.settings.timezone.value, timeZoneAutoDetect)', + 'maybeGetTimeZoneListPerSystem_(' + + 'prefs.cros.system.timezone.value, timeZoneAutoDetect)', + 'updateActiveTimeZoneName_(prefs.cros.system.timezone.value)', + ], + + /** @override */ + attached: function() { + this.maybeGetTimeZoneList_(); + }, + + /** + * Fetches the list of time zones if necessary. + * @param {boolean=} perUserTimeZoneMode Expected value of per-user time zone. + * @private + */ + maybeGetTimeZoneList_: function(perUserTimeZoneMode) { + if (typeof(perUserTimeZoneMode) !== 'undefined') { + /* This method is called as observer. Skip if if current mode does not + * match expected. + */ + if (perUserTimeZoneMode != + this.getPref('cros.flags.per_user_timezone_enabled').value) { + return; + } + } + // Only fetch the list once. + if (this.timeZoneList_.length > 1 || !CrSettingsPrefs.isInitialized) + return; + + // If auto-detect is enabled, we only need the current time zone. + if (this.timeZoneAutoDetect) { + var isPerUserTimezone = + this.getPref('cros.flags.per_user_timezone_enabled').value; + if (this.timeZoneList_[0].value == + (isPerUserTimezone ? this.getPref('settings.timezone').value : + this.getPref('cros.system.timezone').value)) { + return; + } + } + + cr.sendWithPromise('getTimeZones').then(this.setTimeZoneList_.bind(this)); + }, + + /** + * Prefs observer for Per-user time zone enabled mode. + * @private + */ + maybeGetTimeZoneListPerUser_: function() { + this.maybeGetTimeZoneList_(true); + }, + + /** + * Prefs observer for Per-user time zone disabled mode. + * @private + */ + maybeGetTimeZoneListPerSystem_: function() { + this.maybeGetTimeZoneList_(false); + }, + + /** + * Converts the C++ response into an array of menu options. + * @param {!Array<!Array<string>>} timeZones C++ time zones response. + * @private + */ + setTimeZoneList_: function(timeZones) { + this.timeZoneList_ = timeZones.map(function(timeZonePair) { + return { + name: timeZonePair[1], + value: timeZonePair[0], + }; + }); + this.updateActiveTimeZoneName_( + /** @type {!String} */ (this.getPref('cros.system.timezone').value)); + }, + + /** + * Updates active time zone display name when changed. + * @param {!String} activeTimeZoneId value of cros.system.timezone preference. + * @private + */ + updateActiveTimeZoneName_: function(activeTimeZoneId) { + var activeTimeZone = this.timeZoneList_.find( + (timeZone) => timeZone.value == activeTimeZoneId); + if (activeTimeZone) + this.activeTimeZoneDisplayName = activeTimeZone.name; + }, + + + /** + * Computes visibility of user timezone preference. + * @param {?chrome.settingsPrivate.PrefObject} prefUserTimezone + * pref.settings.timezone + * @param {settings.TimeZoneAutoDetectMethod} prefResolveValue + * prefs.settings.resolve_timezone_by_geolocation_method.value + * @return {boolean} + * @private + */ + isUserTimeZoneSelectorHidden_: function(prefUserTimezone, prefResolveValue) { + return (prefUserTimezone && prefUserTimezone.controlledBy != null) || + prefResolveValue != settings.TimeZoneAutoDetectMethod.DISABLED; + }, +}); +})(); diff --git a/chromium/chrome/browser/resources/settings/date_time_page/timezone_subpage.html b/chromium/chrome/browser/resources/settings/date_time_page/timezone_subpage.html new file mode 100644 index 00000000000..200f175ffed --- /dev/null +++ b/chromium/chrome/browser/resources/settings/date_time_page/timezone_subpage.html @@ -0,0 +1,54 @@ +<link rel="import" href="chrome://resources/html/polymer.html"> + +<link rel="import" href="../controls/controlled_radio_button.html"> +<link rel="import" href="../controls/settings_radio_group.html"> +<link rel="import" href="../prefs/prefs.html"> +<link rel="import" href="../prefs/prefs_behavior.html"> +<link rel="import" href="../settings_shared_css.html"> +<link rel="import" href="date_time_types.html"> + +<dom-module id="timezone-subpage"> + <template> + <style include="settings-shared"> + .block { + display: block; + } + </style> + <div class="settings-box block first"> + <settings-radio-group id="timeZoneRadioGroup" + pref="{{prefs.settings.resolve_timezone_by_geolocation_method}}"> + <controlled-radio-button + name="[[timezoneAutodetectMethodValues_.IP_ONLY]]" + pref="[[prefs.settings.resolve_timezone_by_geolocation_method]]" + label="$i18n{setTimeZoneAutomaticallyIpOnlyDefault}" + no-extension-indicator> + <div class="secondary"> + $i18n{setTimeZoneAutomaticallyIpOnlyDefaultDescription} + </div> + </controlled-radio-button> + <controlled-radio-button + name="[[timezoneAutodetectMethodValues_.SEND_ALL_LOCATION_INFO]]" + pref="[[prefs.settings.resolve_timezone_by_geolocation_method]]" + label="$i18n{setTimeZoneAutomaticallyWithAllLocationInfo}" + no-extension-indicator> + <div class="secondary"> + $i18n{setTimeZoneAutomaticallyWithAllLocationInfoDescription} + </div> + </controlled-radio-button> + <controlled-radio-button + name="[[timezoneAutodetectMethodValues_.DISABLED]]" + pref="[[prefs.settings.resolve_timezone_by_geolocation_method]]" + label="$i18n{selectYourTimeZone}" + no-extension-indicator> + </controlled-radio-button> + </settings-radio-group> + </div> + <div class="settings-box block"> + <timezone-selector prefs="{{prefs}}" + time-zone-auto-detect="[[timeZoneAutoDetect]]" + active-time-zone-display-name="{{activeTimeZoneDisplayName}}"> + </timezone-selector> + </div> + </template> + <script src="timezone_subpage.js"></script> +</dom-module> diff --git a/chromium/chrome/browser/resources/settings/date_time_page/timezone_subpage.js b/chromium/chrome/browser/resources/settings/date_time_page/timezone_subpage.js new file mode 100644 index 00000000000..96109be8c76 --- /dev/null +++ b/chromium/chrome/browser/resources/settings/date_time_page/timezone_subpage.js @@ -0,0 +1,43 @@ +// 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. + +/** + * @fileoverview 'timezone-subpage' is the collapsible section containing + * time zone settings. + */ +(function() { +'use strict'; + +Polymer({ + is: 'timezone-subpage', + + behaviors: [PrefsBehavior], + + properties: { + /** + * This is <timezone-selector> parameter. + */ + activeTimeZoneDisplayName: { + type: String, + notify: true, + }, + + /** + * The effective time zone auto-detect enabled/disabled status. + */ + timeZoneAutoDetect: Boolean, + + /** + * settings.TimeZoneAutoDetectMethod values. + * @private {!Object<settings.TimeZoneAutoDetectMethod, number>} + */ + timezoneAutodetectMethodValues_: Object, + + }, + + attached: function() { + this.timezoneAutodetectMethodValues_ = settings.TimeZoneAutoDetectMethod; + }, +}); +})(); diff --git a/chromium/chrome/browser/resources/settings/device_page/display.html b/chromium/chrome/browser/resources/settings/device_page/display.html index 0602de00131..b3e57b250ca 100644 --- a/chromium/chrome/browser/resources/settings/device_page/display.html +++ b/chromium/chrome/browser/resources/settings/device_page/display.html @@ -1,6 +1,7 @@ <link rel="import" href="chrome://resources/html/polymer.html"> <link rel="import" href="chrome://resources/cr_elements/cr_link_row/cr_link_row.html"> +<link rel="import" href="chrome://resources/cr_elements/cr_toggle/cr_toggle.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"> @@ -9,7 +10,6 @@ <link rel="import" href="chrome://resources/polymer/v1_0/paper-button/paper-button.html"> <link rel="import" href="chrome://resources/polymer/v1_0/paper-icon-button/paper-icon-button-light.html"> <link rel="import" href="chrome://resources/polymer/v1_0/paper-tabs/paper-tabs.html"> -<link rel="import" href="chrome://resources/polymer/v1_0/paper-toggle-button/paper-toggle-button.html"> <link rel="import" href="display_layout.html"> <link rel="import" href="display_overscan_dialog.html"> <link rel="import" href="night_light_slider.html"> @@ -28,6 +28,11 @@ padding: 0; } + #nightLightTemperatureDiv[disabled] { + opacity: 0.38; + pointer-events: none; + } + .display-tabs { width: 100%; } @@ -72,6 +77,18 @@ selected-display="[[selectedDisplay]]" on-select-display="onSelectDisplay_"> </display-layout> + + <template is="dom-if" if="[[showMirror_(unifiedDesktopMode_, displays)]]" + restamp> + <div class="secondary self-start"> + <paper-checkbox checked="[[isMirrored_(displays)]]" + on-tap="onMirroredTap_" + aria-label="[[getDisplayMirrorText_(displays)]]"> + <div class="text-area">[[getDisplayMirrorText_(displays)]]</div> + </paper-checkbox> + </div> + </template> + </div> <div hidden="[[!hasMultipleDisplays_(displays)]]" class="settings-box"> <paper-tabs noink selected="[[selectedDisplay.id]]" class="display-tabs" @@ -86,21 +103,6 @@ <div id="controlsDiv" class="settings-box layout vertical first"> <h2>[[selectedDisplay.name]]</h2> - - <template is="dom-if" if="[[showMirror_(unifiedDesktopMode_, displays)]]" - restamp> - <div class="settings-box indented two-line"> - <div class="start"> - <div id="displayMirrorCheckboxLabel">$i18n{displayMirror}</div> - <div class="secondary">[[getDisplayMirrorText_(displays)]]</div> - </div> - <paper-toggle-button checked="[[isMirrored_(displays)]]" - on-tap="onMirroredTap_" - aria-labelledby="displayMirrorCheckboxLabel"> - </paper-toggle-button> - </div> - </template> - <template is="dom-if" if="[[showUnifiedDesktop_(unifiedDesktopAvailable_, unifiedDesktopMode_, displays)]]" restamp> <div class="settings-box indented two-line"> @@ -112,10 +114,10 @@ [[getUnifiedDesktopText_(unifiedDesktopMode_)]] </div> </div> - <paper-toggle-button checked="[[unifiedDesktopMode_]]" + <cr-toggle checked="[[unifiedDesktopMode_]]" on-tap="onUnifiedDesktopTap_" aria-labelledby="displayUnifiedDesktopCheckboxLabel"> - </paper-toggle-button> + </cr-toggle> </div> </template> @@ -208,7 +210,9 @@ <div id="nightLightSettingsDiv" class="settings-box continuation start layout vertical"> <!-- Color temperature slider --> - <div class="settings-box indented continuation"> + <div id="nightLightTemperatureDiv" + class="settings-box indented continuation" + disabled$="[[!prefs.ash.night_light.enabled.value]]"> <div class="start text-area" id="colorTemperatureLabel"> $i18n{displayNightLightTemperatureLabel} </div> @@ -216,7 +220,8 @@ aria-labelledby="colorTemperatureLabel" min="0" max="100" scale="100" label-min="$i18n{displayNightLightTempSliderMinLabel}" label-max="$i18n{displayNightLightTempSliderMaxLabel}" - pref="{{prefs.ash.night_light.color_temperature}}"> + pref="{{prefs.ash.night_light.color_temperature}}" + disabled$="[[!prefs.ash.night_light.enabled.value]]"> </settings-slider> </div> <!-- Schedule settings --> diff --git a/chromium/chrome/browser/resources/settings/device_page/display.js b/chromium/chrome/browser/resources/settings/device_page/display.js index a29d2615c60..1a35186287c 100644 --- a/chromium/chrome/browser/resources/settings/device_page/display.js +++ b/chromium/chrome/browser/resources/settings/device_page/display.js @@ -80,6 +80,9 @@ Polymer({ notify: true, }, + /** Ids for mirroring destination displays. */ + mirroringDestinationIds: Array, + /** @private {!Array<number>} Mode index values for slider. */ modeValues_: Array, @@ -92,6 +95,14 @@ Polymer({ }, /** @private */ + multiMirroringAvailable_: { + type: Boolean, + value: function() { + return loadTimeData.getBoolean('multiMirroringAvailable'); + } + }, + + /** @private */ nightLightFeatureEnabled_: { type: Boolean, value: function() { @@ -205,6 +216,10 @@ Polymer({ return; settings.display.systemDisplayApi.getDisplayLayout( this.displayLayoutFetched_.bind(this, displays)); + if (this.isMirrored_(displays)) + this.mirroringDestinationIds = displays[0].mirroringDestinationIds; + else + this.mirroringDestinationIds = []; }, /** @@ -256,16 +271,17 @@ Polymer({ }, /** - * Returns true if the given display has touch support and is not an internal - * display. If the feature is not enabled via the switch, this will return - * false. + * Returns true if external touch devices are connected and the current + * display is not an internal display. If the feature is not enabled via the + * switch, this will return false. * @param {!chrome.system.display.DisplayUnitInfo} display Display being * checked for touch support. * @return {boolean} * @private */ showTouchCalibrationSetting_: function(display) { - return !display.isInternal && display.hasTouchSupport && + return !display.isInternal && + loadTimeData.getBoolean('hasExternalTouchDevice') && loadTimeData.getBoolean('enableTouchCalibrationSetting'); }, @@ -310,7 +326,7 @@ Polymer({ * @private */ getDisplayMirrorText_: function(displays) { - return this.i18n(this.isMirrored_(displays) ? 'toggleOn' : 'toggleOff'); + return this.i18n('displayMirror', displays[0].name); }, /** @@ -344,7 +360,9 @@ Polymer({ */ showMirror_: function(unifiedDesktopMode, displays) { return this.isMirrored_(displays) || - (!unifiedDesktopMode && displays.length == 2); + (!unifiedDesktopMode && + ((this.multiMirroringAvailable_ && displays.length > 1) || + displays.length == 2)); }, /** @@ -496,7 +514,10 @@ Polymer({ }, /** @private */ - onMirroredTap_: function() { + onMirroredTap_: function(event) { + // Blur the control so that when the transition animation completes and the + // UI is focused, the control does not receive focus. crbug.com/785070 + event.target.blur(); var id = ''; /** @type {!chrome.system.display.DisplayProperties} */ var properties = {}; if (this.isMirrored_(this.displays)) { @@ -565,7 +586,8 @@ Polymer({ this.unifiedDesktopMode_ = !!primaryDisplay && primaryDisplay.isUnified; - this.$.displayLayout.updateDisplays(this.displays, this.layouts); + this.$.displayLayout.updateDisplays( + this.displays, this.layouts, this.mirroringDestinationIds); }, /** @private */ diff --git a/chromium/chrome/browser/resources/settings/device_page/display_layout.html b/chromium/chrome/browser/resources/settings/device_page/display_layout.html index d5a610f0db7..289ebf9c8f2 100644 --- a/chromium/chrome/browser/resources/settings/device_page/display_layout.html +++ b/chromium/chrome/browser/resources/settings/device_page/display_layout.html @@ -58,10 +58,11 @@ } </style> <div id="displayArea" on-iron-resize="calculateVisualScale_"> - <template is="dom-repeat" items="[[displays]]"> - <div id="_mirror_[[item.id]]" class="display mirror" + <template is="dom-repeat" items="[[mirroringDestinationIds_]]"> + <div id="_mirror_[[item]]" class="display mirror" hidden$="[[!mirroring]]" - style$="[[getMirrorDivStyle_(item.id, item.bounds, visualScale)]]"> + style$="[[getMirrorDivStyle_(index, mirroringDestinationIds_.length, + displays, visualScale)]]"> </div> </template> <template is="dom-repeat" items="[[displays]]"> @@ -69,7 +70,12 @@ draggable="[[dragEnabled]]" on-tap="onSelectDisplayTap_" style$="[[getDivStyle_(item.id, item.bounds, visualScale)]]" selected$="[[isSelected_(item, selectedDisplay)]]"> - [[item.name]] + <div hidden$="[[mirroring]]"> + [[item.name]] + </div> + <div hidden$="[[!mirroring]]"> + $i18n{displayMirrorDisplayName} + </div> </div> </template> </div> diff --git a/chromium/chrome/browser/resources/settings/device_page/display_layout.js b/chromium/chrome/browser/resources/settings/device_page/display_layout.js index 7063a7c0a80..c5ef6d6491d 100644 --- a/chromium/chrome/browser/resources/settings/device_page/display_layout.js +++ b/chromium/chrome/browser/resources/settings/device_page/display_layout.js @@ -36,6 +36,13 @@ Polymer({ * @type {number} */ visualScale: 1, + + /** + * Ids for mirroring destination displays. + * @type {!Array<string>|undefined} + * @private + */ + mirroringDestinationIds_: Array, }, /** @private {!{left: number, top: number}} */ @@ -51,10 +58,12 @@ Polymer({ * have been fetched from chrome. * @param {!Array<!chrome.system.display.DisplayUnitInfo>} displays * @param {!Array<!chrome.system.display.DisplayLayout>} layouts + * @param {!Array<string>} mirroringDestinationIds */ - updateDisplays: function(displays, layouts) { + updateDisplays: function(displays, layouts, mirroringDestinationIds) { this.displays = displays; this.layouts = layouts; + this.mirroringDestinationIds_ = mirroringDestinationIds; this.initializeDisplayLayout(displays, layouts); @@ -137,15 +146,15 @@ Polymer({ * @param {string} id * @param {!chrome.system.display.Bounds} displayBounds * @param {number} visualScale - * @param {boolean=} opt_mirrored + * @param {number=} opt_offset * @return {string} The style string for the div. * @private */ - getDivStyle_: function(id, displayBounds, visualScale, opt_mirrored) { + getDivStyle_: function(id, displayBounds, visualScale, opt_offset) { // This matches the size of the box-shadow or border in CSS. /** @const {number} */ var BORDER = 1; /** @const {number} */ var MARGIN = 4; - /** @const {number} */ var OFFSET = opt_mirrored ? -4 : 0; + /** @const {number} */ var OFFSET = opt_offset || 0; /** @const {number} */ var PADDING = 3; var bounds = this.getCalculatedDisplayBounds(id, true /* notest */); if (!bounds) @@ -163,14 +172,22 @@ Polymer({ }, /** - * @param {string} id - * @param {!chrome.system.display.Bounds} displayBounds + * @param {number} mirroringDestinationIndex + * @param {number} mirroringDestinationDisplayNum + * @param {!Array<!chrome.system.display.DisplayUnitInfo>} displays * @param {number} visualScale * @return {string} The style string for the mirror div. * @private */ - getMirrorDivStyle_: function(id, displayBounds, visualScale) { - return this.getDivStyle_(id, displayBounds, visualScale, true); + getMirrorDivStyle_: function( + mirroringDestinationIndex, mirroringDestinationDisplayNum, displays, + visualScale) { + // All destination displays have the same bounds as the mirroring source + // display, but we add a little offset to each destination display's bounds + // so that they can be distinguished from each other in the layout. + return this.getDivStyle_( + displays[0].id, displays[0].bounds, visualScale, + (mirroringDestinationDisplayNum - mirroringDestinationIndex) * -4); }, /** diff --git a/chromium/chrome/browser/resources/settings/device_page/stylus.html b/chromium/chrome/browser/resources/settings/device_page/stylus.html index 4c50c21298c..6a0dad02d98 100644 --- a/chromium/chrome/browser/resources/settings/device_page/stylus.html +++ b/chromium/chrome/browser/resources/settings/device_page/stylus.html @@ -1,5 +1,6 @@ <link rel="import" href="chrome://resources/html/polymer.html"> +<link rel="import" href="chrome://resources/cr_elements/cr_toggle/cr_toggle.html"> <link rel="import" href="chrome://resources/html/action_link.html"> <link rel="import" href="chrome://resources/polymer/v1_0/paper-icon-button/paper-icon-button-light.html"> <link rel="import" href="../controls/settings_toggle_button.html"> @@ -29,13 +30,15 @@ } </style> - <settings-toggle-button class="continuation" + <settings-toggle-button id="enableStylusToolsToggle" + class="continuation" pref="{{prefs.settings.enable_stylus_tools}}" label="$i18n{stylusEnableStylusTools}"> </settings-toggle-button> <template is="dom-if" if="[[hasInternalStylus_]]"> <settings-toggle-button + id ="launchPaletteOnEjectEventToggle" pref="{{prefs.settings.launch_palette_on_eject_event}}" label="$i18n{stylusAutoOpenStylusTools}" disabled="[[!prefs.settings.enable_stylus_tools.value]]"> @@ -103,12 +106,12 @@ indicator-type="[[userPolicyIndicator_]]"> </cr-policy-indicator> </template> - <paper-toggle-button id="enable-app-on-lock-screen-toggle" + <cr-toggle id="enable-app-on-lock-screen-toggle" aria-labelledby="lock-screen-toggle-label" disabled="[[disallowedOnLockScreenByPolicy_(selectedApp_)]]" checked="[[lockScreenSupportEnabled_(selectedApp_)]]" on-change="toggleLockScreenSupport_"> - </paper-toggle-button> + </cr-toggle> </div> <template is="dom-if" if="[[lockScreenSupportEnabled_(selectedApp_)]]"> diff --git a/chromium/chrome/browser/resources/settings/icons.html b/chromium/chrome/browser/resources/settings/icons.html index 61224dceb7b..07119529659 100644 --- a/chromium/chrome/browser/resources/settings/icons.html +++ b/chromium/chrome/browser/resources/settings/icons.html @@ -54,6 +54,7 @@ List icons here rather than importing large sets of (e.g. Polymer) icons. <if expr="chromeos"> <g id="chevron-left"><path d="M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z"</path></g> </if> + <g id="clipboard"><path d="M19 2h-4.18C14.4.84 13.3 0 12 0c-1.3 0-2.4.84-2.82 2H5c-1.1 0-2 .9-2 2v16c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm-7 0c.55 0 1 .45 1 1s-.45 1-1 1-1-.45-1-1 .45-1 1-1zm7 18H5V4h2v3h10V4h2v16z"></path></g> <g id="cloud"><path d="M19.35 10.04C18.67 6.59 15.64 4 12 4 9.11 4 6.6 5.64 5.35 8.04 2.34 8.36 0 10.91 0 14c0 3.31 2.69 6 6 6h13c2.76 0 5-2.24 5-5 0-2.64-2.05-4.78-4.65-4.96z"></path></g> <g id="code"><path d="M9.4 16.6L4.8 12l4.6-4.6L8 6l-6 6 6 6 1.4-1.4zm5.2 0l4.6-4.6-4.6-4.6L16 6l6 6-6 6-1.4-1.4z"></path></g> <g id="content-copy"><path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"></path></g> @@ -64,7 +65,6 @@ List icons here rather than importing large sets of (e.g. Polymer) icons. </if> <g id="done"><path d="M9 16.2L4.8 12l-1.4 1.4L9 19 21 7l-1.4-1.4L9 16.2z"></path></g> <g id="error"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z"></path></g> - <g id="error-outline"><path d="M11 15h2v2h-2zm0-8h2v6h-2zm.99-5C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"></path></g> <if expr="chromeos"> <g id="fingerprint"><path d="M17.81 4.47c-.08 0-.16-.02-.23-.06C15.66 3.42 14 3 12.01 3c-1.98 0-3.86.47-5.57 1.41-.24.13-.54.04-.68-.2-.13-.24-.04-.55.2-.68C7.82 2.52 9.86 2 12.01 2c2.13 0 3.99.47 6.03 1.52.25.13.34.43.21.67-.09.18-.26.28-.44.28zM3.5 9.72c-.1 0-.2-.03-.29-.09-.23-.16-.28-.47-.12-.7.99-1.4 2.25-2.5 3.75-3.27C9.98 4.04 14 4.03 17.15 5.65c1.5.77 2.76 1.86 3.75 3.25.16.22.11.54-.12.7-.23.16-.54.11-.7-.12-.9-1.26-2.04-2.25-3.39-2.94-2.87-1.47-6.54-1.47-9.4.01-1.36.7-2.5 1.7-3.4 2.96-.08.14-.23.21-.39.21zm6.25 12.07c-.13 0-.26-.05-.35-.15-.87-.87-1.34-1.43-2.01-2.64-.69-1.23-1.05-2.73-1.05-4.34 0-2.97 2.54-5.39 5.66-5.39s5.66 2.42 5.66 5.39c0 .28-.22.5-.5.5s-.5-.22-.5-.5c0-2.42-2.09-4.39-4.66-4.39-2.57 0-4.66 1.97-4.66 4.39 0 1.44.32 2.77.93 3.85.64 1.15 1.08 1.64 1.85 2.42.19.2.19.51 0 .71-.11.1-.24.15-.37.15zm7.17-1.85c-1.19 0-2.24-.3-3.1-.89-1.49-1.01-2.38-2.65-2.38-4.39 0-.28.22-.5.5-.5s.5.22.5.5c0 1.41.72 2.74 1.94 3.56.71.48 1.54.71 2.54.71.24 0 .64-.03 1.04-.1.27-.05.53.13.58.41.05.27-.13.53-.41.58-.57.11-1.07.12-1.21.12zM14.91 22c-.04 0-.09-.01-.13-.02-1.59-.44-2.63-1.03-3.72-2.1-1.4-1.39-2.17-3.24-2.17-5.22 0-1.62 1.38-2.94 3.08-2.94 1.7 0 3.08 1.32 3.08 2.94 0 1.07.93 1.94 2.08 1.94s2.08-.87 2.08-1.94c0-3.77-3.25-6.83-7.25-6.83-2.84 0-5.44 1.58-6.61 4.03-.39.81-.59 1.76-.59 2.8 0 .78.07 2.01.67 3.61.1.26-.03.55-.29.64-.26.1-.55-.04-.64-.29-.49-1.31-.73-2.61-.73-3.96 0-1.2.23-2.29.68-3.24 1.33-2.79 4.28-4.6 7.51-4.6 4.55 0 8.25 3.51 8.25 7.83 0 1.62-1.38 2.94-3.08 2.94s-3.08-1.32-3.08-2.94c0-1.07-.93-1.94-2.08-1.94s-2.08.87-2.08 1.94c0 1.71.66 3.31 1.87 4.51.95.94 1.86 1.46 3.27 1.85.27.07.42.35.35.61-.05.23-.26.38-.47.38z"></path></g> <g id="gamepad"><path d="M15 7.5V2H9v5.5l3 3 3-3zM7.5 9H2v6h5.5l3-3-3-3zM9 16.5V22h6v-5.5l-3-3-3 3zM16.5 9l-3 3 3 3H22V9h-5.5z"></path></g> @@ -72,6 +72,7 @@ List icons here rather than importing large sets of (e.g. Polymer) icons. </if> <g id="help-outline"><path d="M11 18h2v-2h-2v2zm1-16C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8zm0-14c-2.21 0-4 1.79-4 4h2c0-1.1.9-2 2-2s2 .9 2 2c0 2-3 1.75-3 5h2c0-2.25 3-2.5 3-5 0-2.21-1.79-4-4-4z"></path></g> <g id="info"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-6h2v6zm0-8h-2V7h2v2z"></path></g> + <g id="info-outline"><path d="M11 17h2v-6h-2v6zm1-15C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8zM11 9h2V7h-2v2z"></path></g> <if expr="chromeos"> <g id="keyboard"><path d="M20 5H4c-1.1 0-1.99.9-1.99 2L2 17c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm-9 3h2v2h-2V8zm0 3h2v2h-2v-2zM8 8h2v2H8V8zm0 3h2v2H8v-2zm-1 2H5v-2h2v2zm0-3H5V8h2v2zm9 7H8v-2h8v2zm0-4h-2v-2h2v2zm0-3h-2V8h2v2zm3 3h-2v-2h2v2zm0-3h-2V8h2v2z"></path></g> </if> @@ -81,9 +82,6 @@ List icons here rather than importing large sets of (e.g. Polymer) icons. </if> <g id="list"><path d="M3 13h2v-2H3v2zm0 4h2v-2H3v2zm0-8h2V7H3v2zm4 4h14v-2H7v2zm0 4h14v-2H7v2zM7 7v2h14V7H7z"></path></g> <g id="location-on"><path d="M12 2C8.13 2 5 5.13 5 9c0 5.25 7 13 7 13s7-7.75 7-13c0-3.87-3.13-7-7-7zm0 9.5c-1.38 0-2.5-1.12-2.5-2.5s1.12-2.5 2.5-2.5 2.5 1.12 2.5 2.5-1.12 2.5-2.5 2.5z"></path></g> -<if expr="chromeos"> - <g id="lock"><path d="M18 8h-1V6c0-2.76-2.24-5-5-5S7 3.24 7 6v2H6c-1.1 0-2 .9-2 2v10c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V10c0-1.1-.9-2-2-2zm-6 9c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2zm3.1-9H8.9V6c0-1.71 1.39-3.1 3.1-3.1 1.71 0 3.1 1.39 3.1 3.1v2z"></path></g> -</if> <g id="mic"><path d="M12 14c1.66 0 2.99-1.34 2.99-3L15 5c0-1.66-1.34-3-3-3S9 3.34 9 5v6c0 1.66 1.34 3 3 3zm5.3-3c0 3-2.54 5.1-5.3 5.1S6.7 14 6.7 11H5c0 3.41 2.72 6.23 6 6.72V21h2v-3.28c3.28-.48 6-3.3 6-6.72h-1.7z"></path></g> <g id="midi"><path d="M21,19.1H3V5h18V19.1z M21,3H3C1.9,3,1,3.9,1,5v14c0,1.1,0.9,2,2,2h18c1.1,0,2-0.9,2-2V5C23,3.9,22.1,3,21,3z"></path><path fill="none" d="M21,19.1H3V5h18V19.1z M21,3H3C1.9,3,1,3.9,1,5v14c0,1.1,0.9,2,2,2h18c1.1,0,2-0.9,2-2V5C23,3.9,22.1,3,21,3z"></path><path d="M14,5h3v8h-3V5z"></path><path d="M15,12h1v8h-1V12z"></path><path fill="none" d="M0,0h24v24H0V0z"></path><rect x="7" y="5" width="3" height="8"></rect><rect x="8" y="12" width="1" height="8"></rect></g> <if expr="chromeos"> @@ -109,7 +107,6 @@ List icons here rather than importing large sets of (e.g. Polymer) icons. <g id="signal-cellular-2-bar"><path fill-opacity=".3" d="M2 22h20V2z"></path><path d="M14 10L2 22h12z"></path></g> <g id="signal-cellular-3-bar"><path fill-opacity=".3" d="M2 22h20V2z"></path><path d="M17 7L2 22h15z"></path></g> <g id="signal-cellular-4-bar"><path d="M2 22h20V2z"></path></g> - <g id="sim-card-alert"><path d="M18 2h-8L4.02 8 4 20c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm-5 15h-2v-2h2v2zm0-4h-2V8h2v5z"></path></g> <g id="smartphone"><path d="M17 1.01L7 1c-1.1 0-2 .9-2 2v18c0 1.1.9 2 2 2h10c1.1 0 2-.9 2-2V3c0-1.1-.9-1.99-2-1.99zM17 19H7V5h10v14z"></path></g> </if> <g id="supervisor-account"><path d="M16.5 12c1.38 0 2.49-1.12 2.49-2.5S17.88 7 16.5 7C15.12 7 14 8.12 14 9.5s1.12 2.5 2.5 2.5zM9 11c1.66 0 2.99-1.34 2.99-3S10.66 5 9 5C7.34 5 6 6.34 6 8s1.34 3 3 3zm7.5 3c-1.83 0-5.5.92-5.5 2.75V19h11v-2.25c0-1.83-3.67-2.75-5.5-2.75zM9 13c-2.33 0-7 1.17-7 3.5V19h7v-2.25c0-.85.33-2.34 2.37-3.47C10.5 13.1 9.66 13 9 13z"></path></g> diff --git a/chromium/chrome/browser/resources/settings/internet_page/compiled_resources2.gyp b/chromium/chrome/browser/resources/settings/internet_page/compiled_resources2.gyp index 18f9191b2ff..7ffb7c767f7 100644 --- a/chromium/chrome/browser/resources/settings/internet_page/compiled_resources2.gyp +++ b/chromium/chrome/browser/resources/settings/internet_page/compiled_resources2.gyp @@ -11,10 +11,20 @@ '<(DEPTH)/ui/webui/resources/cr_elements/chromeos/network/compiled_resources2.gyp:cr_onc_types', '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:assert', '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:i18n_behavior', + '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:web_ui_listener_behavior', '<(EXTERNS_GYP):chrome_send', '<(EXTERNS_GYP):management', '<(EXTERNS_GYP):networking_private', '<(INTERFACES_GYP):networking_private_interface', + 'internet_config', + 'internet_page_browser_proxy', + ], + 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'], + }, + { + 'target_name': 'internet_page_browser_proxy', + 'dependencies': [ + '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr', ], 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'], }, @@ -24,6 +34,7 @@ '../compiled_resources2.gyp:route', '<(DEPTH)/ui/webui/resources/cr_components/chromeos/network/compiled_resources2.gyp:network_config', '<(DEPTH)/ui/webui/resources/cr_elements/chromeos/network/compiled_resources2.gyp:cr_onc_types', + '<(DEPTH)/ui/webui/resources/cr_elements/cr_dialog/compiled_resources2.gyp:cr_dialog', '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:assert', '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:i18n_behavior', '<(EXTERNS_GYP):networking_private', @@ -43,6 +54,7 @@ '<(EXTERNS_GYP):networking_private', '<(INTERFACES_GYP):networking_private_interface', 'tether_connection_dialog', + 'internet_page_browser_proxy', ], 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'], }, @@ -68,6 +80,7 @@ '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:i18n_behavior', '<(EXTERNS_GYP):networking_private', '<(INTERFACES_GYP):networking_private_interface', + 'internet_page_browser_proxy', ], 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'], }, @@ -86,17 +99,6 @@ 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'], }, { - 'target_name': 'network_siminfo', - 'dependencies': [ - '<(DEPTH)/third_party/polymer/v1_0/components-chromium/paper-input/compiled_resources2.gyp:paper-input-extracted', - '<(DEPTH)/ui/webui/resources/cr_elements/chromeos/network/compiled_resources2.gyp:cr_onc_types', - '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:assert', - '<(DEPTH)/ui/webui/resources/js/cr/ui/compiled_resources2.gyp:focus_without_ink', - '<(INTERFACES_GYP):networking_private_interface', - ], - 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'], - }, - { 'target_name': 'network_summary', 'dependencies': [ '<(DEPTH)/ui/webui/resources/cr_elements/chromeos/network/compiled_resources2.gyp:cr_onc_types', diff --git a/chromium/chrome/browser/resources/settings/internet_page/internet_config.html b/chromium/chrome/browser/resources/settings/internet_page/internet_config.html index fd8d716df89..c909581bc60 100644 --- a/chromium/chrome/browser/resources/settings/internet_page/internet_config.html +++ b/chromium/chrome/browser/resources/settings/internet_page/internet_config.html @@ -1,52 +1,47 @@ <link rel="import" href="chrome://resources/html/polymer.html"> <link rel="import" href="chrome://resources/cr_components/chromeos/network/network_config.html"> -<link rel="import" href="chrome://resources/cr_elements/chromeos/network/cr_network_icon.html"> <link rel="import" href="chrome://resources/cr_elements/chromeos/network/cr_onc_types.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/polymer/v1_0/iron-flex-layout/iron-flex-layout-classes.html"> <link rel="import" href="chrome://resources/polymer/v1_0/paper-button/paper-button.html"> <link rel="import" href="internet_shared_css.html"> -<dom-module id="settings-internet-config"> +<dom-module id="internet-config"> <template> <style include="internet-shared iron-flex"> + dialog { + width: 460px; + } </style> - <!-- Title section: Icon + name. --> - <div class="settings-box first"> - <div class="start layout horizontal center"> - <cr-network-icon network-state="[[networkProperties_]]" is-list-item> - </cr-network-icon> - <div class="title">[[getTitle_(networkProperties_.*)]]</div> + <dialog is="cr-dialog" id="dialog" close-text="$i18n{close}"> + <div slot="title">[[getDialogTitle_(networkProperties_)]]</div> + <div slot="body"> + <network-config id="networkConfig" class="flex" + networking-private="[[networkingPrivate]]" + global-policy="[[globalPolicy]]" + network-properties="{{networkProperties_}}" + enable-connect="{{enableConnect_}}" enable-save="{{enableSave_}}" + share-allow-enable="[[shareAllowEnable_]]" + share-default="[[shareDefault_]]" + on-close="close"> + </network-config> </div> - <div id="buttonDiv"> - <paper-button class="secondary-button" on-tap="onCancelTap_"> + + <div slot="button-container"> + <paper-button class="cancel-button" on-tap="onCancelTap_"> $i18n{cancel} </paper-button> - <template is="dom-if" if="[[guid_]]"> - <paper-button class="primary-button" on-tap="onSaveTap_" - disabled="[[!enableSave_]]"> - $i18n{save} - </paper-button> - </template> - <template is="dom-if" if="[[!guid_]]"> - <paper-button class="primary-button" on-tap="onConnectTap_" - disabled="[[!enableConnect_]]"> - $i18n{networkButtonConnect} - </paper-button> - </template> + <paper-button class="action-button" on-tap="onSaveOrConnectTap_" + disabled="[[!getSaveOrConnectEnabled_( + guid, networkProperties_, enableSave_, enableConnect_)]]"> + [[getSaveOrConnectLabel_(guid, networkProperties_)]] + </paper-button> </div> - </div> - <div class="settings-box"> - <network-config id="networkConfig" class="flex" - networking-private="[[networkingPrivate]]" - network-properties="{{networkProperties_}}" - enable-connect="{{enableConnect_}}" enable-save="{{enableSave_}}" - on-close="close_"> - </network-config> - </div> + </dialog> </template> <script src="internet_config.js"></script> </dom-module> diff --git a/chromium/chrome/browser/resources/settings/internet_page/internet_config.js b/chromium/chrome/browser/resources/settings/internet_page/internet_config.js index a74aa471f2e..38b8d8961d5 100644 --- a/chromium/chrome/browser/resources/settings/internet_page/internet_config.js +++ b/chromium/chrome/browser/resources/settings/internet_page/internet_config.js @@ -4,12 +4,12 @@ /** * @fileoverview - * 'settings-internet-config' is a Settings wrapper for network-config. + * 'internet-config' is a Settings dialog wrapper for network-config. */ Polymer({ - is: 'settings-internet-config', + is: 'internet-config', - behaviors: [settings.RouteObserverBehavior, I18nBehavior], + behaviors: [I18nBehavior], properties: { /** @@ -18,18 +18,49 @@ Polymer({ */ networkingPrivate: Object, + /** @type {!chrome.networkingPrivate.GlobalPolicy|undefined} */ + globalPolicy: Object, + + /** @private */ + shareAllowEnable_: { + type: Boolean, + value: function() { + return loadTimeData.getBoolean('shareNetworkAllowEnable'); + } + }, + + /** @private */ + shareDefault_: { + type: Boolean, + value: function() { + return loadTimeData.getBoolean('shareNetworkDefault'); + } + }, + /** * The GUID when an existing network is being configured. This will be * empty when configuring a new network. * @private */ - guid_: String, + guid: String, + + /** + * The type of network to be configured. + * @private {!chrome.networkingPrivate.NetworkType} + */ + type: String, + + /** + * The name of network (for display while the network details are fetched). + * @private + */ + name: String, /** @private */ - enableConnect_: String, + enableConnect_: Boolean, /** @private */ - enableSave_: String, + enableSave_: Boolean, /** * The current properties if an existing network is being configured, or @@ -40,69 +71,72 @@ Polymer({ networkProperties_: Object, }, - /** - * settings.RouteObserverBehavior - * @param {!settings.Route} route - * @protected - */ - currentRouteChanged: function(route) { - if (route != settings.routes.NETWORK_CONFIG) - return; - - var queryParams = settings.getQueryParameters(); - this.guid_ = queryParams.get('guid') || ''; + open: function() { + var dialog = /** @type {!CrDialogElement} */ (this.$.dialog); + if (!dialog.open) + dialog.showModal(); // Set networkProperties for new configurations and for existing // configurations until the current properties are loaded. - var name = queryParams.get('name') || ''; - var typeParam = queryParams.get('type'); - var type = (typeParam && CrOnc.getValidType(typeParam)) || CrOnc.Type.WI_FI; - assert(type && type != CrOnc.Type.ALL); + assert(this.type && this.type != CrOnc.Type.ALL); this.networkProperties_ = { - GUID: this.guid_, - Name: name, - Type: type, + GUID: this.guid, + Name: this.name, + Type: this.type, }; - - // First focus this page (which will focus a button), then init the config - // element which will focus an enabled element if any. - this.focus(); this.$.networkConfig.init(); }, - focus() { - var e = this.$$('paper-button:not([disabled])'); - assert(e); // The 'cancel' button should never be disabled. - e.focus(); + close: function() { + var dialog = /** @type {!CrDialogElement} */ (this.$.dialog); + if (dialog.open) + dialog.close(); }, - /** @private */ - close_: function() { - if (settings.getCurrentRoute() == settings.routes.NETWORK_CONFIG) - settings.navigateToPreviousRoute(); + /** + * @return {string} + * @private + */ + getDialogTitle_: function() { + var name = this.networkProperties_.Name; + if (name) + return this.i18n('internetConfigName', name); + var type = this.i18n('OncType' + this.networkProperties_.Type); + return this.i18n('internetJoinType', type); + }, + + /** + * @return {boolean} + * @private + */ + isConfigured_: function() { + var source = this.networkProperties_.Source; + return !!this.guid && !!source && source != CrOnc.Source.NONE; }, /** * @return {string} * @private */ - getTitle_: function() { - return this.networkProperties_.Name || - this.i18n('OncType' + this.networkProperties_.Type); + getSaveOrConnectLabel_: function() { + return this.i18n(this.isConfigured_() ? 'save' : 'networkButtonConnect'); }, - /** @private */ - onCancelTap_: function() { - this.close_(); + /** + * @return {boolean} + * @private + */ + getSaveOrConnectEnabled_: function() { + return this.isConfigured_() ? this.enableSave_ : this.enableConnect_; }, /** @private */ - onSaveTap_: function() { - this.$.networkConfig.saveOrConnect(); + onCancelTap_: function() { + this.close(); }, /** @private */ - onConnectTap_: function() { + onSaveOrConnectTap_: function() { this.$.networkConfig.saveOrConnect(); }, }); diff --git a/chromium/chrome/browser/resources/settings/internet_page/internet_detail_page.html b/chromium/chrome/browser/resources/settings/internet_page/internet_detail_page.html index ac1652041e5..67fa0ae5221 100644 --- a/chromium/chrome/browser/resources/settings/internet_page/internet_detail_page.html +++ b/chromium/chrome/browser/resources/settings/internet_page/internet_detail_page.html @@ -5,6 +5,7 @@ <link rel="import" href="chrome://resources/cr_components/chromeos/network/network_ip_config.html"> <link rel="import" href="chrome://resources/cr_components/chromeos/network/network_nameservers.html"> <link rel="import" href="chrome://resources/cr_components/chromeos/network/network_property_list.html"> +<link rel="import" href="chrome://resources/cr_components/chromeos/network/network_siminfo.html"> <link rel="import" href="chrome://resources/cr_elements/chromeos/network/cr_network_icon.html"> <link rel="import" href="chrome://resources/cr_elements/chromeos/network/cr_onc_types.html"> <link rel="import" href="chrome://resources/cr_elements/cr_expand_button/cr_expand_button.html"> @@ -23,7 +24,6 @@ <link rel="import" href="../route.html"> <link rel="import" href="internet_shared_css.html"> <link rel="import" href="network_proxy_section.html"> -<link rel="import" href="network_siminfo.html"> <link rel="import" href="tether_connection_dialog.html"> <dom-module id="settings-internet-detail-page"> @@ -96,7 +96,7 @@ <paper-button class="primary-button" on-tap="onConnectTap_" hidden$="[[!showConnect_(networkProperties, globalPolicy)]]" disabled="[[!enableConnect_(networkProperties, defaultNetwork, - globalPolicy)]]"> + globalPolicy, networkPropertiesReceived_)]]"> $i18n{networkButtonConnect} </paper-button> <paper-button class="primary-button" on-tap="onDisconnectTap_" @@ -158,15 +158,6 @@ </paper-toggle-button> </div> </template> - <!-- Choose Mobile Network (Cellular only). --> - <template is="dom-if" - if="[[showCellularChooseNetwork_(networkProperties)]]"> - <div class="settings-box single-column stretch"> - <network-choose-mobile networking-private="[[networkingPrivate]]" - network-properties="[[networkProperties]]"> - </network-choose-mobile> - </div> - </template> <!-- Data roaming (Cellular only). --> <template is="dom-if" if="[[isCellular_(networkProperties)]]"> <settings-toggle-button id="allowDataRoaming" @@ -245,6 +236,15 @@ <iron-collapse opened="[[networkExpanded_]]"> <div class="settings-box single-column stretch indented"> + <!-- Choose Mobile Network (Cellular only). --> + <template is="dom-if" + if="[[showCellularChooseNetwork_(networkProperties)]]"> + <network-choose-mobile + networking-private="[[networkingPrivate]]" + network-properties="[[networkProperties]]"> + </network-choose-mobile> + </template> + <!-- APN --> <template is="dom-if" if="[[isCellular_(networkProperties)]]"> <network-apnlist editable on-apn-change="onNetworkPropertyChange_" diff --git a/chromium/chrome/browser/resources/settings/internet_page/internet_detail_page.js b/chromium/chrome/browser/resources/settings/internet_page/internet_detail_page.js index 03ebf640485..24b95396a3a 100644 --- a/chromium/chrome/browser/resources/settings/internet_page/internet_detail_page.js +++ b/chromium/chrome/browser/resources/settings/internet_page/internet_detail_page.js @@ -120,12 +120,10 @@ Polymer({ proxyExpanded_: Boolean, }, - /** - * Listener function for chrome.networkingPrivate.onNetworksChanged event. - * @type {?function(!Array<string>)} - * @private - */ - networksChangedListener_: null, + listeners: { + 'network-list-changed': 'checkNetworkExists_', + 'networks-changed': 'updateNetworkDetails_', + }, /** @private {boolean} */ didSetFocus_: false, @@ -133,6 +131,8 @@ Polymer({ /** * Set to true to once the initial properties have been received. This * prevents setProperties from being called when setting default properties. + * This will also be set to false if the network no longer exists in the + * list of networks (e.g. it goes out of range). * @private {boolean} */ networkPropertiesReceived_: false, @@ -145,6 +145,14 @@ Polymer({ */ shouldShowConfigureWhenNetworkLoaded_: false, + /** @private {settings.InternetPageBrowserProxy} */ + browserProxy_: null, + + /** @override */ + created: function() { + this.browserProxy_ = settings.InternetPageBrowserProxyImpl.getInstance(); + }, + /** * settings.RouteObserverBehavior * @param {!settings.Route} route @@ -152,19 +160,9 @@ Polymer({ * @protected */ currentRouteChanged: function(route, oldRoute) { - if (route != settings.routes.NETWORK_DETAIL) { - if (this.networksChangedListener_) { - this.networkingPrivate.onNetworksChanged.removeListener( - this.networksChangedListener_); - this.networksChangedListener_ = null; - } + if (route != settings.routes.NETWORK_DETAIL) return; - } - if (!this.networksChangedListener_) { - this.networksChangedListener_ = this.onNetworksChangedEvent_.bind(this); - this.networkingPrivate.onNetworksChanged.addListener( - this.networksChangedListener_); - } + var queryParams = settings.getQueryParameters(); this.guid = queryParams.get('guid') || ''; if (!this.guid) { @@ -193,10 +191,9 @@ Polymer({ /** @private */ close_: function() { + this.guid = ''; // Delay navigating to allow other subpages to load first. - requestAnimationFrame(function() { - settings.navigateToPreviousRoute(); - }); + requestAnimationFrame(() => settings.navigateToPreviousRoute()); }, /** @private */ @@ -263,11 +260,20 @@ Polymer({ }, /** - * networkingPrivate.onNetworksChanged event callback. - * @param {!Array<string>} networkIds The list of changed network GUIDs. + * @param {{detail: !Array<string>}} event + * @private + */ + checkNetworkExists_: function(event) { + var networkIds = event.detail; + this.networkPropertiesReceived_ = networkIds.indexOf(this.guid) != -1; + }, + + /** + * @param {{detail: !Array<string>}} event * @private */ - onNetworksChangedEvent_: function(networkIds) { + updateNetworkDetails_: function(event) { + var networkIds = event.detail; if (networkIds.indexOf(this.guid) != -1) this.getNetworkDetails_(); }, @@ -305,11 +311,23 @@ Polymer({ this.close_(); return; } + + // Details page was closed while request was in progress, ignore the result. + if (!this.guid) + return; + if (!properties) { console.error('No properties for: ' + this.guid); this.close_(); return; } + + // Detail page should not be shown when Arc VPN is not connected. + if (this.isArcVpn_(properties) && !this.isConnectedState_(properties)) { + this.guid = ''; + this.close_(); + } + this.networkProperties = properties; this.networkPropertiesReceived_ = true; }, @@ -435,6 +453,11 @@ Polymer({ showConnect_: function(networkProperties, globalPolicy) { if (this.connectNotAllowed_(networkProperties, globalPolicy)) return false; + // TODO(lgcheng@) support connect Arc VPN from UI once Android support API + // to initiate a VPN session. + if (this.isArcVpn_(networkProperties)) + return false; + return networkProperties.Type != CrOnc.Type.ETHERNET && networkProperties.ConnectionState == CrOnc.ConnectionState.NOT_CONNECTED; @@ -460,6 +483,8 @@ Polymer({ var type = networkProperties.Type; if (type != CrOnc.Type.WI_FI && type != CrOnc.Type.VPN) return false; + if (this.isArcVpn_(networkProperties)) + return false; return !this.isPolicySource(networkProperties.Source) && this.isRemembered_(networkProperties); }, @@ -494,6 +519,10 @@ Polymer({ CrOnc.ConnectionState.NOT_CONNECTED) { return false; } + if (this.isArcVpn_(networkProperties) && + !this.isConnectedState_(networkProperties)) { + return false; + } return true; }, @@ -535,12 +564,17 @@ Polymer({ * @param {!CrOnc.NetworkProperties} networkProperties * @param {?CrOnc.NetworkStateProperties} defaultNetwork * @param {!chrome.networkingPrivate.GlobalPolicy} globalPolicy + * @param {boolean} networkPropertiesReceived * @return {boolean} Whether or not to enable the network connect button. * @private */ - enableConnect_: function(networkProperties, defaultNetwork, globalPolicy) { + enableConnect_: function( + networkProperties, defaultNetwork, globalPolicy, + networkPropertiesReceived) { if (!this.showConnect_(networkProperties, globalPolicy)) return false; + if (!networkPropertiesReceived) + return false; if ((networkProperties.Type == CrOnc.Type.CELLULAR) && (CrOnc.isSimLocked(networkProperties) || this.get('Cellular.Scanning', networkProperties))) { @@ -597,6 +631,11 @@ Polymer({ /** @private */ onConfigureTap_: function() { + if (this.networkProperties && this.isArcVpn_(this.networkProperties)) { + this.browserProxy_.showNetworkConfigure(this.guid); + return; + } + if (loadTimeData.getBoolean('networkSettingsConfig')) this.fire('show-config', this.networkProperties); else @@ -788,7 +827,8 @@ Polymer({ */ showAutoConnect_: function(networkProperties) { return networkProperties.Type != CrOnc.Type.ETHERNET && - this.isRemembered_(networkProperties); + this.isRemembered_(networkProperties) && + !this.isArcVpn_(networkProperties); }, /** @@ -824,7 +864,8 @@ Polymer({ showPreferNetwork_: function(networkProperties) { // TODO(stevenjb): Resolve whether or not we want to allow "preferred" for // networkProperties.Type == CrOnc.Type.ETHERNET. - return this.isRemembered_(networkProperties); + return this.isRemembered_(networkProperties) && + !this.isArcVpn_(networkProperties); }, /** @@ -868,6 +909,8 @@ Polymer({ var vpnType = CrOnc.getActiveValue(this.networkProperties.VPN.Type); if (vpnType == 'ThirdPartyVPN') { fields.push('VPN.ThirdPartyVPN.ProviderName'); + } else if (vpnType == 'ARCVPN') { + fields.push('VPN.Type'); } else { fields.push('VPN.Host', 'VPN.Type'); if (vpnType == 'OpenVPN') @@ -952,7 +995,8 @@ Polymer({ return false; } return this.hasAdvancedFields_() || this.hasDeviceFields_() || - this.isRememberedOrConnected_(networkProperties); + (networkProperties.Type != CrOnc.Type.VPN && + this.isRememberedOrConnected_(networkProperties)); }, /** @@ -1019,12 +1063,29 @@ Polymer({ }, /** + * @param {!CrOnc.NetworkProperties} networkProperties + * @return {boolean} + * @private + */ + isArcVpn_: function(networkProperties) { + return !!networkProperties.VPN && + CrOnc.getActiveValue(networkProperties.VPN.Type) == 'ARCVPN'; + }, + + /** * @param {string} ipAddress * @param {!CrOnc.NetworkProperties} networkProperties * @return {boolean} * @private */ showIpAddress_: function(ipAddress, networkProperties) { + // Arc Vpn does not currently pass IP configuration to ChromeOS. IP address + // property holds an internal IP address Android uses to talk to ChromeOS. + // TODO(lgcheng@) Show correct IP address when we implement IP configuration + // correclty. + if (this.isArcVpn_(networkProperties)) + return false; + return !!ipAddress && this.isConnectedState_(networkProperties); }, diff --git a/chromium/chrome/browser/resources/settings/internet_page/internet_known_networks_page.js b/chromium/chrome/browser/resources/settings/internet_page/internet_known_networks_page.js index 5ec39d7469b..b1dc5e6e712 100644 --- a/chromium/chrome/browser/resources/settings/internet_page/internet_known_networks_page.js +++ b/chromium/chrome/browser/resources/settings/internet_page/internet_known_networks_page.js @@ -54,44 +54,17 @@ Polymer({ enableForget_: Boolean, }, + listeners: {'network-list-changed': 'refreshNetworks_'}, + /** @private {string} */ selectedGuid_: '', - /** - * Listener function for chrome.networkingPrivate.onNetworksChanged event. - * @type {function(!Array<string>)} - * @private - */ - networksChangedListener_: function() {}, - - /** @override */ - attached: function() { - this.networksChangedListener_ = this.onNetworksChangedEvent_.bind(this); - this.networkingPrivate.onNetworksChanged.addListener( - this.networksChangedListener_); - }, - - /** @override */ - detached: function() { - this.networkingPrivate.onNetworksChanged.removeListener( - this.networksChangedListener_); - }, - /** @private */ networkTypeChanged_: function() { this.refreshNetworks_(); }, /** - * networkingPrivate.onNetworksChanged event callback. - * @param {!Array<string>} networkIds The list of changed network GUIDs. - * @private - */ - onNetworksChangedEvent_: function(networkIds) { - this.refreshNetworks_(); - }, - - /** * Requests the list of network states from Chrome. Updates networkStates * once the results are returned from Chrome. * @private diff --git a/chromium/chrome/browser/resources/settings/internet_page/internet_page.html b/chromium/chrome/browser/resources/settings/internet_page/internet_page.html index f77ea978261..cd6b2afbadb 100644 --- a/chromium/chrome/browser/resources/settings/internet_page/internet_page.html +++ b/chromium/chrome/browser/resources/settings/internet_page/internet_page.html @@ -4,6 +4,7 @@ <link rel="import" href="chrome://resources/cr_elements/cr_expand_button/cr_expand_button.html"> <link rel="import" href="chrome://resources/cr_elements/icons.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/neon-animation/neon-animatable.html"> <link rel="import" href="chrome://resources/polymer/v1_0/paper-icon-button/paper-icon-button-light.html"> @@ -73,6 +74,15 @@ </button> </div> </template> + <template is="dom-if" if="[[arcVpnProviders_.length]]"> + <div actionable class="list-item" id="addArcVpn" + on-tap="onAddArcVpnTap_"> + <div class="start">$i18n{internetAddArcVPN}</div> + <button class="icon-external" is="paper-icon-button-light" + aria-label$="$i18n{internetAddArcVPN}"> + </button> + </div> + </template> </div> </template> </template> @@ -84,14 +94,7 @@ </template> </neon-animatable> - <template is="dom-if" route-path="/networkConfig" no-search> - <settings-subpage page-title="$i18n{internetConfigTitle}"> - <settings-internet-config networking-private="[[networkingPrivate]]"> - </settings-internet-config> - </settings-subpage> - </template> - - <template is="dom-if" route-path="/networkDetail" no-search> + <template is="dom-if" route-path="/networkDetail" no-search restamp> <settings-subpage page-title="$i18n{internetDetailPageTitle}"> <settings-internet-detail-page prefs="{{prefs}}" default-network="[[defaultNetwork]]" @@ -101,7 +104,7 @@ </settings-subpage> </template> - <template is="dom-if" route-path="/knownNetworks" no-search> + <template is="dom-if" route-path="/knownNetworks" no-search restamp> <settings-subpage page-title="$i18n{internetKnownNetworksPageTitle}"> <settings-internet-known-networks-page network-type="[[knownNetworksType_]]" @@ -110,7 +113,7 @@ </settings-subpage> </template> - <template is="dom-if" route-path="/networks" no-search> + <template is="dom-if" route-path="/networks" no-search restamp> <settings-subpage page-title="[[getNetworksPageTitle_(subpageType_)]]" show-spinner="[[showSpinner_]]"> <settings-internet-subpage @@ -119,6 +122,7 @@ tether-device-state="[[get('Tether', deviceStates)]]" global-policy="[[globalPolicy_]]" third-party-vpn-providers="[[thirdPartyVpnProviders_]]" + arc-vpn-providers="[[arcVpnProviders_]]" networking-private="[[networkingPrivate]]" show-spinner="{{showSpinner_}}"> </settings-bluetooth-subpage> @@ -126,6 +130,12 @@ </template> </settings-animated-pages> + + <internet-config id="configDialog" + networking-private="[[networkingPrivate]]" + global-policy="[[globalPolicy_]]"> + </internet-config> + </template> <script src="internet_page.js"></script> </dom-module> diff --git a/chromium/chrome/browser/resources/settings/internet_page/internet_page.js b/chromium/chrome/browser/resources/settings/internet_page/internet_page.js index 85c7a78c1c8..8e935fa68cf 100644 --- a/chromium/chrome/browser/resources/settings/internet_page/internet_page.js +++ b/chromium/chrome/browser/resources/settings/internet_page/internet_page.js @@ -10,7 +10,8 @@ Polymer({ is: 'settings-internet-page', - behaviors: [I18nBehavior, settings.RouteObserverBehavior], + behaviors: + [I18nBehavior, settings.RouteObserverBehavior, WebUIListenerBehavior], properties: { /** @@ -89,6 +90,18 @@ Polymer({ } }, + /** + * List of Arc VPN providers. + * @type {!Array<!settings.ArcVpnProvider>} + * @private + */ + arcVpnProviders_: { + type: Array, + value: function() { + return []; + } + }, + /** @private {!Map<string, string>} */ focusConfig_: { type: Object, @@ -112,6 +125,13 @@ Polymer({ }, // chrome.networkingPrivate listeners + /** @private {?function(!Array<string>)} */ + networkListChangedListener_: null, + + /** @private {?function(!Array<string>)} */ + networksChangedListener_: null, + + // chrome.management listeners /** @private {Function} */ onExtensionAddedListener_: null, @@ -121,8 +141,33 @@ Polymer({ /** @private {Function} */ onExtensionDisabledListener_: null, + /** @private {settings.InternetPageBrowserProxy} */ + browserProxy_: null, + + /** @override */ + created: function() { + this.browserProxy_ = settings.InternetPageBrowserProxyImpl.getInstance(); + }, + + /** @override */ + ready: function() { + this.browserProxy_.setUpdateArcVpnProvidersCallback( + this.onArcVpnProvidersReceived_.bind(this)); + this.browserProxy_.requestArcVpnProviders(); + }, + /** @override */ attached: function() { + this.networkListChangedListener_ = this.networkListChangedListener_ || + this.onNetworkListChanged_.bind(this); + this.networkingPrivate.onNetworkListChanged.addListener( + this.networkListChangedListener_); + + this.networksChangedListener_ = + this.networksChangedListener_ || this.onNetworksChanged_.bind(this); + this.networkingPrivate.onNetworksChanged.addListener( + this.networksChangedListener_); + this.onExtensionAddedListener_ = this.onExtensionAddedListener_ || this.onExtensionAdded_.bind(this); chrome.management.onInstalled.addListener(this.onExtensionAddedListener_); @@ -146,6 +191,11 @@ Polymer({ /** @override */ detached: function() { + this.networkingPrivate.onNetworkListChanged.removeListener( + assert(this.networkListChangedListener_)); + this.networkingPrivate.onNetworksChanged.removeListener( + assert(this.networksChangedListener_)); + chrome.management.onInstalled.removeListener( assert(this.onExtensionAddedListener_)); chrome.management.onEnabled.removeListener( @@ -233,13 +283,13 @@ Polymer({ * @private */ showConfig_: function(type, guid, name) { - var params = new URLSearchParams; - params.append('type', type); - if (guid) - params.append('guid', guid); - if (name) - params.append('name', name); - settings.navigateTo(settings.routes.NETWORK_CONFIG, params); + var configDialog = + /** @type {!InternetConfigElement} */ (this.$.configDialog); + configDialog.type = + /** @type {chrome.networkingPrivate.NetworkType} */ (type); + configDialog.guid = guid || ''; + configDialog.name = name || ''; + configDialog.open(); }, /** @@ -261,11 +311,7 @@ Polymer({ * @private */ onShowNetworks_: function(event) { - this.detailType_ = event.detail.Type; - var params = new URLSearchParams; - params.append('type', event.detail.Type); - this.subpageType_ = event.detail.Type; - settings.navigateTo(settings.routes.INTERNET_NETWORKS, params); + this.showNetworksSubpage_(event.detail.Type); }, /** @@ -353,7 +399,24 @@ Polymer({ */ onAddThirdPartyVpnTap_: function(event) { var provider = event.model.item; - chrome.send('addNetwork', [CrOnc.Type.VPN, provider.ExtensionID]); + this.browserProxy_.addThirdPartyVpn(CrOnc.Type.VPN, provider.ExtensionID); + }, + + /** @private */ + onAddArcVpnTap_: function() { + this.showNetworksSubpage_(CrOnc.Type.VPN); + }, + + /** + * @param {string} type + * @private + */ + showNetworksSubpage_: function(type) { + this.detailType_ = type; + var params = new URLSearchParams; + params.append('type', type); + this.subpageType_ = type; + settings.navigateTo(settings.routes.INTERNET_NETWORKS, params); }, /** @@ -393,6 +456,45 @@ Polymer({ }, /** + * This event is triggered when the list of networks changes. + * |networkIds| contains the ids for all visible or configured networks. + * networkingPrivate.onNetworkListChanged event callback. + * @param {!Array<string>} networkIds + * @private + */ + onNetworkListChanged_: function(networkIds) { + var event = new CustomEvent('network-list-changed', {detail: networkIds}); + this.maybeDispatchEvent_('network-summary', event); + this.maybeDispatchEvent_('settings-internet-detail-page', event); + this.maybeDispatchEvent_('settings-internet-known-networks-page', event); + this.maybeDispatchEvent_('settings-internet-subpage', event); + }, + + /** + * This event is triggered when interesting properties of a network change. + * |networkIds| contains the ids for networks whose properties have changed. + * networkingPrivate.onNetworksChanged event callback. + * @param {!Array<string>} networkIds + * @private + */ + onNetworksChanged_: function(networkIds) { + var event = new CustomEvent('networks-changed', {detail: networkIds}); + this.maybeDispatchEvent_('network-summary', event); + this.maybeDispatchEvent_('settings-internet-detail-page', event); + }, + + /** + * @param {!Event} event + * @private + */ + maybeDispatchEvent_: function(identifier, event) { + var element = this.$$(identifier); + if (!element) + return; + element.dispatchEvent(event); + }, + + /** * chrome.management.onInstalled or onEnabled event. * @param {!chrome.management.ExtensionInfo} extension * @private @@ -417,6 +519,29 @@ Polymer({ }, /** + * Compares Arc VPN Providers based on LastlauchTime + * @param {!settings.ArcVpnProvider} arcVpnProvider1 + * @param {!settings.ArcVpnProvider} arcVpnProvider2 + * @private + */ + compareArcVpnProviders_: function(arcVpnProvider1, arcVpnProvider2) { + if (arcVpnProvider1.LastLaunchTime > arcVpnProvider2.LastLaunchTime) + return -1; + if (arcVpnProvider1.LastLaunchTime < arcVpnProvider2.LastLaunchTime) + return 1; + return 0; + }, + + /** + * @param {?Array<!settings.ArcVpnProvider>} arcVpnProviders + * @private + */ + onArcVpnProvidersReceived_: function(arcVpnProviders) { + arcVpnProviders.sort(this.compareArcVpnProviders_); + this.arcVpnProviders_ = arcVpnProviders; + }, + + /** * chrome.management.onDisabled event. * @param {{id: string}} extension * @private diff --git a/chromium/chrome/browser/resources/settings/internet_page/internet_page_browser_proxy.html b/chromium/chrome/browser/resources/settings/internet_page/internet_page_browser_proxy.html new file mode 100644 index 00000000000..5989a2fed95 --- /dev/null +++ b/chromium/chrome/browser/resources/settings/internet_page/internet_page_browser_proxy.html @@ -0,0 +1,2 @@ +<link rel="import" href="chrome://resources/html/cr.html"> +<script src="internet_page_browser_proxy.js"></script> diff --git a/chromium/chrome/browser/resources/settings/internet_page/internet_page_browser_proxy.js b/chromium/chrome/browser/resources/settings/internet_page/internet_page_browser_proxy.js new file mode 100644 index 00000000000..80cce5c9341 --- /dev/null +++ b/chromium/chrome/browser/resources/settings/internet_page/internet_page_browser_proxy.js @@ -0,0 +1,78 @@ +// 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. + +/** @fileoverview A helper object used for Internet page. */ +cr.exportPath('settings'); + +/** + * @typedef {{ + * PackageName: string, + * ProviderName: string, + * AppID: string, + * LastLaunchTime: number, + * }} + */ +settings.ArcVpnProvider; + +cr.define('settings', function() { + /** @interface */ + class InternetPageBrowserProxy { + /** + * Shows configuration of connnected external VPN network. + * @param {string} guid + */ + showNetworkConfigure(guid) {} + + /** + * Sends add VPN request to external VPN provider. + * @param {string} networkType + * @param {string} appId + */ + addThirdPartyVpn(networkType, appId) {} + + /** + * Requests Chrome to send list of Arc VPN providers. + */ + requestArcVpnProviders() {} + + /** + * |callback| is run when there is update of Arc VPN providers. + * Available after |requestArcVpnProviders| has been called. + * @param {function(?Array<settings.ArcVpnProvider>):void} callback + */ + setUpdateArcVpnProvidersCallback(callback) {} + } + + /** + * @implements {settings.InternetPageBrowserProxy} + */ + class InternetPageBrowserProxyImpl { + /** @override */ + showNetworkConfigure(guid) { + chrome.send('configureNetwork', [guid]); + } + + /** @override */ + addThirdPartyVpn(networkType, appId) { + chrome.send('addNetwork', [networkType, appId]); + } + + /** @override */ + requestArcVpnProviders() { + chrome.send('requestArcVpnProviders'); + } + + /** @override */ + setUpdateArcVpnProvidersCallback(callback) { + cr.addWebUIListener('sendArcVpnProviders', callback); + } + } + + cr.addSingletonGetter(InternetPageBrowserProxyImpl); + + return { + InternetPageBrowserProxy: InternetPageBrowserProxy, + InternetPageBrowserProxyImpl: InternetPageBrowserProxyImpl, + }; +}); diff --git a/chromium/chrome/browser/resources/settings/internet_page/internet_shared_css.html b/chromium/chrome/browser/resources/settings/internet_page/internet_shared_css.html index 1d60703ee2c..3b367ab31c3 100644 --- a/chromium/chrome/browser/resources/settings/internet_page/internet_shared_css.html +++ b/chromium/chrome/browser/resources/settings/internet_page/internet_shared_css.html @@ -1,4 +1,5 @@ <link rel="import" href="../settings_shared_css.html"> +<link rel="import" href="internet_page_browser_proxy.html"> <!-- Common styles for Internet settings. --> <dom-module id="internet-shared"> diff --git a/chromium/chrome/browser/resources/settings/internet_page/internet_subpage.html b/chromium/chrome/browser/resources/settings/internet_page/internet_subpage.html index 3d0116aba06..892b52e6555 100644 --- a/chromium/chrome/browser/resources/settings/internet_page/internet_subpage.html +++ b/chromium/chrome/browser/resources/settings/internet_page/internet_subpage.html @@ -102,8 +102,8 @@ class="no-networks"> </div> - <!-- Third party VPNs. --> <template is="dom-if" if="[[isEqual_('VPN', deviceState.Type)]]"> + <!-- Third party VPNs. --> <template is="dom-repeat" items="[[thirdPartyVpnProviders]]"> <div id="[[item.ProviderName]]" class="vpn-header layout horizontal center"> @@ -123,6 +123,26 @@ $i18n{internetNoNetworks} </div> </template> + <!-- Arc VPNs. --> + <template is="dom-repeat" items="[[arcVpnProviders]]"> + <div id="[[item.ProviderName]]" + class="vpn-header layout horizontal center"> + <div class="flex">[[item.ProviderName]]</div> + <button is="paper-icon-button-light" class="icon-add-circle" + aria-label$="[[getAddArcVpnAllyString_(item)]]" + on-tap="onAddArcVpnTap_" tabindex$="[[tabindex]]"> + </button> + </div> + <cr-network-list show-buttons + hidden$="[[!haveArcVpnNetwork_(arcVpns_, item)]]" + networks="[[getArcVpnNetworks_(arcVpns_, item)]]" + on-selected="onNetworkSelected_"> + </cr-network-list> + <div hidden$="[[haveArcVpnNetwork_(arcVpns_, item)]]" + class="no-networks"> + $i18n{internetNoNetworks} + </div> + </template> </template> </div> diff --git a/chromium/chrome/browser/resources/settings/internet_page/internet_subpage.js b/chromium/chrome/browser/resources/settings/internet_page/internet_subpage.js index 0434b0e14c0..69592e2c91b 100644 --- a/chromium/chrome/browser/resources/settings/internet_page/internet_subpage.js +++ b/chromium/chrome/browser/resources/settings/internet_page/internet_subpage.js @@ -50,6 +50,12 @@ Polymer({ thirdPartyVpnProviders: Array, /** + * List of Arc VPN providers. + * @type {!Array<!settings.ArcVpnProvider>|undefined} + */ + arcVpnProviders: Array, + + /** * Interface for networkingPrivate calls, passed from internet_page. * @type {!NetworkingPrivate} */ @@ -82,33 +88,37 @@ Polymer({ return {}; }, }, + + /** + * Dictionary of lists of network states for Arc VPNs. + * @private {!Object<!Array<!CrOnc.NetworkStateProperties>>} + */ + arcVpns_: { + type: Object, + value: function() { + return {}; + } + } }, + listeners: {'network-list-changed': 'getNetworkStateList_'}, + observers: ['deviceStateChanged_(networkingPrivate, deviceState)'], /** @private {number|null} */ scanIntervalId_: null, - /** - * Listener function for chrome.networkingPrivate.onNetworkListChanged event. - * @type {?function(!Array<string>)} - * @private - */ - networkListChangedListener_: null, + /** @private {settings.InternetPageBrowserProxy} */ + browserProxy_: null, - /** override */ - attached: function() { - this.networkListChangedListener_ = this.networkListChangedListener_ || - this.onNetworkListChangedEvent_.bind(this); - this.networkingPrivate.onNetworkListChanged.addListener( - this.networkListChangedListener_); + /** @override */ + created: function() { + this.browserProxy_ = settings.InternetPageBrowserProxyImpl.getInstance(); }, /** override */ detached: function() { this.stopScanning_(); - this.networkingPrivate.onNetworkListChanged.removeListener( - assert(this.networkListChangedListener_)); }, /** @@ -124,6 +134,7 @@ Polymer({ // Clear any stale data. this.networkStateList_ = []; this.thirdPartyVpns_ = {}; + this.arcVpns_ = {}; // Request the list of networks and start scanning if necessary. this.getNetworkStateList_(); this.updateScanning_(); @@ -195,14 +206,6 @@ Polymer({ this.scanIntervalId_ = null; }, - /** - * networkingPrivate.onNetworkListChanged event callback. - * @private - */ - onNetworkListChangedEvent_: function() { - this.getNetworkStateList_(); - }, - /** @private */ getNetworkStateList_: function() { if (!this.deviceState) @@ -237,23 +240,30 @@ Polymer({ return; } - // For VPNs, separate out third party VPNs. + // For VPNs, separate out third party VPNs and Arc VPNs. if (this.deviceState.Type == CrOnc.Type.VPN) { var builtinNetworkStates = []; var thirdPartyVpns = {}; + var arcVpns = {}; for (var i = 0; i < networkStates.length; ++i) { var state = networkStates[i]; - var providerType = state.VPN && state.VPN.ThirdPartyVPN && - state.VPN.ThirdPartyVPN.ProviderName; + var providerType = this.get('VPN.ThirdPartyVPN.ProviderName', state); if (providerType) { thirdPartyVpns[providerType] = thirdPartyVpns[providerType] || []; thirdPartyVpns[providerType].push(state); + } else if (this.get('VPN.Type', state) == 'ARCVPN') { + var arcProviderName = this.get('VPN.Host', state); + if (state.ConnectionState != CrOnc.ConnectionState.CONNECTED) + continue; + arcVpns[arcProviderName] = arcVpns[arcProviderName] || []; + arcVpns[arcProviderName].push(state); } else { builtinNetworkStates.push(state); } } networkStates = builtinNetworkStates; this.thirdPartyVpns_ = thirdPartyVpns; + this.arcVpns_ = arcVpns; } this.networkStateList_ = networkStates; @@ -329,6 +339,15 @@ Polymer({ }, /** + * @param {!settings.ArcVpnProvider} arcVpn + * @return {string} + * @private + */ + getAddArcVpnAllyString_: function(arcVpn) { + return this.i18n('internetAddArcVPNProvider', arcVpn.ProviderName); + }, + + /** * @param {!chrome.networkingPrivate.GlobalPolicy} globalPolicy * @return {boolean} * @private @@ -370,7 +389,19 @@ Polymer({ */ onAddThirdPartyVpnTap_: function(event) { var provider = event.model.item; - chrome.send('addNetwork', [CrOnc.Type.VPN, provider.ExtensionID]); + this.browserProxy_.addThirdPartyVpn(CrOnc.Type.VPN, provider.ExtensionID); + }, + + /** + * @param {!{model: + * !{item: !settings.ArcVpnProvider}, + * }} event + * @private + */ + onAddArcVpnTap_: function(event) { + var provider = event.model.item; + settings.InternetPageBrowserProxyImpl.getInstance().addThirdPartyVpn( + CrOnc.Type.VPN, provider.AppID); }, /** @@ -428,6 +459,27 @@ Polymer({ }, /** + * @param {!Object<!Array<!CrOnc.NetworkStateProperties>>} arcVpns + * @param {!settings.ArcVpnProvider} arcVpnProvider + * @return {!Array<!CrOnc.NetworkStateProperties>} + * @private + */ + getArcVpnNetworks_: function(arcVpns, arcVpnProvider) { + return arcVpns[arcVpnProvider.PackageName] || []; + }, + + /** + * @param {!Object<!Array<!CrOnc.NetworkStateProperties>>} arcVpns + * @param {!settings.ArcVpnProvider} arcVpnProvider + * @return {boolean} + * @private + */ + haveArcVpnNetwork_: function(arcVpns, arcVpnProvider) { + var list = this.getArcVpnNetworks_(arcVpns, arcVpnProvider); + return !!list.length; + }, + + /** * Event triggered when a network list item is selected. * @param {!{target: HTMLElement, detail: !CrOnc.NetworkStateProperties}} e * @private diff --git a/chromium/chrome/browser/resources/settings/internet_page/network_siminfo.html b/chromium/chrome/browser/resources/settings/internet_page/network_siminfo.html deleted file mode 100644 index 8f4df0be364..00000000000 --- a/chromium/chrome/browser/resources/settings/internet_page/network_siminfo.html +++ /dev/null @@ -1,199 +0,0 @@ -<link rel="import" href="chrome://resources/html/polymer.html"> - -<link rel="import" href="chrome://resources/cr_elements/chromeos/network/cr_onc_types.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/cr/ui/focus_without_ink.html"> -<link rel="import" href="chrome://resources/polymer/v1_0/iron-a11y-keys/iron-a11y-keys.html"> -<link rel="import" href="chrome://resources/polymer/v1_0/iron-flex-layout/iron-flex-layout-classes.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-button/paper-button.html"> -<link rel="import" href="chrome://resources/polymer/v1_0/paper-input/paper-input.html"> -<link rel="import" href="chrome://resources/polymer/v1_0/paper-toggle-button/paper-toggle-button.html"> -<link rel="import" href="../icons.html"> -<link rel="import" href="internet_shared_css.html"> - -<dom-module id="network-siminfo"> - <template> - <style include="settings-shared internet-shared iron-flex"> - iron-icon { - -webkit-margin-end: 10px; - } - - .dialog-error { - color: red; - font-size: 125%; - font-weight: 500; - margin-top: 10px; - } - - .error { - color: red; - font-weight: 500; - } - - .pin { - min-width: 100px; - } - - .puk { - min-width: 200px; - } - - /* Siminfo is embedded; remove the padding. */ - .settings-box { - padding: 0; - } - - .settings-box:first-of-type { - border-top: none; - } - - paper-toggle-button { - -webkit-margin-start: var(--settings-control-label-spacing); - } - </style> - - <!-- SIM missing UI --> - <div class="settings-box two-line" - hidden$="[[networkProperties.Cellular.SIMPresent]]"> - <div class="start layout horizontal center"> - <iron-icon icon="settings:sim-card-alert"></iron-icon> - <div class="error">$i18n{networkSimCardMissing}</div> - </div> - </div> - - <!-- SIM locked --> - <div class="settings-box two-line" - hidden$="[[!showSimLocked_(networkProperties)]]"> - <div class="start layout horizontal center"> - <iron-icon icon="settings:lock"></iron-icon> - <div class="error">$i18n{networkSimCardLocked}</div> - </div> - <div class="separator"></div> - <paper-button id="unlockPinButton" on-tap="onUnlockPinTap_"> - $i18n{networkSimUnlock} - </paper-button> - </div> - - <!-- SIM unlocked --> - <div class="settings-box two-line" - hidden$="[[!showSimUnlocked_(networkProperties)]]"> - <div id="simLockToggleLabel" class="start"> - $i18n{networkSimLockEnable} - </div> - <paper-button id="changePinButton" on-tap="onChangePinTap_" - hidden$="[[!networkProperties.Cellular.SIMLockStatus.LockEnabled]]"> - $i18n{networkSimChangePin} - </paper-button> - <paper-toggle-button id="simLockButton" - on-change="onSimLockEnabledChange_" checked="{{lockEnabled_}}" - aria-labelledby="simLockToggleLabel"> - </paper-toggle-button> - </div> - - <!-- Enter PIN dialog --> - <dialog is="cr-dialog" id="enterPinDialog" close-text="$i18n{close}" - on-cancel="onEnterPinDialogCancel_" - on-close="onEnterPinDialogClose_"> - <div slot="title">$i18n{networkSimEnterPinTitle}</div> - <div slot="body"> - <paper-input id="enterPin" class="pin" no-label-float autofocus - label="$i18n{networkSimEnterPin}"> - <iron-a11y-keys keys="enter" on-keys-pressed="sendEnterPin_"> - </iron-a11y-keys> - </paper-input> - <div class="dialog-error"> - [[getErrorMsg_(error_, networkProperties)]] - </div> - </div> - <div slot="button-container"> - <paper-button on-tap="sendEnterPin_"> - $i18n{networkSimEnter} - </paper-button> - </div> - </dialog> - - <!-- Change PIN dialog --> - <dialog is="cr-dialog" id="changePinDialog" close-text="$i18n{close}" - on-close="onChangePinDialogClose_"> - <div slot="title">$i18n{networkSimChangePinTitle}</div> - <div slot="body"> - <paper-input id="changePinOld" class="pin" no-label-float autofocus - label="$i18n{networkSimEnterOldPin}"> - </paper-input> - <paper-input id="changePinNew1" class="pin" no-label-float - label="$i18n{networkSimEnterNewPin}"> - </paper-input> - <paper-input id="changePinNew2" class="pin" no-label-float - label="$i18n{networkSimReEnterNewPin}"> - <iron-a11y-keys keys="enter" on-keys-pressed="sendChangePin_"> - </iron-a11y-keys> - </paper-input> - <div class="dialog-error"> - [[getErrorMsg_(error_, networkProperties)]] - </div> - </div> - <div slot="button-container"> - <paper-button on-tap="sendChangePin_"> - $i18n{networkSimChange} - </paper-button> - </div> - </dialog> - - <!-- Unlock PIN dialog --> - <dialog is="cr-dialog" id="unlockPinDialog" close-text="$i18n{close}" - on-close="onUnlockPinDialogClose_"> - <div slot="title">$i18n{networkSimLockedTitle}</div> - <div slot="body"> - <paper-input id="unlockPin" class="pin" no-label-float autofocus - label="$i18n{networkSimEnterPin}"> - <iron-a11y-keys keys="enter" on-keys-pressed="sendUnlockPin_"> - </iron-a11y-keys> - </paper-input> - <div class="dialog-error"> - [[getErrorMsg_(error_, networkProperties)]] - </div> - </div> - <div slot="button-container"> - <paper-button on-tap="sendUnlockPin_"> - $i18n{networkSimUnlock} - </paper-button> - </div> - </dialog> - - <!-- Unlock PUK dialog --> - <dialog is="cr-dialog" id="unlockPukDialog" close-text="$i18n{close}" - on-close="onUnlockPinDialogClose_"> - <div slot="title">$i18n{networkSimLockedTitle}</div> - <div slot="body"> - <div> - Enter the 8-digit PIN Unblocking Key provided by your carrier - </div> - <paper-input id="unlockPuk" class="puk" no-label-float autofocus - label="$i18n{networkSimEnterPuk}"> - </paper-input> - <paper-input id="unlockPin1" class="pin" no-label-float - label="$i18n{networkSimEnterNewPin}"> - </paper-input> - <paper-input id="unlockPin2" class="pin" no-label-float - label="$i18n{networkSimReEnterNewPin}"> - <iron-a11y-keys keys="enter" on-keys-pressed="sendUnlockPuk_"> - </iron-a11y-keys> - </paper-input> - <div class="dialog-error"> - $i18n{networkSimLockedWarning} - </div> - <div class="dialog-error"> - [[getErrorMsg_(error_, networkProperties)]] - </div> - </div> - <div slot="button-container"> - <paper-button on-tap="sendUnlockPuk_"> - $i18n{networkSimUnlock} - </paper-button> - </div> - </dialog> - </template> - <script src="network_siminfo.js"></script> -</dom-module> diff --git a/chromium/chrome/browser/resources/settings/internet_page/network_siminfo.js b/chromium/chrome/browser/resources/settings/internet_page/network_siminfo.js deleted file mode 100644 index 2ea134f2069..00000000000 --- a/chromium/chrome/browser/resources/settings/internet_page/network_siminfo.js +++ /dev/null @@ -1,402 +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 Polymer element for displaying and modifying cellular sim info. - */ -(function() { - -/** @enum {string} */ -var ErrorType = { - NONE: 'none', - INCORRECT_PIN: 'incorrect-pin', - INCORRECT_PUK: 'incorrect-puk', - MISMATCHED_PIN: 'mismatched-pin', - INVALID_PIN: 'invalid-pin', - INVALID_PUK: 'invalid-puk' -}; - -var PIN_MIN_LENGTH = 4; -var PUK_MIN_LENGTH = 8; - -Polymer({ - is: 'network-siminfo', - - properties: { - /** - * The network properties associated with the element. - * @type {!CrOnc.NetworkProperties|undefined} - */ - networkProperties: { - type: Object, - observer: 'networkPropertiesChanged_', - }, - - /** - * Interface for networkingPrivate calls, passed from internet_page. - * @type {NetworkingPrivate} - */ - networkingPrivate: Object, - - /** - * Reflects networkProperties.Cellular.SIMLockStatus.LockEnabled for the - * toggle button. - * @private - */ - lockEnabled_: { - type: Boolean, - value: false, - }, - - /** - * Set to true when a PUK is required to unlock the SIM. - * @private - */ - pukRequired_: { - type: Boolean, - value: false, - observer: 'pukRequiredChanged_', - }, - - /** - * Set to an ErrorType value after an incorrect PIN or PUK entry. - * @private {ErrorType} - */ - error_: { - type: Object, - value: ErrorType.NONE, - }, - }, - - sendSimLockEnabled_: false, - - /** @override */ - detached: function() { - if (this.$.enterPinDialog.open) - this.$.enterPinDialog.close(); - if (this.$.changePinDialog.open) - this.$.changePinDialog.close(); - if (this.$.unlockPinDialog.open) - this.$.unlockPinDialog.close(); - if (this.$.unlockPukDialog.open) - this.$.unlockPukDialog.close(); - }, - - /** @private */ - networkPropertiesChanged_: function() { - if (!this.networkProperties || !this.networkProperties.Cellular) - return; - var simLockStatus = this.networkProperties.Cellular.SIMLockStatus; - this.pukRequired_ = - !!simLockStatus && simLockStatus.LockType == CrOnc.LockType.PUK; - this.lockEnabled_ = !!simLockStatus && simLockStatus.LockEnabled; - }, - - /** @private */ - pukRequiredChanged_: function() { - if (this.$.unlockPukDialog.open) { - if (this.pukRequired_) - this.$.unlockPuk.focus(); - else - this.$.unlockPukDialog.close(); - return; - } - - if (!this.pukRequired_) - return; - - // If the PUK was activated while attempting to enter or change a pin, - // close the dialog and open the unlock PUK dialog. - var showUnlockPuk = false; - if (this.$.enterPinDialog.open) { - this.$.enterPinDialog.close(); - showUnlockPuk = true; - } - if (this.$.changePinDialog.open) { - this.$.changePinDialog.close(); - showUnlockPuk = true; - } - if (this.$.unlockPinDialog.open) { - this.$.unlockPinDialog.close(); - showUnlockPuk = true; - } - if (!showUnlockPuk) - return; - - this.showUnlockPukDialog_(); - }, - - /** - * Opens the pin dialog when the sim lock enabled state changes. - * @param {!Event} event - * @private - */ - onSimLockEnabledChange_: function(event) { - if (!this.networkProperties || !this.networkProperties.Cellular) - return; - this.sendSimLockEnabled_ = event.target.checked; - this.error_ = ErrorType.NONE; - this.$.enterPin.value = ''; - this.$.enterPinDialog.showModal(); - }, - - /** - * Sends the PIN value from the Enter PIN dialog. - * @param {!Event} event - * @private - */ - sendEnterPin_: function(event) { - event.stopPropagation(); - var guid = (this.networkProperties && this.networkProperties.GUID) || ''; - var pin = this.$.enterPin.value; - if (!this.validatePin_(pin)) { - this.onEnterPinDialogCancel_(); - return; - } - var simState = /** @type {!CrOnc.CellularSimState} */ ({ - currentPin: pin, - requirePin: this.sendSimLockEnabled_, - }); - this.networkingPrivate.setCellularSimState(guid, simState, () => { - if (chrome.runtime.lastError) { - this.error_ = ErrorType.INCORRECT_PIN; - this.$.enterPin.inputElement.select(); - } else { - this.error_ = ErrorType.NONE; - this.$.enterPinDialog.close(); - } - }); - }, - - /** - * Opens the Change PIN dialog. - * @param {!Event} event - * @private - */ - onChangePinTap_: function(event) { - event.stopPropagation(); - if (!this.networkProperties || !this.networkProperties.Cellular) - return; - this.error_ = ErrorType.NONE; - this.$.changePinOld.value = ''; - this.$.changePinNew1.value = ''; - this.$.changePinNew2.value = ''; - this.$.changePinDialog.showModal(); - }, - - /** - * Sends the old and new PIN values from the Change PIN dialog. - * @param {!Event} event - * @private - */ - sendChangePin_: function(event) { - event.stopPropagation(); - var guid = (this.networkProperties && this.networkProperties.GUID) || ''; - var newPin = this.$.changePinNew1.value; - if (!this.validatePin_(newPin, this.$.changePinNew2.value)) - return; - - var simState = /** @type {!CrOnc.CellularSimState} */ ({ - requirePin: true, - currentPin: this.$.changePinOld.value, - newPin: newPin - }); - this.networkingPrivate.setCellularSimState(guid, simState, () => { - if (chrome.runtime.lastError) { - this.error_ = ErrorType.INCORRECT_PIN; - this.$.changePinOld.inputElement.select(); - } else { - this.error_ = ErrorType.NONE; - this.$.changePinDialog.close(); - } - }); - }, - - /** - * Opens the Unlock PIN / PUK dialog. - * @param {!Event} event - * @private - */ - onUnlockPinTap_: function(event) { - event.stopPropagation(); - if (this.pukRequired_) { - this.showUnlockPukDialog_(); - } else { - this.showUnlockPinDialog_(); - } - }, - - /** - * Sends the PIN value from the Unlock PIN dialog. - * @param {!Event} event - * @private - */ - sendUnlockPin_: function(event) { - event.stopPropagation(); - var guid = (this.networkProperties && this.networkProperties.GUID) || ''; - var pin = this.$.unlockPin.value; - if (!this.validatePin_(pin)) - return; - - this.networkingPrivate.unlockCellularSim(guid, pin, '', () => { - if (chrome.runtime.lastError) { - this.error_ = ErrorType.INCORRECT_PIN; - this.$.unlockPin.inputElement.select(); - } else { - this.error_ = ErrorType.NONE; - this.$.unlockPinDialog.close(); - } - }); - }, - - /** @private */ - showUnlockPinDialog_: function() { - this.error_ = ErrorType.NONE; - this.$.unlockPin.value = ''; - this.$.unlockPinDialog.showModal(); - }, - - /** @private */ - showUnlockPukDialog_: function() { - this.error_ = ErrorType.NONE; - this.$.unlockPuk.value = ''; - this.$.unlockPin1.value = ''; - this.$.unlockPin2.value = ''; - this.$.unlockPukDialog.showModal(); - }, - - /** - * Sends the PUK value and new PIN value from the Unblock PUK dialog. - * @param {!Event} event - * @private - */ - sendUnlockPuk_: function(event) { - event.stopPropagation(); - var guid = (this.networkProperties && this.networkProperties.GUID) || ''; - var puk = this.$.unlockPuk.value; - if (!this.validatePuk_(puk)) - return; - var pin = this.$.unlockPin1.value; - if (!this.validatePin_(pin, this.$.unlockPin2.value)) - return; - - this.networkingPrivate.unlockCellularSim(guid, pin, puk, () => { - if (chrome.runtime.lastError) { - this.error_ = ErrorType.INCORRECT_PUK; - this.$.unlockPuk.inputElement.select(); - } else { - this.error_ = ErrorType.NONE; - this.$.unlockPukDialog.close(); - } - }); - }, - - /** - * @return {boolean} - * @private - */ - showSimLocked_: function() { - if (!this.networkProperties || !this.networkProperties.Cellular || - !this.networkProperties.Cellular.SIMPresent) { - return false; - } - return CrOnc.isSimLocked(this.networkProperties); - }, - - /** - * @return {boolean} - * @private - */ - showSimUnlocked_: function() { - if (!this.networkProperties || !this.networkProperties.Cellular || - !this.networkProperties.Cellular.SIMPresent) { - return false; - } - return !CrOnc.isSimLocked(this.networkProperties); - }, - - /** @private */ - getErrorMsg_: function() { - if (this.error_ == ErrorType.NONE) - return ''; - // TODO(stevenjb): Translate - var msg; - if (this.error_ == ErrorType.INCORRECT_PIN) - msg = 'Incorrect PIN.'; - else if (this.error_ == ErrorType.INCORRECT_PUK) - msg = 'Incorrect PUK.'; - else if (this.error_ == ErrorType.MISMATCHED_PIN) - msg = 'PIN values do not match.'; - else if (this.error_ == ErrorType.INVALID_PIN) - msg = 'Invalid PIN.'; - else if (this.error_ == ErrorType.INVALID_PUK) - msg = 'Invalid PUK.'; - else - return 'UNKNOWN ERROR'; - var retriesLeft = - this.get('Cellular.SIMLockStatus.RetriesLeft', this.networkProperties); - if (retriesLeft) { - msg += ' Retries left: ' + retriesLeft.toString(); - } - return msg; - }, - - /** - * Checks whether |pin1| is of the proper length and if opt_pin2 is not - * undefined, whether pin1 and opt_pin2 match. On any failure, sets - * |this.error_| and returns false. - * @param {string} pin1 - * @param {string=} opt_pin2 - * @return {boolean} True if the pins match and are of minimum length. - * @private - */ - validatePin_: function(pin1, opt_pin2) { - if (pin1.length < PIN_MIN_LENGTH) { - this.error_ = ErrorType.INVALID_PIN; - return false; - } - if (opt_pin2 != undefined && pin1 != opt_pin2) { - this.error_ = ErrorType.MISMATCHED_PIN; - return false; - } - return true; - }, - - /** - * Checks whether |puk| is of the proper length. If not, sets |this.error_| - * and returns false. - * @param {string} puk - * @return {boolean} True if the puk is of minimum length. - * @private - */ - validatePuk_: function(puk) { - if (puk.length < PUK_MIN_LENGTH) { - this.error_ = ErrorType.INVALID_PUK; - return false; - } - return true; - }, - - /** @private */ - onEnterPinDialogCancel_: function() { - this.lockEnabled_ = - this.networkProperties.Cellular.SIMLockStatus.LockEnabled; - }, - - /** @private */ - onEnterPinDialogClose_: function() { - cr.ui.focusWithoutInk(assert(this.$$('#simLockButton'))); - }, - - /** @private */ - onChangePinDialogClose_: function() { - cr.ui.focusWithoutInk(assert(this.$$('#changePinButton'))); - }, - - /** @private */ - onUnlockPinDialogClose_: function() { - cr.ui.focusWithoutInk(assert(this.$$('#unlockPinButton'))); - }, -}); -})(); diff --git a/chromium/chrome/browser/resources/settings/internet_page/network_summary.js b/chromium/chrome/browser/resources/settings/internet_page/network_summary.js index a1c6dea2665..a755721b3c4 100644 --- a/chromium/chrome/browser/resources/settings/internet_page/network_summary.js +++ b/chromium/chrome/browser/resources/settings/internet_page/network_summary.js @@ -91,11 +91,10 @@ Polymer({ }, }, - /** - * Listener function for chrome.networkingPrivate.onNetworkListChanged event. - * @private {?function(!Array<string>)} - */ - networkListChangedListener_: null, + listeners: { + 'network-list-changed': 'getNetworkLists_', + 'networks-changed': 'updateActiveNetworks_', + }, /** * Listener function for chrome.networkingPrivate.onDeviceStateListChanged @@ -105,12 +104,6 @@ Polymer({ deviceStateListChangedListener_: null, /** - * Listener function for chrome.networkingPrivate.onNetworksChanged event. - * @private {?function(!Array<string>)} - */ - networksChangedListener_: null, - - /** * Set of GUIDs identifying active networks, one for each type. * @private {?Set<string>} */ @@ -120,41 +113,17 @@ Polymer({ attached: function() { this.getNetworkLists_(); - this.networkListChangedListener_ = this.networkListChangedListener_ || - this.onNetworkListChangedEvent_.bind(this); - this.networkingPrivate.onNetworkListChanged.addListener( - this.networkListChangedListener_); - this.deviceStateListChangedListener_ = this.deviceStateListChangedListener_ || this.onDeviceStateListChangedEvent_.bind(this); this.networkingPrivate.onDeviceStateListChanged.addListener( this.deviceStateListChangedListener_); - - this.networksChangedListener_ = this.networksChangedListener_ || - this.onNetworksChangedEvent_.bind(this); - this.networkingPrivate.onNetworksChanged.addListener( - this.networksChangedListener_); }, /** @override */ detached: function() { - this.networkingPrivate.onNetworkListChanged.removeListener( - assert(this.networkListChangedListener_)); - this.networkingPrivate.onDeviceStateListChanged.removeListener( assert(this.deviceStateListChangedListener_)); - - this.networkingPrivate.onNetworksChanged.removeListener( - assert(this.networksChangedListener_)); - }, - - /** - * networkingPrivate.onNetworkListChanged event callback. - * @private - */ - onNetworkListChangedEvent_: function() { - this.getNetworkLists_(); }, /** @@ -166,13 +135,13 @@ Polymer({ }, /** - * networkingPrivate.onNetworksChanged event callback. - * @param {!Array<string>} networkIds The list of changed network GUIDs. + * @param {{detail: !Array<string>}} event * @private */ - onNetworksChangedEvent_: function(networkIds) { + updateActiveNetworks_: function(event) { if (!this.activeNetworkIds_) return; // Initial list of networks not received yet. + var networkIds = event.detail; networkIds.forEach(function(id) { if (this.activeNetworkIds_.has(id)) { this.networkingPrivate.getState( diff --git a/chromium/chrome/browser/resources/settings/internet_page/network_summary_item.html b/chromium/chrome/browser/resources/settings/internet_page/network_summary_item.html index b1a730a7e82..812bf51fff9 100644 --- a/chromium/chrome/browser/resources/settings/internet_page/network_summary_item.html +++ b/chromium/chrome/browser/resources/settings/internet_page/network_summary_item.html @@ -1,5 +1,6 @@ <link rel="import" href="chrome://resources/html/polymer.html"> +<link rel="import" href="chrome://resources/cr_components/chromeos/network/network_siminfo.html"> <link rel="import" href="chrome://resources/cr_elements/chromeos/network/cr_network_icon.html"> <link rel="import" href="chrome://resources/cr_elements/policy/cr_policy_indicator.html"> <link rel="import" href="chrome://resources/html/i18n_behavior.html"> @@ -8,7 +9,6 @@ <link rel="import" href="chrome://resources/polymer/v1_0/paper-toggle-button/paper-toggle-button.html"> <link rel="import" href="../settings_page/settings_subpage.html"> <link rel="import" href="../settings_shared_css.html"> -<link rel="import" href="network_siminfo.html"> <dom-module id="network-summary-item"> <template> diff --git a/chromium/chrome/browser/resources/settings/internet_page/network_summary_item.js b/chromium/chrome/browser/resources/settings/internet_page/network_summary_item.js index 9555d961bd8..1171557295f 100644 --- a/chromium/chrome/browser/resources/settings/internet_page/network_summary_item.js +++ b/chromium/chrome/browser/resources/settings/internet_page/network_summary_item.js @@ -130,17 +130,24 @@ Polymer({ }, /** - * Show the <network-siminfo> element if this is a disabled and locked - * cellular device. * @param {!CrOnc.DeviceStateProperties|undefined} deviceState * @return {boolean} * @private */ showSimInfo_: function(deviceState) { - if (!deviceState || deviceState.Type != CrOnc.Type.CELLULAR || - this.deviceIsEnabled_(deviceState)) { + if (!deviceState || deviceState.Type != CrOnc.Type.CELLULAR) + return false; + return this.simLockedOrAbsent_(deviceState); + }, + + /** + * @param {!CrOnc.DeviceStateProperties} deviceState + * @return {boolean} + * @private + */ + simLockedOrAbsent_: function(deviceState) { + if (this.deviceIsEnabled_(deviceState)) return false; - } if (deviceState.SIMPresent === false) return true; var simLockType = @@ -184,10 +191,23 @@ Polymer({ * @private */ enableToggleIsVisible_: function(deviceState) { - return !!deviceState && deviceState.Type != CrOnc.Type.ETHERNET && - deviceState.Type != CrOnc.Type.VPN && - (deviceState.Type == CrOnc.Type.TETHER || - deviceState.State != CrOnc.DeviceState.UNINITIALIZED); + if (!deviceState) + return false; + switch (deviceState.Type) { + case CrOnc.Type.ETHERNET: + case CrOnc.Type.VPN: + return false; + case CrOnc.Type.TETHER: + return true; + case CrOnc.Type.WI_FI: + case CrOnc.Type.WI_MAX: + return deviceState.State != CrOnc.DeviceState.UNINITIALIZED; + case CrOnc.Type.CELLULAR: + return deviceState.State != CrOnc.DeviceState.UNINITIALIZED && + !this.simLockedOrAbsent_(deviceState); + } + assertNotReached(); + return false; }, /** diff --git a/chromium/chrome/browser/resources/settings/internet_page/tether_connection_dialog.html b/chromium/chrome/browser/resources/settings/internet_page/tether_connection_dialog.html index 67d7e60dba4..e22b64676bd 100644 --- a/chromium/chrome/browser/resources/settings/internet_page/tether_connection_dialog.html +++ b/chromium/chrome/browser/resources/settings/internet_page/tether_connection_dialog.html @@ -1,6 +1,7 @@ <link rel="import" href="chrome://resources/html/polymer.html"> <link rel="import" href="chrome://resources/cr_elements/chromeos/network/cr_network_icon.html"> <link rel="import" href="chrome://resources/cr_elements/chromeos/network/cr_onc_types.html"> +<link rel="import" href="chrome://resources/cr_elements/cr_dialog/cr_dialog.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-button/paper-button.html"> <link rel="import" href="../icons.html"> diff --git a/chromium/chrome/browser/resources/settings/languages_page/languages.js b/chromium/chrome/browser/resources/settings/languages_page/languages.js index 47a7568bf09..d90b775393c 100644 --- a/chromium/chrome/browser/resources/settings/languages_page/languages.js +++ b/chromium/chrome/browser/resources/settings/languages_page/languages.js @@ -15,6 +15,8 @@ cr.exportPath('settings'); +var MoveType = chrome.languageSettingsPrivate.MoveType; + // Translate server treats some language codes the same. // See also: components/translate/core/common/translate_util.cc. var kLanguageCodeToTranslateCode = { @@ -610,38 +612,22 @@ Polymer({ }, /** - * Moves the language in the list of enabled languages by the given offset. + * Moves the language in the list of enabled languages either up (toward the + * front of the list) or down (toward the back). * @param {string} languageCode - * @param {number} offset Negative offset moves the language toward the front - * of the list. A Positive one moves the language toward the back. + * @param {boolean} upDirection True if we need to move up, false if we + * need to move down */ - moveLanguage: function(languageCode, offset) { + moveLanguage: function(languageCode, upDirection) { if (!CrSettingsPrefs.isInitialized) return; - var languageCodes = - this.getPref(preferredLanguagesPrefName).value.split(','); - - var originalIndex = languageCodes.indexOf(languageCode); - var newIndex = originalIndex; - var direction = Math.sign(offset); - var distance = Math.abs(offset); - - // Step over the distance to find the target index. - while (distance > 0) { - newIndex += direction; - if (newIndex < 0 || newIndex >= languageCodes.length) - return; - - // Skip over non-enabled languages, since they don't appear in the list - // (but we don't want to remove them). - if (this.enabledLanguageSet_.has(languageCodes[newIndex])) - distance--; + if (upDirection) { + this.languageSettingsPrivate_.moveLanguage(languageCode, MoveType.UP); + } else { + this.languageSettingsPrivate_.moveLanguage(languageCode, MoveType.DOWN); } - languageCodes[originalIndex] = languageCodes[newIndex]; - languageCodes[newIndex] = languageCode; - this.setPrefValue(preferredLanguagesPrefName, languageCodes.join(',')); }, /** @@ -652,15 +638,7 @@ Polymer({ if (!CrSettingsPrefs.isInitialized) return; - var languageCodes = - this.getPref(preferredLanguagesPrefName).value.split(','); - var originalIndex = languageCodes.indexOf(languageCode); - assert(originalIndex != -1); - - languageCodes.splice(originalIndex, 1); - languageCodes.unshift(languageCode); - - this.setPrefValue(preferredLanguagesPrefName, languageCodes.join(',')); + this.languageSettingsPrivate_.moveLanguage(languageCode, MoveType.TOP); }, /** diff --git a/chromium/chrome/browser/resources/settings/languages_page/languages_page.html b/chromium/chrome/browser/resources/settings/languages_page/languages_page.html index cfa11d4a722..76bec8e924e 100644 --- a/chromium/chrome/browser/resources/settings/languages_page/languages_page.html +++ b/chromium/chrome/browser/resources/settings/languages_page/languages_page.html @@ -9,10 +9,10 @@ <link rel="import" href="chrome://resources/polymer/v1_0/neon-animation/neon-animatable.html"> <link rel="import" href="chrome://resources/polymer/v1_0/paper-checkbox/paper-checkbox.html"> <link rel="import" href="chrome://resources/polymer/v1_0/paper-icon-button/paper-icon-button-light.html"> -<link rel="import" href="chrome://resources/polymer/v1_0/paper-toggle-button/paper-toggle-button.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_expand_button/cr_expand_button.html"> <link rel="import" href="chrome://resources/cr_elements/cr_lazy_render/cr_lazy_render.html"> +<link rel="import" href="chrome://resources/cr_elements/cr_toggle/cr_toggle.html"> <link rel="import" href="chrome://resources/cr_elements/icons.html"> <link rel="import" href="add_languages_dialog.html"> <link rel="import" href="languages.html"> @@ -222,11 +222,11 @@ actionable$="[[item.language.supportsSpellcheck]]"> [[item.language.displayName]] </div> - <paper-toggle-button on-change="onSpellCheckChange_" + <cr-toggle on-change="onSpellCheckChange_" disabled="[[!item.language.supportsSpellcheck]]" checked="[[item.spellCheckEnabled]]" aria-label$="[[item.language.displayName]]"> - </paper-toggle-button> + </cr-toggle> </div> </template> <div class="list-item" on-tap="onEditDictionaryTap_" actionable> diff --git a/chromium/chrome/browser/resources/settings/languages_page/languages_page.js b/chromium/chrome/browser/resources/settings/languages_page/languages_page.js index 4c0782d2f48..eef8e646f89 100644 --- a/chromium/chrome/browser/resources/settings/languages_page/languages_page.js +++ b/chromium/chrome/browser/resources/settings/languages_page/languages_page.js @@ -342,7 +342,8 @@ Polymer({ */ onMoveUpTap_: function() { /** @type {!CrActionMenuElement} */ (this.$.menu.get()).close(); - this.languageHelper.moveLanguage(this.detailLanguage_.language.code, -1); + this.languageHelper.moveLanguage( + this.detailLanguage_.language.code, true /* upDirection */); }, /** @@ -351,7 +352,8 @@ Polymer({ */ onMoveDownTap_: function() { /** @type {!CrActionMenuElement} */ (this.$.menu.get()).close(); - this.languageHelper.moveLanguage(this.detailLanguage_.language.code, 1); + this.languageHelper.moveLanguage( + this.detailLanguage_.language.code, false /* upDirection */); }, /** diff --git a/chromium/chrome/browser/resources/settings/languages_page/languages_types.js b/chromium/chrome/browser/resources/settings/languages_page/languages_types.js index af76c645853..8d0833feb41 100644 --- a/chromium/chrome/browser/resources/settings/languages_page/languages_types.js +++ b/chromium/chrome/browser/resources/settings/languages_page/languages_types.js @@ -106,8 +106,8 @@ LanguageHelper.prototype = { /** * Moves the language in the list of enabled languages by the given offset. * @param {string} languageCode - * @param {number} offset Negative offset moves the language toward the front - * of the list. A Positive one moves the language toward the back. + * @param {boolean} upDirection True if we need to move toward the front, + * false if we need to move toward the back. */ moveLanguage: assertNotReached, diff --git a/chromium/chrome/browser/resources/settings/on_startup_page/startup_urls_page.html b/chromium/chrome/browser/resources/settings/on_startup_page/startup_urls_page.html index 0fc0746165b..02b87b2093a 100644 --- a/chromium/chrome/browser/resources/settings/on_startup_page/startup_urls_page.html +++ b/chromium/chrome/browser/resources/settings/on_startup_page/startup_urls_page.html @@ -17,25 +17,29 @@ <dom-module id="settings-startup-urls-page"> <template> <style include="settings-shared action-link iron-flex"> - #outer { + .list-frame { @apply(--settings-list-frame-padding); - max-height: 395px; /** Enough height to show six entries. */ } - #container iron-list > settings-startup-url-entry:not(:first-of-type) { - border-top: var(--settings-separator-line); + .list-frame > div { + border-top: var(--cr-separator-line); + } + + #outer { + @apply(--settings-list-frame-padding); + max-height: 355px; /** Enough height to show six entries. */ } #container settings-startup-url-entry { cursor: default; } </style> - <div id="outer" class="layout vertical flex vertical-list"> + <div id="outer" class="layout vertical flex"> <div id="container" class="scroll-container" scrollable> <iron-list items="[[startupPages_]]" scroll-target="container" - preserve-focus risk-selection> + preserve-focus risk-selection class="cr-separators"> <template> - <settings-startup-url-entry model="[[item]]" + <settings-startup-url-entry model="[[item]]" first$="[[!index]]" tabindex$="[[tabIndex]]" iron-list-tab-index="[[tabIndex]]" last-focused="{{lastFocused_}}" editable="[[shouldAllowUrlsEdit_( @@ -44,6 +48,8 @@ </template> </iron-list> </div> + </div> + <div class="list-frame"> <template is="dom-if" if="[[shouldAllowUrlsEdit_( prefs.session.startup_urls.enforcement)]]" restamp> <div class="list-item" id="addPage"> diff --git a/chromium/chrome/browser/resources/settings/passwords_and_forms_page/autofill_section.html b/chromium/chrome/browser/resources/settings/passwords_and_forms_page/autofill_section.html index f6e65e7231b..4da90c016dc 100644 --- a/chromium/chrome/browser/resources/settings/passwords_and_forms_page/autofill_section.html +++ b/chromium/chrome/browser/resources/settings/passwords_and_forms_page/autofill_section.html @@ -1,6 +1,7 @@ <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/policy/cr_policy_indicator.html"> <link rel="import" href="chrome://resources/html/action_link.html"> <link rel="import" href="chrome://resources/html/action_link_css.html"> <link rel="import" href="chrome://resources/html/assert.html"> @@ -57,6 +58,11 @@ text-overflow: ellipsis; white-space: nowrap; } + + cr-policy-indicator { + padding-right: 20px; + width: 20px; + } </style> <settings-toggle-button id="autofillToggle" class="first primary-toggle" @@ -133,51 +139,62 @@ <h2 class="start">$i18n{creditCards}</h2> <paper-button id="addCreditCard" class="secondary-button header-aligned-button" - on-tap="onAddCreditCardTap_"> + on-tap="onAddCreditCardTap_" + hidden$="[[isDisabled_(prefs.autofill.credit_card_enabled)]]"> $i18n{add} </paper-button> </div> <div class="list-frame"> - <div id="creditCardsHeading" class="list-item column-header" - hidden$="[[!hasSome_(creditCards)]]"> - <div class="type-column">$i18n{creditCardType}</div> - <div class="expiration-column">$i18n{creditCardExpiration}</div> - </div> - <div id="creditCardList" class="vertical-list list-with-header"> - <template is="dom-repeat" items="[[creditCards]]"> - <div class="list-item"> - <div class="type-column"> - <span id="creditCardLabel">[[item.metadata.summaryLabel]]</span> - <span class="payments-label" hidden$="[[item.metadata.isLocal]]"> - <span hidden$="[[item.metadata.isCached]]"> - $i18n{googlePayments} - </span> - <span hidden$="[[!item.metadata.isCached]]"> - $i18n{googlePaymentsCached} + <template is="dom-if" + if="[[!isDisabled_(prefs.autofill.credit_card_enabled)]]"> + <div id="creditCardsHeading" class="list-item column-header" + hidden$="[[!hasSome_(creditCards)]]"> + <div class="type-column">$i18n{creditCardType}</div> + <div class="expiration-column">$i18n{creditCardExpiration}</div> + </div> + <div id="creditCardList" class="vertical-list list-with-header"> + <template is="dom-repeat" items="[[creditCards]]"> + <div class="list-item"> + <div class="type-column"> + <span id="creditCardLabel">[[item.metadata.summaryLabel]]</span> + <span class="payments-label" + hidden$="[[item.metadata.isLocal]]"> + <span hidden$="[[item.metadata.isCached]]"> + $i18n{googlePayments} + </span> + <span hidden$="[[!item.metadata.isCached]]"> + $i18n{googlePaymentsCached} + </span> </span> - </span> - </div> - <div class="expiration-column"> - <div id="creditCardExpiration" - class="expiration-date">[[expiration_(item)]]</div> - <template is="dom-if" if="[[showDots_(item.metadata)]]"> - <button is="paper-icon-button-light" id="creditCardMenu" - class="icon-more-vert" title="$i18n{moreActions}" - on-tap="onCreditCardMenuTap_"> - </button> - </template> - <template is="dom-if" if="[[!showDots_(item.metadata)]]"> - <button is="paper-icon-button-light" id="remoteCreditCardLink" - class="icon-external" - on-tap="onRemoteEditCreditCardTap_" actionable></button> - </template> + </div> + <div class="expiration-column"> + <div id="creditCardExpiration" + class="expiration-date">[[expiration_(item)]]</div> + <template is="dom-if" if="[[showDots_(item.metadata)]]"> + <button is="paper-icon-button-light" id="creditCardMenu" + class="icon-more-vert" title="$i18n{moreActions}" + on-tap="onCreditCardMenuTap_"> + </button> + </template> + <template is="dom-if" if="[[!showDots_(item.metadata)]]"> + <button is="paper-icon-button-light" id="remoteCreditCardLink" + class="icon-external" + on-tap="onRemoteEditCreditCardTap_" actionable></button> + </template> + </div> </div> - </div> - </template> - </div> - <div id="noCreditCardsLabel" class="list-item" - hidden$="[[hasSome_(creditCards)]]"> - $i18n{noCreditCardsFound} + </template> + </div> + <div id="noCreditCardsLabel" class="list-item" + hidden$="[[hasSome_(creditCards)]]"> + $i18n{noCreditCardsFound} + </div> + </template> + <div id="CreditCardsDisabledLabel" class="list-item" + hidden$="[[!isDisabled_(prefs.autofill.credit_card_enabled)]]"> + <cr-policy-indicator indicator-type="userPolicy" + icon-aria-label="$i18n{noCreditCardsPolicy}"></cr-policy-indicator> + $i18n{noCreditCardsPolicy} </div> </div> <dialog is="cr-action-menu" id="creditCardSharedMenu"> diff --git a/chromium/chrome/browser/resources/settings/passwords_and_forms_page/autofill_section.js b/chromium/chrome/browser/resources/settings/passwords_and_forms_page/autofill_section.js index ffad7d4c01e..95a22ca7e25 100644 --- a/chromium/chrome/browser/resources/settings/passwords_and_forms_page/autofill_section.js +++ b/chromium/chrome/browser/resources/settings/passwords_and_forms_page/autofill_section.js @@ -435,6 +435,17 @@ Polymer({ }, /** + * Returns true if the pref has been explicitly disabled. + * @param {Object} pref + * @return {boolean} + * @private + */ + isDisabled_: function(pref) { + return !!pref && (pref.value === false); + }, + + + /** * Listens for the save-address event, and calls the private API. * @param {!Event} event * @private diff --git a/chromium/chrome/browser/resources/settings/passwords_and_forms_page/password_edit_dialog.html b/chromium/chrome/browser/resources/settings/passwords_and_forms_page/password_edit_dialog.html index 28f9cec9ad3..c637647b887 100644 --- a/chromium/chrome/browser/resources/settings/passwords_and_forms_page/password_edit_dialog.html +++ b/chromium/chrome/browser/resources/settings/passwords_and_forms_page/password_edit_dialog.html @@ -44,25 +44,25 @@ <div slot="title">$i18n{passwordDetailsTitle}</div> <div slot="body"> <paper-input id="websiteInput" label="$i18n{editPasswordWebsiteLabel}" - value="[[item.loginPair.urls.link]]" readonly always-float-label - on-tap="onReadonlyInputTap_"> + value="[[item.entry.loginPair.urls.link]]" readonly + always-float-label on-tap="onReadonlyInputTap_"> </paper-input> <paper-input id="usernameInput" label="$i18n{editPasswordUsernameLabel}" - value="[[item.loginPair.username]]" readonly always-float-label - on-tap="onReadonlyInputTap_"> + value="[[item.entry.loginPair.username]]" readonly + always-float-label on-tap="onReadonlyInputTap_"> </paper-input> <div id="passwordGroup"> <paper-input id="passwordInput" always-float-label label="$i18n{editPasswordPasswordLabel}" - type="[[getPasswordInputType_(item, password)]]" - value="[[getPassword_(item, password)]]" readonly + type="[[getPasswordInputType_(item.password)]]" + value="[[getPassword_(item.password)]]" readonly on-tap="onReadonlyInputTap_"> </paper-input> <button is="paper-icon-button-light" id="showPasswordButton" - class$="[[getIconClass_(item, password)]]" - hidden$="[[item.federationText]]" + class$="[[getIconClass_(item.password)]]" + hidden$="[[item.entry.federationText]]" on-tap="onShowPasswordButtonTap_" - title="[[showPasswordTitle_(password, + title="[[showPasswordTitle_(item.password, '$i18nPolymer{hidePassword}','$i18nPolymer{showPassword}')]]"> </button> </div> diff --git a/chromium/chrome/browser/resources/settings/passwords_and_forms_page/password_list_item.html b/chromium/chrome/browser/resources/settings/passwords_and_forms_page/password_list_item.html index 1d11c507149..85dda982896 100644 --- a/chromium/chrome/browser/resources/settings/passwords_and_forms_page/password_list_item.html +++ b/chromium/chrome/browser/resources/settings/passwords_and_forms_page/password_list_item.html @@ -31,37 +31,37 @@ </style> <div class="list-item" focus-row-container> <div class="website-column no-min-width" - title="[[item.loginPair.urls.link]]"> + title="[[item.entry.loginPair.urls.link]]"> <a id="originUrl" target="_blank" class="no-min-width" - href="[[item.loginPair.urls.link]]" + href="[[item.entry.loginPair.urls.link]]" focus-row-control focus-type="originUrl"> <span class="text-elide"> <!-- This bdo tag is necessary to fix the display of domains starting with numbers. --> - <bdo dir="ltr">[[item.loginPair.urls.shown]]</bdo> + <bdo dir="ltr">[[item.entry.loginPair.urls.shown]]</bdo> </span> </a> </div> <div class="username-column text-elide" - id="username">[[item.loginPair.username]]</div> + id="username">[[item.entry.loginPair.username]]</div> <div class="password-column"> - <template is="dom-if" if="[[!item.federationText]]"> + <template is="dom-if" if="[[!item.entry.federationText]]"> <input id="password" aria-label=$i18n{editPasswordPasswordLabel} - type="[[getPasswordInputType_(item, password)]]" + type="[[getPasswordInputType_(item.password)]]" on-tap="onReadonlyInputTap_" class="password-field" readonly - disabled$="[[!password]]" - value="[[getPassword_(item, password)]]"> + disabled$="[[!item.password]]" + value="[[getPassword_(item.password)]]"> <button is="paper-icon-button-light" id="showPasswordButton" - class$="[[getIconClass_(item, password)]]" + class$="[[getIconClass_(item.password)]]" on-tap="onShowPasswordButtonTap_" - title="[[showPasswordTitle_(password, + title="[[showPasswordTitle_(item.password, '$i18nPolymer{hidePassword}','$i18nPolymer{showPassword}')]]" focus-row-control focus-type="showPassword"> </button> </template> - <template is="dom-if" if="[[item.federationText]]"> + <template is="dom-if" if="[[item.entry.federationText]]"> <span class="password-field text-elide" id="federated"> - [[item.federationText]] + [[item.entry.federationText]] </span> </template> </div> diff --git a/chromium/chrome/browser/resources/settings/passwords_and_forms_page/password_list_item.js b/chromium/chrome/browser/resources/settings/passwords_and_forms_page/password_list_item.js index 1ade2576b1b..8b2b619fec5 100644 --- a/chromium/chrome/browser/resources/settings/passwords_and_forms_page/password_list_item.js +++ b/chromium/chrome/browser/resources/settings/passwords_and_forms_page/password_list_item.js @@ -27,6 +27,6 @@ Polymer({ */ onPasswordMenuTap_: function() { this.fire( - 'password-menu-tap', {target: this.$.passwordMenu, item: this.item}); + 'password-menu-tap', {target: this.$.passwordMenu, listItem: this}); }, }); diff --git a/chromium/chrome/browser/resources/settings/passwords_and_forms_page/passwords_export_dialog.html b/chromium/chrome/browser/resources/settings/passwords_and_forms_page/passwords_export_dialog.html new file mode 100644 index 00000000000..6da824f6159 --- /dev/null +++ b/chromium/chrome/browser/resources/settings/passwords_and_forms_page/passwords_export_dialog.html @@ -0,0 +1,37 @@ +<link rel="import" href="chrome://resources/html/polymer.html"> + +<link rel="import" href="chrome://resources/cr_elements/cr_dialog/cr_dialog.html"> +<link rel="import" href="chrome://resources/cr_elements/cr_icons_css.html"> +<link rel="import" href="chrome://resources/polymer/v1_0/iron-flex-layout/iron-flex-layout-classes.html"> +<link rel="import" href="chrome://resources/polymer/v1_0/paper-button/paper-button.html"> +<link rel="import" href="../settings_shared_css.html"> + +<dom-module id="passwords-export-dialog"> + <template> + <style include="settings-shared iron-flex"> + #info-icon { + padding-right: 15px; + } + </style> + <dialog is="cr-dialog" id="dialog" close-text="$i18n{close}"> + <div slot="title">$i18n{exportPasswordsTitle}</div> + <div slot="body"> + <div class="layout horizontal center"> + <iron-icon icon="settings:info-outline" id="info-icon"></iron-icon> + <div>$i18n{exportPasswordsDescription}</div> + </div> + </div> + <div slot="button-container"> + <paper-button class="secondary-button header-aligned-button" + on-tap="onCancelButtonTap_"> + $i18n{cancel} + </paper-button> + <paper-button class="action-button header-aligned-button" + on-tap="onExportTap_" id="exportPasswordsButton"> + $i18n{exportPasswords} + </paper-button> + </div> + </dialog> + </template> + <script src="passwords_export_dialog.js"></script> +</dom-module>
\ No newline at end of file diff --git a/chromium/chrome/browser/resources/settings/passwords_and_forms_page/passwords_export_dialog.js b/chromium/chrome/browser/resources/settings/passwords_and_forms_page/passwords_export_dialog.js new file mode 100644 index 00000000000..da06563ff1c --- /dev/null +++ b/chromium/chrome/browser/resources/settings/passwords_and_forms_page/passwords_export_dialog.js @@ -0,0 +1,52 @@ +// 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. + +/** + * @fileoverview 'passwords-export-dialog' is the dialog that allows exporting + * passwords. + */ + +(function() { +'use strict'; + +Polymer({ + is: 'passwords-export-dialog', + + /** + * The interface for callbacks to the browser. + * Defined in passwords_section.js + * @type {PasswordManager} + * @private + */ + passwordManager_: null, + + /** @override */ + attached: function() { + this.$.dialog.showModal(); + + this.passwordManager_ = PasswordManagerImpl.getInstance(); + }, + + /** Closes the dialog. */ + close: function() { + this.$.dialog.close(); + }, + + /** + * Fires an event that should trigger the password export process. + * @private + */ + onExportTap_: function() { + this.passwordManager_.exportPasswords(); + }, + + /** + * Handler for tapping the 'cancel' button. Should just dismiss the dialog. + * @private + */ + onCancelButtonTap_: function() { + this.close(); + }, +}); +})();
\ No newline at end of file diff --git a/chromium/chrome/browser/resources/settings/passwords_and_forms_page/passwords_section.html b/chromium/chrome/browser/resources/settings/passwords_and_forms_page/passwords_section.html index fd2f647da10..5c82c295d86 100644 --- a/chromium/chrome/browser/resources/settings/passwords_and_forms_page/passwords_section.html +++ b/chromium/chrome/browser/resources/settings/passwords_and_forms_page/passwords_section.html @@ -15,6 +15,7 @@ <link rel="import" href="../prefs/prefs.html"> <link rel="import" href="../settings_shared_css.html"> <link rel="import" href="password_edit_dialog.html"> +<link rel="import" href="passwords_export_dialog.html"> <link rel="import" href="passwords_shared_css.html"> <link rel="import" href="password_list_item.html"> @@ -84,16 +85,13 @@ </div> <div class="settings-box first"> <h2 class="start">$i18n{savedPasswordsHeading}</h2> - <template is="dom-if" if="[[showImportExportPasswords_]]"> - <paper-button class="secondary-button header-aligned-button" - on-tap="onImportTap_" id="import"> - $i18n{import} - </paper-button> - <paper-button class="secondary-button header-aligned-button" - on-tap="onExportTap_" id="export" - disabled$="[[!hasSome_(savedPasswords)]]"> - $i18n{export} - </paper-button> + <template is="dom-if" + if="[[showImportOrExportPasswords_( + showExportPasswords_, showImportPasswords_)]]"> + <button is="paper-icon-button-light" id="exportImportMenuButton" + class="icon-more-vert" on-tap="onImportExportMenuTap_" + title="$i18n{moreActions}" focus-type="exportImportMenuButton"> + </button> </template> </div> <div class="list-frame"> @@ -109,11 +107,11 @@ </div> <iron-list id="passwordList" preserve-focus items="[[getFilteredPasswords_(savedPasswords, filter)]]" - class="vertical-list list-with-header" + class="cr-separators list-with-header" scroll-target="[[subpageScrollTarget]]" risk-selection> <template> <password-list-item item="[[item]]" tabindex$="[[tabIndex]]" - iron-list-tab-index="[[tabIndex]]" + first$="[[!index]]" iron-list-tab-index="[[tabIndex]]" last-focused="{{lastFocused_}}"> <password-list-item> </template> @@ -129,9 +127,23 @@ <button id="menuRemovePassword" class="dropdown-item" on-tap="onMenuRemovePasswordTap_">$i18n{removePassword}</button> </dialog> + <dialog is="cr-action-menu" id="exportImportMenu"> + <template is="dom-if" if="[[showImportPasswords_]]"> + <button id="menuImportPassword" class="dropdown-item" + on-tap="onImportTap_">$i18n{import}</button> + </template> + <template is="dom-if" if="[[showExportPasswords_]]"> + <button id="menuExportPassword" class="dropdown-item" + on-tap="onExportTap_">$i18n{export}</button> + </template> + </dialog> + <template is="dom-if" if="[[showPasswordsExportDialog_]]" restamp> + <passwords-export-dialog on-close="onPasswordsExportDialogClosed_"> + </passwords-export-dialog> + </template> <template is="dom-if" if="[[showPasswordEditDialog_]]" restamp> <password-edit-dialog on-close="onPasswordEditDialogClosed_" - item="[[activePassword]]"> + item="[[activePassword.item]]"> </password-edit-dialog> </template> <cr-toast id="undoToast" duration="[[toastDuration_]]"> diff --git a/chromium/chrome/browser/resources/settings/passwords_and_forms_page/passwords_section.js b/chromium/chrome/browser/resources/settings/passwords_and_forms_page/passwords_section.js index 9e5b23059c2..16c02d14e1f 100644 --- a/chromium/chrome/browser/resources/settings/passwords_and_forms_page/passwords_section.js +++ b/chromium/chrome/browser/resources/settings/passwords_and_forms_page/passwords_section.js @@ -100,6 +100,9 @@ PasswordManager.ExceptionEntry; /** @typedef {chrome.passwordsPrivate.PlaintextPasswordEventParameters} */ PasswordManager.PlaintextPasswordEvent; +/** @typedef {{ entry: !PasswordManager.PasswordUiEntry, password: string }} */ +PasswordManager.UiEntryWithPassword; + /** * Implementation that accesses the private API. * @implements {PasswordManager} @@ -234,7 +237,7 @@ Polymer({ /** * The model for any password related action menus or dialogs. - * @private {?chrome.passwordsPrivate.PasswordUiEntry} + * @private {?PasswordListItemElement} */ activePassword: Object, @@ -246,11 +249,20 @@ Polymer({ }, /** @private */ - showImportExportPasswords_: { + showExportPasswords_: { + type: Boolean, + value: function() { + return loadTimeData.valueExists('showExportPasswords') && + loadTimeData.getBoolean('showExportPasswords'); + } + }, + + /** @private */ + showImportPasswords_: { type: Boolean, value: function() { - return loadTimeData.valueExists('showImportExportPasswords') && - loadTimeData.getBoolean('showImportExportPasswords'); + return loadTimeData.valueExists('showImportPasswords') && + loadTimeData.getBoolean('showImportPasswords'); } }, @@ -270,6 +282,7 @@ Polymer({ listeners: { 'show-password': 'showPassword_', 'password-menu-tap': 'onPasswordMenuTap_', + 'export-passwords': 'onExportPasswords_', }, keyBindings: { @@ -310,7 +323,12 @@ Polymer({ attached: function() { // Create listener functions. var setSavedPasswordsListener = list => { - this.savedPasswords = list; + this.savedPasswords = list.map(entry => { + return { + entry: entry, + password: '', + }; + }); }; var setPasswordExceptionsListener = list => { @@ -346,6 +364,9 @@ Polymer({ this.passwordManager_.removeExceptionListChangedListener( /** @type {function(!Array<PasswordManager.ExceptionEntry>):void} */ ( this.setPasswordExceptionsListener_)); + + if (this.$.undoToast.open) + this.$.undoToast.hide(); }, /** @@ -364,12 +385,16 @@ Polymer({ this.showPasswordEditDialog_ = false; cr.ui.focusWithoutInk(assert(this.activeDialogAnchor_)); this.activeDialogAnchor_ = null; + + // Trigger a re-evaluation of the activePassword as the visibility state of + // the password might have changed. + this.activePassword.notifyPath('item.password'); }, /** - * @param {!Array<!chrome.passwordsPrivate.PasswordUiEntry>} savedPasswords + * @param {!Array<!PasswordManager.UiEntryWithPassword>} savedPasswords * @param {string} filter - * @return {!Array<!chrome.passwordsPrivate.PasswordUiEntry>} + * @return {!Array<!PasswordManager.UiEntryWithPassword>} * @private */ getFilteredPasswords_: function(savedPasswords, filter) { @@ -377,7 +402,7 @@ Polymer({ return savedPasswords; return savedPasswords.filter(p => { - return [p.loginPair.urls.shown, p.loginPair.username].some( + return [p.entry.loginPair.urls.shown, p.entry.loginPair.username].some( term => term.toLowerCase().includes(filter.toLowerCase())); }); }, @@ -398,7 +423,8 @@ Polymer({ * @private */ onMenuRemovePasswordTap_: function() { - this.passwordManager_.removeSavedPassword(this.activePassword.index); + this.passwordManager_.removeSavedPassword( + this.activePassword.item.entry.index); this.fire('iron-announce', {text: this.$.undoLabel.textContent}); this.$.undoToast.show(); /** @type {CrActionMenuElement} */ (this.$.menu).close(); @@ -435,8 +461,20 @@ Polymer({ var target = /** @type {!HTMLElement} */ (event.detail.target); this.activePassword = - /** @type {!chrome.passwordsPrivate.PasswordUiEntry} */ ( - event.detail.item); + /** @type {!PasswordListItemElement} */ (event.detail.listItem); + menu.showAt(target); + this.activeDialogAnchor_ = target; + }, + + /** + * Opens the export/import action menu. + * @private + */ + onImportExportMenuTap_: function() { + var menu = /** @type {!CrActionMenuElement} */ (this.$.exportImportMenu); + var target = + /** @type {!HTMLElement} */ (this.$$('#exportImportMenuButton')); + menu.showAt(target); this.activeDialogAnchor_ = target; }, @@ -454,11 +492,17 @@ Polymer({ }, /** - * Fires an event that should trigger the password export process. + * Opens the export passwords dialog. * @private */ onExportTap_: function() { - this.passwordManager_.exportPasswords(); + this.showPasswordsExportDialog_ = true; + this.$.exportImportMenu.close(); + }, + + /** @private */ + onPasswordsExportDialogClosed_: function() { + this.showPasswordsExportDialog_ = false; }, /** @@ -478,8 +522,8 @@ Polymer({ */ showPassword_: function(event) { this.passwordManager_.getPlaintextPassword( - /** @type {!number} */ (event.detail.item.index), item => { - event.detail.password = item.plaintextPassword; + /** @type {!number} */ (event.detail.item.entry.index), item => { + event.detail.set('item.password', item.plaintextPassword); }); }, @@ -490,6 +534,17 @@ Polymer({ */ getOnOffLabel_: function(toggleValue) { return toggleValue ? this.i18n('toggleOn') : this.i18n('toggleOff'); + }, + + /** + * @private + * @param {boolean} showExportPasswords + * @param {boolean} showImportPasswords + * @return {boolean} + */ + showImportOrExportPasswords_: function( + showExportPasswords, showImportPasswords) { + return showExportPasswords || showImportPasswords; } }); })(); diff --git a/chromium/chrome/browser/resources/settings/passwords_and_forms_page/show_password_behavior.js b/chromium/chrome/browser/resources/settings/passwords_and_forms_page/show_password_behavior.js index 8c4a54bf5b0..52c7fcf8338 100644 --- a/chromium/chrome/browser/resources/settings/passwords_and_forms_page/show_password_behavior.js +++ b/chromium/chrome/browser/resources/settings/passwords_and_forms_page/show_password_behavior.js @@ -13,19 +13,9 @@ var ShowPasswordBehavior = { properties: { /** * The password that is being displayed. - * @type {!chrome.passwordsPrivate.PasswordUiEntry} + * @type {!ShowPasswordBehavior.UiEntryWithPassword} */ item: Object, - - /** - * Holds the plaintext password when requested. - * Initializing it to the empty string is necessary to indicate that the - * password hasn't been fetched yet. - */ - password: { - type: String, - value: '', - }, }, /** @@ -34,7 +24,8 @@ var ShowPasswordBehavior = { * @private */ getPasswordInputType_: function() { - return this.password || this.item.federationText ? 'text' : 'password'; + return this.item.password || this.item.entry.federationText ? 'text' : + 'password'; }, /** @@ -54,7 +45,7 @@ var ShowPasswordBehavior = { * @private */ getIconClass_: function() { - return this.password ? 'icon-visibility-off' : 'icon-visibility'; + return this.item.password ? 'icon-visibility-off' : 'icon-visibility'; }, /** @@ -66,9 +57,8 @@ var ShowPasswordBehavior = { getPassword_: function() { if (!this.item) return ''; - - return this.item.federationText || this.password || - ' '.repeat(this.item.numCharactersInPassword); + return this.item.entry.federationText || this.item.password || + ' '.repeat(this.item.entry.numCharactersInPassword); }, /** @@ -77,9 +67,16 @@ var ShowPasswordBehavior = { * @private */ onShowPasswordButtonTap_: function() { - if (this.password) - this.password = ''; + if (this.item.password) + this.set('item.password', ''); else this.fire('show-password', this); // Request the password. }, }; + +/** @typedef {{ + * entry: !chrome.passwordsPrivate.PasswordUiEntry, + * password: string + * }} + */ +ShowPasswordBehavior.UiEntryWithPassword; diff --git a/chromium/chrome/browser/resources/settings/people_page/change_picture.html b/chromium/chrome/browser/resources/settings/people_page/change_picture.html index 82cbc58d44a..87ec0b1917d 100644 --- a/chromium/chrome/browser/resources/settings/people_page/change_picture.html +++ b/chromium/chrome/browser/resources/settings/people_page/change_picture.html @@ -84,7 +84,10 @@ discard-image-label="$i18n{discardPhoto}" preview-alt-text="$i18n{previewAltText}" take-photo-label="$i18n{takePhoto}" - switch-mode-label="$i18n{switchMode}"> + capture-video-label="$i18n{captureVideo}" + switch-mode-to-camera-label="$i18n{switchModeToCamera}" + switch-mode-to-video-label="$i18n{switchModeToVideo}" + camera-video-mode-enabled="[[cameraVideoModeEnabled_]]"> </cr-picture-pane> <div id="authorCredit" hidden="[[!isAuthorCreditShown_(selectedItem_)]]"> @@ -103,8 +106,8 @@ choose-file-label="$i18n{chooseFile}" old-image-label="$i18n{oldPhoto}" profile-image-label="$i18n{profilePhoto}" - take-photo-label="$i18n{takePhoto}" - switch-mode-label="$i18n{switchMode}"> + take-photo-label="$i18n{takePhoto}"> + capture-video-label="$i18n{captureVideo}"> </cr-picture-list> </div> </template> diff --git a/chromium/chrome/browser/resources/settings/people_page/change_picture.js b/chromium/chrome/browser/resources/settings/people_page/change_picture.js index 702225517b3..0703e896395 100644 --- a/chromium/chrome/browser/resources/settings/people_page/change_picture.js +++ b/chromium/chrome/browser/resources/settings/people_page/change_picture.js @@ -53,6 +53,15 @@ Polymer({ * @private */ firstDefaultImageIndex_: Number, + + /** + * True when camera video mode is enabled. + * @private {boolean} + */ + cameraVideoModeEnabled_: { + type: Boolean, + value: false, + }, }, listeners: { @@ -173,7 +182,7 @@ Polymer({ case CrPicture.SelectionTypes.OLD: var imageIndex = image.dataset.imageIndex; if (imageIndex !== undefined && imageIndex >= 0 && image.src) - this.browserProxy_.selectDefaultImage(image.src); + this.browserProxy_.selectDefaultImage(image.dataset.url); else this.browserProxy_.selectOldImage(); break; diff --git a/chromium/chrome/browser/resources/settings/people_page/manage_profile.html b/chromium/chrome/browser/resources/settings/people_page/manage_profile.html index 656400bd7c9..fbc49f4ef9d 100644 --- a/chromium/chrome/browser/resources/settings/people_page/manage_profile.html +++ b/chromium/chrome/browser/resources/settings/people_page/manage_profile.html @@ -1,10 +1,10 @@ <link rel="import" href="chrome://resources/html/polymer.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-input/paper-input.html"> <link rel="import" href="chrome://resources/polymer/v1_0/paper-styles/shadow.html"> -<link rel="import" href="chrome://resources/polymer/v1_0/paper-toggle-button/paper-toggle-button.html"> <link rel="import" href="../i18n_setup.html"> <link rel="import" href="manage_profile_browser_proxy.html"> <link rel="import" href="../route.html"> @@ -27,11 +27,11 @@ <template is="dom-if" if="[[isProfileShortcutSettingVisible_]]"> <div class="settings-box first"> <div id="showShortcutLabel" class="start">$i18n{showShortcutLabel}</div> - <paper-toggle-button id="hasShortcutToggle" + <cr-toggle id="hasShortcutToggle" checked="{{hasProfileShortcut_}}" on-change="onHasProfileShortcutChange_" aria-labelledby="showShortcutLabel"> - </paper-toggle-button> + </cr-toggle> </div> </template> <cr-profile-avatar-selector id="selector" avatars="[[availableIcons]]" diff --git a/chromium/chrome/browser/resources/settings/people_page/password_prompt_dialog.js b/chromium/chrome/browser/resources/settings/people_page/password_prompt_dialog.js index 2d3035ada0d..5115c11f17b 100644 --- a/chromium/chrome/browser/resources/settings/people_page/password_prompt_dialog.js +++ b/chromium/chrome/browser/resources/settings/people_page/password_prompt_dialog.js @@ -136,6 +136,12 @@ Polymer({ // The password might have been cleared during the duration of the // getActiveModes call. this.passwordInvalid_ = !valid && !!this.password_; + // Return focus to the password input if it lost focus while being checked + // (user pressed confirm button). + if (this.passwordInvalid_ && + this.shadowRoot.activeElement != this.$.passwordInput) { + this.$.passwordInput.focus(); + } if (valid) { // Create the |this.setModes| closure and automatically clear it after diff --git a/chromium/chrome/browser/resources/settings/people_page/people_page.html b/chromium/chrome/browser/resources/settings/people_page/people_page.html index cec6369f63b..4ab0dfcd81f 100644 --- a/chromium/chrome/browser/resources/settings/people_page/people_page.html +++ b/chromium/chrome/browser/resources/settings/people_page/people_page.html @@ -274,7 +274,11 @@ <settings-subpage associated-control="[[$$('#manage-other-people-subpage-trigger')]]" page-title="$i18n{manageOtherPeople}"> - <settings-users-page prefs="{{prefs}}"></settings-users-page> + <settings-users-page + prefs="{{prefs}}" + profile-manages-supervised-users= + "[[profileManagesSupervisedUsers_]]"> + </settings-users-page> </settings-subpage> </template> <template is="dom-if" route-path="/changePicture"> 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 index bdee32b9efe..d7a74e2a102 100644 --- a/chromium/chrome/browser/resources/settings/people_page/setup_pin_dialog.html +++ b/chromium/chrome/browser/resources/settings/people_page/setup_pin_dialog.html @@ -1,10 +1,10 @@ +<link rel="import" href="chrome://resources/cr_elements/icons.html"> <link rel="import" href="chrome://resources/html/polymer.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/polymer/v1_0/paper-button/paper-button.html"> <link rel="import" href="../i18n_setup.html"> -<link rel="import" href="../icons.html"> <link rel="import" href="lock_screen_constants.html"> <link rel="import" href="pin_keyboard.html"> <link rel="import" href="../settings_shared_css.html"> @@ -55,7 +55,7 @@ <!-- Warning/error; only shown if title is hidden. --> <div id="problemDiv" class$="[[problemClass_]]" hidden="[[!problemMessage_]]" problem> - <iron-icon icon="settings:error-outline"></iron-icon> + <iron-icon icon="cr:error-outline"></iron-icon> <span id="problemMessage">[[problemMessage_]]</span> </div> </pin-keyboard> diff --git a/chromium/chrome/browser/resources/settings/people_page/sync_page.html b/chromium/chrome/browser/resources/settings/people_page/sync_page.html index 9d6fba87a42..07ae46a0bac 100644 --- a/chromium/chrome/browser/resources/settings/people_page/sync_page.html +++ b/chromium/chrome/browser/resources/settings/people_page/sync_page.html @@ -3,9 +3,9 @@ <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_toggle/cr_toggle.html"> <link rel="import" href="chrome://resources/polymer/v1_0/iron-flex-layout/iron-flex-layout-classes.html"> <link rel="import" href="chrome://resources/polymer/v1_0/paper-button/paper-button.html"> -<link rel="import" href="chrome://resources/polymer/v1_0/paper-toggle-button/paper-toggle-button.html"> <link rel="import" href="chrome://resources/polymer/v1_0/paper-input/paper-input.html"> <link rel="import" href="chrome://resources/polymer/v1_0/paper-radio-button/paper-radio-button.html"> <link rel="import" href="chrome://resources/polymer/v1_0/paper-radio-group/paper-radio-group.html"> @@ -103,23 +103,23 @@ <div id="syncEverythingCheckboxLabel" class="start"> $i18n{syncEverythingCheckboxLabel} </div> - <paper-toggle-button id="syncAllDataTypesControl" + <cr-toggle id="syncAllDataTypesControl" checked="{{syncPrefs.syncAllDataTypes}}" on-change="onSyncAllDataTypesChanged_" aria-labelledby="syncEverythingCheckboxLabel"> - </paper-toggle-button> + </cr-toggle> </div> <div class="list-frame" id="sync-data-types"> <div class="layout horizontal list-item" hidden="[[!syncPrefs.appsRegistered]]"> <div id="appCheckboxLabel" class="flex">$i18n{appCheckboxLabel}</div> - <paper-toggle-button checked="{{syncPrefs.appsSynced}}" + <cr-toggle checked="{{syncPrefs.appsSynced}}" on-change="onSingleSyncDataTypeChanged_" disabled="[[shouldSyncCheckboxBeDisabled_( syncPrefs.syncAllDataTypes, syncPrefs.appsEnforced)]]" aria-labelledby="appCheckboxLabel"> - </paper-toggle-button> + </cr-toggle> </div> <div class="layout horizontal list-item" @@ -129,12 +129,12 @@ </div> <!-- Autofill has a special on-change handler to deal with Payments integriation. --> - <paper-toggle-button checked="{{syncPrefs.autofillSynced}}" + <cr-toggle checked="{{syncPrefs.autofillSynced}}" on-change="onAutofillDataTypeChanged_" disabled="[[shouldSyncCheckboxBeDisabled_( syncPrefs.syncAllDataTypes, syncPrefs.autofillEnforced)]]" aria-labelledby="autofillCheckboxLabel"> - </paper-toggle-button> + </cr-toggle> </div> <div class="layout horizontal list-item" @@ -142,12 +142,12 @@ <div id="bookmarksCheckboxLabel" class="flex"> $i18n{bookmarksCheckboxLabel} </div> - <paper-toggle-button checked="{{syncPrefs.bookmarksSynced}}" + <cr-toggle checked="{{syncPrefs.bookmarksSynced}}" on-change="onSingleSyncDataTypeChanged_" disabled="[[shouldSyncCheckboxBeDisabled_( syncPrefs.syncAllDataTypes, syncPrefs.bookmarksEnforced)]]" aria-labelledby="bookmarksCheckboxLabel"> - </paper-toggle-button> + </cr-toggle> </div> <div class="layout horizontal list-item" @@ -155,12 +155,12 @@ <div id="extensionsCheckboxLabel" class="flex"> $i18n{extensionsCheckboxLabel} </div> - <paper-toggle-button checked="{{syncPrefs.extensionsSynced}}" + <cr-toggle checked="{{syncPrefs.extensionsSynced}}" on-change="onSingleSyncDataTypeChanged_" disabled="[[shouldSyncCheckboxBeDisabled_( syncPrefs.syncAllDataTypes, syncPrefs.extensionsEnforced)]]" aria-labelledby="extensionsCheckboxLabel"> - </paper-toggle-button> + </cr-toggle> </div> <div class="layout horizontal list-item" @@ -168,12 +168,12 @@ <div id="historyCheckboxLabel" class="flex"> $i18n{historyCheckboxLabel} </div> - <paper-toggle-button checked="{{syncPrefs.typedUrlsSynced}}" + <cr-toggle checked="{{syncPrefs.typedUrlsSynced}}" on-change="onSingleSyncDataTypeChanged_" disabled="[[shouldSyncCheckboxBeDisabled_( syncPrefs.syncAllDataTypes, syncPrefs.typedUrlsEnforced)]]" aria-labelledby="historyCheckboxLabel"> - </paper-toggle-button> + </cr-toggle> </div> <div class="layout horizontal list-item" @@ -181,12 +181,12 @@ <div id="passwordsCheckboxLabel" class="flex"> $i18n{passwordsCheckboxLabel} </div> - <paper-toggle-button checked="{{syncPrefs.passwordsSynced}}" + <cr-toggle checked="{{syncPrefs.passwordsSynced}}" on-change="onSingleSyncDataTypeChanged_" disabled="[[shouldSyncCheckboxBeDisabled_( syncPrefs.syncAllDataTypes, syncPrefs.passwordsEnforced)]]" aria-labelledby="passwordsCheckboxLabel"> - </paper-toggle-button> + </cr-toggle> </div> <div class="layout horizontal list-item" @@ -194,12 +194,12 @@ <div id="settingsCheckboxLabel" class="flex"> $i18n{settingsCheckboxLabel} </div> - <paper-toggle-button checked="{{syncPrefs.preferencesSynced}}" + <cr-toggle checked="{{syncPrefs.preferencesSynced}}" on-change="onSingleSyncDataTypeChanged_" disabled="[[shouldSyncCheckboxBeDisabled_( syncPrefs.syncAllDataTypes, syncPrefs.preferencesEnforced)]]" aria-labelledby="settingsCheckboxLabel"> - </paper-toggle-button> + </cr-toggle> </div> <div class="layout horizontal list-item" @@ -207,12 +207,12 @@ <div id="themesAndWallpapersCheckboxLabel" class="flex"> $i18n{themesAndWallpapersCheckboxLabel} </div> - <paper-toggle-button checked="{{syncPrefs.themesSynced}}" + <cr-toggle checked="{{syncPrefs.themesSynced}}" on-change="onSingleSyncDataTypeChanged_" disabled="[[shouldSyncCheckboxBeDisabled_( syncPrefs.syncAllDataTypes, syncPrefs.themesEnforced)]]" aria-labelledby="themesAndWallpapersCheckboxLabel"> - </paper-toggle-button> + </cr-toggle> </div> <div class="layout horizontal list-item" @@ -220,12 +220,12 @@ <div id="openTabsCheckboxLabel" class="flex"> $i18n{openTabsCheckboxLabel} </div> - <paper-toggle-button checked="{{syncPrefs.tabsSynced}}" + <cr-toggle checked="{{syncPrefs.tabsSynced}}" on-change="onSingleSyncDataTypeChanged_" disabled="[[shouldSyncCheckboxBeDisabled_( syncPrefs.syncAllDataTypes, syncPrefs.tabsEnforced)]]" aria-labelledby="openTabsCheckboxLabel"> - </paper-toggle-button> + </cr-toggle> </div> <div class="layout horizontal list-item" @@ -239,13 +239,13 @@ $i18n{learnMore} </a> </div> - <paper-toggle-button + <cr-toggle checked="{{syncPrefs.paymentsIntegrationEnabled}}" on-change="onSingleSyncDataTypeChanged_" disabled="[[shouldPaymentsCheckboxBeDisabled_( syncPrefs.syncAllDataTypes, syncPrefs.autofillSynced)]]" aria-label="$i18n{enablePaymentsIntegrationCheckboxLabel}"> - </paper-toggle-button> + </cr-toggle> </div> </div> diff --git a/chromium/chrome/browser/resources/settings/people_page/users_page.html b/chromium/chrome/browser/resources/settings/people_page/users_page.html index a2fea7f100f..ac720c8628e 100644 --- a/chromium/chrome/browser/resources/settings/people_page/users_page.html +++ b/chromium/chrome/browser/resources/settings/people_page/users_page.html @@ -39,11 +39,13 @@ label="$i18n{guestBrowsingLabel}" disabled="[[isEditingDisabled_(isOwner_, isWhitelistManaged_)]]"> </settings-toggle-button> - <settings-toggle-button class="continuation" - pref="{{prefs.cros.accounts.supervisedUsersEnabled}}" - label="$i18n{supervisedUsersLabel}" - disabled="[[isEditingDisabled_(isOwner_, isWhitelistManaged_)]]"> - </settings-toggle-button> + <template is="dom-if" if="[[profileManagesSupervisedUsers]]"> + <settings-toggle-button class="continuation" + pref="{{prefs.cros.accounts.supervisedUsersEnabled}}" + label="$i18n{supervisedUsersLabel}" + disabled="[[isEditingDisabled_(isOwner_, isWhitelistManaged_)]]"> + </settings-toggle-button> + </template> <settings-toggle-button class="continuation" pref="{{prefs.cros.accounts.showUserNamesOnSignIn}}" label="$i18n{showOnSigninLabel}" diff --git a/chromium/chrome/browser/resources/settings/people_page/users_page.js b/chromium/chrome/browser/resources/settings/people_page/users_page.js index 2d14833a0dc..762fb6763f8 100644 --- a/chromium/chrome/browser/resources/settings/people_page/users_page.js +++ b/chromium/chrome/browser/resources/settings/people_page/users_page.js @@ -19,6 +19,15 @@ Polymer({ notify: true, }, + /** + * True if the current profile manages supervised users. + * Set in people-page. + */ + profileManagesSupervisedUsers: { + type: Boolean, + value: false, + }, + /** @private */ isOwner_: { type: Boolean, diff --git a/chromium/chrome/browser/resources/settings/printing_page/compiled_resources2.gyp b/chromium/chrome/browser/resources/settings/printing_page/compiled_resources2.gyp index 6a3b5f8fddf..cc0e0003a42 100644 --- a/chromium/chrome/browser/resources/settings/printing_page/compiled_resources2.gyp +++ b/chromium/chrome/browser/resources/settings/printing_page/compiled_resources2.gyp @@ -72,6 +72,13 @@ 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'], }, { + 'target_name': 'printing_browser_proxy', + 'dependencies': [ + '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr', + ], + 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'], + }, + { 'target_name': 'printing_page', 'dependencies': [ '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:assert', @@ -79,6 +86,7 @@ '../compiled_resources2.gyp:route', '../settings_page/compiled_resources2.gyp:settings_animated_pages', 'cups_printers_browser_proxy', + 'printing_browser_proxy', ], 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'], }, diff --git a/chromium/chrome/browser/resources/settings/printing_page/cups_add_printer_dialog.html b/chromium/chrome/browser/resources/settings/printing_page/cups_add_printer_dialog.html index 5ca6f7e45de..5f697cc8706 100644 --- a/chromium/chrome/browser/resources/settings/printing_page/cups_add_printer_dialog.html +++ b/chromium/chrome/browser/resources/settings/printing_page/cups_add_printer_dialog.html @@ -61,7 +61,7 @@ $i18n{cancelButtonText} </paper-button> <paper-button class="action-button" id="addPrinterButton" - disabled="[[!selectedPrinter]]" + disabled="[[!canAddPrinter_(selectedPrinter)]]" on-tap="switchToConfiguringDialog_"> $i18n{addPrinterButtonText} </paper-button> diff --git a/chromium/chrome/browser/resources/settings/printing_page/cups_add_printer_dialog.js b/chromium/chrome/browser/resources/settings/printing_page/cups_add_printer_dialog.js index 6ebd338e294..ccd0c66fcdf 100644 --- a/chromium/chrome/browser/resources/settings/printing_page/cups_add_printer_dialog.js +++ b/chromium/chrome/browser/resources/settings/printing_page/cups_add_printer_dialog.js @@ -143,6 +143,15 @@ Polymer({ this.close(); this.fire('open-configuring-printer-dialog'); }, + + /** + * @param {?CupsPrinterInfo} selectedPrinter + * @return {boolean} Whether the add printer button is enabled. + * @private + */ + canAddPrinter_: function(selectedPrinter) { + return !!selectedPrinter && !!selectedPrinter.printerName; + }, }); Polymer({ diff --git a/chromium/chrome/browser/resources/settings/printing_page/cups_printers.js b/chromium/chrome/browser/resources/settings/printing_page/cups_printers.js index 0957580006d..727755f4a89 100644 --- a/chromium/chrome/browser/resources/settings/printing_page/cups_printers.js +++ b/chromium/chrome/browser/resources/settings/printing_page/cups_printers.js @@ -115,7 +115,7 @@ Polymer({ break; case PrinterSetupResult.PRINTER_UNREACHABLE: messageText.textContent = - loadTimeData.getString('printerAddedPrinterUnreachableMessage'); + loadTimeData.getString('printerAddedUnreachableMessage'); break; case PrinterSetupResult.DBUS_ERROR: // Simply display a generic error message as this error should only diff --git a/chromium/chrome/browser/resources/settings/printing_page/cups_printers_browser_proxy.js b/chromium/chrome/browser/resources/settings/printing_page/cups_printers_browser_proxy.js index 6cc0b682015..a1804172813 100644 --- a/chromium/chrome/browser/resources/settings/printing_page/cups_printers_browser_proxy.js +++ b/chromium/chrome/browser/resources/settings/printing_page/cups_printers_browser_proxy.js @@ -4,7 +4,7 @@ /** * @fileoverview A helper object used from the "CUPS printing" section to - * interact with the browser. + * interact with the browser. Used only on Chrome OS. */ /** diff --git a/chromium/chrome/browser/resources/settings/printing_page/printing_browser_proxy.html b/chromium/chrome/browser/resources/settings/printing_page/printing_browser_proxy.html new file mode 100644 index 00000000000..8e6d297ef56 --- /dev/null +++ b/chromium/chrome/browser/resources/settings/printing_page/printing_browser_proxy.html @@ -0,0 +1,2 @@ +<link rel="import" href="chrome://resources/html/cr.html"> +<script src="printing_browser_proxy.js"></script> diff --git a/chromium/chrome/browser/resources/settings/printing_page/printing_browser_proxy.js b/chromium/chrome/browser/resources/settings/printing_page/printing_browser_proxy.js new file mode 100644 index 00000000000..83b8536e836 --- /dev/null +++ b/chromium/chrome/browser/resources/settings/printing_page/printing_browser_proxy.js @@ -0,0 +1,35 @@ +// 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. + +/** + * @fileoverview A helper object used from the Chrome printing section to + * interact with the browser. Used on operating system that is not Chrome OS. + */ + +cr.define('settings', function() { + /** @interface */ + class PrintingBrowserProxy { + /** + * Open the native print system dialog. + */ + openSystemPrintDialog() {} + } + + /** + * @implements {settings.PrintingBrowserProxy} + */ + class PrintingBrowserProxyImpl { + /** @override */ + openSystemPrintDialog() { + chrome.send('openSystemPrintDialog'); + } + } + + cr.addSingletonGetter(PrintingBrowserProxyImpl); + + return { + PrintingBrowserProxy: PrintingBrowserProxy, + PrintingBrowserProxyImpl: PrintingBrowserProxyImpl, + }; +}); diff --git a/chromium/chrome/browser/resources/settings/printing_page/printing_page.html b/chromium/chrome/browser/resources/settings/printing_page/printing_page.html index 77eddcbbdfc..90e18fbb2e5 100644 --- a/chromium/chrome/browser/resources/settings/printing_page/printing_page.html +++ b/chromium/chrome/browser/resources/settings/printing_page/printing_page.html @@ -10,6 +10,9 @@ <if expr="chromeos"> <link rel="import" href="cups_printers.html"> </if> +<if expr="not chromeos"> +<link rel="import" href="printing_browser_proxy.html"> +</if> <dom-module id="settings-printing-page"> <template> @@ -25,6 +28,14 @@ aria-label="$i18n{cupsPrintersTitle}"></button> </div> </if> +<if expr="not chromeos"> + <div class="settings-box first" + on-tap="onTapLocalPrinters_" actionable> + <div class="start">$i18n{localPrintersTitle}</div> + <button class="subpage-arrow" is="paper-icon-button-light" + aria-label="$i18n{localPrintersTitle}"></button> + </div> +</if> <div id="cloudPrinters" class="settings-box" on-tap="onTapCloudPrinters_" actionable> <div class="start">$i18n{cloudPrintersTitle}</div> diff --git a/chromium/chrome/browser/resources/settings/printing_page/printing_page.js b/chromium/chrome/browser/resources/settings/printing_page/printing_page.js index 8c8e14b2934..79a7be19b24 100644 --- a/chromium/chrome/browser/resources/settings/printing_page/printing_page.js +++ b/chromium/chrome/browser/resources/settings/printing_page/printing_page.js @@ -45,6 +45,12 @@ Polymer({ }, // </if> + // <if expr="not chromeos"> + onTapLocalPrinters_: function() { + settings.PrintingBrowserProxyImpl.getInstance().openSystemPrintDialog(); + }, + // </if> + /** @private */ onTapCloudPrinters_: function() { settings.navigateTo(settings.routes.CLOUD_PRINTERS); diff --git a/chromium/chrome/browser/resources/settings/privacy_page/privacy_page.html b/chromium/chrome/browser/resources/settings/privacy_page/privacy_page.html index 52fff4a8457..1ba4c86e60b 100644 --- a/chromium/chrome/browser/resources/settings/privacy_page/privacy_page.html +++ b/chromium/chrome/browser/resources/settings/privacy_page/privacy_page.html @@ -349,8 +349,8 @@ <template is="dom-if" route-path="/content/sound" no-search> <settings-subpage page-title="$i18n{siteSettingsSound}"> <category-default-setting - toggle-off-label="$i18n{siteSettingsBlocked}" - toggle-on-label="$i18n{siteSettingsAllowedRecommended}" + toggle-off-label="$i18n{siteSettingsSoundBlock}" + toggle-on-label="$i18n{siteSettingsSoundAllowRecommended}" category="{{ContentSettingsTypes.SOUND}}"> </category-default-setting> <category-setting-exceptions @@ -358,8 +358,8 @@ block-header="$i18n{siteSettingsBlockSound}"> </category-setting-exceptions> </settings-subpage> - </template> - </template> + </template> + </template> <template is="dom-if" route-path="/content/microphone" no-search> <settings-subpage page-title="$i18n{siteSettingsCategoryMicrophone}"> <media-picker label="$i18n{siteSettingsMicrophoneLabel}" type="mic"> @@ -516,6 +516,22 @@ </if> </settings-subpage> </template> + <template is="dom-if" if="[[enableClipboardContentSetting_]]" + no-search> + <template is="dom-if" route-path="/content/clipboard" no-search> + <settings-subpage page-title="$i18n{siteSettingsClipboard}"> + <category-default-setting + toggle-off-label="$i18n{siteSettingsClipboardBlock}" + toggle-on-label="$i18n{siteSettingsClipboardAskRecommended}" + category="{{ContentSettingsTypes.CLIPBOARD}}"> + </category-default-setting> + <category-setting-exceptions + category="{{ContentSettingsTypes.CLIPBOARD}}" + block-header="$i18n{siteSettingsBlock}"> + </category-setting-exceptions> + </settings-subpage> + </template> + </template> </settings-animated-pages> </template> <script src="privacy_page.js"></script> diff --git a/chromium/chrome/browser/resources/settings/privacy_page/privacy_page.js b/chromium/chrome/browser/resources/settings/privacy_page/privacy_page.js index cb15fd06ff5..46afb457824 100644 --- a/chromium/chrome/browser/resources/settings/privacy_page/privacy_page.js +++ b/chromium/chrome/browser/resources/settings/privacy_page/privacy_page.js @@ -115,6 +115,14 @@ Polymer({ } }, + /** @private */ + enableClipboardContentSetting_: { + type: Boolean, + value: function() { + return loadTimeData.getBoolean('enableClipboardContentSetting'); + } + }, + /** @private {!Map<string, string>} */ focusConfig_: { type: Object, diff --git a/chromium/chrome/browser/resources/settings/reset_page/compiled_resources2.gyp b/chromium/chrome/browser/resources/settings/reset_page/compiled_resources2.gyp index c1e99cfafce..39f600e4c60 100644 --- a/chromium/chrome/browser/resources/settings/reset_page/compiled_resources2.gyp +++ b/chromium/chrome/browser/resources/settings/reset_page/compiled_resources2.gyp @@ -11,6 +11,25 @@ '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr', '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:load_time_data', '<(DEPTH)/ui/webui/resources/js/cr/ui/compiled_resources2.gyp:focus_without_ink', + 'reset_profile_dialog', + ], + 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'], + }, + { + 'target_name': 'reset_browser_proxy', + 'dependencies': [ + '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr', + '<(EXTERNS_GYP):chrome_send', + ], + 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'], + }, + { + 'target_name': 'reset_profile_dialog', + 'dependencies': [ + '../compiled_resources2.gyp:route', + '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:load_time_data', + '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:web_ui_listener_behavior', + 'reset_browser_proxy', ], 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'], }, diff --git a/chromium/chrome/browser/resources/settings/reset_page/reset_browser_proxy.js b/chromium/chrome/browser/resources/settings/reset_page/reset_browser_proxy.js index f43c9a08a38..8b9f2184c51 100644 --- a/chromium/chrome/browser/resources/settings/reset_page/reset_browser_proxy.js +++ b/chromium/chrome/browser/resources/settings/reset_page/reset_browser_proxy.js @@ -114,6 +114,7 @@ cr.define('settings', function() { cr.addSingletonGetter(ResetBrowserProxyImpl); return { + ResetBrowserProxy: ResetBrowserProxy, ResetBrowserProxyImpl: ResetBrowserProxyImpl, }; }); diff --git a/chromium/chrome/browser/resources/settings/reset_page/reset_page.html b/chromium/chrome/browser/resources/settings/reset_page/reset_page.html index fc55ba1f8f4..44214d07820 100644 --- a/chromium/chrome/browser/resources/settings/reset_page/reset_page.html +++ b/chromium/chrome/browser/resources/settings/reset_page/reset_page.html @@ -3,53 +3,95 @@ <link rel="import" href="chrome://resources/cr_elements/cr_lazy_render/cr_lazy_render.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/polymer/v1_0/neon-animation/neon-animatable.html"> <link rel="import" href="chrome://resources/polymer/v1_0/paper-icon-button/paper-icon-button-light.html"> <link rel="import" href="../i18n_setup.html"> <link rel="import" href="reset_profile_dialog.html"> <link rel="import" href="../route.html"> +<link rel="import" href="../settings_page/settings_animated_pages.html"> <link rel="import" href="../settings_shared_css.html"> <if expr="chromeos"> <link rel="import" href="powerwash_dialog.html"> </if> +<if expr="_google_chrome and is_win"> +<link rel="import" href="../chrome_cleanup_page/chrome_cleanup_page.html"> +</if> + <dom-module id="settings-reset-page"> <template> <style include="settings-shared"></style> - <div class="settings-box first two-line" id="resetProfile" - on-tap="onShowResetProfileDialog_" actionable> - <div class="start"> - $i18n{resetPageTitle} - <div class="secondary" id="resetProfileSecondary"> - $i18n{resetPageDescription} + <settings-animated-pages id="reset-pages" section="reset"> + <neon-animatable route-path="default"> + <div class="settings-box first two-line" id="resetProfile" + on-tap="onShowResetProfileDialog_" actionable> + <div class="start"> + $i18n{resetPageTitle} + <div class="secondary" id="resetProfileSecondary"> + $i18n{resetPageDescription} + </div> + </div> + <button id="resetProfileArrow" is="paper-icon-button-light" + class="subpage-arrow" aria-label="$i18n{resetPageTitle}" + aria-describedby="resetProfileSecondary"></button> </div> - </div> - <button id="resetProfileArrow" is="paper-icon-button-light" - class="subpage-arrow" aria-label="$i18n{resetPageTitle}" - aria-describedby="resetProfileSecondary"></button> - </div> - <template is="dom-if" if="[[showResetProfileDialog_]]" restamp> - <settings-reset-profile-dialog on-close="onResetProfileDialogClose_"> - </settings-reset-profile-dialog> - </template> + <!-- Keep a single instance of reset-profile-dialog on purpose, to + preserve state across show/hide operations. --> + <template is="cr-lazy-render" id="resetProfileDialog"> + <settings-reset-profile-dialog on-close="onResetProfileDialogClose_"> + </settings-reset-profile-dialog> + </template> <if expr="chromeos"> - <div class="settings-box two-line" id="powerwash" actionable - on-tap="onShowPowerwashDialog_" hidden="[[!allowPowerwash_]]"> - <div class="start"> - $i18n{powerwashTitle} - <div class="secondary" id="powerwashSecondary"> - $i18n{powerwashDescription} + <div class="settings-box two-line" id="powerwash" actionable + on-tap="onShowPowerwashDialog_" hidden="[[!allowPowerwash_]]"> + <div class="start"> + $i18n{powerwashTitle} + <div class="secondary" id="powerwashSecondary"> + $i18n{powerwashDescription} + </div> + </div> + <button id="powerwashArrow" is="paper-icon-button-light" + class="subpage-arrow" aria-label="$i18n{powerwashTitle}" + aria-describedby="powerwashSecondary"></button> </div> - </div> - <button id="powerwashArrow" is="paper-icon-button-light" - class="subpage-arrow" aria-label="$i18n{powerwashTitle}" - aria-describedby="powerwashSecondary"></button> - </div> - <template is="dom-if" if="[[showPowerwashDialog_]]" restamp> - <settings-powerwash-dialog on-close="onPowerwashDialogClose_"> - </settings-powerwash-dialog> - </template> + <template is="dom-if" if="[[showPowerwashDialog_]]" restamp> + <settings-powerwash-dialog on-close="onPowerwashDialogClose_"> + </settings-powerwash-dialog> + </template> +</if> +<!-- This needs to be conditioned to a feature being enabled. --> +<if expr="_google_chrome and is_win"> + <template is="dom-if" if="[[userInitiatedCleanupsEnabled_]]" restamp> + <div class="settings-box two-line" id="chromeCleanupSubpageTrigger" + on-tap="onChromeCleanupTap_" actionable> + <div class="start"> + $i18n{resetCleanupComputerTrigger} + <div class="secondary" id="chromeCleanupSecondary"> + $i18n{resetCleanupComputerTriggerDescription} + </div> + </div> + <button id="chromeCleanupArrow" is="paper-icon-button-light" + class="subpage-arrow" + aria-label="$i18n{resetCleanupComputerTrigger}" + aria-describedby="chromeCleanupSecondary"></button> + </div> + </template> +</if> + </neon-animatable> +<if expr="_google_chrome and is_win"> + <template is="dom-if" if="[[userInitiatedCleanupsEnabled_]]"> + <template is="dom-if" route-path="/cleanup"> + <settings-subpage id="chromeCleanupSubpage" + associated-control="[[$$('#chromeCleanupSubpageTrigger')]]" + page-title="$i18n{resetCleanupComputerTrigger}" + learn-more-url="$i18n{chromeCleanupLearnMoreUrl}"> + <settings-chrome-cleanup-page></settings-chrome-cleanup-page> + </settings-subpage> + </template> + </template> </if> + </settings-animated-pages> </template> <script src="reset_page.js"></script> </dom-module> diff --git a/chromium/chrome/browser/resources/settings/reset_page/reset_page.js b/chromium/chrome/browser/resources/settings/reset_page/reset_page.js index 2c4d88e249c..fb5c2229223 100644 --- a/chromium/chrome/browser/resources/settings/reset_page/reset_page.js +++ b/chromium/chrome/browser/resources/settings/reset_page/reset_page.js @@ -32,11 +32,15 @@ Polymer({ value: cr.isChromeOS ? loadTimeData.getBoolean('allowPowerwash') : false }, + // <if expr="_google_chrome and is_win"> /** @private */ - showResetProfileDialog_: { + userInitiatedCleanupsEnabled_: { type: Boolean, - value: false, + value: function() { + return loadTimeData.getBoolean('userInitiatedCleanupsEnabled'); + }, }, + // </if> }, /** @@ -45,9 +49,12 @@ Polymer({ * @protected */ currentRouteChanged: function(route) { - this.showResetProfileDialog_ = - route == settings.routes.TRIGGERED_RESET_DIALOG || - route == settings.routes.RESET_DIALOG; + if (route == settings.routes.TRIGGERED_RESET_DIALOG || + route == settings.routes.RESET_DIALOG) { + /** @type {!SettingsResetProfileDialogElement} */ ( + this.$.resetProfileDialog.get()) + .show(); + } }, /** @private */ @@ -78,4 +85,11 @@ Polymer({ cr.ui.focusWithoutInk(assert(this.$.powerwashArrow)); }, // </if> + + // <if expr="_google_chrome and is_win"> + onChromeCleanupTap_: function() { + settings.navigateTo(settings.routes.CHROME_CLEANUP); + }, + // </if> + }); diff --git a/chromium/chrome/browser/resources/settings/reset_page/reset_profile_dialog.js b/chromium/chrome/browser/resources/settings/reset_page/reset_profile_dialog.js index 40827a89e20..b7c6519625c 100644 --- a/chromium/chrome/browser/resources/settings/reset_page/reset_profile_dialog.js +++ b/chromium/chrome/browser/resources/settings/reset_page/reset_profile_dialog.js @@ -41,7 +41,7 @@ Polymer({ }, }, - /** @private {!settings.ResetBrowserProxy} */ + /** @private {?settings.ResetBrowserProxy} */ browserProxy_: null, /** @@ -87,12 +87,12 @@ Polymer({ /** @private */ showDialog_: function() { - this.$.dialog.showModal(); + if (!this.$.dialog.open) + this.$.dialog.showModal(); this.browserProxy_.onShowResetProfileDialog(); }, - /** @override */ - attached: function() { + show: function() { this.isTriggered_ = settings.getCurrentRoute() == settings.routes.TRIGGERED_RESET_DIALOG; if (this.isTriggered_) { diff --git a/chromium/chrome/browser/resources/settings/route.js b/chromium/chrome/browser/resources/settings/route.js index 20b8d4b29a7..d6bf83c237b 100644 --- a/chromium/chrome/browser/resources/settings/route.js +++ b/chromium/chrome/browser/resources/settings/route.js @@ -20,10 +20,12 @@ * BLUETOOTH_DEVICES: (undefined|!settings.Route), * CERTIFICATES: (undefined|!settings.Route), * CHANGE_PICTURE: (undefined|!settings.Route), + * CHROME_CLEANUP: (undefined|!settings.Route), * CLEAR_BROWSER_DATA: (undefined|!settings.Route), * CLOUD_PRINTERS: (undefined|!settings.Route), * CUPS_PRINTERS: (undefined|!settings.Route), * DATETIME: (undefined|!settings.Route), + * DATETIME_TIMEZONE_SUBPAGE: (undefined|!settings.Route), * DEFAULT_BROWSER: (undefined|!settings.Route), * DETAILED_BUILD_INFO: (undefined|!settings.Route), * DEVICE: (undefined|!settings.Route), @@ -45,7 +47,6 @@ * MANAGE_PASSWORDS: (undefined|!settings.Route), * MANAGE_PROFILE: (undefined|!settings.Route), * MULTIDEVICE: (undefined|!settings.Route), - * NETWORK_CONFIG: (undefined|!settings.Route), * NETWORK_DETAIL: (undefined|!settings.Route), * ON_STARTUP: (undefined|!settings.Route), * PASSWORDS: (undefined|!settings.Route), @@ -65,6 +66,7 @@ * SITE_SETTINGS_AUTOMATIC_DOWNLOADS: (undefined|!settings.Route), * SITE_SETTINGS_BACKGROUND_SYNC: (undefined|!settings.Route), * SITE_SETTINGS_CAMERA: (undefined|!settings.Route), + * SITE_SETTINGS_CLIPBOARD: (undefined|!settings.Route), * SITE_SETTINGS_COOKIES: (undefined|!settings.Route), * SITE_SETTINGS_DATA_DETAILS: (undefined|!settings.Route), * SITE_SETTINGS_FLASH: (undefined|!settings.Route), @@ -135,7 +137,7 @@ cr.define('settings', function() { // |path| extends this route's path if it doesn't have a leading slash. // If it does have a leading slash, it's just set as the new route's URL. - var newUrl = path[0] == '/' ? path : this.path + '/' + path; + var newUrl = path[0] == '/' ? path : `${this.path}/${path}`; var route = new Route(newUrl); route.parent = this; @@ -216,7 +218,6 @@ cr.define('settings', function() { // <if expr="chromeos"> r.INTERNET = r.BASIC.createSection('/internet', 'internet'); r.INTERNET_NETWORKS = r.INTERNET.createChild('/networks'); - r.NETWORK_CONFIG = r.INTERNET.createChild('/networkConfig'); r.NETWORK_DETAIL = r.INTERNET.createChild('/networkDetail'); r.KNOWN_NETWORKS = r.INTERNET.createChild('/knownNetworks'); r.BLUETOOTH = r.BASIC.createSection('/bluetooth', 'bluetooth'); @@ -290,10 +291,9 @@ cr.define('settings', function() { r.SITE_SETTINGS_ALL = r.SITE_SETTINGS.createChild('all'); r.SITE_SETTINGS_SITE_DETAILS = r.SITE_SETTINGS_ALL.createChild('/content/siteDetails'); - } else if (loadTimeData.getBoolean('enableSiteDetails')) { + } else { // When there is no "All Sites", pressing 'back' from "Site Details" - // should return to "Content Settings". This should only occur when - // |kSiteSettings| is off and |kSiteDetails| is on. + // should return to "Content Settings". r.SITE_SETTINGS_SITE_DETAILS = r.SITE_SETTINGS.createChild('/content/siteDetails'); } @@ -308,6 +308,7 @@ cr.define('settings', function() { r.SITE_SETTINGS_BACKGROUND_SYNC = r.SITE_SETTINGS.createChild('backgroundSync'); r.SITE_SETTINGS_CAMERA = r.SITE_SETTINGS.createChild('camera'); + r.SITE_SETTINGS_CLIPBOARD = r.SITE_SETTINGS.createChild('clipboard'); r.SITE_SETTINGS_COOKIES = r.SITE_SETTINGS.createChild('cookies'); r.SITE_SETTINGS_SITE_DATA = r.SITE_SETTINGS_COOKIES.createChild('/siteData'); @@ -335,6 +336,8 @@ cr.define('settings', function() { // <if expr="chromeos"> if (pageVisibility.dateTime !== false) { r.DATETIME = r.ADVANCED.createSection('/dateTime', 'dateTime'); + r.DATETIME_TIMEZONE_SUBPAGE = + r.DATETIME.createChild('/dateTime/timeZone'); } // </if> @@ -380,6 +383,12 @@ cr.define('settings', function() { r.TRIGGERED_RESET_DIALOG = r.ADVANCED.createChild('/triggeredResetProfileSettings'); r.TRIGGERED_RESET_DIALOG.isNavigableDialog = true; + // <if expr="_google_chrome and is_win"> + // This should only be added if the feature is enabled. + if (loadTimeData.getBoolean('userInitiatedCleanupsEnabled')) { + r.CHROME_CLEANUP = r.RESET.createChild('/cleanup'); + } + // </if> } } diff --git a/chromium/chrome/browser/resources/settings/search_engines_page/search_engines_browser_proxy.js b/chromium/chrome/browser/resources/settings/search_engines_page/search_engines_browser_proxy.js index 947dcbefc39..27db88365fa 100644 --- a/chromium/chrome/browser/resources/settings/search_engines_page/search_engines_browser_proxy.js +++ b/chromium/chrome/browser/resources/settings/search_engines_page/search_engines_browser_proxy.js @@ -37,18 +37,6 @@ var SearchEngine; */ var SearchEnginesInfo; -/** - * @typedef {{ - * allowed: boolean, - * enabled: boolean, - * alwaysOn: boolean, - * errorMessage: string, - * userName: string, - * historyEnabled: boolean - * }} - */ -var SearchPageHotwordInfo; - cr.define('settings', function() { /** @interface */ class SearchEnginesBrowserProxy { @@ -80,12 +68,6 @@ cr.define('settings', function() { */ validateSearchEngineInput(fieldName, fieldValue) {} - /** @return {!Promise<!SearchPageHotwordInfo>} */ - getHotwordInfo() {} - - /** @param {boolean} enabled */ - setHotwordSearchEnabled(enabled) {} - turnOnGoogleAssistant() {} } @@ -134,16 +116,6 @@ cr.define('settings', function() { } /** @override */ - getHotwordInfo() { - return cr.sendWithPromise('getHotwordInfo'); - } - - /** @override */ - setHotwordSearchEnabled(enabled) { - chrome.send('setHotwordSearchEnabled', [enabled]); - } - - /** @override */ turnOnGoogleAssistant() { chrome.send('turnOnGoogleAssistant'); } diff --git a/chromium/chrome/browser/resources/settings/search_page/search_page.html b/chromium/chrome/browser/resources/settings/search_page/search_page.html index e10d8141330..1e9f88f1e7c 100644 --- a/chromium/chrome/browser/resources/settings/search_page/search_page.html +++ b/chromium/chrome/browser/resources/settings/search_page/search_page.html @@ -82,62 +82,6 @@ </template> </div> - <template is="dom-if" if="[[hotwordInfo_.allowed]]"> - <!-- Hotword (OK Google) --> - <settings-toggle-button id="hotwordSearchEnable" - class="continuation indented" - pref="{{hotwordSearchEnablePref_}}" - label="$i18n{searchOkGoogleLabel}" - sub-label="[[getHotwordSearchEnableSubLabel_( - hotwordInfo_.alwaysOn)]]" - on-change="onHotwordSearchEnableChange_"> - </settings-toggle-button> - <div class="settings-row indented" - hidden$="[[!getShowHotwordSearchRetrain_(hotwordInfo_.*)]]"> - <div class="separator"></div> - <paper-button on-tap="onRetrainTap_" class="secondary-button"> - $i18n{searchOkGoogleRetrain} - </paper-button> - </div> - - <template is="dom-if" - if="[[getShowHotwordError_(hotwordInfo_.*, - hotwordSearchEnablePref_)]]"> - <div class="settings-box continuation indented"> - <iron-icon icon="settings:warning"></iron-icon> - <div inner-h-t-m-l="[[hotwordInfo_.errorMessage]]"></div> - </div> - </template> - - <template is="dom-if" if="[[hotwordInfo_.historyEnabled]]"> - <a class="settings-box two-line continuation indented inherit-color - no-outline" tabindex="-1" target="_blank" - href="$i18n{manageAudioHistoryUrl}"> - <div class="start"> - [[i18n('searchOkGoogleAudioHistoryLabel', - hotwordInfo_.userName)]] - <div class="secondary" id="audioHistorySecondary"> - $i18n{searchOkGoogleAudioHistorySubtext} - </div> - </div> - <button actionable class="icon-external" - is="paper-icon-button-light" - aria-label$="[[i18n('searchOkGoogleAudioHistoryLabel', - hotwordInfo_.userName)]]" - aria-describedby="audioHistorySecondary"></button> - </a> - </template> - </template> - -<if expr="chromeos"> - <template is="dom-if" - if="[[hotwordSearchEnablePref_.value]]"> - <div class="start settings-box continuation indented"> - $i18n{searchOkGoogleDisabled} - </div> - </template> -</if> - <!-- Manage search engines --> <div id="engines-subpage-trigger" class="settings-box" on-tap="onManageSearchEnginesTap_" actionable> diff --git a/chromium/chrome/browser/resources/settings/search_page/search_page.js b/chromium/chrome/browser/resources/settings/search_page/search_page.js index 3dbfcf19d69..9a3d913e969 100644 --- a/chromium/chrome/browser/resources/settings/search_page/search_page.js +++ b/chromium/chrome/browser/resources/settings/search_page/search_page.js @@ -34,18 +34,6 @@ Polymer({ /** @private Filter applied to search engines. */ searchEnginesFilter_: String, - /** @private {!SearchPageHotwordInfo|undefined} */ - hotwordInfo_: Object, - - /** - * This is a local PrefObject used to reflect the enabled state of hotword - * search. It is not tied directly to a pref. (There are two prefs - * associated with state and they do not map directly to whether or not - * hotword search is actually enabled). - * @private {!chrome.settingsPrivate.PrefObject|undefined} - */ - hotwordSearchEnablePref_: Object, - /** @type {?Map<string, string>} */ focusConfig_: Object, @@ -80,15 +68,10 @@ Polymer({ // Omnibox search engine var updateSearchEngines = searchEngines => { this.set('searchEngines_', searchEngines.defaults); - this.requestHotwordInfoUpdate_(); }; this.browserProxy_.getSearchEnginesList().then(updateSearchEngines); cr.addWebUIListener('search-engines-changed', updateSearchEngines); - // Hotword (OK Google) listener - cr.addWebUIListener( - 'hotword-info-update', this.hotwordInfoUpdate_.bind(this)); - this.focusConfig_ = new Map(); if (settings.routes.SEARCH_ENGINES) { this.focusConfig_.set( @@ -139,68 +122,6 @@ Polymer({ }, // </if> - /** - * @param {!Event} event - * @private - */ - onHotwordSearchEnableChange_: function(event) { - // Do not set the pref directly, allow Chrome to run the setup app instead. - this.browserProxy_.setHotwordSearchEnabled( - !!this.hotwordSearchEnablePref_.value); - }, - - /** @private */ - requestHotwordInfoUpdate_: function() { - this.browserProxy_.getHotwordInfo().then(hotwordInfo => { - this.hotwordInfoUpdate_(hotwordInfo); - }); - }, - - /** - * @param {!SearchPageHotwordInfo} hotwordInfo - * @private - */ - hotwordInfoUpdate_: function(hotwordInfo) { - this.hotwordInfo_ = hotwordInfo; - this.hotwordSearchEnablePref_ = { - key: 'unused', // required for PrefObject - type: chrome.settingsPrivate.PrefType.BOOLEAN, - value: this.hotwordInfo_.enabled, - }; - }, - - /** - * @return {string} - * @private - */ - getHotwordSearchEnableSubLabel_: function() { - return this.i18n( - this.hotwordInfo_.alwaysOn ? 'searchOkGoogleSubtextAlwaysOn' : - 'searchOkGoogleSubtextNoHardware'); - }, - - /** - * @return {boolean} - * @private - */ - getShowHotwordSearchRetrain_: function() { - return this.hotwordInfo_.enabled && this.hotwordInfo_.alwaysOn; - }, - - /** - * @return {boolean} True if the pref is enabled but hotword is not. - * @private - */ - getShowHotwordError_: function() { - return this.hotwordInfo_.enabled && !!this.hotwordInfo_.errorMessage; - }, - - /** @private */ - onRetrainTap_: function() { - // Re-enable hotword search enable; this will trigger the retrain UI. - this.browserProxy_.setHotwordSearchEnabled(this.hotwordInfo_.enabled); - }, - // <if expr="chromeos"> /** * @param {boolean} toggleValue diff --git a/chromium/chrome/browser/resources/settings/search_settings.js b/chromium/chrome/browser/resources/settings/search_settings.js index b05aa1106f4..0b89de713a7 100644 --- a/chromium/chrome/browser/resources/settings/search_settings.js +++ b/chromium/chrome/browser/resources/settings/search_settings.js @@ -517,7 +517,7 @@ cr.define('settings', function() { // problematic for regular expressions. var searchText = this.rawQuery_.trim().replace(SANITIZE_REGEX, '\\$&'); if (searchText.length > 0) - regExp = new RegExp('(' + searchText + ')', 'i'); + regExp = new RegExp(`(${searchText})`, 'i'); return regExp; } diff --git a/chromium/chrome/browser/resources/settings/settings_page/settings_section.html b/chromium/chrome/browser/resources/settings/settings_page/settings_section.html index 17101c8f335..644879a6d93 100644 --- a/chromium/chrome/browser/resources/settings/settings_page/settings_section.html +++ b/chromium/chrome/browser/resources/settings/settings_page/settings_section.html @@ -20,9 +20,7 @@ } #header .title { - color: var(--paper-grey-700); - font-size: 100%; - font-weight: 500; + @apply(--cr-section-text); margin-bottom: 0; margin-top: var(--settings-page-vertical-margin); } diff --git a/chromium/chrome/browser/resources/settings/settings_resources.grd b/chromium/chrome/browser/resources/settings/settings_resources.grd index 93c5edf1a72..f5cc6960361 100644 --- a/chromium/chrome/browser/resources/settings/settings_resources.grd +++ b/chromium/chrome/browser/resources/settings/settings_resources.grd @@ -681,6 +681,12 @@ <structure name="IDR_SETTINGS_PASSWORD_EDIT_DIALOG_JS" file="passwords_and_forms_page/password_edit_dialog.js" type="chrome_html" /> + <structure name="IDR_SETTINGS_PASSWORDS_EXPORT_DIALOG_HTML" + file="passwords_and_forms_page/passwords_export_dialog.html" + type="chrome_html" /> + <structure name="IDR_SETTINGS_PASSWORDS_EXPORT_DIALOG_JS" + file="passwords_and_forms_page/passwords_export_dialog.js" + type="chrome_html" /> <structure name="IDR_SETTINGS_PEOPLE_PAGE_HTML" file="people_page/people_page.html" type="chrome_html" @@ -813,6 +819,14 @@ file="printing_page/cups_add_printer_dialog_util.js" type="chrome_html" /> </if> + <if expr="not chromeos"> + <structure name="IDR_SETTINGS_PRINTING_BROWSER_PROXY_HTML" + file="printing_page/printing_browser_proxy.html" + type="chrome_html" /> + <structure name="IDR_SETTINGS_PRINTING_BROWSER_PROXY_JS" + file="printing_page/printing_browser_proxy.js" + type="chrome_html" /> + </if> <structure name="IDR_SETTINGS_CLOUD_PRINTING_PAGE_HTML" file="printing_page/cloud_printers.html" type="chrome_html" /> @@ -856,9 +870,11 @@ type="chrome_html" /> <structure name="IDR_SETTINGS_PROTOCOL_HANDLERS_HTML" file="site_settings/protocol_handlers.html" + preprocess="true" type="chrome_html" /> <structure name="IDR_SETTINGS_PROTOCOL_HANDLERS_JS" file="site_settings/protocol_handlers.js" + preprocess="true" type="chrome_html" /> <structure name="IDR_SETTINGS_ROUTE_HTML" file="route.html" @@ -909,6 +925,7 @@ type="chrome_html" /> <structure name="IDR_SETTINGS_SITE_SETTINGS_PREFS_BROWSER_PROXY_JS" file="site_settings/site_settings_prefs_browser_proxy.js" + preprocess="true" type="chrome_html" /> <structure name="IDR_SETTINGS_SITE_DETAILS_HTML" file="site_settings/site_details.html" @@ -1105,6 +1122,24 @@ <structure name="IDR_SETTINGS_DATE_TIME_PAGE_JS" file="date_time_page/date_time_page.js" type="chrome_html" /> + <structure name="IDR_SETTINGS_DATE_TIME_TYPES_HTML" + file="date_time_page/date_time_types.html" + type="chrome_html" /> + <structure name="IDR_SETTINGS_DATE_TIME_TYPES_JS" + file="date_time_page/date_time_types.js" + type="chrome_html" /> + <structure name="IDR_SETTINGS_TIMEZONE_SELECTOR_HTML" + file="date_time_page/timezone_selector.html" + type="chrome_html" /> + <structure name="IDR_SETTINGS_TIMEZONE_SELECTOR_JS" + file="date_time_page/timezone_selector.js" + type="chrome_html" /> + <structure name="IDR_SETTINGS_TIMEZONE_SUBPAGE_HTML" + file="date_time_page/timezone_subpage.html" + type="chrome_html" /> + <structure name="IDR_SETTINGS_TIMEZONE_SUBPAGE_JS" + file="date_time_page/timezone_subpage.js" + type="chrome_html" /> <structure name="IDR_SETTINGS_INTERNET_CONFIG_HTML" file="internet_page/internet_config.html" type="chrome_html" /> @@ -1123,6 +1158,12 @@ <structure name="IDR_SETTINGS_INTERNET_KNOWN_NETWORKS_PAGE_JS" file="internet_page/internet_known_networks_page.js" type="chrome_html" /> + <structure name="IDR_SETTINGS_INTERNET_PAGE_BROWSER_PROXY_HTML" + file="internet_page/internet_page_browser_proxy.html" + type="chrome_html" /> + <structure name="IDR_SETTINGS_INTERNET_PAGE_BROWSER_PROXY_JS" + file="internet_page/internet_page_browser_proxy.js" + type="chrome_html" /> <structure name="IDR_SETTINGS_INTERNET_PAGE_HTML" file="internet_page/internet_page.html" type="chrome_html" /> @@ -1150,12 +1191,6 @@ <structure name="IDR_SETTINGS_NETWORK_PROXY_SECTION_JS" file="internet_page/network_proxy_section.js" type="chrome_html" /> - <structure name="IDR_SETTINGS_NETWORK_SIMINFO_HTML" - file="internet_page/network_siminfo.html" - type="chrome_html" /> - <structure name="IDR_SETTINGS_NETWORK_SIMINFO_JS" - file="internet_page/network_siminfo.js" - type="chrome_html" /> <structure name="IDR_SETTINGS_NETWORK_SUMMARY_HTML" file="internet_page/network_summary.html" type="chrome_html" /> diff --git a/chromium/chrome/browser/resources/settings/settings_ui/settings_ui.html b/chromium/chrome/browser/resources/settings/settings_ui/settings_ui.html index 0b217e7ada0..7aca114c1af 100644 --- a/chromium/chrome/browser/resources/settings/settings_ui/settings_ui.html +++ b/chromium/chrome/browser/resources/settings/settings_ui/settings_ui.html @@ -39,7 +39,6 @@ cr-toolbar { @apply(--layout-center); - --cr-toolbar-field-width: var(--settings-card-max-width); --iron-icon-fill-color: white; background-color: var(--google-blue-700); color: white; diff --git a/chromium/chrome/browser/resources/settings/site_settings/category_default_setting.js b/chromium/chrome/browser/resources/settings/site_settings/category_default_setting.js index 08f2e59a2fa..a73e3303987 100644 --- a/chromium/chrome/browser/resources/settings/site_settings/category_default_setting.js +++ b/chromium/chrome/browser/resources/settings/site_settings/category_default_setting.js @@ -108,6 +108,7 @@ Polymer({ break; case settings.ContentSettingsTypes.AUTOMATIC_DOWNLOADS: case settings.ContentSettingsTypes.CAMERA: + case settings.ContentSettingsTypes.CLIPBOARD: case settings.ContentSettingsTypes.GEOLOCATION: case settings.ContentSettingsTypes.MIC: case settings.ContentSettingsTypes.NOTIFICATIONS: diff --git a/chromium/chrome/browser/resources/settings/site_settings/compiled_resources2.gyp b/chromium/chrome/browser/resources/settings/site_settings/compiled_resources2.gyp index fbc1a37e421..952595bdf69 100644 --- a/chromium/chrome/browser/resources/settings/site_settings/compiled_resources2.gyp +++ b/chromium/chrome/browser/resources/settings/site_settings/compiled_resources2.gyp @@ -88,6 +88,7 @@ '<(DEPTH)/ui/webui/resources/cr_elements/cr_action_menu/compiled_resources2.gyp:cr_action_menu', '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:web_ui_listener_behavior', 'site_settings_behavior', + '../android_apps_page/compiled_resources2.gyp:android_apps_browser_proxy', ], 'includes': ['../../../../../third_party/closure_compiler/compile_js2.gypi'], }, diff --git a/chromium/chrome/browser/resources/settings/site_settings/constants.js b/chromium/chrome/browser/resources/settings/site_settings/constants.js index 44fbc1546d1..468d0b9fff3 100644 --- a/chromium/chrome/browser/resources/settings/site_settings/constants.js +++ b/chromium/chrome/browser/resources/settings/site_settings/constants.js @@ -32,6 +32,7 @@ settings.ContentSettingsTypes = { ZOOM_LEVELS: 'zoom-levels', PROTECTED_CONTENT: 'protectedContent', ADS: 'ads', + CLIPBOARD: 'clipboard', }; /** @@ -56,6 +57,8 @@ settings.ContentSetting = { * @enum {string} */ settings.SiteSettingSource = { + ADS_BLOCKED: 'ads-blocked', + ADS_FILTER_BLACKLIST: 'ads-filter-blacklist', DEFAULT: 'default', // This source is for the Protected Media Identifier / Protected Content // content setting only, which is only available on ChromeOS. diff --git a/chromium/chrome/browser/resources/settings/site_settings/cookie_info.js b/chromium/chrome/browser/resources/settings/site_settings/cookie_info.js index 43056bb906f..c41527432e4 100644 --- a/chromium/chrome/browser/resources/settings/site_settings/cookie_info.js +++ b/chromium/chrome/browser/resources/settings/site_settings/cookie_info.js @@ -61,6 +61,8 @@ var CookieDataForDisplay; ['origin', 'serviceWorkerOrigin'], ['size', 'serviceWorkerSize'], ['scopes', 'serviceWorkerScopes'] ], + 'shared_worker': + [['worker', 'sharedWorkerWorker'], ['name', 'sharedWorkerName']], 'cache_storage': [ ['origin', 'cacheStorageOrigin'], ['size', 'cacheStorageSize'], ['modified', 'cacheStorageLastModified'] diff --git a/chromium/chrome/browser/resources/settings/site_settings/local_data_browser_proxy.js b/chromium/chrome/browser/resources/settings/site_settings/local_data_browser_proxy.js index 28d4a1dccce..224b4ba722d 100644 --- a/chromium/chrome/browser/resources/settings/site_settings/local_data_browser_proxy.js +++ b/chromium/chrome/browser/resources/settings/site_settings/local_data_browser_proxy.js @@ -28,7 +28,6 @@ var LocalDataItem; * TODO(dschuyler): add |filter| and |order|. * @typedef {{ * items: !Array<!LocalDataItem>, - * start: number, * total: number, * }} */ @@ -39,13 +38,9 @@ cr.define('settings', function() { class LocalDataBrowserProxy { /** * @param {string} filter Search filter (use "" for none). - * @param {number} begin Which element to start with. (Similar to 'offset' - * in SQL). The first item is at 0. - * @param {number} count How many list elements are displayed. (Similar to - * 'limit' in SQL). Pass -1 to get all remaining items. * @return {!Promise<!LocalDataList>} */ - getDisplayList(filter, begin, count) {} + getDisplayList(filter) {} /** * Removes all local data (local storage, cookies, etc.). @@ -93,9 +88,8 @@ cr.define('settings', function() { */ class LocalDataBrowserProxyImpl { /** @override */ - getDisplayList(filter, begin, count) { - return cr.sendWithPromise( - 'localData.getDisplayList', filter, begin, count); + getDisplayList(filter) { + return cr.sendWithPromise('localData.getDisplayList', filter); } /** @override */ diff --git a/chromium/chrome/browser/resources/settings/site_settings/protocol_handlers.html b/chromium/chrome/browser/resources/settings/site_settings/protocol_handlers.html index 04de6344da3..a37356e6dda 100644 --- a/chromium/chrome/browser/resources/settings/site_settings/protocol_handlers.html +++ b/chromium/chrome/browser/resources/settings/site_settings/protocol_handlers.html @@ -1,10 +1,10 @@ <link rel="import" href="chrome://resources/html/polymer.html"> -<link rel="import" href="chrome://resources/cr_elements/icons.html"> -<link rel="import" href="chrome://resources/polymer/v1_0/paper-icon-button/paper-icon-button-light.html"> -<link rel="import" href="chrome://resources/polymer/v1_0/paper-toggle-button/paper-toggle-button.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_toggle/cr_toggle.html"> +<link rel="import" href="chrome://resources/cr_elements/icons.html"> <link rel="import" href="chrome://resources/html/web_ui_listener_behavior.html"> +<link rel="import" href="chrome://resources/polymer/v1_0/paper-icon-button/paper-icon-button-light.html"> <link rel="import" href="../i18n_setup.html"> <link rel="import" href="../settings_shared_css.html"> <link rel="import" href="site_settings_behavior.html"> @@ -27,9 +27,9 @@ <div id="categoryLabel" class="start"> [[computeHandlersDescription_(categoryEnabled)]] </div> - <paper-toggle-button id="toggle" checked="{{categoryEnabled}}" + <cr-toggle id="toggle" checked="{{categoryEnabled}}" on-change="onToggleChange_" aria-labelledby="categoryLabel"> - </paper-toggle-button> + </cr-toggle> </div> <template is="dom-repeat" items="[[protocols]]" as="protocol"> @@ -67,6 +67,18 @@ $i18n{handlerRemove} </button> </dialog> + +<if expr="chromeos"> + <template is="dom-if" if="[[settingsAppAvailable_]]"> + <div class="settings-box first" + on-tap="onManageAndroidAppsTap_" actionable> + <div class="start"> + <div>$i18n{androidAppsManageAppLinks}</div> + </div> + <button class="icon-external" is="paper-icon-button-light"></button> + </div> + </template> +</if> </template> <script src="protocol_handlers.js"></script> </dom-module> diff --git a/chromium/chrome/browser/resources/settings/site_settings/protocol_handlers.js b/chromium/chrome/browser/resources/settings/site_settings/protocol_handlers.js index 871659b8eb8..7da371a9afe 100644 --- a/chromium/chrome/browser/resources/settings/site_settings/protocol_handlers.js +++ b/chromium/chrome/browser/resources/settings/site_settings/protocol_handlers.js @@ -59,6 +59,14 @@ Polymer({ /* Labels for the toggle on/off positions. */ toggleOffLabel: String, toggleOnLabel: String, + + // <if expr="chromeos"> + /** @private */ + settingsAppAvailable_: { + type: Boolean, + value: false, + }, + // </if> }, /** @override */ @@ -73,6 +81,29 @@ Polymer({ this.browserProxy.observeProtocolHandlers(); }, + // <if expr="chromeos"> + /** @override */ + attached: function() { + if (settings.AndroidAppsBrowserProxyImpl) { + cr.addWebUIListener( + 'android-apps-info-update', this.androidAppsInfoUpdate_.bind(this)); + settings.AndroidAppsBrowserProxyImpl.getInstance() + .requestAndroidAppsInfo(); + } + }, + // </if> + + // <if expr="chromeos"> + /** + * Receives updates on whether or not ARC settings app is available. + * @param {AndroidAppsInfo} info + * @private + */ + androidAppsInfoUpdate_: function(info) { + this.settingsAppAvailable_ = info.settingsAppAvailable; + }, + // </if> + /** * Obtains the description for the main toggle. * @return {string} The description to use. @@ -177,5 +208,15 @@ Polymer({ .showAt( /** @type {!Element} */ ( Polymer.dom(/** @type {!Event} */ (event)).localTarget)); - } + }, + + // <if expr="chromeos"> + /** + * Opens an activity to handle App links (preferred apps). + * @private + */ + onManageAndroidAppsTap_: function() { + this.browserProxy.showAndroidManageAppLinks(); + }, + // </if> }); diff --git a/chromium/chrome/browser/resources/settings/site_settings/site_data.html b/chromium/chrome/browser/resources/settings/site_settings/site_data.html index eb7d2da4117..72c73a87961 100644 --- a/chromium/chrome/browser/resources/settings/site_settings/site_data.html +++ b/chromium/chrome/browser/resources/settings/site_settings/site_data.html @@ -9,6 +9,7 @@ <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-icon-button/paper-icon-button-light.html"> +<link rel="import" href="chrome://resources/polymer/v1_0/paper-spinner/paper-spinner-lite.html"> <link rel="import" href="../global_scroll_target_behavior.html"> <link rel="import" href="../settings_page/settings_subpage_search.html"> <link rel="import" href="../settings_shared_css.html"> @@ -22,6 +23,16 @@ border-top: none; } + paper-spinner-lite { + @apply(--cr-icon-height-width); + opacity: 0; + transition-delay: 1s; + } + + paper-spinner-lite[active] { + opacity: 1; + } + #removeShowingSites { -webkit-margin-start: auto; } @@ -31,7 +42,9 @@ } </style> <div class="settings-box continuation"> - <paper-button class="secondary-button" id="removeShowingSites" + <paper-spinner-lite active="[[isLoading_]]"></paper-spinner-lite> + <paper-button class="secondary-button" + disabled$="[[isLoading_]]" id="removeShowingSites" on-tap="onRemoveShowingSitesTap_" hidden$="[[!sites.length]]"> [[computeRemoveLabel_(filter)]] </paper-button> diff --git a/chromium/chrome/browser/resources/settings/site_settings/site_data.js b/chromium/chrome/browser/resources/settings/site_settings/site_data.js index 097465dbc0a..e0e85e99d8b 100644 --- a/chromium/chrome/browser/resources/settings/site_settings/site_data.js +++ b/chromium/chrome/browser/resources/settings/site_settings/site_data.js @@ -60,6 +60,8 @@ Polymer({ observer: 'focusConfigChanged_', }, + isLoading_: Boolean, + /** @type {!Array<!LocalDataItem>} */ sites: { type: Array, @@ -99,6 +101,7 @@ Polymer({ settings.GlobalScrollTargetBehaviorImpl.currentRouteChanged.call( this, currentRoute); if (currentRoute == settings.routes.SITE_SETTINGS_SITE_DATA) { + this.isLoading_ = true; this.browserProxy_.reloadCookies().then(this.updateSiteList_.bind(this)); } }, @@ -138,12 +141,12 @@ Polymer({ * @private */ updateSiteList_: function() { - this.browserProxy_ - .getDisplayList(this.filter, 0 /* start */, -1 /* count */) - .then((listInfo) => { - this.sites = listInfo.items; - this.fire('site-data-list-complete'); - }); + this.isLoading_ = true; + this.browserProxy_.getDisplayList(this.filter).then((listInfo) => { + this.sites = listInfo.items; + this.isLoading_ = false; + this.fire('site-data-list-complete'); + }); }, /** diff --git a/chromium/chrome/browser/resources/settings/site_settings/site_data_details_subpage.js b/chromium/chrome/browser/resources/settings/site_settings/site_data_details_subpage.js index 8e8b802b64a..b749a1f87d4 100644 --- a/chromium/chrome/browser/resources/settings/site_settings/site_data_details_subpage.js +++ b/chromium/chrome/browser/resources/settings/site_settings/site_data_details_subpage.js @@ -15,6 +15,7 @@ var categoryLabels = { indexed_db: loadTimeData.getString('cookieDatabaseStorage'), local_storage: loadTimeData.getString('cookieLocalStorage'), service_worker: loadTimeData.getString('cookieServiceWorker'), + shared_worker: loadTimeData.getString('cookieSharedWorker'), media_license: loadTimeData.getString('cookieMediaLicense'), }; diff --git a/chromium/chrome/browser/resources/settings/site_settings/site_details.html b/chromium/chrome/browser/resources/settings/site_settings/site_details.html index 4f903171bb8..9a10a9ebf6b 100644 --- a/chromium/chrome/browser/resources/settings/site_settings/site_details.html +++ b/chromium/chrome/browser/resources/settings/site_settings/site_details.html @@ -107,6 +107,12 @@ icon="cr:open-in-new" id="popups" label="$i18n{siteSettingsPopups}"> </site-details-permission> <site-details-permission + category="{{ContentSettingsTypes.ADS}}" + icon="settings:ads" id="ads" + label="$i18n{siteSettingsAds}" + hidden$="[[!enableSafeBrowsingSubresourceFilter_]]"> + </site-details-permission> + <site-details-permission category="{{ContentSettingsTypes.BACKGROUND_SYNC}}" icon="settings:sync" id="backgroundSync" label="$i18n{siteSettingsBackgroundSync}"> @@ -126,6 +132,12 @@ id="midiDevices" label="$i18n{siteSettingsMidiDevices}"> </site-details-permission> <site-details-permission + category="{{ContentSettingsTypes.CLIPBOARD}}" + icon="settings:clipboard" id="clipboard" + label="$i18n{siteSettingsClipboard}" + hidden$="[[!enableClipboardContentSetting_]]"> + </site-details-permission> + <site-details-permission category="{{ContentSettingsTypes.UNSANDBOXED_PLUGINS}}" icon="cr:extension" id="unsandboxedPlugins" label="$i18n{siteSettingsUnsandboxedPlugins}"> diff --git a/chromium/chrome/browser/resources/settings/site_settings/site_details.js b/chromium/chrome/browser/resources/settings/site_settings/site_details.js index cc2e9aec5c9..b7fe492082f 100644 --- a/chromium/chrome/browser/resources/settings/site_settings/site_details.js +++ b/chromium/chrome/browser/resources/settings/site_settings/site_details.js @@ -51,6 +51,14 @@ Polymer({ }, /** @private */ + enableSafeBrowsingSubresourceFilter_: { + type: Boolean, + value: function() { + return loadTimeData.getBoolean('enableSafeBrowsingSubresourceFilter'); + }, + }, + + /** @private */ enableSoundContentSetting_: { type: Boolean, value: function() { @@ -58,6 +66,14 @@ Polymer({ }, }, + /** @private */ + enableClipboardContentSetting_: { + type: Boolean, + value: function() { + return loadTimeData.getBoolean('enableClipboardContentSetting'); + }, + }, + /** * The type of storage for the origin. * @private @@ -125,8 +141,9 @@ Polymer({ */ onPermissionChanged_: function(category, origin, embeddingOrigin) { if (this.origin === undefined || this.origin == '' || - origin === undefined || origin == '') + origin === undefined || origin == '') { return; + } if (!this.getCategoryList_().includes(category)) return; diff --git a/chromium/chrome/browser/resources/settings/site_settings/site_details_permission.html b/chromium/chrome/browser/resources/settings/site_settings/site_details_permission.html index c55f5716acf..fdf7d369701 100644 --- a/chromium/chrome/browser/resources/settings/site_settings/site_details_permission.html +++ b/chromium/chrome/browser/resources/settings/site_settings/site_details_permission.html @@ -15,7 +15,8 @@ <style include="settings-shared md-select"></style> <div id="details"> <div id="permissionItem" - class$="list-item [[permissionSourceStringClass_(site.source)]]"> + class$="list-item [[permissionInfoStringClass_(site.source, category, + site.setting)]]"> <div> <iron-icon icon="[[icon]]"> </iron-icon> @@ -23,9 +24,14 @@ <div class="middle" id="permissionHeader"> [[label]] <div class="secondary" - hidden$="[[!hasPermissionSourceString_(site.source)]]" - inner-h-t-m-l="[[permissionSourceString_( + hidden$="[[!hasPermissionInfoString_(site.source, category, + site.setting)]]" + inner-h-t-m-l="[[permissionInfoString_( site.source, + category, + site.setting, + '$i18nPolymer{siteSettingsSourceAdsBlacklist}', + '$i18nPolymer{siteSettingsAdsBlockSingular}', '$i18nPolymer{siteSettingsSourceEmbargo}', '$i18nPolymer{siteSettingsSourceInsecureOrigin}', '$i18nPolymer{siteSettingsSourceKillSwitch}', @@ -41,8 +47,10 @@ <select id="permission" class="md-select" aria-labelledby="permissionHeader" on-change="onPermissionSelectionChange_" - disabled$="[[!isPermissionUserControlled_(site.source)]]"> - <option id="default" value$="[[ContentSetting.DEFAULT]]"> + disabled$="[[!isPermissionUserControlled_(site.source, category, + site.setting)]]"> + <option id="default" value$="[[ContentSetting.DEFAULT]]" + hidden$="[[isAdsCategory_(category)]]"> [[defaultSettingString_( defaultSetting_, '$i18nPolymer{siteSettingsActionAskDefault}', diff --git a/chromium/chrome/browser/resources/settings/site_settings/site_details_permission.js b/chromium/chrome/browser/resources/settings/site_settings/site_details_permission.js index 27c34c2dce2..e01a47a8478 100644 --- a/chromium/chrome/browser/resources/settings/site_settings/site_details_permission.js +++ b/chromium/chrome/browser/resources/settings/site_settings/site_details_permission.js @@ -118,38 +118,52 @@ Polymer({ }, /** - * Returns true if there's a string to display that describes the source of - * this permission's setting. Currently, this only gets called when + * Returns true if there's a string to display that provides more information + * about this permission's setting. Currently, this only gets called when * |this.site| is updated. * @param {!settings.SiteSettingSource} source The source of the permission. + * @param {!settings.ContentSettingsTypes} category The permission type. + * @param {!settings.ContentSetting} setting The permission setting. + * @return {boolean} Whether the permission will have a source string to + * display. * @private */ - hasPermissionSourceString_: function(source) { + hasPermissionInfoString_: function(source, category, setting) { return ( source != settings.SiteSettingSource.DEFAULT && source != settings.SiteSettingSource.PREFERENCE); }, /** - * Checks if there's a permission source string to display, and returns the + * Checks if there's a additional information to display, and returns the * class name to apply to permissions if so. + * @param {!settings.SiteSettingSource} source The source of the permission. + * @param {!settings.ContentSettingsTypes} category The permission type. + * @param {!settings.ContentSetting} setting The permission setting. * @return {string} CSS class applied when there is an additional description * string. * @private */ - permissionSourceStringClass_: function(source) { - return this.hasPermissionSourceString_(source) ? 'two-line' : ''; + permissionInfoStringClass_: function(source, category, setting) { + return this.hasPermissionInfoString_(source, category, setting) ? + 'two-line' : + ''; }, /** - * Returns true if this permission's source is controlled by the user. + * Returns true if this permission can be controlled by the user. + * @param {!settings.SiteSettingSource} source The source of the permission. + * @param {!settings.ContentSettingsTypes} category The permission type. + * @param {!settings.ContentSetting} setting The permission setting. * @return {boolean} * @private */ - isPermissionUserControlled_: function(source) { - // Users are able override embargo. - return !this.hasPermissionSourceString_(source) || - source == settings.SiteSettingSource.EMBARGO; + isPermissionUserControlled_: function(source, category, setting) { + // Users are able override embargo and ads blacklisting. + return !this.hasPermissionInfoString_(source, category, setting) || + source == settings.SiteSettingSource.EMBARGO || + source == settings.SiteSettingSource.ADS_FILTER_BLACKLIST || + source == settings.SiteSettingSource.ADS_BLOCKED; }, /** @@ -173,9 +187,25 @@ Polymer({ }, /** - * Updates the string used to describe the source of this permission setting. + * Returns true if this permission is the Ads permission. + * @param {!settings.ContentSettingsTypes} category The permission type. + * @return {boolean} + * @private + */ + isAdsCategory_: function(category) { + return category == settings.ContentSettingsTypes.ADS; + }, + + /** + * Updates the information string for the current permission. * Currently, this only gets called when |this.site| is updated. * @param {!settings.SiteSettingSource} source The source of the permission. + * @param {!settings.ContentSettingsTypes} category The permission type. + * @param {!settings.ContentSetting} setting The permission setting. + * @param {!string} adsBlacklistString The string to show if the site is + * blacklisted for showing bad ads. + * @param {!string} adsBlockString The string to show if ads are blocked, but + * the site is not blacklisted. * @param {!string} embargoString * @param {!string} insecureOriginString * @param {!string} killSwitchString @@ -187,8 +217,9 @@ Polymer({ * @param {!string} policyAskString * @private */ - permissionSourceString_: function( - source, embargoString, insecureOriginString, killSwitchString, + permissionInfoString_: function( + source, category, setting, adsBlacklistString, adsBlockString, + embargoString, insecureOriginString, killSwitchString, extensionAllowString, extensionBlockString, extensionAskString, policyAllowString, policyBlockString, policyAskString) { @@ -204,12 +235,25 @@ Polymer({ policyStrings[settings.ContentSetting.BLOCK] = policyBlockString; policyStrings[settings.ContentSetting.ASK] = policyAskString; - if (source == settings.SiteSettingSource.DRM_DISABLED) { + if (source == settings.SiteSettingSource.ADS_FILTER_BLACKLIST) { + assert( + settings.ContentSettingsTypes.ADS == category, + 'The ads filter blacklist only applies to Ads.'); + return adsBlacklistString; + } else if (source == settings.SiteSettingSource.ADS_BLOCKED) { assert( - settings.ContentSetting.BLOCK == this.site.setting, + settings.ContentSettingsTypes.ADS == category, + 'The Ads user-blocked source only applies to Ads.'); + assert( + settings.ContentSetting.ALLOW != setting, + 'The Ads setting must be blocked for this source.'); + return adsBlockString; + } else if (source == settings.SiteSettingSource.DRM_DISABLED) { + assert( + settings.ContentSetting.BLOCK == setting, 'If DRM is disabled, Protected Content must be blocked.'); assert( - settings.ContentSettingsTypes.PROTECTED_CONTENT == this.category, + settings.ContentSettingsTypes.PROTECTED_CONTENT == category, 'The DRM disabled source only applies to Protected Content.'); return this.i18nAdvanced('siteSettingsSourceDrmDisabled', { substitutions: @@ -217,29 +261,28 @@ Polymer({ }); } else if (source == settings.SiteSettingSource.EMBARGO) { assert( - settings.ContentSetting.BLOCK == this.site.setting, + settings.ContentSetting.BLOCK == setting, 'Embargo is only used to block permissions.'); return embargoString; } else if (source == settings.SiteSettingSource.EXTENSION) { - return extensionStrings[this.site.setting]; + return extensionStrings[setting]; } else if (source == settings.SiteSettingSource.INSECURE_ORIGIN) { assert( - settings.ContentSetting.BLOCK == this.site.setting, + settings.ContentSetting.BLOCK == setting, 'Permissions can only be blocked due to insecure origins.'); return insecureOriginString; } else if (source == settings.SiteSettingSource.KILL_SWITCH) { assert( - settings.ContentSetting.BLOCK == this.site.setting, + settings.ContentSetting.BLOCK == setting, 'The permissions kill switch can only be used to block permissions.'); return killSwitchString; } else if (source == settings.SiteSettingSource.POLICY) { - return policyStrings[this.site.setting]; + return policyStrings[setting]; } else if ( source == settings.SiteSettingSource.DEFAULT || source == settings.SiteSettingSource.PREFERENCE) { return ''; } - assertNotReached( - `No string for ${this.category} setting source '${source}'`); + assertNotReached(`No string for ${category} setting source '${source}'`); }, }); diff --git a/chromium/chrome/browser/resources/settings/site_settings/site_settings_prefs_browser_proxy.js b/chromium/chrome/browser/resources/settings/site_settings/site_settings_prefs_browser_proxy.js index 6ab9c0a38a5..e19f90cfec8 100644 --- a/chromium/chrome/browser/resources/settings/site_settings/site_settings_prefs_browser_proxy.js +++ b/chromium/chrome/browser/resources/settings/site_settings/site_settings_prefs_browser_proxy.js @@ -266,6 +266,14 @@ cr.define('settings', function() { * @param {string} host The host to remove zoom levels for. */ removeZoomLevel(host) {} + + // <if expr="chromeos"> + /** + * Links to com.android.settings.Settings$ManageDomainUrlsActivity on ARC + * side, this is to manage app preferences. + */ + showAndroidManageAppLinks() {} + // </if> } /** @@ -386,6 +394,13 @@ cr.define('settings', function() { removeZoomLevel(host) { chrome.send('removeZoomLevel', [host]); } + + // <if expr="chromeos"> + /** @override */ + showAndroidManageAppLinks() { + chrome.send('showAndroidManageAppLinks'); + } + // </if> } // The singleton instance_ is replaced with a test version of this wrapper diff --git a/chromium/chrome/browser/resources/settings/site_settings/usb_devices.html b/chromium/chrome/browser/resources/settings/site_settings/usb_devices.html index 7388b9f6fd2..0d49492c635 100644 --- a/chromium/chrome/browser/resources/settings/site_settings/usb_devices.html +++ b/chromium/chrome/browser/resources/settings/site_settings/usb_devices.html @@ -21,7 +21,7 @@ } </style> - <div class="settings-box" hidden$="[[hasDevices_(devices_)]]"> + <div class="settings-box first" hidden$="[[hasDevices_(devices_)]]"> $i18n{noUsbDevicesFound} </div> <template is="dom-repeat" items="[[devices_]]"> diff --git a/chromium/chrome/browser/resources/settings/site_settings_page/site_settings_page.html b/chromium/chrome/browser/resources/settings/site_settings_page/site_settings_page.html index b0d1207994a..c523b2f8536 100644 --- a/chromium/chrome/browser/resources/settings/site_settings_page/site_settings_page.html +++ b/chromium/chrome/browser/resources/settings/site_settings_page/site_settings_page.html @@ -234,8 +234,8 @@ <div class="secondary" id="soundSecondary"> [[defaultSettingLabel_( default_.sound, - '$i18nPolymer{siteSettingsAllowed}', - '$i18nPolymer{siteSettingsBlocked}')]] + '$i18nPolymer{siteSettingsSoundAllow}', + '$i18nPolymer{siteSettingsSoundBlock}')]] </div> </div> <button class="subpage-arrow" is="paper-icon-button-light" @@ -317,6 +317,26 @@ aria-label="$i18n{siteSettingsMidiDevices}" aria-describedby="midiDevicesSecondary"></button> </div> + <template is="dom-if" if="[[enableClipboardContentSetting_]]"> + <div id="clipboard" class="settings-box two-line" + category$="[[ContentSettingsTypes.CLIPBOARD]]" + data-route="SITE_SETTINGS_CLIPBOARD" on-tap="onTapNavigate_" + actionable> + <iron-icon icon="settings:clipboard"></iron-icon> + <div class="middle"> + $i18n{siteSettingsClipboard} + <div class="secondary" id="clipboardSecondary"> + [[defaultSettingLabel_( + default_.clipboard, + '$i18nPolymer{siteSettingsAskBeforeAccessing}', + '$i18nPolymer{siteSettingsBlocked}')]] + </div> + </div> + <button class="subpage-arrow" is="paper-icon-button-light" + aria-label="$i18n{siteSettingsClipboard}" + aria-describedby="clipboardSecondary"></button> + </div> + </template> <div id="zoom-levels" class="settings-box" category$="[[ContentSettingsTypes.ZOOM_LEVELS]]" data-route="SITE_SETTINGS_ZOOM_LEVELS" on-tap="onTapNavigate_" diff --git a/chromium/chrome/browser/resources/settings/site_settings_page/site_settings_page.js b/chromium/chrome/browser/resources/settings/site_settings_page/site_settings_page.js index e3354d023cb..cc72fa6d4fa 100644 --- a/chromium/chrome/browser/resources/settings/site_settings_page/site_settings_page.js +++ b/chromium/chrome/browser/resources/settings/site_settings_page/site_settings_page.js @@ -52,6 +52,14 @@ Polymer({ }, /** @private */ + enableClipboardContentSetting_: { + type: Boolean, + value: function() { + return loadTimeData.getBoolean('enableClipboardContentSetting'); + } + }, + + /** @private */ enableSoundContentSetting_: { type: Boolean, value: function() { @@ -96,6 +104,7 @@ Polymer({ [R.SITE_SETTINGS_USB_DEVICES, 'usb-devices'], [R.SITE_SETTINGS_PDF_DOCUMENTS, 'pdf-documents'], [R.SITE_SETTINGS_PROTECTED_CONTENT, 'protected-content'], + [R.SITE_SETTINGS_CLIPBOARD, "clipboard"], ].forEach(pair => { var route = pair[0]; var id = pair[1]; |