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

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: Fixed patch set 7 errors. 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, LockStateBehavior, WebUIListenerBehavior,
22 settings.RouteObserverBehavior
23 ],
21 24
22 properties: { 25 properties: {
23 /** Preferences state. */ 26 /** Preferences state. */
24 prefs: { 27 prefs: {type: Object},
25 type: Object
26 },
27 28
28 /** 29 /**
29 * setModes_ is a partially applied function that stores the previously 30 * setModes_ is a partially applied function that stores the previously
30 * entered password. It's defined only when the user has already entered a 31 * entered password. It's defined only when the user has already entered a
31 * valid password. 32 * valid password.
32 * 33 *
33 * @type {Object|undefined} 34 * @type {Object|undefined}
34 * @private 35 * @private
35 */ 36 */
36 setModes_: { 37 setModes_: {type: Object, observer: 'onSetModesChanged_'},
stevenjb 2017/04/11 17:29:38 nit: You can force multiple lines here (which I pr
sammiequon 2017/04/11 17:57:11 Done.
37 type: Object,
38 observer: 'onSetModesChanged_'
39 },
40 38
41 /** 39 /**
42 * writeUma_ is a function that handles writing uma stats. It may be 40 * writeUma_ is a function that handles writing uma stats. It may be
43 * overridden for tests. 41 * overridden for tests.
44 * 42 *
45 * @type {Function} 43 * @type {Function}
46 * @private 44 * @private
47 */ 45 */
48 writeUma_: { 46 writeUma_: {
49 type: Object, 47 type: Object,
50 value: function() { return settings.recordLockScreenProgress; } 48 value: function() {
49 return settings.recordLockScreenProgress;
50 }
51 }, 51 },
52 52
53 /** 53 /**
54 * True if pin unlock settings should be displayed on this machine. 54 * True if pin unlock settings should be displayed on this machine.
55 * @private 55 * @private
56 */ 56 */
57 pinUnlockEnabled_: { 57 pinUnlockEnabled_: {
58 type: Boolean, 58 type: Boolean,
59 value: function() { 59 value: function() {
60 return loadTimeData.getBoolean('pinUnlockEnabled'); 60 return loadTimeData.getBoolean('pinUnlockEnabled');
(...skipping 11 matching lines...) Expand all
72 return loadTimeData.getBoolean('fingerprintUnlockEnabled'); 72 return loadTimeData.getBoolean('fingerprintUnlockEnabled');
73 }, 73 },
74 readOnly: true, 74 readOnly: true,
75 }, 75 },
76 76
77 /** @private */ 77 /** @private */
78 numFingerprints_: { 78 numFingerprints_: {
79 type: Number, 79 type: Number,
80 value: 0, 80 value: 0,
81 }, 81 },
82
83 /**
84 * True if Easy Unlock is allowed on this machine.
85 */
86 easyUnlockAllowed_: {
87 type: Boolean,
88 value: function() {
89 return loadTimeData.getBoolean('easyUnlockAllowed');
90 },
91 readOnly: true,
92 },
93
94 /**
95 * True if Easy Unlock is enabled.
96 */
97 easyUnlockEnabled_: {
98 type: Boolean,
99 value: function() {
100 return loadTimeData.getBoolean('easyUnlockEnabled');
101 },
102 },
103
104 /**
105 * True if Easy Unlock's proximity detection feature is allowed.
106 */
107 easyUnlockProximityDetectionAllowed_: {
108 type: Boolean,
109 value: function() {
110 return loadTimeData.getBoolean('easyUnlockAllowed') &&
111 loadTimeData.getBoolean('easyUnlockProximityDetectionAllowed');
112 },
113 readOnly: true,
114 },
115
116 /** @private */
117 showEasyUnlockTurnOffDialog_: {
118 type: Boolean,
119 value: false,
120 },
82 }, 121 },
83 122
123 /** @private {!settings.EasyUnlockBrowserProxy} */
124 easyUnlockBrowserProxy_: null,
125
84 /** @private {?settings.FingerprintBrowserProxy} */ 126 /** @private {?settings.FingerprintBrowserProxy} */
85 browserProxy_: null, 127 fingerprintBrowserProxy_: null,
86 128
87 /** selectedUnlockType is defined in LockStateBehavior. */ 129 /** selectedUnlockType is defined in LockStateBehavior. */
88 observers: ['selectedUnlockTypeChanged_(selectedUnlockType)'], 130 observers: ['selectedUnlockTypeChanged_(selectedUnlockType)'],
89 131
90 /** @override */ 132 /** @override */
91 attached: function() { 133 attached: function() {
92 if (this.shouldAskForPassword_(settings.getCurrentRoute())) 134 if (this.shouldAskForPassword_(settings.getCurrentRoute()))
93 this.$.passwordPrompt.open(); 135 this.$.passwordPrompt.open();
94 this.browserProxy_ = settings.FingerprintBrowserProxyImpl.getInstance(); 136
137 this.easyUnlockBrowserProxy_ =
138 settings.EasyUnlockBrowserProxyImpl.getInstance();
139 this.fingerprintBrowserProxy_ =
140 settings.FingerprintBrowserProxyImpl.getInstance();
141
142 if (this.easyUnlockAllowed_) {
143 this.addWebUIListener(
144 'easy-unlock-enabled-status',
145 this.handleEasyUnlockEnabledStatusChanged_.bind(this));
146 this.easyUnlockBrowserProxy_.getEnabledStatus().then(
147 this.handleEasyUnlockEnabledStatusChanged_.bind(this));
148 }
95 }, 149 },
96 150
97 /** 151 /**
98 * Overridden from settings.RouteObserverBehavior. 152 * Overridden from settings.RouteObserverBehavior.
99 * @param {!settings.Route} newRoute 153 * @param {!settings.Route} newRoute
100 * @param {!settings.Route} oldRoute 154 * @param {!settings.Route} oldRoute
101 * @protected 155 * @protected
102 */ 156 */
103 currentRouteChanged: function(newRoute, oldRoute) { 157 currentRouteChanged: function(newRoute, oldRoute) {
104 if (newRoute == settings.Route.LOCK_SCREEN && 158 if (newRoute == settings.Route.LOCK_SCREEN &&
105 this.fingerprintUnlockEnabled_ && 159 this.fingerprintUnlockEnabled_ && this.fingerprintBrowserProxy_) {
106 this.browserProxy_) { 160 this.fingerprintBrowserProxy_.getNumFingerprints().then(
107 this.browserProxy_.getNumFingerprints().then(
108 function(numFingerprints) { 161 function(numFingerprints) {
109 this.numFingerprints_ = numFingerprints; 162 this.numFingerprints_ = numFingerprints;
110 }.bind(this)); 163 }.bind(this));
111 } 164 }
112 165
113 if (this.shouldAskForPassword_(newRoute)) { 166 if (this.shouldAskForPassword_(newRoute)) {
114 this.$.passwordPrompt.open(); 167 this.$.passwordPrompt.open();
115 } else if (newRoute != settings.Route.FINGERPRINT && 168 } else if (newRoute != settings.Route.FINGERPRINT &&
116 oldRoute != settings.Route.FINGERPRINT) { 169 oldRoute != settings.Route.FINGERPRINT) {
117 // If the user navigated away from the lock screen settings page they will 170 // 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 }, 252 },
200 253
201 /** 254 /**
202 * @param {!settings.Route} route 255 * @param {!settings.Route} route
203 * @return {boolean} Whether the password dialog should be shown. 256 * @return {boolean} Whether the password dialog should be shown.
204 * @private 257 * @private
205 */ 258 */
206 shouldAskForPassword_: function(route) { 259 shouldAskForPassword_: function(route) {
207 return route == settings.Route.LOCK_SCREEN && !this.setModes_; 260 return route == settings.Route.LOCK_SCREEN && !this.setModes_;
208 }, 261 },
262
263 /**
264 * Handler for when the Easy Unlock enabled status has changed.
265 * @private
266 */
267 handleEasyUnlockEnabledStatusChanged_: function(easyUnlockEnabled) {
268 this.easyUnlockEnabled_ = easyUnlockEnabled;
269 this.showEasyUnlockTurnOffDialog_ =
270 easyUnlockEnabled && this.showEasyUnlockTurnOffDialog_;
271 },
272
273 /** @private */
274 onEasyUnlockSetupTap_: function() {
275 this.easyUnlockBrowserProxy_.startTurnOnFlow();
276 },
277
278 /**
279 * @param {!Event} e
280 * @private
281 */
282 onEasyUnlockTurnOffTap_: function(e) {
283 // Prevent the end of the tap event from focusing what is underneath the
284 // button.
285 e.preventDefault();
286 this.showEasyUnlockTurnOffDialog_ = true;
287 },
288
289 /** @private */
290 onEasyUnlockTurnOffDialogClose_: function() {
291 this.showEasyUnlockTurnOffDialog_ = false;
292
293 // Restores focus on close to either the turn-off or set-up button,
294 // whichever is being displayed.
295 this.$$('.secondary-button').focus();
296 },
297
298 /**
299 * @param {boolean} enabled
300 * @param {!string} enabledStr
301 * @param {!string} disabledStr
302 * @private
303 */
304 getEasyUnlockDescription_: function(enabled, enabledStr, disabledStr) {
305 if (enabled)
306 return enabledStr;
307
308 return disabledStr;
stevenjb 2017/04/11 17:29:37 nit: return enabled ? enabledStr : disabledStr;
sammiequon 2017/04/11 17:57:11 Done.
309 },
310
311 /**
312 * @param {boolean} enabled
stevenjb 2017/04/11 17:29:38 nit: easyUnlockEnabled (here and below)
sammiequon 2017/04/11 17:57:10 Done.
313 * @param {boolean} proximityDetectionAllowed
314 * @private
315 */
316 getShowEasyUnlockToggle_: function(enabled, proximityDetectionAllowed) {
317 return enabled && proximityDetectionAllowed;
318 },
209 }); 319 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698