Bug 499123 - Coalesce browser about: pages. r=dietrich/gavin

--HG--
rename : docshell/base/nsAboutRedirector.cpp => browser/components/about/AboutRedirector.cpp
rename : docshell/base/nsAboutRedirector.h => browser/components/about/AboutRedirector.h
This commit is contained in:
Ryan Flint 2009-08-20 02:24:10 -04:00
Родитель 4f036876e8
Коммит 3f8f40882a
22 изменённых файлов: 324 добавлений и 528 удалений

Просмотреть файл

@ -53,13 +53,12 @@ XPIDLSRCS = \
EXTRA_PP_COMPONENTS = \
nsBrowserContentHandler.js \
nsBrowserGlue.js \
aboutRights.js \
aboutRobots.js \
$(NULL)
EXTRA_JS_MODULES = distribution.js
DIRS = \
about \
certerror \
dirprovider \
microsummaries \

Просмотреть файл

@ -0,0 +1,185 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Gagan Saksena (original author)
* Ryan Flint <rflint@mozilla.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
// See also: docshell/base/nsAboutRedirector.cpp
#include "AboutRedirector.h"
#include "nsNetUtil.h"
#include "nsIScriptSecurityManager.h"
namespace mozilla {
namespace browser {
NS_IMPL_ISUPPORTS1(AboutRedirector, nsIAboutModule)
struct RedirEntry {
const char* id;
const char* url;
PRUint32 flags; // See nsIAboutModule. The URI_SAFE_FOR_UNTRUSTED_CONTENT
// flag does double duty here -- if it's not set, we don't
// drop chrome privileges.
};
/*
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. Also note, however, that adding
URI_SAFE_FOR_UNTRUSTED_CONTENT will allow random web sites to link to that
URI. Perhaps we should separate the two concepts out...
*/
static RedirEntry kRedirMap[] = {
#ifdef MOZ_SAFE_BROWSING
{ "blocked", "chrome://browser/content/safebrowsing/blockedSite.xhtml",
nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT |
nsIAboutModule::ALLOW_SCRIPT },
#endif
{ "certerror", "chrome://browser/content/certerror/aboutCertError.xhtml",
nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT |
nsIAboutModule::ALLOW_SCRIPT },
{ "feeds", "chrome://browser/content/feeds/subscribe.xhtml",
nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT |
nsIAboutModule::ALLOW_SCRIPT },
{ "privatebrowsing", "chrome://browser/content/aboutPrivateBrowsing.xhtml",
nsIAboutModule::ALLOW_SCRIPT },
{ "rights", "chrome://browser/content/aboutRights.xhtml",
nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT |
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 }
};
static const int kRedirTotal = NS_ARRAY_LENGTH(kRedirMap);
static nsCAutoString
GetAboutModuleName(nsIURI *aURI)
{
nsCAutoString path;
aURI->GetPath(path);
PRInt32 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, nsIChannel **result)
{
NS_ENSURE_ARG_POINTER(aURI);
NS_ASSERTION(result, "must not be null");
nsCAutoString 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;
rv = ioService->NewChannel(nsDependentCString(kRedirMap[i].url),
nsnull, nsnull, getter_AddRefs(tempChannel));
NS_ENSURE_SUCCESS(rv, rv);
tempChannel->SetOriginalURI(aURI);
// Keep the page from getting unnecessary privileges unless it needs them
if (kRedirMap[i].flags & nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT) {
nsCOMPtr<nsIScriptSecurityManager> securityManager =
do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIPrincipal> principal;
rv = securityManager->GetCodebasePrincipal(aURI, getter_AddRefs(principal));
NS_ENSURE_SUCCESS(rv, rv);
rv = tempChannel->SetOwner(principal);
NS_ENSURE_SUCCESS(rv, rv);
}
NS_ADDREF(*result = tempChannel);
return rv;
}
}
return NS_ERROR_ILLEGAL_VALUE;
}
NS_IMETHODIMP
AboutRedirector::GetURIFlags(nsIURI *aURI, PRUint32 *result)
{
NS_ENSURE_ARG_POINTER(aURI);
nsCAutoString 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;
}
NS_METHOD
AboutRedirector::Create(nsISupports *aOuter, REFNSIID aIID, void **result)
{
AboutRedirector* about = new AboutRedirector();
if (about == nsnull)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(about);
nsresult rv = about->QueryInterface(aIID, result);
NS_RELEASE(about);
return rv;
}
} // namespace browser
} // namespace mozilla

