Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / resources / extensions / extensions.js
index ec2d60c..ca186f2 100644 (file)
@@ -2,19 +2,33 @@
 // 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_code.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>
-<include src="extension_loader.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"></include>
+<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;
@@ -66,8 +80,10 @@ cr.define('extensions', function() {
       }
       // 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();
@@ -103,8 +119,7 @@ cr.define('extensions', 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.
@@ -152,6 +167,9 @@ cr.define('extensions', function() {
       extensions.ExtensionErrorOverlay.getInstance().initializePage(
           extensions.ExtensionSettings.showOverlay);
 
+      extensions.ExtensionOptionsOverlay.getInstance().initializePage(
+          extensions.ExtensionSettings.showOverlay);
+
       // Initialize the kiosk overlay.
       if (cr.isChromeOS) {
         var kioskOverlay = extensions.KioskAppsOverlay.getInstance();
@@ -254,7 +272,7 @@ cr.define('extensions', function() {
       } else {
         $('extension-settings').classList.remove('dev-mode');
       }
-      window.setTimeout(this.updatePromoVisibility_.bind(this));
+      window.setTimeout(this.updatePromoVisibility_.bind(this), 0);
 
       chrome.send('extensionSettingsToggleDeveloperMode');
     },
@@ -275,6 +293,7 @@ cr.define('extensions', function() {
   /**
    * 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
@@ -304,12 +323,12 @@ cr.define('extensions', function() {
 
     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;
@@ -338,7 +357,7 @@ cr.define('extensions', function() {
     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
@@ -360,7 +379,7 @@ cr.define('extensions', function() {
         },
         closeAlert);
     ExtensionSettings.showOverlay($('alertOverlay'));
-  }
+  };
 
   /**
    * Returns the current overlay or null if one does not exist.
@@ -368,7 +387,7 @@ cr.define('extensions', function() {
    */
   ExtensionSettings.getCurrentOverlay = function() {
     return document.querySelector('#overlay .page.showing');
-  }
+  };
 
   /**
    * Sets the given overlay to show. This hides whatever overlay is currently
@@ -398,10 +417,10 @@ cr.define('extensions', function() {
       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
@@ -413,12 +432,15 @@ cr.define('extensions', function() {
     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');
@@ -431,7 +453,7 @@ cr.define('extensions', function() {
         '  min-width: ' + pxWidth + 'px;' +
         '}';
     document.querySelector('head').appendChild(style);
-  }
+  };
 
   // Export
   return {