summaryrefslogtreecommitdiffstats
path: root/application/palemoon/components/about
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/components/about
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/components/about')
-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
3 files changed, 0 insertions, 235 deletions
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',
-]