Просмотреть файл

@ -1,5 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* vim:set ts=4 sw=4 sts=4 et cindent: */
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -13,14 +12,16 @@
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is The about:feeds Page.
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Google Inc.
* Portions created by the Initial Developer are Copyright (C) 2006
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Ben Goodger <beng@google.com>
* Gagan Saksena (original author)
* Ryan Flint <rflint@mozilla.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
@ -36,25 +37,30 @@
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsAboutFeeds_h__
#define nsAboutFeeds_h__
#ifndef AboutRedirector_h__
#define AboutRedirector_h__
#include "nsIAboutModule.h"
class nsAboutFeeds : public nsIAboutModule
namespace mozilla {
namespace browser {
class AboutRedirector : public nsIAboutModule
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIABOUTMODULE
AboutRedirector() {}
virtual ~AboutRedirector() {}
nsAboutFeeds() { }
virtual ~nsAboutFeeds() { }
static NS_METHOD
Create(nsISupports* outer, REFNSIID iid, void** result);
Create(nsISupports *aOuter, REFNSIID aIID, void **aResult);
protected:
};
#endif // nsAboutFeeds_h__
} // namespace browser
} // namespace mozilla
#endif // AboutRedirector_h__

Просмотреть файл

@ -0,0 +1,62 @@
# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Original Code is mozilla.org code.
#
# The Initial Developer of the Original Code is Mozilla Foundation.
# Portions created by the Initial Developer are Copyright (C) 2009
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
# Ryan Flint <rflint@mozilla.com>
#
# Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 2 or later (the "GPL"), or
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the MPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the MPL, the GPL or the LGPL.
#
# ***** END LICENSE BLOCK *****
DEPTH = ../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = browserabout
LIBRARY_NAME = browserabout_s
FORCE_STATIC_LIB = 1
FORCE_USE_PIC = 1
ifndef MOZ_MEMORY
USE_STATIC_LIBS = 1
endif
REQUIRES = xpcom string necko caps
EXPORTS_NAMESPACES = mozilla/browser
EXPORTS_mozilla/browser = AboutRedirector.h
CPPSRCS = AboutRedirector.cpp
LOCAL_INCLUDES = -I$(srcdir)/../build
include $(topsrcdir)/config/rules.mk

Просмотреть файл

@ -1,73 +0,0 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is about:robots.
*
* The Initial Developer of the Original Code is Mozilla Foundation.
* Portions created by the Initial Developer are Copyright (C) 2008
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Ryan Flint <rflint@mozilla.com>
* Justin Dolske <dolske@mozilla.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
const Cc = Components.classes;
const Ci = Components.interfaces;
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
function AboutRights() {}
AboutRights.prototype = {
classDescription: "about:rights",
contractID: "@mozilla.org/network/protocol/about;1?what=rights",
classID: Components.ID("{89e9da80-4c03-46a0-a357-cf77bbef98b9}"),
QueryInterface: XPCOMUtils.generateQI([Ci.nsIAboutModule]),
getURIFlags: function(aURI) {
return (Ci.nsIAboutModule.ALLOW_SCRIPT |
Ci.nsIAboutModule.URI_SAFE_FOR_UNTRUSTED_CONTENT);
},
newChannel: function(aURI) {
var ios = Cc["@mozilla.org/network/io-service;1"].
getService(Ci.nsIIOService);
var secMan = Cc["@mozilla.org/scriptsecuritymanager;1"].
getService(Ci.nsIScriptSecurityManager);
var channel = ios.newChannel("chrome://browser/content/aboutRights.xhtml",
null, null);
var principal = secMan.getCodebasePrincipal(aURI);
channel.originalURI = aURI;
channel.owner = principal;
return channel;
}
};
function NSGetModule(compMgr, fileSpec)
XPCOMUtils.generateModule([AboutRights]);

Просмотреть файл

