From 43df2515e7ffb719e86e4248c2f5d1e4e9f04440 Mon Sep 17 00:00:00 2001 From: Tim Taubert Date: Tue, 5 Nov 2013 13:21:28 +0100 Subject: [PATCH] Bug 754344 - Make in-content prefs navigation look like about:addons r=jaws From 8e5ce19d039052d06c099a87c2c315353bc589cf Mon Sep 17 00:00:00 2001 --- .../content/test/general/browser_bug735471.js | 32 ++-- browser/base/content/test/general/head.js | 7 +- browser/base/content/utilityOverlay.js | 46 +++-- browser/components/nsBrowserContentHandler.js | 6 +- browser/components/preferences/handlers.css | 4 +- .../preferences/in-content/advanced.xul | 5 - .../preferences/in-content/applications.xul | 5 - .../preferences/in-content/content.xul | 7 +- .../components/preferences/in-content/jar.mn | 1 - .../preferences/in-content/landing.xul | 55 ------ .../preferences/in-content/main.xul | 11 +- .../preferences/in-content/preferences.js | 37 +++- .../preferences/in-content/preferences.xul | 64 ++++++- .../preferences/in-content/privacy.xul | 5 - .../preferences/in-content/security.xul | 7 +- .../preferences/in-content/sync.xul | 5 - .../chrome/browser/preferences/content.dtd | 2 + .../chrome/browser/preferences/security.dtd | 2 + browser/themes/linux/jar.mn | 2 +- .../themes/linux/preferences/applications.css | 4 +- .../preferences/in-content/preferences.css | 172 +++++++++-------- browser/themes/osx/jar.mn | 2 +- .../themes/osx/preferences/applications.css | 4 +- .../preferences/in-content/preferences.css | 175 +++++++++-------- browser/themes/windows/jar.mn | 4 +- .../windows/preferences/applications.css | 4 +- .../preferences/in-content/preferences.css | 176 ++++++++++-------- 27 files changed, 454 insertions(+), 390 deletions(-) delete mode 100644 browser/components/preferences/in-content/landing.xul diff --git a/browser/base/content/test/general/browser_bug735471.js b/browser/base/content/test/general/browser_bug735471.js index eb9e7d338113..beb33802fa88 100644 --- a/browser/base/content/test/general/browser_bug735471.js +++ b/browser/base/content/test/general/browser_bug735471.js @@ -15,24 +15,20 @@ function test() { // Verify that about:preferences tab is displayed when // browser.preferences.inContent is set to true Services.prefs.setBoolPref("browser.preferences.inContent", true); - - gBrowser.tabContainer.addEventListener("TabOpen", function(aEvent) { - - gBrowser.tabContainer.removeEventListener("TabOpen", arguments.callee, true); - let browser = aEvent.originalTarget.linkedBrowser; - browser.addEventListener("load", function(aEvent) { - browser.removeEventListener("load", arguments.callee, true); - - is(Services.prefs.getBoolPref("browser.preferences.inContent"), true, "In-content prefs are enabled"); - is(browser.contentWindow.location.href, "about:preferences", "Checking if the preferences tab was opened"); - - gBrowser.removeCurrentTab(); - Services.prefs.setBoolPref("browser.preferences.inContent", false); - openPreferences(); - - }, true); - }, true); - + + // Open a new tab. + whenNewTabLoaded(window, testPreferences); +} + +function testPreferences() { + whenTabLoaded(gBrowser.selectedTab, function () { + is(Services.prefs.getBoolPref("browser.preferences.inContent"), true, "In-content prefs are enabled"); + is(content.location.href, "about:preferences", "Checking if the preferences tab was opened"); + + gBrowser.removeCurrentTab(); + Services.prefs.setBoolPref("browser.preferences.inContent", false); + openPreferences(); + }); let observer = { observe: function(aSubject, aTopic, aData) { diff --git a/browser/base/content/test/general/head.js b/browser/base/content/test/general/head.js index b9dbbbb7607c..1d33893e8ede 100644 --- a/browser/base/content/test/general/head.js +++ b/browser/base/content/test/general/head.js @@ -237,9 +237,14 @@ function whenNewTabLoaded(aWindow, aCallback) { return; } + whenTabLoaded(aWindow.gBrowser.selectedTab, aCallback); +} + +function whenTabLoaded(aTab, aCallback) { + let browser = aTab.linkedBrowser; browser.addEventListener("load", function onLoad() { browser.removeEventListener("load", onLoad, true); - aCallback(); + executeSoon(aCallback); }, true); } diff --git a/browser/base/content/utilityOverlay.js b/browser/base/content/utilityOverlay.js index 8c5e9fa72140..7046a56e20c1 100644 --- a/browser/base/content/utilityOverlay.js +++ b/browser/base/content/utilityOverlay.js @@ -473,8 +473,37 @@ function openAboutDialog() { function openPreferences(paneID, extraArgs) { - if (Services.prefs.getBoolPref("browser.preferences.inContent")) { - openUILinkIn("about:preferences", "tab"); + function switchToAdvancedSubPane(doc) { + if (extraArgs && extraArgs["advancedTab"]) { + let advancedPaneTabs = doc.getElementById("advancedPrefs"); + advancedPaneTabs.selectedTab = doc.getElementById(extraArgs["advancedTab"]); + } + } + + if (getBoolPref("browser.preferences.inContent")) { + let win = Services.wm.getMostRecentWindow("navigator:browser"); + if (!win) { + return; + } + + let newLoad = !win.switchToTabHavingURI("about:preferences", true); + let browser = win.gBrowser.selectedBrowser; + + function switchToPane() { + if (paneID) { + browser.contentWindow.selectCategory(paneID); + } + switchToAdvancedSubPane(browser.contentDocument); + } + + if (newLoad) { + browser.addEventListener("load", function onload() { + browser.removeEventListener("load", onload, true); + switchToPane(); + }, true); + } else { + switchToPane(); + } } else { var instantApply = getBoolPref("browser.preferences.instantApply", false); var features = "chrome,titlebar,toolbar,centerscreen" + (instantApply ? ",dialog=no" : ",modal"); @@ -487,16 +516,11 @@ function openPreferences(paneID, extraArgs) win.document.documentElement.showPane(pane); } - if (extraArgs && extraArgs["advancedTab"]) { - var advancedPaneTabs = win.document.getElementById("advancedPrefs"); - advancedPaneTabs.selectedTab = win.document.getElementById(extraArgs["advancedTab"]); - } - - return; + switchToAdvancedSubPane(win.document); + } else { + openDialog("chrome://browser/content/preferences/preferences.xul", + "Preferences", features, paneID, extraArgs); } - - openDialog("chrome://browser/content/preferences/preferences.xul", - "Preferences", features, paneID, extraArgs); } } diff --git a/browser/components/nsBrowserContentHandler.js b/browser/components/nsBrowserContentHandler.js index f129168609b0..1624089522b4 100644 --- a/browser/components/nsBrowserContentHandler.js +++ b/browser/components/nsBrowserContentHandler.js @@ -452,8 +452,10 @@ nsBrowserContentHandler.prototype = { var chromeParam = cmdLine.handleFlagWithParam("chrome", false); if (chromeParam) { - // Handle the old preference dialog URL separately (bug 285416) - if (chromeParam == "chrome://browser/content/pref/pref.xul") { + // Handle old preference dialog URLs. + if (chromeParam == "chrome://browser/content/pref/pref.xul" || + (Services.prefs.getBoolPref("browser.preferences.inContent") && + chromeParam == "chrome://browser/content/preferences/preferences.xul")) { openPreferences(); cmdLine.preventDefault = true; } else try { diff --git a/browser/components/preferences/handlers.css b/browser/components/preferences/handlers.css index 9a1d47446d09..abac7d575e9f 100644 --- a/browser/components/preferences/handlers.css +++ b/browser/components/preferences/handlers.css @@ -2,11 +2,11 @@ * 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/. */ -richlistitem { +#handlersView > richlistitem { -moz-binding: url("chrome://browser/content/preferences/handlers.xml#handler"); } -richlistitem[selected="true"] { +#handlersView > richlistitem[selected="true"] { -moz-binding: url("chrome://browser/content/preferences/handlers.xml#handler-selected"); } diff --git a/browser/components/preferences/in-content/advanced.xul b/browser/components/preferences/in-content/advanced.xul index 40781fe7e31b..9231fe4972c9 100644 --- a/browser/components/preferences/in-content/advanced.xul +++ b/browser/components/preferences/in-content/advanced.xul @@ -128,11 +128,6 @@ #endif - -