Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(113)

Side by Side Diff: chrome/browser/resources/settings/people_page/lock_screen.js

Issue 2787153002: MD Settings: Move easy unlock from people to lock screen. (Closed)
Patch Set: Added comment. Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * @fileoverview 6 * @fileoverview
7 * 'settings-lock-screen' allows the user to change how they unlock their 7 * 'settings-lock-screen' allows the user to change how they unlock their
8 * device. 8 * device.
9 * 9 *
10 * Example: 10 * Example:
11 * 11 *
12 * <settings-lock-screen 12 * <settings-lock-screen
13 * prefs="{{prefs}}"> 13 * prefs="{{prefs}}">
14 * </settings-lock-screen> 14 * </settings-lock-screen>
15 */ 15 */
16 16
17 Polymer({ 17 Polymer({
18 is: 'settings-lock-screen', 18 is: 'settings-lock-screen',
19 19
20 behaviors: [I18nBehavior, LockStateBehavior, settings.RouteObserverBehavior], 20 behaviors: [
21 I18nBehavior,
22 LockStateBehavior,
23 WebUIListenerBehavior,
24 settings.RouteObserverBehavior
25 ],
21 26
22 properties: { 27 properties: {
23 /** Preferences state. */ 28 /** Preferences state. */
24 prefs: { 29 prefs: {
25 type: Object 30 type: Object
26 }, 31 },
27 32
28 /** 33 /**
29 * setModes_ is a partially applied function that stores the previously 34 * setModes_ is a partially applied function that stores the previously
30 * entered password. It's defined only when the user has already entered a 35 * entered password. It's defined only when the user has already entered a
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 return loadTimeData.getBoolean('fingerprintUnlockEnabled'); 77 return loadTimeData.getBoolean('fingerprintUnlockEnabled');
73 }, 78 },
74 readOnly: true, 79 readOnly: true,
75 }, 80 },
76 81
77 /** @private */ 82 /** @private */
78 numFingerprints_: { 83 numFingerprints_: {
79 type: Number, 84 type: Number,
80 value: 0, 85 value: 0,
81 }, 86 },
87
88 /** @private {!settings.EasyUnlockBrowserProxy} */
89 easyUnlockBrowserProxy_: {
90 type: Object,
91 value: function() {
92 return settings.EasyUnlockBrowserProxyImpl.getInstance();
93 },
94 },
95
96 /**
97 * True if Easy Unlock is allowed on this machine.
98 */
99 easyUnlockAllowed_: {
100 type: Boolean,
101 value: function() {
102 return loadTimeData.getBoolean('easyUnlockAllowed');
103 },
104 readOnly: true,
105 },
106
107 /**
108 * True if Easy Unlock is enabled.
109 */
110 easyUnlockEnabled_: {
111 type: Boolean,
112 value: function() {
113 return loadTimeData.getBoolean('easyUnlockEnabled');
114 },
115 },
116
117 /**
118 * True if Easy Unlock's proximity detection feature is allowed.
119 */
120 easyUnlockProximityDetectionAllowed_: {
121 type: Boolean,
122 value: function() {
123 return loadTimeData.getBoolean('easyUnlockAllowed') &&
124 loadTimeData.getBoolean('easyUnlockProximityDetectionAllowed');
125 },
126 readOnly: true,
127 },
128
129 /** @private */
130 showEasyUnlockTurnOffDialog_: {
131 type: Boolean,
132 value: false,
133 },
82 }, 134 },
83 135
84 /** @private {?settings.FingerprintBrowserProxy} */ 136 /** @private {?settings.FingerprintBrowserProxy} */
85 browserProxy_: null, 137 fingerprintBrowserProxy_: null,
86 138
87 /** selectedUnlockType is defined in LockStateBehavior. */ 139 /** selectedUnlockType is defined in LockStateBehavior. */
88 observers: ['selectedUnlockTypeChanged_(selectedUnlockType)'], 140 observers: ['selectedUnlockTypeChanged_(selectedUnlockType)'],
89 141
90 /** @override */ 142 /** @override */
91 attached: function() { 143 attached: function() {
92 if (this.shouldAskForPassword_(settings.getCurrentRoute())) 144 if (this.shouldAskForPassword_(settings.getCurrentRoute()))
93 this.$.passwordPrompt.open(); 145 this.$.passwordPrompt.open();
94 this.browserProxy_ = settings.FingerprintBrowserProxyImpl.getInstance(); 146 this.fingerprintBrowserProxy_ =
147 settings.FingerprintBrowserProxyImpl.getInstance();
148
149 if (this.easyUnlockAllowed_) {
150 this.addWebUIListener(
151 'easy-unlock-enabled-status',
152 this.handleEasyUnlockEnabledStatusChanged_.bind(this));
153 this.easyUnlockBrowserProxy_.getEnabledStatus().then(
154 this.handleEasyUnlockEnabledStatusChanged_.bind(this));
155 }
95 }, 156 },
96 157
97 /** 158 /**
98 * Overridden from settings.RouteObserverBehavior. 159 * Overridden from settings.RouteObserverBehavior.
99 * @param {!settings.Route} newRoute 160 * @param {!settings.Route} newRoute
100 * @param {!settings.Route} oldRoute 161 * @param {!settings.Route} oldRoute
101 * @protected 162 * @protected
102 */ 163 */
103 currentRouteChanged: function(newRoute, oldRoute) { 164 currentRouteChanged: function(newRoute, oldRoute) {
104 if (newRoute == settings.Route.LOCK_SCREEN && 165 if (newRoute == settings.Route.LOCK_SCREEN &&
105 this.fingerprintUnlockEnabled_ && 166 this.fingerprintUnlockEnabled_ &&
106 this.browserProxy_) { 167 this.fingerprintBrowserProxy_) {
107 this.browserProxy_.getNumFingerprints().then( 168 this.fingerprintBrowserProxy_.getNumFingerprints().then(
108 function(numFingerprints) { 169 function(numFingerprints) {
109 this.numFingerprints_ = numFingerprints; 170 this.numFingerprints_ = numFingerprints;
110 }.bind(this)); 171 }.bind(this));
111 } 172 }
112 173
113 if (this.shouldAskForPassword_(newRoute)) { 174 if (this.shouldAskForPassword_(newRoute)) {
114 this.$.passwordPrompt.open(); 175 this.$.passwordPrompt.open();
115 } else if (newRoute != settings.Route.FINGERPRINT && 176 } else if (newRoute != settings.Route.FINGERPRINT &&
116 oldRoute != settings.Route.FINGERPRINT) { 177 oldRoute != settings.Route.FINGERPRINT) {
117 // If the user navigated away from the lock screen settings page they will 178 // If the user navigated away from the lock screen settings page they will
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 }, 260 },
200 261
201 /** 262 /**
202 * @param {!settings.Route} route 263 * @param {!settings.Route} route
203 * @return {boolean} Whether the password dialog should be shown. 264 * @return {boolean} Whether the password dialog should be shown.
204 * @private 265 * @private
205 */ 266 */
206 shouldAskForPassword_: function(route) { 267 shouldAskForPassword_: function(route) {
207 return route == settings.Route.LOCK_SCREEN && !this.setModes_; 268 return route == settings.Route.LOCK_SCREEN && !this.setModes_;
208 }, 269 },
270
271 /**
272 * Handler for when the Easy Unlock enabled status has changed.
273 * @private
274 */
275 handleEasyUnlockEnabledStatusChanged_: function(easyUnlockEnabled) {
276 this.easyUnlockEnabled_ = easyUnlockEnabled;
277 this.showEasyUnlockTurnOffDialog_ =
278 easyUnlockEnabled && this.showEasyUnlockTurnOffDialog_;
279 },
280
281 /** @private */
282 onEasyUnlockSetupTap_: function() {
283 this.easyUnlockBrowserProxy_.startTurnOnFlow();
284 },
285
286 /**
287 * @param {!Event} e
288 * @private
289 */
290 onEasyUnlockTurnOffTap_: function(e) {
291 // Prevent the end of the tap event to focus what is underneath it as the
jdufault 2017/04/06 23:40:44 I'm confused by what this means "to focus what is
sammiequon 2017/04/06 23:56:15 Done.
292 // dialog comes up.
293 e.preventDefault();
294 this.showEasyUnlockTurnOffDialog_ = true;
295 },
296
297 /** @private */
298 onEasyUnlockTurnOffDialogClose_: function() {
299 this.showEasyUnlockTurnOffDialog_ = false;
300 },
209 }); 301 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698