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 cr.define('options', function() { | 5 cr.define('options', function() { |
6 var Page = cr.ui.pageManager.Page; | 6 var Page = cr.ui.pageManager.Page; |
7 var PageManager = cr.ui.pageManager.PageManager; | 7 var PageManager = cr.ui.pageManager.PageManager; |
8 | 8 |
9 /** | 9 /** |
| 10 * Maximum time to wait after the page is fully loaded before we start to |
| 11 * load polymer elements. |
| 12 * @type {number} |
| 13 * @const |
| 14 */ |
| 15 var POLYMER_LOAD_TIMEOUT_MS = 5000; |
| 16 |
| 17 /** |
10 * QuickUnlockConfigureOverlay class | 18 * QuickUnlockConfigureOverlay class |
11 * Dialog that allows users to configure screen lock. | 19 * Dialog that allows users to configure screen lock. |
12 * @constructor | 20 * @constructor |
13 * @extends {cr.ui.pageManager.Page} | 21 * @extends {cr.ui.pageManager.Page} |
14 */ | 22 */ |
15 function QuickUnlockConfigureOverlay() { | 23 function QuickUnlockConfigureOverlay() { |
16 Page.call(this, 'quickUnlockConfigureOverlay', | 24 Page.call(this, 'quickUnlockConfigureOverlay', |
17 loadTimeData.getString('lockScreenTitle'), | 25 loadTimeData.getString('lockScreenTitle'), |
18 'quick-unlock-configure-overlay'); | 26 'quick-unlock-configure-overlay'); |
19 | 27 |
20 } | 28 } |
21 | 29 |
22 cr.addSingletonGetter(QuickUnlockConfigureOverlay); | 30 cr.addSingletonGetter(QuickUnlockConfigureOverlay); |
23 | 31 |
24 QuickUnlockConfigureOverlay.prototype = { | 32 QuickUnlockConfigureOverlay.prototype = { |
25 __proto__: Page.prototype, | 33 __proto__: Page.prototype, |
26 | 34 |
27 /** @override */ | 35 /** @override */ |
28 initializePage: function() { | 36 initializePage: function() { |
29 Page.prototype.initializePage.call(this); | 37 Page.prototype.initializePage.call(this); |
30 $('screen-lock-done').onclick = function() { | 38 $('screen-lock-done').onclick = function() { |
31 QuickUnlockConfigureOverlay.dismiss(); | 39 QuickUnlockConfigureOverlay.dismiss(); |
32 }; | 40 }; |
| 41 |
| 42 window.addEventListener('load', function() { |
| 43 // Setting a timeout here to avoid racing with some browsertests, |
| 44 // this should be here for only a short period of time as |
| 45 // md-settings are launching soon. |
| 46 setTimeout( |
| 47 this.ensurePolymerIsLoaded_.bind(this), POLYMER_LOAD_TIMEOUT_MS); |
| 48 }.bind(this)); |
33 }, | 49 }, |
34 | 50 |
35 /** @override */ | 51 /** @override */ |
36 didClosePage: function() { | 52 didClosePage: function() { |
37 settings.navigateTo(settings.Route.PEOPLE); | 53 settings.navigateTo(settings.Route.PEOPLE); |
38 }, | 54 }, |
39 | 55 |
40 /** @override */ | 56 /** @override */ |
41 didShowPage: function() { | 57 didShowPage: function() { |
42 this.ensurePolymerIsLoaded_().then(this.onPolymerLoaded_.bind(this)); | 58 this.ensurePolymerIsLoaded_().then(this.onPolymerLoaded_.bind(this)); |
(...skipping 15 matching lines...) Expand all Loading... |
58 }, | 74 }, |
59 | 75 |
60 /** | 76 /** |
61 * Called when polymer has been loaded and the dialog should be displayed. | 77 * Called when polymer has been loaded and the dialog should be displayed. |
62 * @private | 78 * @private |
63 */ | 79 */ |
64 onPolymerLoaded_: function() { | 80 onPolymerLoaded_: function() { |
65 settings.navigateTo(settings.Route.LOCK_SCREEN); | 81 settings.navigateTo(settings.Route.LOCK_SCREEN); |
66 var lockScreen = document.querySelector('settings-lock-screen'); | 82 var lockScreen = document.querySelector('settings-lock-screen'); |
67 | 83 |
68 var checkbox = | 84 var checkbox = lockScreen.root.querySelector('div.settings-box'); |
69 lockScreen.root.querySelector( | |
70 'div.settings-box.single-column.screen-lock'); | |
71 checkbox.hidden = true; | 85 checkbox.hidden = true; |
72 | 86 |
73 var passwordPrompt = lockScreen.root. | 87 var passwordPrompt = lockScreen.root. |
74 querySelector('settings-password-prompt-dialog'); | 88 querySelector('settings-password-prompt-dialog'); |
75 passwordPrompt.addEventListener('close', function() { | 89 passwordPrompt.addEventListener('close', function() { |
76 if (!lockScreen.setModes_) { | 90 if (!lockScreen.setModes_) { |
77 QuickUnlockConfigureOverlay.dismiss(); | 91 QuickUnlockConfigureOverlay.dismiss(); |
78 } | 92 } |
79 }.bind(this)); | 93 }.bind(this)); |
80 }, | 94 }, |
81 }; | 95 }; |
82 | 96 |
83 QuickUnlockConfigureOverlay.dismiss = function() { | 97 QuickUnlockConfigureOverlay.dismiss = function() { |
84 PageManager.closeOverlay(); | 98 PageManager.closeOverlay(); |
85 }; | 99 }; |
86 | 100 |
87 // Export | 101 // Export |
88 return { | 102 return { |
89 QuickUnlockConfigureOverlay: QuickUnlockConfigureOverlay | 103 QuickUnlockConfigureOverlay: QuickUnlockConfigureOverlay |
90 }; | 104 }; |
91 }); | 105 }); |
OLD | NEW |