@ -1,73 +0,0 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is About:IceCream.
*
* The Initial Developer of the Original Code is Mozilla Foundation.
* Portions created by the Initial Developer are Copyright (C) 2008
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Ryan Flint <rflint@mozilla.com>
* Justin Dolske <dolske@mozilla.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
const Cc = Components.classes;
const Ci = Components.interfaces;
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
function AboutRobots() {}
AboutRobots.prototype = {
classDescription: "About Robots",
contractID: "@mozilla.org/network/protocol/about;1?what=robots",
classID: Components.ID("{e18da21c-a4b8-4be5-98aa-942e1e19f35c}"),
QueryInterface: XPCOMUtils.generateQI([Ci.nsIAboutModule]),
getURIFlags: function(aURI) {
return (Ci.nsIAboutModule.ALLOW_SCRIPT |
Ci.nsIAboutModule.URI_SAFE_FOR_UNTRUSTED_CONTENT);
},
newChannel: function(aURI) {
var ios = Cc["@mozilla.org/network/io-service;1"].
getService(Ci.nsIIOService);
var secMan = Cc["@mozilla.org/scriptsecuritymanager;1"].
getService(Ci.nsIScriptSecurityManager);
var channel = ios.newChannel("chrome://browser/content/aboutRobots.xhtml",
null, null);
var principal = secMan.getCodebasePrincipal(aURI);
channel.originalURI = aURI;
channel.owner = principal;
return channel;
}
};
function NSGetModule(compMgr, fileSpec)
XPCOMUtils.generateModule([AboutRobots]);

Просмотреть файл

@ -31,6 +31,7 @@ REQUIRES = \
browserplaces \
microsummaries \
privatebrowsing \
browserabout \
$(NULL)
EXPORTS = nsBrowserCompsCID.h
@ -49,6 +50,7 @@ LOCAL_INCLUDES = \
-I$(srcdir)/../feeds/src \
-I$(srcdir)/../places/src \
-I$(srcdir)/../privatebrowsing/src \
-I$(srcdir)/../about \
$(NULL)
ifeq ($(OS_ARCH),WINNT)
@ -59,6 +61,7 @@ SHARED_LIBRARY_LIBS = \
../feeds/src/$(LIB_PREFIX)browser_feeds_s.$(LIB_SUFFIX) \
../places/src/$(LIB_PREFIX)browserplaces_s.$(LIB_SUFFIX) \
../privatebrowsing/src/$(LIB_PREFIX)privatebrowsing_s.$(LIB_SUFFIX) \
../about/$(LIB_PREFIX)browserabout_s.$(LIB_SUFFIX) \
$(NULL)
ifneq (,$(filter windows mac cocoa gtk2, $(MOZ_WIDGET_TOOLKIT)))

Просмотреть файл

@ -101,3 +101,8 @@
// 136e2c4d-c5a4-477c-b131-d93d7d704f64
#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 } }

Просмотреть файл

@ -74,12 +74,14 @@
#include "rdf.h"
#include "nsFeedSniffer.h"
#include "nsAboutFeeds.h"
#include "AboutRedirector.h"
#include "nsIAboutModule.h"
#include "nsPrivateBrowsingServiceWrapper.h"
#include "nsNetCID.h"
using namespace mozilla::browser;
/////////////////////////////////////////////////////////////////////////////
NS_GENERIC_FACTORY_CONSTRUCTOR(nsPlacesImportExportService)
@ -148,11 +150,42 @@ static const nsModuleComponentInfo components[] =
nsFeedSnifferConstructor,
nsFeedSniffer::Register },
{ "about:feeds Page",
NS_ABOUTFEEDS_CID,
#ifdef MOZ_SAFE_BROWSING
{ "about:blocked",
NS_BROWSER_ABOUT_REDIRECTOR_CID,
NS_ABOUT_MODULE_CONTRACTID_PREFIX "blocked",
AboutRedirector::Create },
#endif
{ "about:certerror",
NS_BROWSER_ABOUT_REDIRECTOR_CID,
NS_ABOUT_MODULE_CONTRACTID_PREFIX "certerror",
AboutRedirector::Create },
{ "about:feeds",
NS_BROWSER_ABOUT_REDIRECTOR_CID,
NS_ABOUT_MODULE_CONTRACTID_PREFIX "feeds",
nsAboutFeeds::Create
},
AboutRedirector::Create },
{ "about:privatebrowsing",
NS_BROWSER_ABOUT_REDIRECTOR_CID,
NS_ABOUT_MODULE_CONTRACTID_PREFIX "privatebrowsing",
AboutRedirector::Create },
{ "about:rights",
NS_BROWSER_ABOUT_REDIRECTOR_CID,
NS_ABOUT_MODULE_CONTRACTID_PREFIX "rights",
AboutRedirector::Create },
{ "about:robots",
NS_BROWSER_ABOUT_REDIRECTOR_CID,
NS_ABOUT_MODULE_CONTRACTID_PREFIX "robots",
AboutRedirector::Create },
{ "about:sessionrestore",
NS_BROWSER_ABOUT_REDIRECTOR_CID,
NS_ABOUT_MODULE_CONTRACTID_PREFIX "sessionrestore",
AboutRedirector::Create },
#ifndef WINCE

