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

Side by Side Diff: chrome/browser/resources/task_manager/includes.js

Issue 8993007: WebUI TaskManager: Delay scripts loading. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 // This script includes additional resources via document.write(). Hence, it 5 // This script includes additional resources via document.write(). Hence, it
6 // must be a separate script file loaded before other scripts which would 6 // must be a separate script file loaded before other scripts which would
7 // reference the resources. 7 // reference the resources.
8 8
9 var css = [ 9 var css = [
10 'chrome_shared.css', 10 'chrome_shared.css',
(...skipping 21 matching lines...) Expand all
32 'cr/ui/splitter.js', 32 'cr/ui/splitter.js',
33 'cr/ui/table/table_splitter.js', 33 'cr/ui/table/table_splitter.js',
34 34
35 'cr/ui/table/table_column.js', 35 'cr/ui/table/table_column.js',
36 'cr/ui/table/table_column_model.js', 36 'cr/ui/table/table_column_model.js',
37 'cr/ui/table/table_header.js', 37 'cr/ui/table/table_header.js',
38 'cr/ui/table/table_list.js', 38 'cr/ui/table/table_list.js',
39 'cr/ui/table.js', 39 'cr/ui/table.js',
40 40
41 'cr/ui/grid.js', 41 'cr/ui/grid.js',
42 ];
42 43
44 var scriptDelayed = [
43 'cr/ui/command.js', 45 'cr/ui/command.js',
44 'cr/ui/position_util.js', 46 'cr/ui/position_util.js',
45 'cr/ui/menu_item.js', 47 'cr/ui/menu_item.js',
46 'cr/ui/menu.js', 48 'cr/ui/menu.js',
47 'cr/ui/context_menu_handler.js', 49 'cr/ui/context_menu_handler.js',
48 ]; 50 ];
49 51
52 var loadDelayedIncludes;
James Hawkins 2011/12/19 18:35:56 Why is this here?
yoshiki 2011/12/20 15:18:25 This variable will be set in the function below, t
53
50 (function() { 54 (function() {
51 // Switch to 'test harness' mode when loading from a file url. 55 // Switch to 'test harness' mode when loading from a file url.
52 var isHarness = document.location.protocol == 'file:'; 56 var isHarness = document.location.protocol == 'file:';
53 57
54 // In test harness mode we load resources from relative dirs. 58 // In test harness mode we load resources from relative dirs.
55 var prefix = isHarness ? './shared/' : 'chrome://resources/'; 59 var prefix = isHarness ? './shared/' : 'chrome://resources/';
56 60
57 for (var i = 0; i < css.length; ++i) { 61 for (var i = 0; i < css.length; ++i) {
58 document.write('<link href="' + prefix + 'css/' + css[i] + 62 document.write('<link href="' + prefix + 'css/' + css[i] +
59 '" rel="stylesheet"></link>'); 63 '" rel="stylesheet"></link>');
60 } 64 }
61 65
62 for (var i = 0; i < script.length; ++i) { 66 for (var i = 0; i < script.length; ++i) {
63 document.write('<script src="' + prefix + 'js/' + script[i] + 67 document.write('<script src="' + prefix + 'js/' + script[i] +
64 '"><\/script>'); 68 '"><\/script>');
65 } 69 }
70
71 /**
72 * Loads delayed scripts.
73 * This function is called by TaskManager::initalize() in main.js.
74 */
75 loadDelayedIncludes = function (taskmanager) {
76 // Number of remaining scripts to load.
77 var remain = scriptDelayed.length;
78
79 // Waits for initialization of task manager.
80 for (var i = 0; i < scriptDelayed.length; ++i) {
81 var s = document.createElement('script');
82 s.onload = function(e) {
83 if (!--remain)
84 taskmanager.delayedInitialize();
85 };
86 s.type = 'text/javascript';
87 s.src = prefix + 'js/' + scriptDelayed[i];
88 document.body.appendChild(s);
89 }
90 };
66 })(); 91 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698