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

Side by Side Diff: chrome/browser/resources/plugins.js

Issue 10010019: JS style nits (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: couple more Created 8 years, 8 months 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
« no previous file with comments | « chrome/browser/resources/flags.js ('k') | chrome/browser/resources/policy.js » ('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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 /** 5 /**
6 * This variable structure is here to document the structure that the template 6 * This variable structure is here to document the structure that the template
7 * expects to correctly populate the page. 7 * expects to correctly populate the page.
8 */ 8 */
9 var pluginDataFormat = { 9 var pluginDataFormat = {
10 'plugins': [ 10 'plugins': [
11 { 11 {
12 'name': 'Group Name', 12 'name': 'Group Name',
13 'description': 'description', 13 'description': 'description',
14 'version': 'version', 14 'version': 'version',
15 'update_url': 'http://update/', 15 'update_url': 'http://update/',
16 'critical': true, 16 'critical': true,
17 'enabled': true, 17 'enabled': true,
18 'plugin_files': [ 18 'plugin_files': [
19 { 19 {
20 'path': '/blahblah/blahblah/MyCrappyPlugin.plugin', 20 'path': '/blahblah/blahblah/MyCrappyPlugin.plugin',
21 'name': 'MyCrappyPlugin', 21 'name': 'MyCrappyPlugin',
22 'version': '1.2.3', 22 'version': '1.2.3',
23 'description': 'My crappy plugin', 23 'description': 'My crappy plugin',
24 'mimeTypes': [ 24 'mimeTypes': [
25 { 'description': 'Foo Media', 25 { 'description': 'Foo Media',
26 'fileExtensions': [ 'foo' ], 26 'fileExtensions': ['foo'],
27 'mimeType': 'application/x-my-foo' }, 27 'mimeType': 'application/x-my-foo' },
28 { 'description': 'Bar Stuff', 28 { 'description': 'Bar Stuff',
29 'fileExtensions': [ 'bar','baz' ], 29 'fileExtensions': ['bar', 'baz'],
30 'mimeType': 'application/my-bar' } 30 'mimeType': 'application/my-bar' }
31 ], 31 ],
32 'enabledMode': 'enabledByUser' 32 'enabledMode': 'enabledByUser'
33 }, 33 },
34 { 34 {
35 'path': '/tmp/MyFirst.plugin', 35 'path': '/tmp/MyFirst.plugin',
36 'name': 'MyFirstPlugin', 36 'name': 'MyFirstPlugin',
37 'version': '3.14r15926', 37 'version': '3.14r15926',
38 'description': 'My first plugin', 38 'description': 'My first plugin',
39 'mimeTypes': [ 39 'mimeTypes': [
40 { 'description': 'New Guy Media', 40 { 'description': 'New Guy Media',
41 'fileExtensions': [ 'mfp' ], 41 'fileExtensions': ['mfp'],
42 'mimeType': 'application/x-my-first' } 42 'mimeType': 'application/x-my-first' }
43 ], 43 ],
44 'enabledMode': 'enabledByPolicy' 44 'enabledMode': 'enabledByPolicy'
45 }, 45 },
46 { 46 {
47 'path': '/foobar/baz/YourGreatPlugin.plugin', 47 'path': '/foobar/baz/YourGreatPlugin.plugin',
48 'name': 'YourGreatPlugin', 48 'name': 'YourGreatPlugin',
49 'version': '4.5', 49 'version': '4.5',
50 'description': 'Your great plugin', 50 'description': 'Your great plugin',
51 'mimeTypes': [ 51 'mimeTypes': [
52 { 'description': 'Baz Stuff', 52 { 'description': 'Baz Stuff',
53 'fileExtensions': [ 'baz' ], 53 'fileExtensions': ['baz'],
54 'mimeType': 'application/x-your-baz' } 54 'mimeType': 'application/x-your-baz' }
55 ], 55 ],
56 'enabledMode': 'disabledByUser' 56 'enabledMode': 'disabledByUser'
57 }, 57 },
58 { 58 {
59 'path': '/foobiz/bar/HisGreatPlugin.plugin', 59 'path': '/foobiz/bar/HisGreatPlugin.plugin',
60 'name': 'HisGreatPlugin', 60 'name': 'HisGreatPlugin',
61 'version': '1.2', 61 'version': '1.2',
62 'description': 'His great plugin', 62 'description': 'His great plugin',
63 'mimeTypes': [ 63 'mimeTypes': [
64 { 'description': 'More baz Stuff', 64 { 'description': 'More baz Stuff',
65 'fileExtensions': [ 'bor' ], 65 'fileExtensions': ['bor'],
66 'mimeType': 'application/x-his-bor' } 66 'mimeType': 'application/x-his-bor' }
67 ], 67 ],
68 'enabledMode': 'disabledByPolicy' 68 'enabledMode': 'disabledByPolicy'
69 } 69 }
70 ] 70 ]
71 } 71 }
72 ] 72 ]
73 }; 73 };
74 74
75 /** 75 /**
76 * Takes the |pluginsData| input argument which represents data about the 76 * Takes the |pluginsData| input argument which represents data about the
77 * currently installed/running plugins and populates the html jstemplate with 77 * currently installed/running plugins and populates the html jstemplate with
78 * that data. It expects an object structure like the above. 78 * that data. It expects an object structure like the above.
79 * @param {Object} pluginsData Detailed info about installed plugins 79 * @param {Object} pluginsData Detailed info about installed plugins
80 */ 80 */
81 function renderTemplate(pluginsData) { 81 function renderTemplate(pluginsData) {
82 // This is the javascript code that processes the template: 82 // This is the javascript code that processes the template:
83 var input = new JsEvalContext(pluginsData); 83 var input = new JsEvalContext(pluginsData);
84 var output = document.getElementById('pluginTemplate'); 84 var output = document.getElementById('pluginTemplate');
85 jstProcess(input, output); 85 jstProcess(input, output);
86 } 86 }
87 87
88 /** 88 /**
89 * Asks the C++ PluginsDOMHandler to get details about the installed plugins and 89 * Asks the C++ PluginsDOMHandler to get details about the installed plugins and
90 * return detailed data about the configuration. The PluginsDOMHandler should 90 * return detailed data about the configuration. The PluginsDOMHandler should
91 * reply to returnPluginsData() (below). 91 * reply to returnPluginsData() (below).
92 */ 92 */
93 function requestPluginsData() { 93 function requestPluginsData() {
94 chrome.send('requestPluginsData', []); 94 chrome.send('requestPluginsData');
95 chrome.send('getShowDetails', []); 95 chrome.send('getShowDetails');
96 } 96 }
97 97
98 function loadShowDetailsFromPrefs(show_details) { 98 function loadShowDetailsFromPrefs(show_details) {
99 tmiModeExpanded = show_details; 99 tmiModeExpanded = show_details;
100 document.getElementById('collapse').style.display = 100 document.getElementById('collapse').style.display =
101 show_details ? 'inline' : 'none'; 101 show_details ? 'inline' : 'none';
102 document.getElementById('expand').style.display = 102 document.getElementById('expand').style.display =
103 show_details ? 'none' : 'inline'; 103 show_details ? 'none' : 'inline';
104 104
105 document.body.className = show_details ? 'show-tmi-mode' : 'hide-tmi-mode'; 105 document.body.className = show_details ? 'show-tmi-mode' : 'hide-tmi-mode';
106 } 106 }
107 107
108 /** 108 /**
109 * Called by the web_ui_ to re-populate the page with data representing the 109 * Called by the web_ui_ to re-populate the page with data representing the
110 * current state of installed plugins. 110 * current state of installed plugins.
111 */ 111 */
112 function returnPluginsData(pluginsData){ 112 function returnPluginsData(pluginsData) {
113 var bodyContainer = document.getElementById('body-container'); 113 var bodyContainer = document.getElementById('body-container');
114 var body = document.body; 114 var body = document.body;
115 115
116 // Set all page content to be visible so we can measure heights. 116 // Set all page content to be visible so we can measure heights.
117 bodyContainer.style.visibility = 'hidden'; 117 bodyContainer.style.visibility = 'hidden';
118 body.className = ''; 118 body.className = '';
119 var slidables = document.getElementsByClassName('show-in-tmi-mode'); 119 var slidables = document.getElementsByClassName('show-in-tmi-mode');
120 for (var i = 0; i < slidables.length; i++) 120 for (var i = 0; i < slidables.length; i++)
121 slidables[i].style.height = 'auto'; 121 slidables[i].style.height = 'auto';
122 122
123 renderTemplate(pluginsData); 123 renderTemplate(pluginsData);
124 124
125 // Add handlers to dynamically created HTML elements. 125 // Add handlers to dynamically created HTML elements.
126 var links = document.getElementsByClassName('disable-plugin-link'); 126 var links = document.getElementsByClassName('disable-plugin-link');
127 for (var i = 0; i < links.length; i++) { 127 for (var i = 0; i < links.length; i++) {
128 links[i].onclick = function () { 128 links[i].onclick = function() {
129 handleEnablePlugin(this, false, false); 129 handleEnablePlugin(this, false, false);
130 return false; 130 return false;
131 }; 131 };
132 } 132 }
133 links = document.getElementsByClassName('enable-plugin-link'); 133 links = document.getElementsByClassName('enable-plugin-link');
134 for (var i = 0; i < links.length; i++) { 134 for (var i = 0; i < links.length; i++) {
135 links[i].onclick = function () { 135 links[i].onclick = function() {
136 handleEnablePlugin(this, true, false); 136 handleEnablePlugin(this, true, false);
137 return false; 137 return false;
138 }; 138 };
139 } 139 }
140 links = document.getElementsByClassName('disable-group-link'); 140 links = document.getElementsByClassName('disable-group-link');
141 for (var i = 0; i < links.length; i++) { 141 for (var i = 0; i < links.length; i++) {
142 links[i].onclick = function () { 142 links[i].onclick = function() {
143 handleEnablePlugin(this, false, true); 143 handleEnablePlugin(this, false, true);
144 return false; 144 return false;
145 }; 145 };
146 } 146 }
147 links = document.getElementsByClassName('enable-group-link'); 147 links = document.getElementsByClassName('enable-group-link');
148 for (var i = 0; i < links.length; i++) { 148 for (var i = 0; i < links.length; i++) {
149 links[i].onclick = function () { 149 links[i].onclick = function() {
150 handleEnablePlugin(this, true, true); 150 handleEnablePlugin(this, true, true);
151 return false; 151 return false;
152 }; 152 };
153 } 153 }
154 var checkboxes = document.getElementsByClassName('always-allow'); 154 var checkboxes = document.getElementsByClassName('always-allow');
155 for (var i = 0; i < checkboxes.length; i++) { 155 for (var i = 0; i < checkboxes.length; i++) {
156 checkboxes[i].onclick = function () { 156 checkboxes[i].onclick = function() {
157 handleSetPluginAlwaysAllowed(this) 157 handleSetPluginAlwaysAllowed(this);
158 }; 158 };
159 }; 159 }
160 160
161 // Make sure the left column (with "Description:", "Location:", etc.) is the 161 // Make sure the left column (with "Description:", "Location:", etc.) is the
162 // same size for all plugins. 162 // same size for all plugins.
163 var labels = document.getElementsByClassName('plugin-details-label'); 163 var labels = document.getElementsByClassName('plugin-details-label');
164 var maxLabelWidth = 0; 164 var maxLabelWidth = 0;
165 for (var i = 0; i < labels.length; i++) 165 for (var i = 0; i < labels.length; i++)
166 labels[i].style.width = 'auto'; 166 labels[i].style.width = 'auto';
167 for (var i = 0; i < labels.length; i++) 167 for (var i = 0; i < labels.length; i++)
168 maxLabelWidth = Math.max(maxLabelWidth, labels[i].offsetWidth); 168 maxLabelWidth = Math.max(maxLabelWidth, labels[i].offsetWidth);
169 for (var i = 0; i < labels.length; i++) 169 for (var i = 0; i < labels.length; i++)
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 // (yet), so in the meanwhile just update regularly. 250 // (yet), so in the meanwhile just update regularly.
251 setInterval(requestPluginsData, 30000); 251 setInterval(requestPluginsData, 30000);
252 252
253 // Get data and have it displayed upon loading. 253 // Get data and have it displayed upon loading.
254 document.addEventListener('DOMContentLoaded', requestPluginsData); 254 document.addEventListener('DOMContentLoaded', requestPluginsData);
255 255
256 // Add handlers to static HTML elements. 256 // Add handlers to static HTML elements.
257 document.getElementById('collapse').onclick = toggleTmiMode; 257 document.getElementById('collapse').onclick = toggleTmiMode;
258 document.getElementById('expand').onclick = toggleTmiMode; 258 document.getElementById('expand').onclick = toggleTmiMode;
259 document.getElementById('details-link').onclick = toggleTmiMode; 259 document.getElementById('details-link').onclick = toggleTmiMode;
260
OLDNEW
« no previous file with comments | « chrome/browser/resources/flags.js ('k') | chrome/browser/resources/policy.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698