Bug 719717 - Move the tabs preferences to in-content UI. r=bmcbride
authorOwen Carpenter <owenccarpenter@gmail.com>
Tue, 08 May 2012 19:15:13 -0700
changeset 93575 c14a9f3448da84e456a71cd7920ac737d8c9527a
parent 93574 c9262b622112c8f9cb4165c64aa7789040914dec
child 93576 d849b7493ea2348c99fc7582e3d6950ca6125fdf
push id9210
push userjwein@mozilla.com
push dateWed, 09 May 2012 05:35:43 +0000
treeherdermozilla-inbound@8b195889f55c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbmcbride
bugs719717
milestone15.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 719717 - Move the tabs preferences to in-content UI. r=bmcbride
browser/components/preferences/in-content/jar.mn
browser/components/preferences/in-content/preferences.js
browser/components/preferences/in-content/preferences.xul
browser/components/preferences/in-content/tabs.js
browser/components/preferences/in-content/tabs.xul
--- a/browser/components/preferences/in-content/jar.mn
+++ b/browser/components/preferences/in-content/jar.mn
@@ -1,6 +1,8 @@
 browser.jar:
 *  content/browser/preferences/in-content/preferences.js
    content/browser/preferences/in-content/landing.xul
 *  content/browser/preferences/in-content/preferences.xul
 *  content/browser/preferences/in-content/main.xul
    content/browser/preferences/in-content/main.js
