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

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

Issue 10006028: Plugins page in BWSI session has unnecessary and misleading UI components (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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
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 = $('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 $('collapse').style.display =
101 show_details ? 'inline' : 'none'; 101 show_details ? 'inline' : 'none';
102 document.getElementById('expand').style.display = 102 $('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 = $('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
161 // Disable some controls for Guest in ChromeOS.
162 if (cr.isChromeOS)
163 uiAccountTweaks.UIAccountTweaks.applyGuestModeVisibility(document);
160 164
161 // Make sure the left column (with "Description:", "Location:", etc.) is the 165 // Make sure the left column (with "Description:", "Location:", etc.) is the
162 // same size for all plugins. 166 // same size for all plugins.
163 var labels = document.getElementsByClassName('plugin-details-label'); 167 var labels = document.getElementsByClassName('plugin-details-label');
164 var maxLabelWidth = 0; 168 var maxLabelWidth = 0;
165 for (var i = 0; i < labels.length; i++) 169 for (var i = 0; i < labels.length; i++)
166 labels[i].style.width = 'auto'; 170 labels[i].style.width = 'auto';
167 for (var i = 0; i < labels.length; i++) 171 for (var i = 0; i < labels.length; i++)
168 maxLabelWidth = Math.max(maxLabelWidth, labels[i].offsetWidth); 172 maxLabelWidth = Math.max(maxLabelWidth, labels[i].offsetWidth);
169 for (var i = 0; i < labels.length; i++) 173 for (var i = 0; i < labels.length; i++)
170 labels[i].style.width = maxLabelWidth + 'px'; 174 labels[i].style.width = maxLabelWidth + 'px';
171 175
172 // Explicitly set the height for each element that wants to be "slid" in and 176 // Explicitly set the height for each element that wants to be "slid" in and
173 // out when the tmiModeExpanded is toggled. 177 // out when the tmiModeExpanded is toggled.
174 var slidables = document.getElementsByClassName('show-in-tmi-mode'); 178 var slidables = document.getElementsByClassName('show-in-tmi-mode');
175 for (var i = 0; i < slidables.length; i++) 179 for (var i = 0; i < slidables.length; i++)
176 slidables[i].style.height = slidables[i].offsetHeight + 'px'; 180 slidables[i].style.height = slidables[i].offsetHeight + 'px';
177 181
178 // Reset visibility of page based on the current tmi mode. 182 // Reset visibility of page based on the current tmi mode.
179 document.getElementById('collapse').style.display = 183 $('collapse').style.display =
180 tmiModeExpanded ? 'inline' : 'none'; 184 tmiModeExpanded ? 'inline' : 'none';
181 document.getElementById('expand').style.display = 185 $('expand').style.display =
182 tmiModeExpanded ? 'none' : 'inline'; 186 tmiModeExpanded ? 'none' : 'inline';
183 bodyContainer.style.visibility = 'visible'; 187 bodyContainer.style.visibility = 'visible';
184 body.className = tmiModeExpanded ? 188 body.className = tmiModeExpanded ?
185 'show-tmi-mode-initial' : 'hide-tmi-mode-initial'; 189 'show-tmi-mode-initial' : 'hide-tmi-mode-initial';
186 } 190 }
187 191
188 /** 192 /**
189 * Handles a 'enable' or 'disable' button getting clicked. 193 * Handles a 'enable' or 'disable' button getting clicked.
190 */ 194 */
191 function handleEnablePlugin(node, enable, isGroup) { 195 function handleEnablePlugin(node, enable, isGroup) {
192 // Tell the C++ PluginsDOMHandler to enable/disable the plugin. 196 // Tell the C++ PluginsDOMHandler to enable/disable the plugin.
193 chrome.send('enablePlugin', [String(node.path), String(enable), 197 chrome.send('enablePlugin', [String(node.path), String(enable),
194 String(isGroup)]); 198 String(isGroup)]);
195 } 199 }
196 200
197 // Keeps track of whether details have been made visible (expanded) or not. 201 // Keeps track of whether details have been made visible (expanded) or not.
198 var tmiModeExpanded = false; 202 var tmiModeExpanded = false;
199 203
200 /* 204 /*
201 * Toggles visibility of details. 205 * Toggles visibility of details.
202 */ 206 */
203 function toggleTmiMode() { 207 function toggleTmiMode() {
204 tmiModeExpanded = !tmiModeExpanded; 208 tmiModeExpanded = !tmiModeExpanded;
205 209
206 document.getElementById('collapse').style.display = 210 $('collapse').style.display =
207 tmiModeExpanded ? 'inline' : 'none'; 211 tmiModeExpanded ? 'inline' : 'none';
208 document.getElementById('expand').style.display = 212 $('expand').style.display =
209 tmiModeExpanded ? 'none' : 'inline'; 213 tmiModeExpanded ? 'none' : 'inline';
210 214
211 document.body.className = 215 document.body.className =
212 tmiModeExpanded ? 'show-tmi-mode' : 'hide-tmi-mode'; 216 tmiModeExpanded ? 'show-tmi-mode' : 'hide-tmi-mode';
213 217
214 chrome.send('saveShowDetailsToPrefs', [String(tmiModeExpanded)]); 218 chrome.send('saveShowDetailsToPrefs', [String(tmiModeExpanded)]);
215 } 219 }
216 220
217 function handleSetPluginAlwaysAllowed(el) { 221 function handleSetPluginAlwaysAllowed(el) {
218 chrome.send('setPluginAlwaysAllowed', [el.identifier, el.checked]); 222 chrome.send('setPluginAlwaysAllowed', [el.identifier, el.checked]);
(...skipping 28 matching lines...) Expand all
247 } 251 }
248 252
249 // Unfortunately, we don't have notifications for plugin (list) status changes 253 // Unfortunately, we don't have notifications for plugin (list) status changes
250 // (yet), so in the meanwhile just update regularly. 254 // (yet), so in the meanwhile just update regularly.
251 setInterval(requestPluginsData, 30000); 255 setInterval(requestPluginsData, 30000);
252 256
253 // Get data and have it displayed upon loading. 257 // Get data and have it displayed upon loading.
254 document.addEventListener('DOMContentLoaded', requestPluginsData); 258 document.addEventListener('DOMContentLoaded', requestPluginsData);
255 259
256 // Add handlers to static HTML elements. 260 // Add handlers to static HTML elements.
257 document.getElementById('collapse').onclick = toggleTmiMode; 261 $('collapse').onclick = toggleTmiMode;
258 document.getElementById('expand').onclick = toggleTmiMode; 262 $('expand').onclick = toggleTmiMode;
259 document.getElementById('details-link').onclick = toggleTmiMode; 263 $('details-link').onclick = toggleTmiMode;
260 264
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698