Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(90)

Side by Side Diff: chrome/browser/resources/options/chromeos/quick_unlock_configure_overlay.js

Issue 2547273002: Lazy load lock_screen.html in options. (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/resources/options/options.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 * QuickUnlockConfigureOverlay class 10 * QuickUnlockConfigureOverlay class
11 * Dialog that allows users to configure screen lock. 11 * Dialog that allows users to configure screen lock.
12 * @constructor 12 * @constructor
13 * @extends {cr.ui.pageManager.Page} 13 * @extends {cr.ui.pageManager.Page}
14 */ 14 */
15 function QuickUnlockConfigureOverlay() { 15 function QuickUnlockConfigureOverlay() {
16 Page.call(this, 'quickUnlockConfigureOverlay', 16 Page.call(this, 'quickUnlockConfigureOverlay',
17 loadTimeData.getString('lockScreenTitle'), 17 loadTimeData.getString('lockScreenTitle'),
18 'quick-unlock-configure-overlay'); 18 'quick-unlock-configure-overlay');
19 19
20 } 20 }
21 21
22 cr.addSingletonGetter(QuickUnlockConfigureOverlay); 22 cr.addSingletonGetter(QuickUnlockConfigureOverlay);
23 23
24 QuickUnlockConfigureOverlay.prototype = { 24 QuickUnlockConfigureOverlay.prototype = {
25 __proto__: Page.prototype, 25 __proto__: Page.prototype,
26 26
27 /** @private */
28 lazyLoadPolymer_: function() {
29 /** @const */ var idleTimeoutMs = 500;
30 window.requestIdleCallback(
31 this.ensurePolymerIsLoaded_.bind(this, function() {}),
32 { timeout: idleTimeoutMs });
33 },
34
35 /** @private */
36 ensurePolymerIsLoaded_: function(onload) {
37 if (this.loaded_) {
38 onload();
39 return;
40 }
41
42 var link = document.createElement('link');
43 link.setAttribute('rel', 'import');
44 link.setAttribute('href', 'chrome://settings-frame/options_polymer.html');
45 link.onload = function() {
46 this.loaded_ = true;
47 onload();
48 }.bind(this);
49 document.head.appendChild(link);
50 },
51
27 /** @override */ 52 /** @override */
28 initializePage: function() { 53 initializePage: function() {
29 Page.prototype.initializePage.call(this); 54 Page.prototype.initializePage.call(this);
30 $('screen-lock-done').onclick = function() { 55 $('screen-lock-done').onclick = function() {
31 QuickUnlockConfigureOverlay.dismiss(); 56 QuickUnlockConfigureOverlay.dismiss();
32 }; 57 };
58
59 this.lazyLoadPolymer_();
Dan Beam 2016/12/03 02:05:06 i don't think we should load polymer until we actu
33 }, 60 },
34 61
35 /** @override */ 62 /** @override */
36 didClosePage: function() { 63 didClosePage: function() {
37 settings.navigateTo(settings.Route.PEOPLE); 64 settings.navigateTo(settings.Route.PEOPLE);
38 }, 65 },
39 66
40 /** @override */ 67 /** @override */
41 didShowPage: function() { 68 didShowPage: function() {
69 this.ensurePolymerIsLoaded_(this.onDidShowPage_.bind(this));
70 },
71
72 /**
73 * Called when polymer has been loaded and the dialog should be displayed.
74 * @private
75 */
76 onDidShowPage_: function() {
42 settings.navigateTo(settings.Route.LOCK_SCREEN); 77 settings.navigateTo(settings.Route.LOCK_SCREEN);
43 var lockScreen = document.querySelector('settings-lock-screen'); 78 var lockScreen = document.querySelector('settings-lock-screen');
44 79
45 var checkbox = 80 var checkbox =
46 lockScreen.root.querySelector('div.settings-box.single-column'); 81 lockScreen.root.querySelector('div.settings-box.single-column');
47 checkbox.hidden = true; 82 checkbox.hidden = true;
48 83
49 var passwordPrompt = lockScreen.root. 84 var passwordPrompt = lockScreen.root.
50 querySelector('settings-password-prompt-dialog'); 85 querySelector('settings-password-prompt-dialog');
51 passwordPrompt.addEventListener('close', function() { 86 passwordPrompt.addEventListener('close', function() {
52 if (!lockScreen.setModes_) { 87 if (!lockScreen.setModes_) {
53 QuickUnlockConfigureOverlay.dismiss(); 88 QuickUnlockConfigureOverlay.dismiss();
54 } 89 }
55 }.bind(this)); 90 }.bind(this));
56 }, 91 },
57 92
58 }; 93 };
59 94
60 QuickUnlockConfigureOverlay.dismiss = function() { 95 QuickUnlockConfigureOverlay.dismiss = function() {
61 PageManager.closeOverlay(); 96 PageManager.closeOverlay();
62 }; 97 };
63 98
64 // Export 99 // Export
65 return { 100 return {
66 QuickUnlockConfigureOverlay: QuickUnlockConfigureOverlay 101 QuickUnlockConfigureOverlay: QuickUnlockConfigureOverlay
67 }; 102 };
68 }); 103 });
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/resources/options/options.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698