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

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

Issue 2154213008: Settings Router Refactor: Clean up Quick Unlock (and a few misc fixes) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@0211-settings-router-impl-part-3-navigateTo
Patch Set: change test Created 4 years, 4 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-quick-unlock-choose-method' allows the user to change how they 7 * 'settings-quick-unlock-choose-method' allows the user to change how they
8 * unlock their device. Note that setting up the unlock method is delegated 8 * unlock their device. Note that setting up the unlock method is delegated
9 * to other elements. 9 * to other elements.
10 * 10 *
(...skipping 15 matching lines...) Expand all
26 var QuickUnlockUnlockType = { 26 var QuickUnlockUnlockType = {
27 VALUE_PENDING: 'value_pending', 27 VALUE_PENDING: 'value_pending',
28 NONE: 'none', 28 NONE: 'none',
29 PASSWORD: 'password', 29 PASSWORD: 'password',
30 PIN_PASSWORD: 'pin+password' 30 PIN_PASSWORD: 'pin+password'
31 }; 31 };
32 32
33 Polymer({ 33 Polymer({
34 is: 'settings-quick-unlock-choose-method', 34 is: 'settings-quick-unlock-choose-method',
35 35
36 behaviors: [ 36 behaviors: [PrefsBehavior, QuickUnlockPasswordDetectBehavior],
37 PrefsBehavior, QuickUnlockPasswordDetectBehavior
38 ],
39 37
40 properties: { 38 properties: {
39 /** @type {!settings.Route} */
40 currentRoute: {
41 type: Object,
42 observer: 'onRouteChanged_',
43 },
44
41 /** Preferences state. */ 45 /** Preferences state. */
42 prefs: { 46 prefs: {
43 type: Object, 47 type: Object,
44 notify: true, 48 notify: true,
45 }, 49 },
46 50
47 /** 51 /**
48 * The currently selected unlock type. 52 * The currently selected unlock type.
49 * @type {!QuickUnlockUnlockType} 53 * @type {!QuickUnlockUnlockType}
50 * @private 54 * @private
51 */ 55 */
52 selectedUnlockType_: { 56 selectedUnlockType_: {
53 type: String, 57 type: String,
54 notify: true, 58 notify: true,
55 value: QuickUnlockUnlockType.VALUE_PENDING, 59 value: QuickUnlockUnlockType.VALUE_PENDING,
56 observer: 'selectedUnlockTypeChanged_' 60 observer: 'selectedUnlockTypeChanged_'
57 } 61 }
58 }, 62 },
59 63
60 observers: [ 64 observers: ['onSetModesChanged_(setModes)'],
61 'onRouteChanged_(currentRoute)',
62 'onSetModesChanged_(setModes)'
63 ],
64 65
65 /** @override */ 66 /** @override */
66 attached: function() { 67 attached: function() {
67 CrSettingsPrefs.initialized.then(this.updateUnlockType_.bind(this)); 68 CrSettingsPrefs.initialized.then(this.updateUnlockType_.bind(this));
68 69
69 this.boundOnPrefsChanged_ = function(prefs) { 70 this.boundOnPrefsChanged_ = function(prefs) {
70 for (var i = 0; i < prefs.length; ++i) { 71 for (var i = 0; i < prefs.length; ++i) {
71 if (prefs[i].key == ENABLE_LOCK_SCREEN_PREF) 72 if (prefs[i].key == ENABLE_LOCK_SCREEN_PREF)
72 this.updateUnlockType_(); 73 this.updateUnlockType_();
73 } 74 }
74 }.bind(this); 75 }.bind(this);
75 this.boundOnActiveModesChanged_ = this.updateUnlockType_.bind(this); 76 this.boundOnActiveModesChanged_ = this.updateUnlockType_.bind(this);
76 77
77 chrome.settingsPrivate.onPrefsChanged.addListener( 78 chrome.settingsPrivate.onPrefsChanged.addListener(
78 this.boundOnPrefsChanged_); 79 this.boundOnPrefsChanged_);
79 chrome.quickUnlockPrivate.onActiveModesChanged.addListener( 80 chrome.quickUnlockPrivate.onActiveModesChanged.addListener(
80 this.boundOnActiveModesChanged_); 81 this.boundOnActiveModesChanged_);
81 82
82 if (this.isScreenActive(QuickUnlockScreen.CHOOSE_METHOD)) 83 if (this.currentRoute == settings.Route.QUICK_UNLOCK_CHOOSE_METHOD)
83 this.askForPasswordIfUnset(); 84 this.askForPasswordIfUnset();
84 }, 85 },
85 86
86 /** @override */ 87 /** @override */
87 detached: function() { 88 detached: function() {
88 chrome.settingsPrivate.onPrefsChanged.removeListener( 89 chrome.settingsPrivate.onPrefsChanged.removeListener(
89 this.boundOnPrefsChanged_); 90 this.boundOnPrefsChanged_);
90 chrome.quickUnlockPrivate.onActiveModesChanged.removeListener( 91 chrome.quickUnlockPrivate.onActiveModesChanged.removeListener(
91 this.boundOnActiveModesChanged_); 92 this.boundOnActiveModesChanged_);
92 }, 93 },
93 94
94 /** @private */ 95 /** @private */
95 onRouteChanged_: function() { 96 onRouteChanged_: function() {
96 if (this.isScreenActive(QuickUnlockScreen.CHOOSE_METHOD)) 97 if (this.currentRoute == settings.Route.QUICK_UNLOCK_CHOOSE_METHOD)
97 this.askForPasswordIfUnset(); 98 this.askForPasswordIfUnset();
98 }, 99 },
99 100
100 /** @private */ 101 /** @private */
101 onSetModesChanged_: function() { 102 onSetModesChanged_: function() {
102 if (this.isScreenActive(QuickUnlockScreen.CHOOSE_METHOD)) 103 if (this.currentRoute == settings.Route.QUICK_UNLOCK_CHOOSE_METHOD)
103 this.askForPasswordIfUnset(); 104 this.askForPasswordIfUnset();
104 }, 105 },
105 106
106 /** 107 /**
107 * Updates the selected unlock type radio group. This function will get called 108 * Updates the selected unlock type radio group. This function will get called
108 * after preferences are initialized, after the quick unlock mode has been 109 * after preferences are initialized, after the quick unlock mode has been
109 * changed, and after the lockscreen preference has changed. 110 * changed, and after the lockscreen preference has changed.
110 * 111 *
111 * @private 112 * @private
112 */ 113 */
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 return selectedUnlockType === QuickUnlockUnlockType.PIN_PASSWORD; 172 return selectedUnlockType === QuickUnlockUnlockType.PIN_PASSWORD;
172 }, 173 },
173 174
174 /** @private */ 175 /** @private */
175 onConfigurePin_: function() { 176 onConfigurePin_: function() {
176 settings.navigateTo(settings.Route.QUICK_UNLOCK_SETUP_PIN); 177 settings.navigateTo(settings.Route.QUICK_UNLOCK_SETUP_PIN);
177 }, 178 },
178 }); 179 });
179 180
180 })(); 181 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698