Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / resources / options / controlled_setting.js
index 17048d4..df428fa 100644 (file)
@@ -10,7 +10,7 @@ cr.define('options', function() {
    * indicator that the value is controlled by some external entity such as
    * policy or an extension.
    * @constructor
-   * @extends {HTMLSpanElement}
+   * @extends {cr.ui.BubbleButton}
    */
   var ControlledSettingIndicator = cr.ui.define('span');
 
@@ -51,29 +51,20 @@ cr.define('options', function() {
       Preferences.clearPref(this.pref, !this.dialogPref);
     },
 
-    /* Handle changes to the associated pref by hiding any currently visible
+    /**
+     * Handle changes to the associated pref by hiding any currently visible
      * bubble and updating the controlledBy property.
      * @param {Event} event Pref change event.
      */
     handlePrefChange: function(event) {
-      OptionsPage.hideBubble();
+      PageManager.hideBubble();
       if (event.value.controlledBy) {
         if (!this.value || String(event.value.value) == this.value) {
           this.controlledBy = event.value.controlledBy;
           if (event.value.extension) {
-            if (this.pref == 'session.restore_on_startup' ||
-                this.pref == 'homepage_is_newtabpage') {
-              // Special case for the restore on startup, which is implied
-              // by the startup pages settings being controlled by an
-              // extension, and same for the home page as NTP, so we don't want
-              // to show two buttons in these cases.
-              // TODO(mad): Find a better way to handle this.
-              this.controlledBy = null;
-            } else {
-              this.extensionId = event.value.extension.id;
-              this.extensionIcon = event.value.extension.icon;
-              this.extensionName = event.value.extension.name;
-            }
+            this.extensionId = event.value.extension.id;
+            this.extensionIcon = event.value.extension.icon;
+            this.extensionName = event.value.extension.name;
           }
         } else {
           this.controlledBy = null;
@@ -89,11 +80,11 @@ cr.define('options', function() {
 
     /**
      * Open or close a bubble with further information about the pref.
-     * @private
+     * @override
      */
-    toggleBubble_: function() {
+    toggleBubble: function() {
       if (this.showingBubble) {
-        OptionsPage.hideBubble();
+        PageManager.hideBubble();
       } else {
         var self = this;
 
@@ -142,6 +133,7 @@ cr.define('options', function() {
 
         // Create the DOM tree.
         var content = document.createElement('div');
+        content.classList.add('controlled-setting-bubble-header');
         content.textContent = text;
 
         if (this.controlledBy == 'hasRecommendation' && this.resetHandler_ &&
@@ -173,27 +165,28 @@ cr.define('options', function() {
 
           var manageLink = extensionContainer.querySelector(
               '.controlled-setting-bubble-extension-manage-link');
+          var extensionId = this.extensionId;
           manageLink.onclick = function() {
             uber.invokeMethodOnWindow(
-                window.top, 'showPage', {pageId: 'extensions'});
+                window.top, 'showPage', {pageId: 'extensions',
+                                         path: '?id=' + extensionId});
           };
 
-          var disableButton = extensionContainer.querySelector('button');
-          var extensionId = this.extensionId;
+          var disableButton = extensionContainer.querySelector(
+              '.controlled-setting-bubble-extension-disable-button');
           disableButton.onclick = function() {
             chrome.send('disableExtension', [extensionId]);
           };
           content.appendChild(extensionContainer);
         }
 
-        OptionsPage.showBubble(content, this.image, this, this.location);
+        PageManager.showBubble(content, this.image, this, this.location);
       }
     },
   };
 
   /**
    * The name of the associated preference.
-   * @type {string}
    */
   cr.defineProperty(ControlledSettingIndicator, 'pref', cr.PropertyKind.ATTR);
 
@@ -203,7 +196,6 @@ cr.define('options', function() {
    * only actually committed when the user confirms the dialog. If the user
    * cancels the dialog instead, the changes are rolled back in the settings UI
    * and never committed.
-   * @type {boolean}
    */
   cr.defineProperty(ControlledSettingIndicator, 'dialogPref',
                     cr.PropertyKind.BOOL_ATTR);
@@ -221,7 +213,7 @@ cr.define('options', function() {
 
   /**
    * The status of the associated preference:
-   * - 'policy':            A specific value is enfoced by policy.
+   * - 'policy':            A specific value is enforced by policy.
    * - 'extension':         A specific value is enforced by an extension.
    * - 'recommended':       A value is recommended by policy. The user could
    *                        override this recommendation but has not done so.
@@ -232,7 +224,6 @@ cr.define('options', function() {
    * - 'shared':            A value belongs to the primary user but can be
    *                        modified (Chrome OS only).
    * - unset:               The value is controlled by the user alone.
-   * @type {string}
    */
   cr.defineProperty(ControlledSettingIndicator, 'controlledBy',
                     cr.PropertyKind.ATTR);