Files
palemoon27/docshell/base/nsAboutRedirector.cpp
T
roytam1 be13290522 import changes from `dev' branch of rmottola/Arctic-Fox:
- Bug 847287 patch 1 - Add additional tests. r=birtles (10f885ee6)
- Bug 847287 patch 2 - Add flag for CSS properties that can be animated on the compositor. r=birtles (859fae81c)
- Bug 847287 patch 3 - Add assertions about consistency of the flags for animating on the compositor. r=birtles (bd7565728)
- Bug 1144973 - Ensure that StringifySavedFrameStack puts its stack string in the cx's compartment. r=bz (546bef57a)
- Bug 1147670 - Remove duplicate IsMarked/IsAboutToBeFinalized for off-thread use; r=jonco (b460a96ca)
- Bug 674779 - Per-component CPU monitoring, low-level. r=blassey, r=jandem (040bdbad7)
- Bug 674779 - Per-component CPU monitoring, high-level. r=blassey, r=mossop (59af11234)
- Bug 674779 - PerformanceStatsService data is not monotonic (wallpaper). r=yoric (32cecadf9)
- Bug 674779 - Deactivating subtest of test_measure for Windows XP. r=yoric (08833731a)
- Bug 1039866 - Rip out a bunch of metro-only code. r=jimm,gavin,rstrong (8e0e04182)
- Bug 1024668 - Extract core logic of abouthealth.js into new WebIDL interface. r=bz,gps,wchen (52675144a)
- Bug 1046420 - Part 1: Make MozSelfSupport a Window property instead of a global property. r=bz,wchen (7d50f737d)
- goannaAppInfo -> geckoAppInfo for coherency with IDL (8f04e1cdd)
- Bug 1075160 - Support action: reset a pref to the default setting r=gfritzsche, r=bholley (d68725e18)
- Bug 1075157 - Support action: reset search. r=gfritzsche, r=florian, r=bholley (1c770639b)
- Bug 1149343 - Part 1: Unify prefs/blacklist for hardware acceleration video decoding. r=cpearce (6380c6d16)
- Bug 1158430 - A small construct to allow only sending errors and warnings once per statement. r=botond (219130127)
- Bug 1162530 - Part 1: Add versioning to graphics blocklist. r=jmuizelaar (7f344653c)
- Bug 1162530 - Part 2: We were not allowing webrtc to be blocklisted in the downloadable scenario at all, expicitly look for unknown OS, and some minor white space changes. r=jrmuizel (45389ab14)
- Add an nsIGfxInfo function to query monitors. (bug 1175005 part 1, r=mattwoodrow) (22c4e7813)
- Add nsIGfxInfo::GetMonitor support for Windows. (bug 1175005 part 2, r=jimm) (307254292)
- Add nsIGfxInfo::ListMonitors support for OS X. (bug 1175005 part 3, r=mstange) (9b691de8d)
- Add nsIGfxInfo::GetMonitor support for Linux. (bug 1175005 part 4, r=nical) (a5cb518f2)
- Add APZ info to about:support. (bug 1146727, r=jrmuizel) (262235820)
- Bug 1146315 - Part 1: Create D3D media device on the ImageBridge thread. r=nical (3f930ad66)
- Bug 1146315 - Part 2: Release D3D11 YUV textures on the main thread. r=nical (9271a351f)
- Bug 1144900: Fix windows gfx out of memory assertion. r=Bas (73f7e963b)
- Bug 1147439: Report telemetry correctly for individual devices resetting. r=vladan (c19fb3322)
- Bug 1162587 - Part 1: Ensure consistent reporting of device reset until reinitialization. r=jrmuizel (eeb66799a)
- Bug 1162587 - Part 2: Abort painting a painted layer when a device reset has ocurred. r=jrmuizel (ae666232c)
2020-03-25 10:36:32 +08:00

193 lines
5.6 KiB
C++

/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* 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/. */
#include "nsAboutRedirector.h"
#include "nsNetUtil.h"
#include "nsAboutProtocolUtils.h"
#include "mozilla/ArrayUtils.h"
#include "nsDOMString.h"
NS_IMPL_ISUPPORTS(nsAboutRedirector, 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[] = {
{
"", "chrome://global/content/about.xhtml",
nsIAboutModule::ALLOW_SCRIPT
},
{ "about", "chrome://global/content/aboutAbout.xhtml", 0 },
{
"credits", "http://www.palemoon.org/Contributors.shtml",
nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT |
nsIAboutModule::MAKE_LINKABLE
},
{
"mozilla", "chrome://global/content/mozilla.xhtml",
nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT
},
{ "plugins", "chrome://global/content/plugins.html", 0 },
{ "config", "chrome://global/content/config.xul", 0 },
{
"logo", "chrome://branding/content/about.png",
nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT |
nsIAboutModule::MAKE_LINKABLE
},
{
"buildconfig", "chrome://global/content/buildconfig.html",
nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT |
nsIAboutModule::MAKE_LINKABLE
},
{
"license", "chrome://global/content/license.html",
nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT |
nsIAboutModule::MAKE_LINKABLE
},
{
"neterror", "chrome://global/content/netError.xhtml",
nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT |
nsIAboutModule::URI_CAN_LOAD_IN_CHILD |
nsIAboutModule::ALLOW_SCRIPT |
nsIAboutModule::HIDE_FROM_ABOUTABOUT
},
{
"memory", "chrome://global/content/aboutMemory.xhtml",
nsIAboutModule::ALLOW_SCRIPT
},
{
"performance", "chrome://global/content/aboutPerformance.xhtml",
nsIAboutModule::ALLOW_SCRIPT
},
{
"addons", "chrome://mozapps/content/extensions/extensions.xul",
nsIAboutModule::ALLOW_SCRIPT
},
{
"newaddon", "chrome://mozapps/content/extensions/newaddon.xul",
nsIAboutModule::ALLOW_SCRIPT |
nsIAboutModule::HIDE_FROM_ABOUTABOUT
},
{
"support", "chrome://global/content/aboutSupport.xhtml",
nsIAboutModule::ALLOW_SCRIPT
},
{
"telemetry", "chrome://global/content/aboutTelemetry.xhtml",
nsIAboutModule::ALLOW_SCRIPT
},
{
"networking", "chrome://global/content/aboutNetworking.xhtml",
nsIAboutModule::ALLOW_SCRIPT
},
{
"webrtc", "chrome://global/content/aboutwebrtc/aboutWebrtc.xhtml",
nsIAboutModule::ALLOW_SCRIPT
},
{
"serviceworkers", "chrome://global/content/aboutServiceWorkers.xhtml",
nsIAboutModule::ALLOW_SCRIPT
},
// about:srcdoc is unresolvable by specification. It is included here
// because the security manager would disallow srcdoc iframes otherwise.
{
"srcdoc", "about:blank",
nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT |
nsIAboutModule::HIDE_FROM_ABOUTABOUT |
// Needs to be linkable so content can touch its own srcdoc frames
nsIAboutModule::MAKE_LINKABLE
}
};
static const int kRedirTotal = mozilla::ArrayLength(kRedirMap);
NS_IMETHODIMP
nsAboutRedirector::NewChannel(nsIURI* aURI,
nsILoadInfo* aLoadInfo,
nsIChannel** aResult)
{
NS_ENSURE_ARG_POINTER(aURI);
NS_ASSERTION(aResult, "must not be null");
nsAutoCString path;
nsresult rv = NS_GetAboutModuleName(aURI, path);
NS_ENSURE_SUCCESS(rv, 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), kRedirMap[i].url);
NS_ENSURE_SUCCESS(rv, rv);
rv = NS_NewChannelInternal(getter_AddRefs(tempChannel),
tempURI,
aLoadInfo);
if (NS_FAILED(rv)) {
return rv;
}
tempChannel->SetOriginalURI(aURI);
NS_ADDREF(*aResult = tempChannel);
return rv;
}
}
NS_ERROR("nsAboutRedirector called for unknown case");
return NS_ERROR_ILLEGAL_VALUE;
}
NS_IMETHODIMP
nsAboutRedirector::GetURIFlags(nsIURI* aURI, uint32_t* aResult)
{
NS_ENSURE_ARG_POINTER(aURI);
nsAutoCString name;
nsresult rv = NS_GetAboutModuleName(aURI, name);
NS_ENSURE_SUCCESS(rv, rv);
for (int i = 0; i < kRedirTotal; i++) {
if (name.EqualsASCII(kRedirMap[i].id)) {
*aResult = kRedirMap[i].flags;
return NS_OK;
}
}
NS_ERROR("nsAboutRedirector called for unknown case");
return NS_ERROR_ILLEGAL_VALUE;
}
NS_IMETHODIMP
nsAboutRedirector::GetIndexedDBOriginPostfix(nsIURI* aURI, nsAString& aResult)
{
SetDOMStringToNull(aResult);
return NS_ERROR_NOT_IMPLEMENTED;
}
nsresult
nsAboutRedirector::Create(nsISupports* aOuter, REFNSIID aIID, void** aResult)
{
nsAboutRedirector* about = new nsAboutRedirector();
NS_ADDREF(about);
nsresult rv = about->QueryInterface(aIID, aResult);
NS_RELEASE(about);
return rv;
}