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

Unified Diff: chrome/browser/resources/settings/people_page/lock_screen.js

Issue 2208473007: Rework quick unlock settings to follow new specs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkgr
Patch Set: Initial upload 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/settings/people_page/lock_screen.js
diff --git a/chrome/browser/resources/settings/people_page/lock_screen.js b/chrome/browser/resources/settings/people_page/lock_screen.js
new file mode 100644
index 0000000000000000000000000000000000000000..76f6e92193e4730acccbc760613d16deca722916
--- /dev/null
+++ b/chrome/browser/resources/settings/people_page/lock_screen.js
@@ -0,0 +1,120 @@
+// Copyright 2016 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
+ * 'settings-lock-screen' allows the user to change how they unlock their
+ * device.
+ *
+ * Example:
+ *
+ * <settings-lock-screen
+ * set-modes="[[quickUnlockSetModes]]"
tommycli 2016/08/05 17:46:19 Is this example usage still up to date? It doesn't
jdufault 2016/08/05 20:59:51 Done.
+ * prefs="{{prefs}}">
+ * </settings-lock-screen>
+ */
+
+(function() {
tommycli 2016/08/05 17:46:19 Since there's no variables here you want to keep o
jdufault 2016/08/05 20:59:51 Done.
+'use strict';
+
+Polymer({
+ is: 'settings-lock-screen',
+
+ behaviors: [I18nBehavior, LockStateBehavior],
+
+ properties: {
+ /** @type {!settings.Route} */
tommycli 2016/08/05 17:46:19 Since this is new code, I recommend using the new
jdufault 2016/08/05 20:59:51 Done.
+ currentRoute: {
+ type: Object,
+ observer: 'onRouteChanged_',
+ },
+
+ /** Preferences state. */
+ prefs: {
+ type: Object
+ },
+
+ /**
+ * @type {Object|undefined}
+ * @private
+ */
+ setModes_: {
tommycli 2016/08/05 17:46:19 Since this setModes_ usage is subtle, it could use
jdufault 2016/08/05 20:59:51 Done.
+ type: Object,
+ observer: 'onSetModesChanged_'
+ },
+ },
+
+ // selectedUnlockType is defined in LockStateBehavior.
tommycli 2016/08/05 17:46:19 nit: Comment should probably be like: /** Foo */
jdufault 2016/08/05 20:59:51 Done.
+ observers: ['selectedUnlockTypeChanged_(selectedUnlockType)'],
+
+ /** @private */
+ onRouteChanged_: function(currentRoute) {
tommycli 2016/08/05 17:46:19 If you go with the settings.RouteObserverBehavior
jdufault 2016/08/05 20:59:51 Done.
+ if (this.currentRoute == settings.Route.LOCK_SCREEN && !this.setModes_) {
+ this.$.passwordPrompt.open();
+ } else {
+ // If the user navigated away from the lock screen settings page they will
+ // have to re-enter their password.
+ this.setModes_ = undefined;
+ }
+ },
+
+ /**
+ * Called when the unlock type has changed.
+ * @param {!string} selected The current unlock type.
+ * @private
+ */
+ selectedUnlockTypeChanged_: function(selected) {
+ if (selected == LockScreenUnlockType.VALUE_PENDING)
+ return;
+
+ if (selected != LockScreenUnlockType.PIN_PASSWORD && this.setModes_) {
+ this.setModes_.call(null, [], [], function(didSet) {
+ assert(didSet, 'Failed to clear quick unlock modes');
+ });
+ }
+ },
+
+ /** @private */
+ onSetModesChanged_: function() {
+ if (this.currentRoute == settings.Route.LOCK_SCREEN && !this.setModes_) {
+ this.$.setupPin.close();
+ this.$.passwordPrompt.open();
+ }
+ },
+
+ /** @private */
+ onPasswordClosed_: function() {
+ if (!this.setModes_)
+ settings.navigateTo(settings.Route.PEOPLE);
+ },
+
+ /** @private */
+ onPinSetupDone_: function() {
+ this.$.setupPin.close();
+ },
+
+ /**
+ * Retruns true if the setup pin section should be shown.
tommycli 2016/08/05 17:46:19 typo: Returns
jdufault 2016/08/05 20:59:51 Done.
+ * @param {!string} selectedUnlockType The current unlock type. Used to let
+ * polymer know about the dependency.
tommycli 2016/08/05 17:46:19 nit: indent four spaces, then Polymer
jdufault 2016/08/05 20:59:51 Done.
+ * @private
+ */
+ showSetupPin_: function(selectedUnlockType) {
tommycli 2016/08/05 17:46:18 nit: maybe rename: showConfigurePinButton_ ?
jdufault 2016/08/05 20:59:51 Done.
+ return selectedUnlockType === LockScreenUnlockType.PIN_PASSWORD;
+ },
+
+ /** @private */
+ getSetupPinText_: function() {
tommycli 2016/08/05 17:46:19 My interpretation of the mocks was that selecting
jdufault 2016/08/05 20:59:51 That part of the mocks is likely to change (UI rev
+ if (this.hasPin)
+ return this.i18n('lockScreenChangePinButton');
+ return this.i18n('lockScreenSetupPinButton');
+ },
+
+ /** @private */
+ onConfigurePin_: function() {
+ this.$.setupPin.open();
+ },
+});
+
+})();

Powered by Google App Engine
This is Rietveld 408576698