// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-<include src="../uber/uber_utils.js"></include>
-<include src="extension_commands_overlay.js"></include>
-<include src="extension_focus_manager.js"></include>
-<include src="extension_list.js"></include>
-<include src="pack_extension_overlay.js"></include>
-<include src="extension_error_overlay.js"></include>
-
-<if expr="pp_ifdef('chromeos')">
-<include src="chromeos/kiosk_apps.js"></include>
+<include src="../uber/uber_utils.js">
+<include src="extension_code.js">
+<include src="extension_commands_overlay.js">
+<include src="extension_error_overlay.js">
+<include src="extension_focus_manager.js">
+<include src="extension_list.js">
+<include src="pack_extension_overlay.js">
+<include src="extension_loader.js">
+<include src="extension_options_overlay.js">
+
+<if expr="chromeos">
+<include src="chromeos/kiosk_apps.js">
</if>
+/**
+ * The type of the extension data object. The definition is based on
+ * chrome/browser/ui/webui/extensions/extension_settings_handler.cc:
+ * ExtensionSettingsHandler::HandleRequestExtensionsData()
+ * @typedef {{developerMode: boolean,
+ * extensions: Array,
+ * incognitoAvailable: boolean,
+ * loadUnpackedDisabled: boolean,
+ * profileIsSupervised: boolean,
+ * promoteAppsDevTools: boolean}}
+ */
+var ExtensionDataResponse;
+
// Used for observing function of the backend datasource for this page by
// tests.
var webuiResponded = false;
}
// Only process files that look like extensions. Other files should
// navigate the browser normally.
- if (!toSend && /\.(crx|user\.js)$/i.test(e.dataTransfer.files[0].name))
+ if (!toSend &&
+ /\.(crx|user\.js|zip)$/i.test(e.dataTransfer.files[0].name)) {
toSend = 'installDroppedFile';
+ }
if (toSend) {
e.preventDefault();
__proto__: HTMLDivElement.prototype,
/**
+ * Whether or not to try to display the Apps Developer Tools promotion.
+ * @type {boolean}
+ * @private
+ */
+ displayPromo_: false,
+
+ /**
* Perform initial setup.
*/
initialize: function() {
measureCheckboxStrings();
// Set the title.
- var title = loadTimeData.getString('extensionSettings');
- uber.invokeMethodOnParent('setTitle', {title: title});
+ uber.setTitle(loadTimeData.getString('extensionSettings'));
// This will request the data to show on the page and will get a response
// back in returnExtensionsData.
chrome.send('extensionSettingsRequestExtensionsData');
+ var extensionLoader = extensions.ExtensionLoader.getInstance();
+
$('toggle-dev-on').addEventListener('change',
this.handleToggleDevMode_.bind(this));
$('dev-controls').addEventListener('webkitTransitionEnd',
this.handleDevControlsTransitionEnd_.bind(this));
// Set up the three dev mode buttons (load unpacked, pack and update).
- $('load-unpacked').addEventListener('click',
- this.handleLoadUnpackedExtension_.bind(this));
+ $('load-unpacked').addEventListener('click', function(e) {
+ extensionLoader.loadUnpacked();
+ });
$('pack-extension').addEventListener('click',
this.handlePackExtension_.bind(this));
$('update-extensions-now').addEventListener('click',
this.handleUpdateExtensionNow_.bind(this));
+ // Set up the close dialog for the apps developer tools promo.
+ $('apps-developer-tools-promo').querySelector('.close-button').
+ addEventListener('click', function(e) {
+ this.displayPromo_ = false;
+ this.updatePromoVisibility_();
+ chrome.send('extensionSettingsDismissADTPromo');
+ }.bind(this));
+
if (!loadTimeData.getBoolean('offStoreInstallEnabled')) {
this.dragWrapper_ = new cr.ui.DragWrapper(document.documentElement,
dragWrapperHandler);
// Initialize the Commands overlay.
extensions.ExtensionCommandsOverlay.getInstance().initializePage();
- extensions.ExtensionErrorOverlay.getInstance().initializePage();
+ extensions.ExtensionErrorOverlay.getInstance().initializePage(
+ extensions.ExtensionSettings.showOverlay);
+
+ extensions.ExtensionOptionsOverlay.getInstance().initializePage(
+ extensions.ExtensionSettings.showOverlay);
// Initialize the kiosk overlay.
if (cr.isChromeOS) {
},
/**
- * Handles the Load Unpacked Extension button.
- * @param {Event} e Change event.
+ * Updates the Chrome Apps and Extensions Developer Tools promotion's
+ * visibility.
* @private
*/
- handleLoadUnpackedExtension_: function(e) {
- chrome.send('extensionSettingsLoadUnpackedExtension');
+ updatePromoVisibility_: function() {
+ var extensionSettings = $('extension-settings');
+ var visible = extensionSettings.classList.contains('dev-mode') &&
+ this.displayPromo_;
+
+ var adtPromo = $('apps-developer-tools-promo');
+ var controls = adtPromo.querySelectorAll('a, button');
+ Array.prototype.forEach.call(controls, function(control) {
+ control[visible ? 'removeAttribute' : 'setAttribute']('tabindex', '-1');
+ });
+
+ adtPromo.setAttribute('aria-hidden', !visible);
+ extensionSettings.classList.toggle('adt-promo', visible);
},
/**
} else {
$('extension-settings').classList.remove('dev-mode');
}
+ window.setTimeout(this.updatePromoVisibility_.bind(this), 0);
chrome.send('extensionSettingsToggleDeveloperMode');
},
/**
* Called by the dom_ui_ to re-populate the page with data representing
* the current state of installed extensions.
+ * @param {ExtensionDataResponse} extensionsData
*/
ExtensionSettings.returnExtensionsData = function(extensionsData) {
// We can get called many times in short order, thus we need to
var pageDiv = $('extension-settings');
var marginTop = 0;
- if (extensionsData.profileIsManaged) {
- pageDiv.classList.add('profile-is-managed');
+ if (extensionsData.profileIsSupervised) {
+ pageDiv.classList.add('profile-is-supervised');
} else {
- pageDiv.classList.remove('profile-is-managed');
+ pageDiv.classList.remove('profile-is-supervised');
}
- if (extensionsData.profileIsManaged) {
+ if (extensionsData.profileIsSupervised) {
pageDiv.classList.add('showing-banner');
$('toggle-dev-on').disabled = true;
marginTop += 45;
$('toggle-dev-on').checked = false;
}
+ ExtensionSettings.getInstance().displayPromo_ =
+ extensionsData.promoteAppsDevTools;
+ ExtensionSettings.getInstance().updatePromoVisibility_();
+
$('load-unpacked').disabled = extensionsData.loadUnpackedDisabled;
ExtensionsList.prototype.data_ = extensionsData;
var extensionList = $('extension-settings-list');
ExtensionsList.decorate(extensionList);
- }
+ };
// Indicate that warning |message| has occured for pack of |crx_path| and
// |pem_path| files. Ask if user wants override the warning. Send
},
closeAlert);
ExtensionSettings.showOverlay($('alertOverlay'));
- }
+ };
/**
* Returns the current overlay or null if one does not exist.
*/
ExtensionSettings.getCurrentOverlay = function() {
return document.querySelector('#overlay .page.showing');
- }
+ };
/**
* Sets the given overlay to show. This hides whatever overlay is currently
pages[i].setAttribute('aria-hidden', node ? 'true' : 'false');
}
- overlay.hidden = !node;
+ $('overlay').hidden = !node;
uber.invokeMethodOnParent(node ? 'beginInterceptingEvents' :
'stopInterceptingEvents');
- }
+ };
/**
* Utility function to find the width of various UI strings and synchronize
var measuringDiv = $('font-measuring-div');
measuringDiv.textContent =
loadTimeData.getString('extensionSettingsEnabled');
+ measuringDiv.className = 'enabled-text';
var pxWidth = measuringDiv.clientWidth + trashWidth;
measuringDiv.textContent =
loadTimeData.getString('extensionSettingsEnable');
+ measuringDiv.className = 'enable-text';
pxWidth = Math.max(measuringDiv.clientWidth + trashWidth, pxWidth);
measuringDiv.textContent =
loadTimeData.getString('extensionSettingsDeveloperMode');
+ measuringDiv.className = '';
pxWidth = Math.max(measuringDiv.clientWidth, pxWidth);
var style = document.createElement('style');
' min-width: ' + pxWidth + 'px;' +
'}';
document.querySelector('head').appendChild(style);
- }
+ };
// Export
return {