Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 /** | |
| 6 * @fileoverview | |
| 7 * 'settings-lock-screen' allows the user to change how they unlock their | |
| 8 * device. | |
| 9 * | |
| 10 * Example: | |
| 11 * | |
| 12 * <settings-lock-screen | |
| 13 * prefs="{{prefs}}"> | |
| 14 * </settings-lock-screen> | |
| 15 */ | |
| 16 | |
| 17 Polymer({ | |
| 18 is: 'settings-lock-screen', | |
| 19 | |
| 20 behaviors: [I18nBehavior, LockStateBehavior, settings.RouteObserverBehavior], | |
| 21 | |
| 22 properties: { | |
| 23 /** Preferences state. */ | |
| 24 prefs: { | |
| 25 type: Object | |
| 26 }, | |
| 27 | |
| 28 /** | |
| 29 * 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 * valid password. | |
| 32 * | |
| 33 * @type {Object|undefined} | |
| 34 * @private | |
| 35 */ | |
| 36 setModes_: { | |
| 37 type: Object, | |
| 38 observer: 'onSetModesChanged_' | |
| 39 }, | |
| 40 }, | |
| 41 | |
| 42 /** selectedUnlockType is defined in LockStateBehavior. */ | |
| 43 observers: ['selectedUnlockTypeChanged_(selectedUnlockType)'], | |
| 44 | |
| 45 /** @override */ | |
| 46 attached: function() { | |
| 47 // currentRouteChanged is not called during the initial navigation. If the | |
| 48 // user navigates directly to the lockScreen page, we still want to show the | |
| 49 // password prompt page. | |
| 50 this.currentRouteChanged(); | |
| 51 }, | |
| 52 | |
| 53 /** | |
| 54 * Overridden from settings.RouteObserverBehavior. | |
| 55 * @protected | |
| 56 */ | |
| 57 currentRouteChanged: function() { | |
| 58 if (settings.getCurrentRoute() == settings.Route.LOCK_SCREEN && | |
| 59 !this.setModes_) { | |
| 60 this.$.passwordPrompt.open(); | |
| 61 } else { | |
| 62 // If the user navigated away from the lock screen settings page they will | |
| 63 // have to re-enter their password. | |
| 64 this.setModes_ = undefined; | |
| 65 } | |
| 66 }, | |
| 67 | |
| 68 /** | |
| 69 * Called when the unlock type has changed. | |
| 70 * @param {!string} selected The current unlock type. | |
| 71 * @private | |
| 72 */ | |
| 73 selectedUnlockTypeChanged_: function(selected) { | |
| 74 if (selected == LockScreenUnlockType.VALUE_PENDING) | |
| 75 return; | |
| 76 | |
| 77 if (selected != LockScreenUnlockType.PIN_PASSWORD && this.setModes_) { | |
| 78 this.setModes_.call(null, [], [], function(didSet) { | |
| 79 assert(didSet, 'Failed to clear quick unlock modes'); | |
| 80 }); | |
| 81 } | |
| 82 }, | |
| 83 | |
| 84 /** @private */ | |
| 85 onSetModesChanged_: function() { | |
| 86 if (settings.getCurrentRoute() == settings.Route.LOCK_SCREEN && | |
| 87 !this.setModes_) { | |
|
tommycli
2016/08/09 16:15:36
nit: odd indent?
jdufault
2016/08/09 23:58:18
Done.
| |
| 88 this.$.setupPin.close(); | |
| 89 this.$.passwordPrompt.open(); | |
| 90 } | |
| 91 }, | |
| 92 | |
| 93 /** @private */ | |
| 94 onPasswordClosed_: function() { | |
| 95 if (!this.setModes_) | |
| 96 settings.navigateTo(settings.Route.PEOPLE); | |
| 97 }, | |
| 98 | |
| 99 /** @private */ | |
| 100 onPinSetupDone_: function() { | |
| 101 this.$.setupPin.close(); | |
| 102 }, | |
| 103 | |
| 104 /** | |
| 105 * Returns true if the setup pin section should be shown. | |
| 106 * @param {!string} selectedUnlockType The current unlock type. Used to let | |
| 107 * Polymer know about the dependency. | |
| 108 * @private | |
| 109 */ | |
| 110 showConfigurePinButton_: function(selectedUnlockType) { | |
| 111 return selectedUnlockType === LockScreenUnlockType.PIN_PASSWORD; | |
| 112 }, | |
| 113 | |
| 114 /** @private */ | |
| 115 getSetupPinText_: function() { | |
| 116 if (this.hasPin) | |
| 117 return this.i18n('lockScreenChangePinButton'); | |
| 118 return this.i18n('lockScreenSetupPinButton'); | |
| 119 }, | |
| 120 | |
| 121 /** @private */ | |
| 122 onConfigurePin_: function() { | |
| 123 this.$.setupPin.open(); | |
| 124 }, | |
| 125 }); | |
| OLD | NEW |