Chromium Code Reviews| 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 | |
| 11 * we start to load polymer elements. | |
|
Dan Beam
2017/02/17 02:45:17
please wrap comments at 80 cols
xiaoyinh(OOO Sep 11-29)
2017/02/17 19:33:46
Done.
| |
| 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 document.onreadystatechange = function () { | |
|
Dan Beam
2017/02/17 02:45:17
this is not properly formatted, please run git cl
xiaoyinh(OOO Sep 11-29)
2017/02/17 19:33:46
Done.
| |
| 43 if (document.readyState == "complete") { | |
| 44 // Setting a timeout here to avoid racing with some browsertests, | |
|
Dan Beam
2017/02/17 02:45:17
i don't think this guarantees anything about racin
xiaoyinh(OOO Sep 11-29)
2017/02/17 19:33:46
Thanks, I think the failed browsertests are runnin
| |
| 45 // this should be here for only a short period of time as | |
| 46 // md-settings are launching soon. | |
| 47 setTimeout(this.ensurePolymerIsLoaded_.bind(this), | |
| 48 POLYMER_LOAD_TIMEOUT_MS); | |
| 49 } | |
| 50 }.bind(this); | |
|
Dan Beam
2017/02/17 02:45:17
can you just do
window.addEventListener('load', f
xiaoyinh(OOO Sep 11-29)
2017/02/17 19:33:46
Done.
| |
| 33 }, | 51 }, |
| 34 | 52 |
| 35 /** @override */ | 53 /** @override */ |
| 36 didClosePage: function() { | 54 didClosePage: function() { |
| 37 settings.navigateTo(settings.Route.PEOPLE); | 55 settings.navigateTo(settings.Route.PEOPLE); |
| 38 }, | 56 }, |
| 39 | 57 |
| 40 /** @override */ | 58 /** @override */ |
| 41 didShowPage: function() { | 59 didShowPage: function() { |
| 42 this.ensurePolymerIsLoaded_().then(this.onPolymerLoaded_.bind(this)); | 60 this.ensurePolymerIsLoaded_().then(this.onPolymerLoaded_.bind(this)); |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 60 /** | 78 /** |
| 61 * Called when polymer has been loaded and the dialog should be displayed. | 79 * Called when polymer has been loaded and the dialog should be displayed. |
| 62 * @private | 80 * @private |
| 63 */ | 81 */ |
| 64 onPolymerLoaded_: function() { | 82 onPolymerLoaded_: function() { |
| 65 settings.navigateTo(settings.Route.LOCK_SCREEN); | 83 settings.navigateTo(settings.Route.LOCK_SCREEN); |
| 66 var lockScreen = document.querySelector('settings-lock-screen'); | 84 var lockScreen = document.querySelector('settings-lock-screen'); |
| 67 | 85 |
| 68 var checkbox = | 86 var checkbox = |
| 69 lockScreen.root.querySelector( | 87 lockScreen.root.querySelector( |
| 70 'div.settings-box.single-column.screen-lock'); | 88 'div.settings-box'); |
|
Dan Beam
2017/02/17 02:45:17
please reformat this with git cl format --js
xiaoyinh(OOO Sep 11-29)
2017/02/17 19:33:46
Done.
| |
| 71 checkbox.hidden = true; | 89 checkbox.hidden = true; |
| 72 | 90 |
| 73 var passwordPrompt = lockScreen.root. | 91 var passwordPrompt = lockScreen.root. |
| 74 querySelector('settings-password-prompt-dialog'); | 92 querySelector('settings-password-prompt-dialog'); |
| 75 passwordPrompt.addEventListener('close', function() { | 93 passwordPrompt.addEventListener('close', function() { |
| 76 if (!lockScreen.setModes_) { | 94 if (!lockScreen.setModes_) { |
| 77 QuickUnlockConfigureOverlay.dismiss(); | 95 QuickUnlockConfigureOverlay.dismiss(); |
| 78 } | 96 } |
| 79 }.bind(this)); | 97 }.bind(this)); |
| 80 }, | 98 }, |
| 81 }; | 99 }; |
| 82 | 100 |
| 83 QuickUnlockConfigureOverlay.dismiss = function() { | 101 QuickUnlockConfigureOverlay.dismiss = function() { |
| 84 PageManager.closeOverlay(); | 102 PageManager.closeOverlay(); |
| 85 }; | 103 }; |
| 86 | 104 |
| 87 // Export | 105 // Export |
| 88 return { | 106 return { |
| 89 QuickUnlockConfigureOverlay: QuickUnlockConfigureOverlay | 107 QuickUnlockConfigureOverlay: QuickUnlockConfigureOverlay |
| 90 }; | 108 }; |
| 91 }); | 109 }); |
| OLD | NEW |