| OLD | NEW |
| 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-setup-pin' is the settings page for choosing a PIN. | 7 * 'settings-quick-unlock-setup-pin' is the settings page for choosing a PIN. |
| 8 * | 8 * |
| 9 * Example: | 9 * Example: |
| 10 * | 10 * |
| 11 * <settings-quick-unlock-setup-pin | 11 * <settings-quick-unlock-setup-pin set-modes="[[quickUnlockSetModes]]"> |
| 12 * set-modes="[[quickUnlockSetModes]]" | |
| 13 * current-route="{{currentRoute}}"> | |
| 14 * </settings-quick-unlock-setup-pin> | 12 * </settings-quick-unlock-setup-pin> |
| 15 */ | 13 */ |
| 16 | 14 |
| 17 (function() { | 15 (function() { |
| 18 'use strict'; | 16 'use strict'; |
| 19 | 17 |
| 20 /** | 18 /** |
| 21 * Metainformation about a problem message to pass to showProblem. |class| is | 19 * Metainformation about a problem message to pass to showProblem. |class| is |
| 22 * the css class to show the problem message with. |messageId| is the i18n | 20 * the css class to show the problem message with. |messageId| is the i18n |
| 23 * string id to use. | 21 * string id to use. |
| (...skipping 20 matching lines...) Expand all Loading... |
| 44 * @const | 42 * @const |
| 45 */ | 43 */ |
| 46 var WEAK_PINS = [ | 44 var WEAK_PINS = [ |
| 47 '1234', '1111', '0000', '1212', '7777', '1004', '2000', '4444', '2222', | 45 '1234', '1111', '0000', '1212', '7777', '1004', '2000', '4444', '2222', |
| 48 '6969' | 46 '6969' |
| 49 ]; | 47 ]; |
| 50 | 48 |
| 51 Polymer({ | 49 Polymer({ |
| 52 is: 'settings-quick-unlock-setup-pin', | 50 is: 'settings-quick-unlock-setup-pin', |
| 53 | 51 |
| 54 behaviors: [I18nBehavior, QuickUnlockPasswordDetectBehavior], | 52 behaviors: [ |
| 53 I18nBehavior, |
| 54 QuickUnlockPasswordDetectBehavior, |
| 55 settings.RouteObserverBehavior |
| 56 ], |
| 55 | 57 |
| 56 properties: { | 58 properties: { |
| 57 /** @type {!settings.Route} */ | |
| 58 currentRoute: { | |
| 59 type: Object, | |
| 60 observer: 'onRouteChanged_', | |
| 61 }, | |
| 62 | |
| 63 /** | 59 /** |
| 64 * The current PIN keyboard value. | 60 * The current PIN keyboard value. |
| 65 * @private | 61 * @private |
| 66 */ | 62 */ |
| 67 pinKeyboardValue_: String, | 63 pinKeyboardValue_: String, |
| 68 | 64 |
| 69 /** | 65 /** |
| 70 * Stores the initial PIN value so it can be confirmed. | 66 * Stores the initial PIN value so it can be confirmed. |
| 71 * @private | 67 * @private |
| 72 */ | 68 */ |
| (...skipping 25 matching lines...) Expand all Loading... |
| 98 value: false | 94 value: false |
| 99 }, | 95 }, |
| 100 }, | 96 }, |
| 101 | 97 |
| 102 observers: ['onSetModesChanged_(setModes)'], | 98 observers: ['onSetModesChanged_(setModes)'], |
| 103 | 99 |
| 104 /** @override */ | 100 /** @override */ |
| 105 attached: function() { | 101 attached: function() { |
| 106 this.resetState_(); | 102 this.resetState_(); |
| 107 | 103 |
| 108 if (this.currentRoute == settings.Route.QUICK_UNLOCK_SETUP_PIN) | 104 if (settings.getCurrentRoute() == settings.Route.QUICK_UNLOCK_SETUP_PIN) |
| 109 this.askForPasswordIfUnset(); | 105 this.askForPasswordIfUnset(); |
| 110 }, | 106 }, |
| 111 | 107 |
| 112 /** | 108 /** @protected */ |
| 113 * @param {!settings.Route} currentRoute | 109 currentRouteChanged: function() { |
| 114 * @private | 110 if (settings.getCurrentRoute() == settings.Route.QUICK_UNLOCK_SETUP_PIN) { |
| 115 */ | |
| 116 onRouteChanged_: function(currentRoute) { | |
| 117 if (this.currentRoute == settings.Route.QUICK_UNLOCK_SETUP_PIN) { | |
| 118 this.askForPasswordIfUnset(); | 111 this.askForPasswordIfUnset(); |
| 119 } else { | 112 } else { |
| 120 // If the user hits the back button, they can leave the element | 113 // If the user hits the back button, they can leave the element |
| 121 // half-completed; therefore, reset state if the element is not active. | 114 // half-completed; therefore, reset state if the element is not active. |
| 122 this.resetState_(); | 115 this.resetState_(); |
| 123 } | 116 } |
| 124 }, | 117 }, |
| 125 | 118 |
| 126 /** @private */ | 119 /** @private */ |
| 127 onSetModesChanged_: function() { | 120 onSetModesChanged_: function() { |
| 128 if (this.currentRoute == settings.Route.QUICK_UNLOCK_SETUP_PIN) | 121 if (settings.getCurrentRoute() == settings.Route.QUICK_UNLOCK_SETUP_PIN) |
| 129 this.askForPasswordIfUnset(); | 122 this.askForPasswordIfUnset(); |
| 130 }, | 123 }, |
| 131 | 124 |
| 132 /** | 125 /** |
| 133 * Resets the element to the initial state. | 126 * Resets the element to the initial state. |
| 134 * @private | 127 * @private |
| 135 */ | 128 */ |
| 136 resetState_: function() { | 129 resetState_: function() { |
| 137 this.initialPin_ = ''; | 130 this.initialPin_ = ''; |
| 138 this.pinKeyboardValue_ = ''; | 131 this.pinKeyboardValue_ = ''; |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 289 * @return {string} | 282 * @return {string} |
| 290 */ | 283 */ |
| 291 getContinueMessage_: function(isConfirmStep) { | 284 getContinueMessage_: function(isConfirmStep) { |
| 292 if (!isConfirmStep) | 285 if (!isConfirmStep) |
| 293 return this.i18n('quickUnlockConfigurePinContinueButton'); | 286 return this.i18n('quickUnlockConfigurePinContinueButton'); |
| 294 return this.i18n('save'); | 287 return this.i18n('save'); |
| 295 }, | 288 }, |
| 296 }); | 289 }); |
| 297 | 290 |
| 298 })(); | 291 })(); |
| OLD | NEW |