Просмотреть файл

@ -47,9 +47,4 @@ ifdef ENABLE_TESTS
DIRS += test
endif
# EXTRA_COMPONENTS installs components written in JS to dist/bin/components
EXTRA_PP_COMPONENTS = \
aboutCertError.js \
$(NULL)
include $(topsrcdir)/config/rules.mk

Просмотреть файл

@ -1,75 +0,0 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is about:robots
*
* The Initial Developer of the Original Code is Mozilla Foundation.
* Portions created by the Initial Developer are Copyright (C) 2008
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Ryan Flint <rflint@mozilla.com>
* Justin Dolske <dolske@mozilla.com>
* Johnathan Nightingale <johnath@mozilla.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
const Cc = Components.classes;
const Ci = Components.interfaces;
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
function AboutCertError() {}
AboutCertError.prototype = {
classDescription: "About Cert Error",
contractID: "@mozilla.org/network/protocol/about;1?what=certerror",
classID: Components.ID("{78d2286f-de9d-47ac-9c26-e8675aedf3be}"),
QueryInterface: XPCOMUtils.generateQI([Ci.nsIAboutModule]),
getURIFlags: function(aURI) {
return (Ci.nsIAboutModule.ALLOW_SCRIPT |
Ci.nsIAboutModule.URI_SAFE_FOR_UNTRUSTED_CONTENT);
},
newChannel: function(aURI) {
var ios = Cc["@mozilla.org/network/io-service;1"].
getService(Ci.nsIIOService);
var secMan = Cc["@mozilla.org/scriptsecuritymanager;1"].
getService(Ci.nsIScriptSecurityManager);
var channel = ios.newChannel("chrome://browser/content/certerror/aboutCertError.xhtml",
null, null);
var principal = secMan.getCodebasePrincipal(aURI);
channel.originalURI = aURI;
channel.owner = principal;
return channel;
}
};
function NSGetModule(compMgr, fileSpec) {
return XPCOMUtils.generateModule([AboutCertError]);
}

Просмотреть файл

@ -60,9 +60,9 @@ EXTRA_PP_COMPONENTS = \
WebContentConverter.js \
$(NULL)
REQUIRES = xpcom string necko caps js xpconnect mimetype
REQUIRES = xpcom string necko mimetype
CPPSRCS = nsFeedSniffer.cpp nsAboutFeeds.cpp
CPPSRCS = nsFeedSniffer.cpp
LOCAL_INCLUDES = -I$(srcdir)/../../build

Просмотреть файл

