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

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

Issue 2157673002: Browser tests for the quick_unlock settings pages. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@pin-unlock-quick-unlock-interface
Patch Set: Created 4 years, 5 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 /** 47 /**
48 * The currently selected unlock type. 48 * The currently selected unlock type.
49 * @type {!QuickUnlockUnlockType} 49 * @type {!QuickUnlockUnlockType}
50 * @private 50 * @private
51 */ 51 */
52 selectedUnlockType_: { 52 selectedUnlockType_: {
53 type: String, 53 type: String,
54 notify: true, 54 notify: true,
55 value: QuickUnlockUnlockType.VALUE_PENDING, 55 value: QuickUnlockUnlockType.VALUE_PENDING,
56 observer: 'selectedUnlockTypeChanged_' 56 observer: 'selectedUnlockTypeChanged_'
57 } 57 },
58
59 /**
60 * Interface for chrome.quickUnlockPrivate calls. May be overriden by tests.
61 * @private
62 * @type {QuickUnlockPrivate}
63 */
64 quickUnlockPrivate_: {
65 type: Object,
66 value: chrome.quickUnlockPrivate
67 },
68
69 /**
70 * Interface for chrome.settingsPrivate calls. May be overriden by tests.
71 * @private
72 * @type {SettingsPrivate}
73 */
74 settingsPrivate_: {
75 type: Object,
76 value: chrome.settingsPrivate
77 },
58 }, 78 },
59 79
60 observers: [ 80 observers: [
61 'onRouteChanged_(currentRoute)', 81 'onRouteChanged_(currentRoute)',
62 'onSetModesChanged_(setModes)' 82 'onSetModesChanged_(setModes)'
63 ], 83 ],
64 84
65 /** @override */ 85 /** @override */
66 attached: function() { 86 attached: function() {
67 CrSettingsPrefs.initialized.then(this.updateUnlockType_.bind(this)); 87 CrSettingsPrefs.initialized.then(this.updateUnlockType_.bind(this));
68 88
69 this.boundOnPrefsChanged_ = function(prefs) { 89 this.boundOnPrefsChanged_ = function(prefs) {
70 for (var i = 0; i < prefs.length; ++i) { 90 for (var i = 0; i < prefs.length; ++i) {
71 if (prefs[i].key == ENABLE_LOCK_SCREEN_PREF) 91 if (prefs[i].key == ENABLE_LOCK_SCREEN_PREF)
72 this.updateUnlockType_(); 92 this.updateUnlockType_();
73 } 93 }
74 }.bind(this); 94 }.bind(this);
75 this.boundOnActiveModesChanged_ = this.updateUnlockType_.bind(this); 95 this.boundOnActiveModesChanged_ = this.updateUnlockType_.bind(this);
76 96
77 chrome.settingsPrivate.onPrefsChanged.addListener( 97 this.settingsPrivate_.onPrefsChanged.addListener(
78 this.boundOnPrefsChanged_); 98 this.boundOnPrefsChanged_);
79 chrome.quickUnlockPrivate.onActiveModesChanged.addListener( 99 this.quickUnlockPrivate_.onActiveModesChanged.addListener(
80 this.boundOnActiveModesChanged_); 100 this.boundOnActiveModesChanged_);
81 101
82 this.askForPasswordIfUnset(); 102 this.askForPasswordIfUnset();
83 }, 103 },
84 104
85 /** @override */ 105 /** @override */
86 detached: function() { 106 detached: function() {
87 chrome.settingsPrivate.onPrefsChanged.removeListener( 107 this.settingsPrivate_.onPrefsChanged.removeListener(
88 this.boundOnPrefsChanged_); 108 this.boundOnPrefsChanged_);
89 chrome.quickUnlockPrivate.onActiveModesChanged.removeListener( 109 this.quickUnlockPrivate_.onActiveModesChanged.removeListener(
90 this.boundOnActiveModesChanged_); 110 this.boundOnActiveModesChanged_);
91 }, 111 },
92 112
93 /** @private */ 113 /** @private */
94 onRouteChanged_: function() { 114 onRouteChanged_: function() {
95 if (this.isScreenActive(QuickUnlockScreen.CHOOSE_METHOD)) 115 if (this.isScreenActive(QuickUnlockScreen.CHOOSE_METHOD))
96 this.askForPasswordIfUnset(); 116 this.askForPasswordIfUnset();
97 }, 117 },
98 118
99 /** @private */ 119 /** @private */
(...skipping 14 matching lines...) Expand all
114 // function before CrSettingsPrefs is initialized if another settings page 134 // function before CrSettingsPrefs is initialized if another settings page
115 // changes the quick unlock state. 135 // changes the quick unlock state.
116 if (!CrSettingsPrefs.isInitialized) 136 if (!CrSettingsPrefs.isInitialized)
117 return; 137 return;
118 138
119 if (!this.getPref(ENABLE_LOCK_SCREEN_PREF).value) { 139 if (!this.getPref(ENABLE_LOCK_SCREEN_PREF).value) {
120 this.selectedUnlockType_ = QuickUnlockUnlockType.NONE; 140 this.selectedUnlockType_ = QuickUnlockUnlockType.NONE;
121 return; 141 return;
122 } 142 }
123 143
124 chrome.quickUnlockPrivate.getActiveModes(function(modes) { 144 this.quickUnlockPrivate_.getActiveModes(function(modes) {
125 if (modes.includes(chrome.quickUnlockPrivate.QuickUnlockMode.PIN)) { 145 if (modes.includes(chrome.quickUnlockPrivate.QuickUnlockMode.PIN)) {
126 this.selectedUnlockType_ = QuickUnlockUnlockType.PIN_PASSWORD; 146 this.selectedUnlockType_ = QuickUnlockUnlockType.PIN_PASSWORD;
127 } else if (this.selectedUnlockType_ != 147 } else if (this.selectedUnlockType_ !=
128 QuickUnlockUnlockType.PIN_PASSWORD) { 148 QuickUnlockUnlockType.PIN_PASSWORD) {
129 // We don't want to clobber an existing PIN+PASSWORD state because the 149 // We don't want to clobber an existing PIN+PASSWORD state because the
130 // user needs to configure that option before actually using it. 150 // user needs to configure that option before actually using it.
131 // 151 //
132 // Specifically, this check is needed because this function gets called 152 // Specifically, this check is needed because this function gets called
133 // by the pref system after changing the unlock type from NONE to 153 // by the pref system after changing the unlock type from NONE to
134 // PIN+PASSWORD. Without the conditional assignment, this function would 154 // PIN+PASSWORD. Without the conditional assignment, this function would
135 // change the PIN+PASSWORD lock type to PASSWORD because the PIN hasn't 155 // change the PIN+PASSWORD lock type to PASSWORD because the PIN hasn't
136 // been configured yet. 156 // been configured yet.
137 this.selectedUnlockType_ = QuickUnlockUnlockType.PASSWORD; 157 this.selectedUnlockType_ = QuickUnlockUnlockType.PASSWORD;
138 } 158 }
139 }.bind(this)); 159 }.bind(this));
140 }, 160 },
141 161
142 /** 162 /**
143 * Called when the unlock type has changed. 163 * Called when the unlock type has changed.
144 * @param {!string} selected The current unlock type. 164 * @param {!string} selected The current unlock type.
145 * @param {?string} previous The old unlock type. undefined if not present. 165 * @param {?string} previous The old unlock type. undefined if not present.
146 * @private 166 * @private
147 */ 167 */
148 selectedUnlockTypeChanged_: function(selected, previous) { 168 selectedUnlockTypeChanged_: function(selected, previous) {
149 // This method gets invoked when setting the initial value from the existing 169 // This method gets invoked when setting the initial value from the existing
150 // state. In that case, we don't need to bother updating the prefs. 170 // state. In that case, we don't need to bother updating the prefs.
151 if (!previous) 171 if (!previous || previous == QuickUnlockUnlockType.VALUE_PENDING)
152 return; 172 return;
153 173
154 this.setPrefValue(ENABLE_LOCK_SCREEN_PREF, 174 this.setPrefValue(ENABLE_LOCK_SCREEN_PREF,
155 selected != QuickUnlockUnlockType.NONE); 175 selected != QuickUnlockUnlockType.NONE);
156 if (selected != QuickUnlockUnlockType.PIN_PASSWORD && this.setModes) { 176 if (selected != QuickUnlockUnlockType.PIN_PASSWORD && this.setModes) {
157 this.setModes.call(null, [], [], function(didSet) { 177 this.setModes.call(null, [], [], function(didSet) {
158 assert(didSet, 'Failed to clear quick unlock modes'); 178 assert(didSet, 'Failed to clear quick unlock modes');
159 }); 179 });
160 } 180 }
161 }, 181 },
(...skipping 12 matching lines...) Expand all
174 onConfigurePin_: function() { 194 onConfigurePin_: function() {
175 this.currentRoute = { 195 this.currentRoute = {
176 page: 'basic', 196 page: 'basic',
177 section: 'people', 197 section: 'people',
178 subpage: [QuickUnlockScreen.CHOOSE_METHOD, QuickUnlockScreen.SETUP_PIN] 198 subpage: [QuickUnlockScreen.CHOOSE_METHOD, QuickUnlockScreen.SETUP_PIN]
179 }; 199 };
180 }, 200 },
181 }); 201 });
182 202
183 })(); 203 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698