+*  content/browser/preferences/in-content/tabs.xul
+*  content/browser/preferences/in-content/tabs.js
--- a/browser/components/preferences/in-content/preferences.js
+++ b/browser/components/preferences/in-content/preferences.js
@@ -13,16 +13,19 @@ Cu.import("resource://gre/modules/XPCOMU
 Cu.import("resource://gre/modules/Services.jsm");
 
 function init_all() {
   document.documentElement.instantApply = true;
   window.history.replaceState("landing", document.title);
   window.addEventListener("popstate", onStatePopped, true);
   updateCommands();
   gMainPane.init();
+#ifdef XP_WIN
+  gTabsPane.init();
+#endif
   var initFinished = document.createEvent("Event");
   initFinished.initEvent("Initialized", true, true);
   document.dispatchEvent(initFinished);
 }
 
 function gotoPref(page) {
   search(page, "data-category");
   window.history.pushState(page, document.title);
--- a/browser/components/preferences/in-content/preferences.xul
+++ b/browser/components/preferences/in-content/preferences.xul
@@ -86,12 +86,13 @@
                    oncommand="cmd_forward()" tooltiptext="&buttonForward.tooltip;"
                    disabled="true"/>
   </hbox>
   
   <hbox class="main-content" flex="1">
     <prefpane flex="1" id="mainPrefPane">
 #include landing.xul
 #include main.xul
+#include tabs.xul
     </prefpane>
   </hbox>
   
 </page>
new file mode 100644
--- /dev/null
+++ b/browser/components/preferences/in-content/tabs.js
@@ -0,0 +1,66 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+var gTabsPane = {
+
+  /*
+   * Preferences:
+   *
+   * browser.link.open_newwindow
+   * - determines where pages which would open in a new window are opened:
+   *     1 opens such links in the most recent window or tab,
+   *     2 opens such links in a new window,
+   *     3 opens such links in a new tab
+   * browser.tabs.autoHide
+   * - true if the tab bar is hidden when only one tab is open, false to always
+   *   show it
+   * browser.tabs.loadInBackground
+   * - true if display should switch to a new tab which has been opened from a
+   *   link, false if display shouldn't switch
+   * browser.tabs.warnOnClose
+   * - true if when closing a window with multiple tabs the user is warned and
+   *   allowed to cancel the action, false to just close the window
+   * browser.tabs.warnOnOpen
+   * - true if the user should be warned if he attempts to open a lot of tabs at
+   *   once (e.g. a large folder of bookmarks), false otherwise
+   * browser.taskbar.previews.enable
+   * - true if tabs are to be shown in the Windows 7 taskbar
+   */
+
+#ifdef XP_WIN
+  /**
+   * Initialize any platform-specific UI.
+   */
+  init: function () {
+    try {
+      let sysInfo = Cc["@mozilla.org/system-info;1"].
+                    getService(Ci.nsIPropertyBag2);
+      let ver = parseFloat(sysInfo.getProperty("version"));
+      let showTabsInTaskbar = document.getElementById("showTabsInTaskbar");
+      showTabsInTaskbar.hidden = ver < 6.1 || (ver >= 6.1 && history.state != "tabs");
+    } catch (ex) {}
+  },
+#endif
+
+  /**
+   * Determines where a link which opens a new window will open.
+   *
+   * @returns |true| if such links should be opened in new tabs
+   */
+  readLinkTarget: function() {
+    var openNewWindow = document.getElementById("browser.link.open_newwindow");
+    return openNewWindow.value != 2;
+  },
+
+  /**
+   * Determines where a link which opens a new window will open.
+   *
+   * @returns 2 if such links should be opened in new windows,
+   *          3 if such links should be opened in new tabs
+   */
+  writeLinkTarget: function() {
+    var linkTargeting = document.getElementById("linkTargeting");
+    return linkTargeting.checked ? 3 : 2;
+  }
+};
new file mode 100644
--- /dev/null
+++ b/browser/components/preferences/in-content/tabs.xul
@@ -0,0 +1,76 @@
+<!-- This Source Code Form is subject to the terms of the Mozilla Public License,
+   - v. 2.0. If a copy of the MPL was not distributed with this file,
+   - You can obtain one at http://mozilla.org/MPL/2.0/. -->
+
+<script type="application/javascript"
+        src="chrome://browser/content/preferences/in-content/tabs.js"/>
+
+<preferences id="tabsPreferences">
+  <preference id="browser.link.open_newwindow"
+              name="browser.link.open_newwindow"
+              type="int"/>
+  <preference id="browser.tabs.autoHide"
+              name="browser.tabs.autoHide"
+              type="bool"
+              inverted="true"/>
+  <preference id="browser.tabs.loadInBackground"
+              name="browser.tabs.loadInBackground"
+              type="bool"
+              inverted="true"/>
+  <preference id="browser.tabs.warnOnClose"
+              name="browser.tabs.warnOnClose"
+              type="bool"/>
+  <preference id="browser.tabs.warnOnOpen"
+              name="browser.tabs.warnOnOpen"
+              type="bool"/>
+#ifdef XP_WIN
+  <preference id="browser.taskbar.previews.enable"
+              name="browser.taskbar.previews.enable"
+              type="bool"/>
+#endif
+</preferences>
+
+<hbox class="heading" data-category="paneTabs" hidden="true">
+  <image class="preference-icon" type="tabs"/>
+  <html:h1>&paneTabs.title;</html:h1>
+</hbox>
+
+<checkbox id="linkTargeting" label="&newWindowsAsTabs.label;"
+          data-category="paneTabs" hidden="true"
+          accesskey="&newWindowsAsTabs.accesskey;"
+          preference="browser.link.open_newwindow"
+          onsyncfrompreference="return gTabsPane.readLinkTarget();"
+          onsynctopreference="return gTabsPane.writeLinkTarget();"
+          class="indent"/>
+
+<checkbox id="warnCloseMultiple" label="&warnCloseMultipleTabs.label;"
+          data-category="paneTabs" hidden="true"
+          accesskey="&warnCloseMultipleTabs.accesskey;"
+          preference="browser.tabs.warnOnClose"
+          class="indent"/>
+
+<checkbox id="warnOpenMany" label="&warnOpenManyTabs.label;"
+          data-category="paneTabs" hidden="true"
+          accesskey="&warnOpenManyTabs.accesskey;"
+          preference="browser.tabs.warnOnOpen"
+          class="indent"/>
+
+<checkbox id="showTabBar" label="&showTabBar.label;"
+          data-category="paneTabs" hidden="true"
+          accesskey="&showTabBar.accesskey;"
+          preference="browser.tabs.autoHide"
+          class="indent"/>
+
+<checkbox id="switchToNewTabs" label="&switchToNewTabs.label;"
+          data-category="paneTabs" hidden="true"
+          accesskey="&switchToNewTabs.accesskey;"
+          preference="browser.tabs.loadInBackground"
+          class="indent"/>
+
+#ifdef XP_WIN
+<checkbox id="showTabsInTaskbar" label="&showTabsInTaskbar.label;"
+          data-category="paneTabs" hidden="true"
+          accesskey="&showTabsInTaskbar.accesskey;"
+          preference="browser.taskbar.previews.enable"
+          class="indent"/>
+#endif