Chromium Code Reviews| Index: chrome/browser/resources/settings/people_page/quick_unlock_routing_behavior.js |
| diff --git a/chrome/browser/resources/settings/people_page/quick_unlock_routing_behavior.js b/chrome/browser/resources/settings/people_page/quick_unlock_routing_behavior.js |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..0d55545667f39852771a661fa8adfe4d03c46343 |
| --- /dev/null |
| +++ b/chrome/browser/resources/settings/people_page/quick_unlock_routing_behavior.js |
| @@ -0,0 +1,64 @@ |
| +// 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. |
| + |
| +QuickUnlockScreen = { |
| + AUTHENTICATE: 'quick-unlock-authenticate', |
| + CHOOSE_METHOD: 'quick-unlock-choose-method', |
| + SETUP_PIN: 'quick-unlock-setup-pin' |
| +}; |
| + |
| +QuickUnlockRoutingBehavior = { |
| + properties: { |
| + currentRoute: { |
| + type: Object, |
| + notify: true, |
| + } |
| + }, |
| + |
| + /** |
| + * Returns the QuickUnlockScreen type that is associated with this object. |
| + */ |
| + screenType: function() { |
| + console.error('Missing method definition'); |
| + }, |
| + |
| + /** |
| + * Returns true if the given screen is active. |
| + * @param {!QuickUnlockScreen} screen |
| + * @return {!boolean} |
| + */ |
| + isScreenActive: function(screen) { |
| + var subpage = this.currentRoute.subpage; |
| + return subpage.length > 0 && subpage[subpage.length - 1] == screen; |
| + }, |
| + |
| + /** |
| + * Navigate to the given screen. |
| + * @param {!QuickUnlockScreen} screen |
| + */ |
| + 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.
|
| + this.currentRoute = { |
| + page: 'basic', |
| + section: 'people', |
| + subpage: this.getSubpagesForScreen_(screen) |
| + }; |
| + }, |
| + |
| + /** |
| + * Returns the subpages to use in the router for the given screen. |
| + * @param {!QuickUnlockScreen} screen |
| + * @return {!Array<QuickUnlockScreen>} |
| + * @private |
| + */ |
| + 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.
|
| + switch (screen) { |
| + case QuickUnlockScreen.AUTHENTICATE: |
| + return [QuickUnlockScreen.AUTHENTICATE]; |
| + case QuickUnlockScreen.CHOOSE_METHOD: |
| + return [QuickUnlockScreen.CHOOSE_METHOD]; |
| + case QuickUnlockScreen.SETUP_PIN: |
| + return [QuickUnlockScreen.CHOOSE_METHOD, QuickUnlockScreen.SETUP_PIN]; |
| + } |
| + } |
| +}; |
|
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.
|