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 QuickUnlockScreen = { | |
| 6 AUTHENTICATE: 'quick-unlock-authenticate', | |
| 7 CHOOSE_METHOD: 'quick-unlock-choose-method', | |
| 8 SETUP_PIN: 'quick-unlock-setup-pin' | |
| 9 }; | |
| 10 | |
| 11 QuickUnlockRoutingBehavior = { | |
| 12 properties: { | |
| 13 currentRoute: { | |
| 14 type: Object, | |
| 15 notify: true, | |
| 16 } | |
| 17 }, | |
| 18 | |
| 19 /** | |
| 20 * Returns the QuickUnlockScreen type that is associated with this object. | |
| 21 */ | |
| 22 screenType: function() { | |
| 23 console.error('Missing method definition'); | |
| 24 }, | |
| 25 | |
| 26 /** | |
| 27 * Returns true if the given screen is active. | |
| 28 * @param {!QuickUnlockScreen} screen | |
| 29 * @return {!boolean} | |
| 30 */ | |
| 31 isScreenActive: function(screen) { | |
| 32 var subpage = this.currentRoute.subpage; | |
| 33 return subpage.length > 0 && subpage[subpage.length - 1] == screen; | |
| 34 }, | |
| 35 | |
| 36 /** | |
| 37 * Navigate to the given screen. | |
| 38 * @param {!QuickUnlockScreen} screen | |
| 39 */ | |
| 40 navigateToScreen: function(screen) { | |
|
tommycli
2016/06/24 00:56:39
With only 3 callsites, I'm not sure it's worthwhil
jdufault
2016/06/29 19:06:39
Done.
| |
| 41 this.currentRoute = { | |
| 42 page: 'basic', | |
| 43 section: 'people', | |
| 44 subpage: this.getSubpagesForScreen_(screen) | |
| 45 }; | |
| 46 }, | |
| 47 | |
| 48 /** | |
| 49 * Returns the subpages to use in the router for the given screen. | |
| 50 * @param {!QuickUnlockScreen} screen | |
| 51 * @return {!Array<QuickUnlockScreen>} | |
| 52 * @private | |
| 53 */ | |
| 54 getSubpagesForScreen_: function(screen) { | |
|
tommycli
2016/06/24 00:56:39
I think we can eliminate this method, since each o
jdufault
2016/06/29 19:06:39
Done.
| |
| 55 switch (screen) { | |
| 56 case QuickUnlockScreen.AUTHENTICATE: | |
| 57 return [QuickUnlockScreen.AUTHENTICATE]; | |
| 58 case QuickUnlockScreen.CHOOSE_METHOD: | |
| 59 return [QuickUnlockScreen.CHOOSE_METHOD]; | |
| 60 case QuickUnlockScreen.SETUP_PIN: | |
| 61 return [QuickUnlockScreen.CHOOSE_METHOD, QuickUnlockScreen.SETUP_PIN]; | |
| 62 } | |
| 63 } | |
| 64 }; | |
|
tommycli
2016/06/24 00:56:39
I don't think this behavior is "worth it". I don't
jdufault
2016/06/29 19:06:39
I've removed everything except isScreenActive.
| |
| OLD | NEW |