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

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

Issue 1083573002: Revert https://codereview.chromium.org/1060993003 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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
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 <include src="../../../../ui/webui/resources/js/cr/ui/focus_row.js"> 5 <include src="../../../../ui/webui/resources/js/cr/ui/focus_row.js">
6 <include src="../../../../ui/webui/resources/js/cr/ui/focus_grid.js"> 6 <include src="../../../../ui/webui/resources/js/cr/ui/focus_grid.js">
7 <include src="../uber/uber_utils.js"> 7 <include src="../uber/uber_utils.js">
8 <include src="extension_code.js"> 8 <include src="extension_code.js">
9 <include src="extension_commands_overlay.js"> 9 <include src="extension_commands_overlay.js">
10 <include src="extension_error_overlay.js"> 10 <include src="extension_error_overlay.js">
11 <include src="extension_focus_manager.js"> 11 <include src="extension_focus_manager.js">
12 <include src="extension_list.js"> 12 <include src="extension_list.js">
13 <include src="pack_extension_overlay.js"> 13 <include src="pack_extension_overlay.js">
14 <include src="extension_loader.js"> 14 <include src="extension_loader.js">
15 <include src="extension_options_overlay.js"> 15 <include src="extension_options_overlay.js">
16 16
17 <if expr="chromeos"> 17 <if expr="chromeos">
18 <include src="chromeos/kiosk_apps.js"> 18 <include src="chromeos/kiosk_apps.js">
19 </if> 19 </if>
20 20
21 /**
22 * The type of the extension data object. The definition is based on
23 * chrome/browser/ui/webui/extensions/extension_settings_handler.cc:
24 * ExtensionSettingsHandler::HandleRequestExtensionsData()
25 * @typedef {{developerMode: boolean,
26 * enableAppInfoDialog: boolean,
27 * incognitoAvailable: boolean,
28 * loadUnpackedDisabled: boolean,
29 * profileIsSupervised: boolean}}
30 */
31 var ExtensionDataResponse;
32
21 // Used for observing function of the backend datasource for this page by 33 // Used for observing function of the backend datasource for this page by
22 // tests. 34 // tests.
23 var webuiResponded = false; 35 var webuiResponded = false;
24 36
25 cr.define('extensions', function() { 37 cr.define('extensions', function() {
26 var ExtensionList = extensions.ExtensionList; 38 var ExtensionList = extensions.ExtensionList;
27 39
28 // Implements the DragWrapper handler interface. 40 // Implements the DragWrapper handler interface.
29 var dragWrapperHandler = { 41 var dragWrapperHandler = {
30 /** @override */ 42 /** @override */
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 measureCheckboxStrings(); 143 measureCheckboxStrings();
132 144
133 // Set the title. 145 // Set the title.
134 uber.setTitle(loadTimeData.getString('extensionSettings')); 146 uber.setTitle(loadTimeData.getString('extensionSettings'));
135 147
136 var extensionList = new ExtensionList(); 148 var extensionList = new ExtensionList();
137 extensionList.id = 'extension-settings-list'; 149 extensionList.id = 'extension-settings-list';
138 var wrapper = $('extension-list-wrapper'); 150 var wrapper = $('extension-list-wrapper');
139 wrapper.insertBefore(extensionList, wrapper.firstChild); 151 wrapper.insertBefore(extensionList, wrapper.firstChild);
140 152
141 this.update_(); 153 // This will request the data to show on the page and will get a response
142 // TODO(devlin): Remove this once all notifications are moved to events on 154 // back in returnExtensionsData.
143 // the developerPrivate api. 155 chrome.send('extensionSettingsRequestExtensionsData');
144 chrome.send('extensionSettingsRegister');
145 156
146 var extensionLoader = extensions.ExtensionLoader.getInstance(); 157 var extensionLoader = extensions.ExtensionLoader.getInstance();
147 158
148 $('toggle-dev-on').addEventListener('change', function(e) { 159 $('toggle-dev-on').addEventListener('change', function(e) {
149 this.updateDevControlsVisibility_(true); 160 this.updateDevControlsVisibility_(true);
150 extensionList.updateFocusableElements(); 161 extensionList.updateFocusableElements();
151 chrome.developerPrivate.updateProfileConfiguration( 162 chrome.send('extensionSettingsToggleDeveloperMode',
152 {inDeveloperMode: e.target.checked}); 163 [$('toggle-dev-on').checked]);
153 }.bind(this)); 164 }.bind(this));
154 165
155 window.addEventListener('resize', function() { 166 window.addEventListener('resize', function() {
156 this.updateDevControlsVisibility_(false); 167 this.updateDevControlsVisibility_(false);
157 }.bind(this)); 168 }.bind(this));
158 169
159 // Set up the three dev mode buttons (load unpacked, pack and update). 170 // Set up the three dev mode buttons (load unpacked, pack and update).
160 $('load-unpacked').addEventListener('click', function(e) { 171 $('load-unpacked').addEventListener('click', function(e) {
161 extensionLoader.loadUnpacked(); 172 extensionLoader.loadUnpacked();
162 }); 173 });
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 var path = document.location.pathname; 219 var path = document.location.pathname;
209 if (path.length > 1) { 220 if (path.length > 1) {
210 // Skip starting slash and remove trailing slash (if any). 221 // Skip starting slash and remove trailing slash (if any).
211 var overlayName = path.slice(1).replace(/\/$/, ''); 222 var overlayName = path.slice(1).replace(/\/$/, '');
212 if (overlayName == 'configureCommands') 223 if (overlayName == 'configureCommands')
213 this.showExtensionCommandsConfigUi_(); 224 this.showExtensionCommandsConfigUi_();
214 } 225 }
215 }, 226 },
216 227
217 /** 228 /**
218 * Updates the extensions page to the latest profile and extensions
219 * configuration.
220 * @private
221 */
222 update_: function() {
223 chrome.developerPrivate.getProfileConfiguration(
224 this.returnProfileConfiguration_.bind(this));
225 },
226
227 /**
228 * [Re]-Populates the page with data representing the current state of
229 * installed extensions.
230 * @param {ProfileInfo} profileInfo
231 * @private
232 */
233 returnProfileConfiguration_: function(profileInfo) {
234 webuiResponded = true;
235 /** @const */
236 var supervised = profileInfo.isSupervised;
237
238 var pageDiv = $('extension-settings');
239 pageDiv.classList.toggle('profile-is-supervised', supervised);
240 pageDiv.classList.toggle('showing-banner', supervised);
241
242 var devControlsCheckbox = $('toggle-dev-on');
243 devControlsCheckbox.checked = profileInfo.inDeveloperMode;
244 devControlsCheckbox.disabled = supervised;
245
246 this.updateDevControlsVisibility_(false);
247
248 $('load-unpacked').disabled = !profileInfo.canLoadUnpacked;
249 var extensionList = $('extension-settings-list');
250 extensionList.updateExtensionsData(
251 profileInfo.isIncognitoAvailable,
252 profileInfo.appInfoDialogEnabled).then(function() {
253 // We can get called many times in short order, thus we need to
254 // be careful to remove the 'finished loading' timeout.
255 if (this.loadingTimeout_)
256 window.clearTimeout(this.loadingTimeout_);
257 document.documentElement.classList.add('loading');
258 this.loadingTimeout_ = window.setTimeout(function() {
259 document.documentElement.classList.remove('loading');
260 }, 0);
261
262 /** @const */
263 var hasExtensions = extensionList.getNumExtensions() != 0;
264 $('no-extensions').hidden = hasExtensions;
265 $('extension-list-wrapper').hidden = !hasExtensions;
266 $('extension-settings-list').updateFocusableElements();
267 }.bind(this));
268 },
269
270 /**
271 * Handles the Pack Extension button. 229 * Handles the Pack Extension button.
272 * @param {Event} e Change event. 230 * @param {Event} e Change event.
273 * @private 231 * @private
274 */ 232 */
275 handlePackExtension_: function(e) { 233 handlePackExtension_: function(e) {
276 ExtensionSettings.showOverlay($('pack-extension-overlay')); 234 ExtensionSettings.showOverlay($('pack-extension-overlay'));
277 chrome.send('metricsHandler:recordAction', ['Options_PackExtension']); 235 chrome.send('metricsHandler:recordAction', ['Options_PackExtension']);
278 }, 236 },
279 237
280 /** 238 /**
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 }); 284 });
327 buttons.setAttribute('aria-hidden', !showDevControls); 285 buttons.setAttribute('aria-hidden', !showDevControls);
328 286
329 window.requestAnimationFrame(function() { 287 window.requestAnimationFrame(function() {
330 devControls.style.height = !showDevControls ? '' : 288 devControls.style.height = !showDevControls ? '' :
331 buttons.offsetHeight + 'px'; 289 buttons.offsetHeight + 'px';
332 }.bind(this)); 290 }.bind(this));
333 }, 291 },
334 }; 292 };
335 293
336 ExtensionSettings.onExtensionsChanged = function() { 294 /**
337 ExtensionSettings.getInstance().update_(); 295 * Called by the dom_ui_ to re-populate the page with data representing
296 * the current state of installed extensions.
297 * @param {ExtensionDataResponse} extensionsData
298 */
299 ExtensionSettings.returnExtensionsData = function(extensionsData) {
300 webuiResponded = true;
301
302 var supervised = extensionsData.profileIsSupervised;
303
304 var pageDiv = $('extension-settings');
305 pageDiv.classList.toggle('profile-is-supervised', supervised);
306 pageDiv.classList.toggle('showing-banner', supervised);
307
308 var devControlsCheckbox = $('toggle-dev-on');
309 devControlsCheckbox.checked = extensionsData.developerMode;
310 devControlsCheckbox.disabled = supervised;
311
312 ExtensionSettings.getInstance().updateDevControlsVisibility_(false);
313
314 $('load-unpacked').disabled = extensionsData.loadUnpackedDisabled;
315 var extensionList = $('extension-settings-list');
316 extensionList.updateExtensionsData(
317 extensionsData.incognitoAvailable,
318 extensionsData.enableAppInfoDialog).then(function() {
319 // We can get called many times in short order, thus we need to
320 // be careful to remove the 'finished loading' timeout.
321 if (this.loadingTimeout_)
322 window.clearTimeout(this.loadingTimeout_);
323 this.loadingTimeout_ = window.setTimeout(function() {
324 document.documentElement.classList.remove('loading');
325 }, 0);
326
327 var hasExtensions = extensionList.getNumExtensions() != 0;
328 $('no-extensions').hidden = hasExtensions;
329 $('extension-list-wrapper').hidden = !hasExtensions;
330 $('extension-settings-list').updateFocusableElements();
331 }.bind(this));
338 }; 332 };
339 333
340 /** 334 /**
341 * Returns the current overlay or null if one does not exist. 335 * Returns the current overlay or null if one does not exist.
342 * @return {Element} The overlay element. 336 * @return {Element} The overlay element.
343 */ 337 */
344 ExtensionSettings.getCurrentOverlay = function() { 338 ExtensionSettings.getCurrentOverlay = function() {
345 return document.querySelector('#overlay .page.showing'); 339 return document.querySelector('#overlay .page.showing');
346 }; 340 };
347 341
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 // Export 437 // Export
444 return { 438 return {
445 ExtensionSettings: ExtensionSettings 439 ExtensionSettings: ExtensionSettings
446 }; 440 };
447 }); 441 });
448 442
449 window.addEventListener('load', function(e) { 443 window.addEventListener('load', function(e) {
450 document.documentElement.classList.add('loading'); 444 document.documentElement.classList.add('loading');
451 extensions.ExtensionSettings.getInstance().initialize(); 445 extensions.ExtensionSettings.getInstance().initialize();
452 }); 446 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698