@ -1,100 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* vim:set ts=4 sw=4 sts=4 et cindent: */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is The about:feeds Page.
*
* The Initial Developer of the Original Code is Google Inc.
* Portions created by the Initial Developer are Copyright (C) 2006
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Ben Goodger <beng@google.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsAboutFeeds.h"
#include "nsNetUtil.h"
#include "nsIScriptSecurityManager.h"
NS_IMPL_ISUPPORTS1(nsAboutFeeds, nsIAboutModule)
#define FEEDS_PAGE_URI "chrome://browser/content/feeds/subscribe.xhtml"
NS_IMETHODIMP
nsAboutFeeds::NewChannel(nsIURI* uri, nsIChannel** result)
{
nsresult rv;
nsCOMPtr<nsIIOService> ios(do_GetIOService(&rv));
if (NS_FAILED(rv))
return rv;
nsCOMPtr<nsIChannel> channel;
rv = ios->NewChannel(NS_LITERAL_CSTRING(FEEDS_PAGE_URI),
nsnull, nsnull, getter_AddRefs(channel));
if (NS_FAILED(rv))
return rv;
channel->SetOriginalURI(uri);
nsCOMPtr<nsIScriptSecurityManager> ssm =
do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID, &rv);
if (NS_FAILED(rv))
return rv;
nsCOMPtr<nsIPrincipal> principal;
rv = ssm->GetCodebasePrincipal(uri, getter_AddRefs(principal));
if (NS_FAILED(rv))
return rv;
rv = channel->SetOwner(principal);
if (NS_FAILED(rv))
return rv;
NS_ADDREF(*result = channel);
return NS_OK;
}
NS_IMETHODIMP
nsAboutFeeds::GetURIFlags(nsIURI* uri, PRUint32* uriFlags)
{
// Feeds page needs script, and is untrusted-content-safe
*uriFlags = URI_SAFE_FOR_UNTRUSTED_CONTENT | ALLOW_SCRIPT;
return NS_OK;
}
NS_METHOD
nsAboutFeeds::Create(nsISupports* outer, REFNSIID iid, void** result)
{
nsAboutFeeds* aboutFeeds = new nsAboutFeeds();
if (aboutFeeds == nsnull)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(aboutFeeds);
nsresult rv = aboutFeeds->QueryInterface(iid, result);
NS_RELEASE(aboutFeeds);
return rv;
}

Просмотреть файл

@ -66,7 +66,6 @@ LOCAL_INCLUDES = -I$(srcdir)/../../build
EXTRA_PP_COMPONENTS = \
nsPrivateBrowsingService.js \
aboutPrivateBrowsing.js \
$(NULL)
include $(topsrcdir)/config/rules.mk

Просмотреть файл

@ -1,63 +0,0 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Private Browsing.
*
* The Initial Developer of the Original Code is
* Ehsan Akhgari <ehsan.akhgari@gmail.com>
* Portions created by the Initial Developer are Copyright (C) 2008
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
const Cc = Components.classes;
const Ci = Components.interfaces;
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
function AboutPrivateBrowsing() { }
AboutPrivateBrowsing.prototype = {
classDescription: "about:privatebrowsing",
contractID: "@mozilla.org/network/protocol/about;1?what=privatebrowsing",
classID: Components.ID("{d92a18c8-234d-49e4-9936-3b7e020c29a2}"),
QueryInterface: XPCOMUtils.generateQI([Ci.nsIAboutModule]),
getURIFlags: function(aURI) {
return Ci.nsIAboutModule.ALLOW_SCRIPT;
},
newChannel: function(aURI) {
let ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
let channel = ios.newChannel("chrome://browser/content/aboutPrivateBrowsing.xhtml",
null, null);
channel.originalURI = aURI;
return channel;
}
};
function NSGetModule(compMgr, fileSpec)
XPCOMUtils.generateModule([AboutPrivateBrowsing]);

Просмотреть файл

@ -130,41 +130,10 @@ PROT_Application.prototype.getReportURL = function(name) {
return gDataProvider["getReport" + name + "URL"]();
}
/**
* about:blocked implementation
*/
PROT_Application.prototype.newChannel = function(uri) {
var ioService = Cc["@mozilla.org/network/io-service;1"]
.getService(Ci.nsIIOService);
var secMan = Cc["@mozilla.org/scriptsecuritymanager;1"]
.getService(Ci.nsIScriptSecurityManager);
var childURI = ioService.newURI("chrome://browser/content/safebrowsing/blockedSite.xhtml",
null, null);
var channel = ioService.newChannelFromURI(childURI);
channel.originalURI = uri;
// Drop chrome privilege
var principal = secMan.getCodebasePrincipal(uri);
channel.owner = principal;
return channel;
}
PROT_Application.prototype.getURIFlags = function(uri) {
// We don't particularly *want* people linking to this from
// untrusted content, but given that bad sites can cause this page
// to appear (e.g. by having an iframe pointing to known malware),
// we should code as though this is explicitly possible.
return Ci.nsIAboutModule.ALLOW_SCRIPT |
Ci.nsIAboutModule.URI_SAFE_FOR_UNTRUSTED_CONTENT;
}
PROT_Application.prototype.QueryInterface = function(iid) {
if (iid.equals(Ci.nsISupports) ||
iid.equals(Ci.nsISupportsWeakReference) ||
iid.equals(Ci.nsIObserver) ||
iid.equals(Ci.nsIAboutModule))
iid.equals(Ci.nsIObserver))
return this;
throw Components.results.NS_ERROR_NO_INTERFACE;

