summaryrefslogtreecommitdiffstats
path: root/application/palemoon
diff options
context:
space:
mode:
authorMatt A. Tobin <email@mattatobin.com>2018-11-30 10:33:08 -0500
committerMatt A. Tobin <email@mattatobin.com>2018-11-30 10:33:08 -0500
commit26f7e0ce36350d309c6b0fbd6261adbe98e93aab (patch)
treec34bf7add9ee10287f55158b93de1b6e131551d0 /application/palemoon
parentda447504ddabd5519d9952f79f6bad954eba60e6 (diff)
downloadUXP-26f7e0ce36350d309c6b0fbd6261adbe98e93aab.tar
UXP-26f7e0ce36350d309c6b0fbd6261adbe98e93aab.tar.gz
UXP-26f7e0ce36350d309c6b0fbd6261adbe98e93aab.tar.lz
UXP-26f7e0ce36350d309c6b0fbd6261adbe98e93aab.tar.xz
UXP-26f7e0ce36350d309c6b0fbd6261adbe98e93aab.zip
Issue #890 - Port cpp aboutRedirector to javascript
Diffstat (limited to 'application/palemoon')
-rw-r--r--application/palemoon/components/BrowserComponents.manifest19
-rw-r--r--application/palemoon/components/about/AboutRedirector.cpp184
-rw-r--r--application/palemoon/components/about/AboutRedirector.h32
-rw-r--r--application/palemoon/components/about/moz.build19
-rw-r--r--application/palemoon/components/build/moz.build1
-rw-r--r--application/palemoon/components/build/nsBrowserCompsCID.h4
-rw-r--r--application/palemoon/components/build/nsModule.cpp20
-rw-r--r--application/palemoon/components/moz.build5
-rw-r--r--application/palemoon/components/nsAboutRedirector.js118
9 files changed, 139 insertions, 263 deletions
diff --git a/application/palemoon/components/BrowserComponents.manifest b/application/palemoon/components/BrowserComponents.manifest
index 1e4bff59a..b7f054eab 100644
--- a/application/palemoon/components/BrowserComponents.manifest
+++ b/application/palemoon/components/BrowserComponents.manifest
@@ -1,3 +1,22 @@
+# nsAboutRedirector.js
+component {8cc51368-6aa0-43e8-b762-bde9b9fd828c} nsAboutRedirector.js
+# Each entry here should be coupled with an entry in nsAboutRedirector.js
+contract @mozilla.org/network/protocol/about;1?what=certerror {8cc51368-6aa0-43e8-b762-bde9b9fd828c}
+contract @mozilla.org/network/protocol/about;1?what=downloads {8cc51368-6aa0-43e8-b762-bde9b9fd828c}
+contract @mozilla.org/network/protocol/about;1?what=feeds {8cc51368-6aa0-43e8-b762-bde9b9fd828c}
+contract @mozilla.org/network/protocol/about;1?what=home {8cc51368-6aa0-43e8-b762-bde9b9fd828c}
+contract @mozilla.org/network/protocol/about;1?what=newtab {8cc51368-6aa0-43e8-b762-bde9b9fd828c}
+contract @mozilla.org/network/protocol/about;1?what=palemoon {8cc51368-6aa0-43e8-b762-bde9b9fd828c}
+contract @mozilla.org/network/protocol/about;1?what=permissions {8cc51368-6aa0-43e8-b762-bde9b9fd828c}
+contract @mozilla.org/network/protocol/about;1?what=privatebrowsing {8cc51368-6aa0-43e8-b762-bde9b9fd828c}
+contract @mozilla.org/network/protocol/about;1?what=rights {8cc51368-6aa0-43e8-b762-bde9b9fd828c}
+contract @mozilla.org/network/protocol/about;1?what=robots {8cc51368-6aa0-43e8-b762-bde9b9fd828c}
+contract @mozilla.org/network/protocol/about;1?what=sessionrestore {8cc51368-6aa0-43e8-b762-bde9b9fd828c}
+#ifdef MOZ_SERVICES_SYNC
+contract @mozilla.org/network/protocol/about;1?what=sync-progress {8cc51368-6aa0-43e8-b762-bde9b9fd828c}
+contract @mozilla.org/network/protocol/about;1?what=sync-tabs {8cc51368-6aa0-43e8-b762-bde9b9fd828c}
+#endif
+
# nsBrowserContentHandler.js
component {5d0ce354-df01-421a-83fb-7ead0990c24e} nsBrowserContentHandler.js application={8de7fcbb-c55c-4fbe-bfc5-fc555c87dbc4}
contract @mozilla.org/browser/clh;1 {5d0ce354-df01-421a-83fb-7ead0990c24e} application={8de7fcbb-c55c-4fbe-bfc5-fc555c87dbc4}
diff --git a/application/palemoon/components/about/AboutRedirector.cpp b/application/palemoon/components/about/AboutRedirector.cpp
deleted file mode 100644
index fbcad6094..000000000
--- a/application/palemoon/components/about/AboutRedirector.cpp
+++ /dev/null
@@ -1,184 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* 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/. */
-
-// See also: docshell/base/nsAboutRedirector.cpp
-
-#include "AboutRedirector.h"
-#include "nsNetUtil.h"
-#include "nsIScriptSecurityManager.h"
-#include "mozilla/ArrayUtils.h"
-
-namespace mozilla {
-namespace browser {
-
-NS_IMPL_ISUPPORTS(AboutRedirector, nsIAboutModule)
-
-struct RedirEntry {
- const char* id;
- const char* url;
- uint32_t flags;
-};
-
-/*
- Entries which do not have URI_SAFE_FOR_UNTRUSTED_CONTENT will run with chrome
- privileges. This is potentially dangerous. Please use
- URI_SAFE_FOR_UNTRUSTED_CONTENT in the third argument to each map item below
- unless your about: page really needs chrome privileges. Security review is
- required before adding new map entries without
- URI_SAFE_FOR_UNTRUSTED_CONTENT.
-*/
-static RedirEntry kRedirMap[] = {
- {
- "certerror", "chrome://browser/content/certerror/aboutCertError.xhtml",
- nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT |
- nsIAboutModule::ALLOW_SCRIPT |
- nsIAboutModule::HIDE_FROM_ABOUTABOUT
- },
- {
- "downloads", "chrome://browser/content/downloads/contentAreaDownloadsView.xul",
- nsIAboutModule::ALLOW_SCRIPT
- },
- {
- "feeds", "chrome://browser/content/feeds/subscribe.xhtml",
- nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT |
- nsIAboutModule::ALLOW_SCRIPT |
- nsIAboutModule::HIDE_FROM_ABOUTABOUT
- },
- {
- "home", "chrome://browser/content/abouthome/aboutHome.xhtml",
- nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT |
- nsIAboutModule::MAKE_LINKABLE |
- nsIAboutModule::ALLOW_SCRIPT
- },
- {
- "newtab", "chrome://browser/content/newtab/newTab.xhtml",
- nsIAboutModule::ALLOW_SCRIPT
- },
- {
- "palemoon", "chrome://browser/content/palemoon.xhtml",
- nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT |
- nsIAboutModule::HIDE_FROM_ABOUTABOUT
- },
- {
- "permissions", "chrome://browser/content/permissions/aboutPermissions.xul",
- nsIAboutModule::ALLOW_SCRIPT
- },
- {
- "privatebrowsing", "chrome://browser/content/aboutPrivateBrowsing.xhtml",
- nsIAboutModule::ALLOW_SCRIPT
- },
- {
- "rights", "chrome://global/content/aboutRights.xhtml",
- nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT |
- nsIAboutModule::MAKE_LINKABLE |
- nsIAboutModule::ALLOW_SCRIPT
- },
- {
- "robots", "chrome://browser/content/aboutRobots.xhtml",
- nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT |
- nsIAboutModule::ALLOW_SCRIPT
- },
- {
- "sessionrestore", "chrome://browser/content/aboutSessionRestore.xhtml",
- nsIAboutModule::ALLOW_SCRIPT
- },
-#ifdef MOZ_SERVICES_SYNC
- {
- "sync-progress", "chrome://browser/content/sync/progress.xhtml",
- nsIAboutModule::ALLOW_SCRIPT
- },
- {
- "sync-tabs", "chrome://browser/content/sync/aboutSyncTabs.xul",
- nsIAboutModule::ALLOW_SCRIPT
- },
-#endif
-};
-static const int kRedirTotal = ArrayLength(kRedirMap);
-
-static nsAutoCString
-GetAboutModuleName(nsIURI *aURI)
-{
- nsAutoCString path;
- aURI->GetPath(path);
-
- int32_t f = path.FindChar('#');
- if (f >= 0)
- path.SetLength(f);
-
- f = path.FindChar('?');
- if (f >= 0)
- path.SetLength(f);
-
- ToLowerCase(path);
- return path;
-}
-
-NS_IMETHODIMP
-AboutRedirector::NewChannel(nsIURI* aURI,
- nsILoadInfo* aLoadInfo,
- nsIChannel** result)
-{
- NS_ENSURE_ARG_POINTER(aURI);
- NS_ASSERTION(result, "must not be null");
-
- nsAutoCString path = GetAboutModuleName(aURI);
-
- nsresult rv;
- nsCOMPtr<nsIIOService> ioService = do_GetIOService(&rv);
- NS_ENSURE_SUCCESS(rv, rv);
-
- for (int i = 0; i < kRedirTotal; i++) {
- if (!strcmp(path.get(), kRedirMap[i].id)) {
- nsCOMPtr<nsIChannel> tempChannel;
- nsCOMPtr<nsIURI> tempURI;
- rv = NS_NewURI(getter_AddRefs(tempURI),
- nsDependentCString(kRedirMap[i].url));
- NS_ENSURE_SUCCESS(rv, rv);
- rv = NS_NewChannelInternal(getter_AddRefs(tempChannel),
- tempURI,
- aLoadInfo);
- NS_ENSURE_SUCCESS(rv, rv);
-
- tempChannel->SetOriginalURI(aURI);
-
- NS_ADDREF(*result = tempChannel);
- return rv;
- }
- }
-
- return NS_ERROR_ILLEGAL_VALUE;
-}
-
-NS_IMETHODIMP
-AboutRedirector::GetURIFlags(nsIURI *aURI, uint32_t *result)
-{
- NS_ENSURE_ARG_POINTER(aURI);
-
- nsAutoCString name = GetAboutModuleName(aURI);
-
- for (int i = 0; i < kRedirTotal; i++) {
- if (name.Equals(kRedirMap[i].id)) {
- *result = kRedirMap[i].flags;
- return NS_OK;
- }
- }
-
- return NS_ERROR_ILLEGAL_VALUE;
-}
-
-nsresult
-AboutRedirector::Create(nsISupports *aOuter, REFNSIID aIID, void **result)
-{
- AboutRedirector* about = new AboutRedirector();
- if (about == nullptr)
- return NS_ERROR_OUT_OF_MEMORY;
- NS_ADDREF(about);
- nsresult rv = about->QueryInterface(aIID, result);
- NS_RELEASE(about);
- return rv;
-}
-
-} // namespace browser
-} // namespace mozilla
diff --git a/application/palemoon/components/about/AboutRedirector.h b/application/palemoon/components/about/AboutRedirector.h
deleted file mode 100644
index 8feeb7491..000000000
--- a/application/palemoon/components/about/AboutRedirector.h
+++ /dev/null
@@ -1,32 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* 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/. */
-
-#ifndef AboutRedirector_h__
-#define AboutRedirector_h__
-
-#include "nsIAboutModule.h"
-
-namespace mozilla {
-namespace browser {
-
-class AboutRedirector : public nsIAboutModule
-{
-public:
- NS_DECL_ISUPPORTS
- NS_DECL_NSIABOUTMODULE
-
- AboutRedirector() {}
-
- static nsresult
- Create(nsISupports *aOuter, REFNSIID aIID, void **aResult);
-
-protected:
- virtual ~AboutRedirector() {}
-};
-
-} // namespace browser
-} // namespace mozilla
-
-#endif // AboutRedirector_h__
diff --git a/application/palemoon/components/about/moz.build b/application/palemoon/components/about/moz.build
deleted file mode 100644
index 95a8451ba..000000000
--- a/application/palemoon/components/about/moz.build
+++ /dev/null
@@ -1,19 +0,0 @@
-# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
-# vim: set filetype=python:
-# 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/.
-
-EXPORTS.mozilla.browser += [
- 'AboutRedirector.h',
-]
-
-SOURCES += [
- 'AboutRedirector.cpp',
-]
-
-FINAL_LIBRARY = 'browsercomps'
-
-LOCAL_INCLUDES += [
- '../build',
-]
diff --git a/application/palemoon/components/build/moz.build b/application/palemoon/components/build/moz.build
index c85723e16..d2b200968 100644
--- a/application/palemoon/components/build/moz.build
+++ b/application/palemoon/components/build/moz.build
@@ -15,7 +15,6 @@ SOURCES += [
XPCOMBinaryComponent('browsercomps')
LOCAL_INCLUDES += [
- '../about',
'../dirprovider',
'../feeds',
'../shell',
diff --git a/application/palemoon/components/build/nsBrowserCompsCID.h b/application/palemoon/components/build/nsBrowserCompsCID.h
index 23670ae80..bbaa9ab8a 100644
--- a/application/palemoon/components/build/nsBrowserCompsCID.h
+++ b/application/palemoon/components/build/nsBrowserCompsCID.h
@@ -26,10 +26,6 @@
#define NS_PRIVATE_BROWSING_SERVICE_WRAPPER_CID \
{ 0x136e2c4d, 0xc5a4, 0x477c, { 0xb1, 0x31, 0xd9, 0x3d, 0x7d, 0x70, 0x4f, 0x64 } }
-// 7e4bb6ad-2fc4-4dc6-89ef-23e8e5ccf980
-#define NS_BROWSER_ABOUT_REDIRECTOR_CID \
-{ 0x7e4bb6ad, 0x2fc4, 0x4dc6, { 0x89, 0xef, 0x23, 0xe8, 0xe5, 0xcc, 0xf9, 0x80 } }
-
// {6DEB193C-F87D-4078-BC78-5E64655B4D62}
#define NS_BROWSERDIRECTORYPROVIDER_CID \
{ 0x6deb193c, 0xf87d, 0x4078, { 0xbc, 0x78, 0x5e, 0x64, 0x65, 0x5b, 0x4d, 0x62 } }
diff --git a/application/palemoon/components/build/nsModule.cpp b/application/palemoon/components/build/nsModule.cpp
index 304280ca9..f98fc08d7 100644
--- a/application/palemoon/components/build/nsModule.cpp
+++ b/application/palemoon/components/build/nsModule.cpp
@@ -18,8 +18,6 @@
#include "rdf.h"
#include "nsFeedSniffer.h"
-#include "AboutRedirector.h"
-#include "nsIAboutModule.h"
#include "nsNetCID.h"
@@ -45,7 +43,6 @@ NS_DEFINE_NAMED_CID(NS_SHELLSERVICE_CID);
NS_DEFINE_NAMED_CID(NS_SHELLSERVICE_CID);
#endif
NS_DEFINE_NAMED_CID(NS_FEEDSNIFFER_CID);
-NS_DEFINE_NAMED_CID(NS_BROWSER_ABOUT_REDIRECTOR_CID);
#ifdef XP_MACOSX
NS_DEFINE_NAMED_CID(NS_SHELLSERVICE_CID);
#endif
@@ -58,7 +55,6 @@ static const mozilla::Module::CIDEntry kBrowserCIDs[] = {
{ &kNS_SHELLSERVICE_CID, false, nullptr, nsGNOMEShellServiceConstructor },
#endif
{ &kNS_FEEDSNIFFER_CID, false, nullptr, nsFeedSnifferConstructor },
- { &kNS_BROWSER_ABOUT_REDIRECTOR_CID, false, nullptr, AboutRedirector::Create },
#ifdef XP_MACOSX
{ &kNS_SHELLSERVICE_CID, false, nullptr, nsMacShellServiceConstructor },
#endif
@@ -73,22 +69,6 @@ static const mozilla::Module::ContractIDEntry kBrowserContracts[] = {
{ NS_SHELLSERVICE_CONTRACTID, &kNS_SHELLSERVICE_CID },
#endif
{ NS_FEEDSNIFFER_CONTRACTID, &kNS_FEEDSNIFFER_CID },
- { NS_ABOUT_MODULE_CONTRACTID_PREFIX "certerror", &kNS_BROWSER_ABOUT_REDIRECTOR_CID },
- { NS_ABOUT_MODULE_CONTRACTID_PREFIX "socialerror", &kNS_BROWSER_ABOUT_REDIRECTOR_CID },
- { NS_ABOUT_MODULE_CONTRACTID_PREFIX "feeds", &kNS_BROWSER_ABOUT_REDIRECTOR_CID },
- { NS_ABOUT_MODULE_CONTRACTID_PREFIX "privatebrowsing", &kNS_BROWSER_ABOUT_REDIRECTOR_CID },
- { NS_ABOUT_MODULE_CONTRACTID_PREFIX "rights", &kNS_BROWSER_ABOUT_REDIRECTOR_CID },
- { NS_ABOUT_MODULE_CONTRACTID_PREFIX "palemoon", &kNS_BROWSER_ABOUT_REDIRECTOR_CID },
- { NS_ABOUT_MODULE_CONTRACTID_PREFIX "robots", &kNS_BROWSER_ABOUT_REDIRECTOR_CID },
- { NS_ABOUT_MODULE_CONTRACTID_PREFIX "sessionrestore", &kNS_BROWSER_ABOUT_REDIRECTOR_CID },
-#ifdef MOZ_SERVICES_SYNC
- { NS_ABOUT_MODULE_CONTRACTID_PREFIX "sync-tabs", &kNS_BROWSER_ABOUT_REDIRECTOR_CID },
- { NS_ABOUT_MODULE_CONTRACTID_PREFIX "sync-progress", &kNS_BROWSER_ABOUT_REDIRECTOR_CID },
-#endif
- { NS_ABOUT_MODULE_CONTRACTID_PREFIX "home", &kNS_BROWSER_ABOUT_REDIRECTOR_CID },
- { NS_ABOUT_MODULE_CONTRACTID_PREFIX "newtab", &kNS_BROWSER_ABOUT_REDIRECTOR_CID },
- { NS_ABOUT_MODULE_CONTRACTID_PREFIX "permissions", &kNS_BROWSER_ABOUT_REDIRECTOR_CID },
- { NS_ABOUT_MODULE_CONTRACTID_PREFIX "downloads", &kNS_BROWSER_ABOUT_REDIRECTOR_CID },
#ifdef XP_MACOSX
{ NS_SHELLSERVICE_CONTRACTID, &kNS_SHELLSERVICE_CID },
#endif
diff --git a/application/palemoon/components/moz.build b/application/palemoon/components/moz.build
index 397bf5142..b9df76330 100644
--- a/application/palemoon/components/moz.build
+++ b/application/palemoon/components/moz.build
@@ -5,7 +5,6 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
DIRS += [
- 'about',
'certerror',
'dirprovider',
'downloads',
@@ -32,9 +31,9 @@ XPIDL_SOURCES += [
XPIDL_MODULE = 'browsercompsbase'
-EXTRA_COMPONENTS += [ 'BrowserComponents.manifest' ]
-
EXTRA_PP_COMPONENTS += [
+ 'BrowserComponents.manifest',
+ 'nsAboutRedirector.js',
'nsBrowserContentHandler.js',
'nsBrowserGlue.js',
]
diff --git a/application/palemoon/components/nsAboutRedirector.js b/application/palemoon/components/nsAboutRedirector.js
new file mode 100644
index 000000000..9c7d7953f
--- /dev/null
+++ b/application/palemoon/components/nsAboutRedirector.js
@@ -0,0 +1,118 @@
+/* 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 Ci = Components.interfaces;
+var Cr = Components.results;
+var Cu = Components.utils;
+
+Cu.import("resource://gre/modules/XPCOMUtils.jsm");
+Cu.import("resource://gre/modules/Services.jsm");
+
+// See: netwerk/protocol/about/nsIAboutModule.idl
+const URI_SAFE_FOR_UNTRUSTED_CONTENT = Ci.nsIAboutModule.URI_SAFE_FOR_UNTRUSTED_CONTENT;
+const ALLOW_SCRIPT = Ci.nsIAboutModule.ALLOW_SCRIPT;
+const HIDE_FROM_ABOUTABOUT = Ci.nsIAboutModule.HIDE_FROM_ABOUTABOUT;
+const MAKE_LINKABLE = Ci.nsIAboutModule.MAKE_LINKABLE;
+
+function AboutRedirector() {}
+AboutRedirector.prototype = {
+ classDescription: "Browser about: Redirector",
+ classID: Components.ID("{8cc51368-6aa0-43e8-b762-bde9b9fd828c}"),
+ QueryInterface: XPCOMUtils.generateQI([Ci.nsIAboutModule]),
+
+ // Each entry in the map has the key as the part after the "about:" and the
+ // value as a record with url and flags entries. Note that each addition here
+ // should be coupled with a corresponding addition in BrowserComponents.manifest.
+ _redirMap: {
+ "certerror": {
+ url: "chrome://browser/content/certerror/aboutCertError.xhtml",
+ flags: (URI_SAFE_FOR_UNTRUSTED_CONTENT | ALLOW_SCRIPT | HIDE_FROM_ABOUTABOUT)
+ },
+ "downloads": {
+ url: "chrome://browser/content/downloads/contentAreaDownloadsView.xul",
+ flags: ALLOW_SCRIPT
+ },
+ "feeds": {
+ url: "chrome://browser/content/feeds/subscribe.xhtml",
+ flags: (URI_SAFE_FOR_UNTRUSTED_CONTENT | ALLOW_SCRIPT | HIDE_FROM_ABOUTABOUT)
+ },
+ "home": {
+ url: "chrome://browser/content/abouthome/aboutHome.xhtml",
+ flags: (URI_SAFE_FOR_UNTRUSTED_CONTENT | MAKE_LINKABLE | ALLOW_SCRIPT)
+ },
+ "newtab": {
+ url: "chrome://browser/content/newtab/newTab.xhtml",
+ flags: ALLOW_SCRIPT
+ },
+ "palemoon": {
+ url: "chrome://browser/content/palemoon.xhtml",
+ flags: (URI_SAFE_FOR_UNTRUSTED_CONTENT | HIDE_FROM_ABOUTABOUT)
+ },
+ "permissions": {
+ url: "chrome://browser/content/permissions/aboutPermissions.xul",
+ flags: ALLOW_SCRIPT
+ },
+ "privatebrowsing": {
+ url: "chrome://browser/content/aboutPrivateBrowsing.xhtml",
+ flags: ALLOW_SCRIPT
+ },
+ "rights": {
+ url: "chrome://global/content/aboutRights.xhtml",
+ flags: (URI_SAFE_FOR_UNTRUSTED_CONTENT | MAKE_LINKABLE | ALLOW_SCRIPT)
+ },
+ "robots": {
+ url: "chrome://browser/content/aboutRobots.xhtml",
+ flags: (URI_SAFE_FOR_UNTRUSTED_CONTENT | ALLOW_SCRIPT | HIDE_FROM_ABOUTABOUT)
+ },
+ "sessionrestore": {
+ url: "chrome://browser/content/aboutSessionRestore.xhtml",
+ flags: ALLOW_SCRIPT
+ },
+#ifdef MOZ_SERVICES_SYNC
+ "sync-progress": {
+ url: "chrome://browser/content/sync/progress.xhtml",
+ flags: ALLOW_SCRIPT
+ },
+ "sync-tabs": {
+ url: "chrome://browser/content/sync/aboutSyncTabs.xul",
+ flags: ALLOW_SCRIPT
+ },
+#endif
+ },
+
+ /**
+ * Gets the module name from the given URI.
+ */
+ _getModuleName: function AboutRedirector__getModuleName(aURI) {
+ // Strip out the first ? or #, and anything following it
+ let name = (/[^?#]+/.exec(aURI.path))[0];
+ return name.toLowerCase();
+ },
+
+ getURIFlags: function(aURI) {
+ let name = this._getModuleName(aURI);
+ if (!(name in this._redirMap))
+ throw Cr.NS_ERROR_ILLEGAL_VALUE;
+ return this._redirMap[name].flags;
+ },
+
+ newChannel: function(aURI, aLoadInfo) {
+ let name = this._getModuleName(aURI);
+ if (!(name in this._redirMap))
+ throw Cr.NS_ERROR_ILLEGAL_VALUE;
+
+ let newURI = Services.io.newURI(this._redirMap[name].url, null, null);
+ let channel = Services.io.newChannelFromURIWithLoadInfo(newURI, aLoadInfo);
+ channel.originalURI = aURI;
+
+ if (this._redirMap[name].flags & Ci.nsIAboutModule.URI_SAFE_FOR_UNTRUSTED_CONTENT) {
+ let principal = Services.scriptSecurityManager.getNoAppCodebasePrincipal(aURI);
+ channel.owner = principal;
+ }
+
+ return channel;
+ }
+};
+
+var NSGetFactory = XPCOMUtils.generateNSGetFactory([AboutRedirector]);