Просмотреть файл

@ -55,13 +55,6 @@ SafebrowsingApplicationMod.prototype.registerSelf = function(compMgr, fileSpec,
fileSpec,
loc,
type);
compMgr.registerFactoryLocation(this.cid,
"UrlClassifier Blocked Error Page",
"@mozilla.org/network/protocol/about;1?what=blocked",
fileSpec,
loc,
type);
};
SafebrowsingApplicationMod.prototype.getClassObject = function(compMgr, cid, iid) {

Просмотреть файл

@ -42,7 +42,6 @@ include $(DEPTH)/config/autoconf.mk
EXTRA_PP_COMPONENTS = \
nsSessionStore.js \
nsSessionStartup.js \
aboutSessionRestore.js \
$(NULL)
include $(topsrcdir)/config/rules.mk

Просмотреть файл

@ -1,63 +0,0 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is the nsSessionStore component.
*
* The Initial Developer of the Original Code is
* Simon Bünzli <zeniko@gmail.com>
* Portions created by the Initial Developer are Copyright (C) 2008
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
const Cc = Components.classes;
const Ci = Components.interfaces;
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
function AboutSessionRestore() { }
AboutSessionRestore.prototype = {
classDescription: "about:sessionrestore",
contractID: "@mozilla.org/network/protocol/about;1?what=sessionrestore",
classID: Components.ID("{7c65e6f0-7605-11dd-ad8b-0800200c9a66}"),
QueryInterface: XPCOMUtils.generateQI([Ci.nsIAboutModule]),
getURIFlags: function(aURI) {
return Ci.nsIAboutModule.ALLOW_SCRIPT;
},
newChannel: function(aURI) {
let ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
let channel = ios.newChannel("chrome://browser/content/aboutSessionRestore.xhtml",
null, null);
channel.originalURI = aURI;
return channel;
}
};
function NSGetModule(compMgr, fileSpec)
XPCOMUtils.generateModule([AboutSessionRestore]);

Просмотреть файл

@ -61,6 +61,11 @@ XUL
#endif
@DLL_PREFIX@xpistub@DLL_SUFFIX@
component.reg
components/aboutCertError.js
components/aboutPrivateBrowsing.js
components/aboutRights.js
components/aboutRobots.js
components/aboutSessionRestore.js
components/compreg.dat
components/@DLL_PREFIX@myspell@DLL_SUFFIX@
components/@DLL_PREFIX@spellchecker@DLL_SUFFIX@

Просмотреть файл

@ -226,8 +226,6 @@ bin/components/extensions.xpt
bin/components/update.xpt
bin/components/nsSessionStartup.js
bin/components/nsSessionStore.js
bin/components/aboutPrivateBrowsing.js
bin/components/aboutSessionRestore.js
bin/components/sessionstore.xpt
bin/components/nsURLFormatter.js
bin/components/urlformatter.xpt
@ -244,9 +242,6 @@ bin/components/nsContentDispatchChooser.js
bin/components/nsHandlerService.js
bin/components/nsWebHandlerApp.js
bin/components/libdbusservice.so
bin/components/aboutRights.js
bin/components/aboutRobots.js
bin/components/aboutCertError.js
bin/components/nsBadCertHandler.js
bin/components/nsFormAutoComplete.js

Просмотреть файл

@ -242,8 +242,6 @@ bin\components\extensions.xpt
bin\components\update.xpt
bin\components\nsSessionStartup.js
bin\components\nsSessionStore.js
bin\components\aboutPrivateBrowsing.js
bin\components\aboutSessionRestore.js
bin\components\sessionstore.xpt
bin\components\nsURLFormatter.js
bin\components\urlformatter.xpt
@ -259,9 +257,6 @@ bin\components\nsContentPrefService.js
bin\components\nsContentDispatchChooser.js
bin\components\nsHandlerService.js
bin\components\nsWebHandlerApp.js
bin\components\aboutRights.js
bin\components\aboutRobots.js
bin\components\aboutCertError.js
bin\components\nsBadCertHandler.js
bin\components\nsFormAutoComplete.js