2001-09-28 20:14:13 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2007-12-20 03:11:02 +00:00
|
|
|
/* vim: set ts=2 sw=2 et tw=78: */
|
2012-05-21 11:12:37 +00:00
|
|
|
/* 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/. */
|
1999-04-02 00:52:35 +00:00
|
|
|
|
2005-02-22 21:49:45 +00:00
|
|
|
#include "nsChromeRegistry.h"
|
2010-07-01 15:55:57 +00:00
|
|
|
#include "nsChromeRegistryChrome.h"
|
|
|
|
#include "nsChromeRegistryContent.h"
|
2005-02-22 21:49:45 +00:00
|
|
|
|
2005-04-05 15:20:20 +00:00
|
|
|
#include "prprf.h"
|
2005-02-22 21:49:45 +00:00
|
|
|
|
1999-04-02 00:52:35 +00:00
|
|
|
#include "nsCOMPtr.h"
|
2012-07-27 14:03:27 +00:00
|
|
|
#include "nsError.h"
|
2005-02-22 21:49:45 +00:00
|
|
|
#include "nsEscape.h"
|
|
|
|
#include "nsNetUtil.h"
|
|
|
|
#include "nsString.h"
|
|
|
|
|
2014-06-20 10:32:49 +00:00
|
|
|
#include "mozilla/CSSStyleSheet.h"
|
|
|
|
#include "mozilla/dom/URL.h"
|
2005-04-05 15:20:20 +00:00
|
|
|
#include "nsIConsoleService.h"
|
2005-02-22 21:49:45 +00:00
|
|
|
#include "nsIDocument.h"
|
|
|
|
#include "nsIDOMDocument.h"
|
|
|
|
#include "nsIDOMLocation.h"
|
2005-02-20 01:47:13 +00:00
|
|
|
#include "nsIDOMWindowCollection.h"
|
2011-07-15 10:31:34 +00:00
|
|
|
#include "nsIDOMWindow.h"
|
2005-02-22 21:49:45 +00:00
|
|
|
#include "nsIObserverService.h"
|
|
|
|
#include "nsIPresShell.h"
|
2005-04-05 15:20:20 +00:00
|
|
|
#include "nsIScriptError.h"
|
2005-02-22 21:49:45 +00:00
|
|
|
#include "nsIWindowMediator.h"
|
1999-12-01 08:44:43 +00:00
|
|
|
|
2005-02-25 21:11:46 +00:00
|
|
|
nsChromeRegistry* nsChromeRegistry::gChromeRegistry;
|
2014-06-20 10:32:49 +00:00
|
|
|
|
|
|
|
// DO NOT use namespace mozilla; it'll break due to a naming conflict between
|
|
|
|
// mozilla::TextRange and a TextRange in OSX headers.
|
|
|
|
using mozilla::CSSStyleSheet;
|
2013-11-20 16:29:03 +00:00
|
|
|
using mozilla::dom::IsChromeURI;
|
2004-10-13 19:05:48 +00:00
|
|
|
|
1999-04-02 00:52:35 +00:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2010-05-13 23:44:53 +00:00
|
|
|
void
|
|
|
|
nsChromeRegistry::LogMessage(const char* aMsg, ...)
|
2005-04-05 15:20:20 +00:00
|
|
|
{
|
|
|
|
nsCOMPtr<nsIConsoleService> console
|
|
|
|
(do_GetService(NS_CONSOLESERVICE_CONTRACTID));
|
|
|
|
if (!console)
|
|
|
|
return;
|
|
|
|
|
|
|
|
va_list args;
|
|
|
|
va_start(args, aMsg);
|
|
|
|
char* formatted = PR_vsmprintf(aMsg, args);
|
|
|
|
va_end(args);
|
|
|
|
if (!formatted)
|
|
|
|
return;
|
|
|
|
|
|
|
|
console->LogStringMessage(NS_ConvertUTF8toUTF16(formatted).get());
|
|
|
|
PR_smprintf_free(formatted);
|
|
|
|
}
|
|
|
|
|
2010-05-13 23:44:53 +00:00
|
|
|
void
|
2012-08-22 15:56:38 +00:00
|
|
|
nsChromeRegistry::LogMessageWithContext(nsIURI* aURL, uint32_t aLineNumber, uint32_t flags,
|
2010-05-13 23:44:53 +00:00
|
|
|
const char* aMsg, ...)
|
2005-04-05 15:20:20 +00:00
|
|
|
{
|
|
|
|
nsresult rv;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIConsoleService> console
|
|
|
|
(do_GetService(NS_CONSOLESERVICE_CONTRACTID));
|
|
|
|
|
|
|
|
nsCOMPtr<nsIScriptError> error
|
|
|
|
(do_CreateInstance(NS_SCRIPTERROR_CONTRACTID));
|
|
|
|
if (!console || !error)
|
|
|
|
return;
|
|
|
|
|
|
|
|
va_list args;
|
|
|
|
va_start(args, aMsg);
|
|
|
|
char* formatted = PR_vsmprintf(aMsg, args);
|
|
|
|
va_end(args);
|
|
|
|
if (!formatted)
|
|
|
|
return;
|
|
|
|
|
|
|
|
nsCString spec;
|
|
|
|
if (aURL)
|
|
|
|
aURL->GetSpec(spec);
|
|
|
|
|
2012-09-09 23:29:12 +00:00
|
|
|
rv = error->Init(NS_ConvertUTF8toUTF16(formatted),
|
|
|
|
NS_ConvertUTF8toUTF16(spec),
|
|
|
|
EmptyString(),
|
2005-05-20 12:58:57 +00:00
|
|
|
aLineNumber, 0, flags, "chrome registration");
|
2005-04-05 15:20:20 +00:00
|
|
|
PR_smprintf_free(formatted);
|
|
|
|
|
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return;
|
|
|
|
|
|
|
|
console->LogMessage(error);
|
|
|
|
}
|
|
|
|
|
2005-02-22 21:49:45 +00:00
|
|
|
nsChromeRegistry::~nsChromeRegistry()
|
|
|
|
{
|
2012-07-30 14:20:58 +00:00
|
|
|
gChromeRegistry = nullptr;
|
1999-04-02 00:52:35 +00:00
|
|
|
}
|
|
|
|
|
2006-01-25 20:23:24 +00:00
|
|
|
NS_INTERFACE_MAP_BEGIN(nsChromeRegistry)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIChromeRegistry)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIXULChromeRegistry)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIToolkitChromeRegistry)
|
|
|
|
#ifdef MOZ_XUL
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIXULOverlayProvider)
|
|
|
|
#endif
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIObserver)
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
|
2006-01-26 01:07:37 +00:00
|
|
|
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIChromeRegistry)
|
2006-01-25 20:23:24 +00:00
|
|
|
NS_INTERFACE_MAP_END
|
|
|
|
|
|
|
|
NS_IMPL_ADDREF(nsChromeRegistry)
|
|
|
|
NS_IMPL_RELEASE(nsChromeRegistry)
|
1999-04-02 00:52:35 +00:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// nsIChromeRegistry methods:
|
1999-07-30 00:53:42 +00:00
|
|
|
|
2010-03-11 05:33:00 +00:00
|
|
|
already_AddRefed<nsIChromeRegistry>
|
|
|
|
nsChromeRegistry::GetService()
|
2004-09-21 20:19:48 +00:00
|
|
|
{
|
2010-07-23 18:16:00 +00:00
|
|
|
if (!gChromeRegistry)
|
2010-03-11 05:33:00 +00:00
|
|
|
{
|
|
|
|
// We don't actually want this ref, we just want the service to
|
|
|
|
// initialize if it hasn't already.
|
|
|
|
nsCOMPtr<nsIChromeRegistry> reg(
|
|
|
|
do_GetService(NS_CHROMEREGISTRY_CONTRACTID));
|
|
|
|
if (!gChromeRegistry)
|
2013-04-03 00:15:07 +00:00
|
|
|
return nullptr;
|
2010-03-11 05:33:00 +00:00
|
|
|
}
|
2013-04-22 11:15:59 +00:00
|
|
|
nsCOMPtr<nsIChromeRegistry> registry = gChromeRegistry;
|
|
|
|
return registry.forget();
|
2004-09-21 20:19:48 +00:00
|
|
|
}
|
|
|
|
|
2001-01-10 20:22:17 +00:00
|
|
|
nsresult
|
|
|
|
nsChromeRegistry::Init()
|
|
|
|
{
|
2005-02-25 21:11:46 +00:00
|
|
|
// This initialization process is fairly complicated and may cause reentrant
|
|
|
|
// getservice calls to resolve chrome URIs (especially locale files). We
|
|
|
|
// don't want that, so we inform the protocol handler about our existence
|
|
|
|
// before we are actually fully initialized.
|
|
|
|
gChromeRegistry = this;
|
|
|
|
|
2011-10-17 14:59:28 +00:00
|
|
|
mInitialized = true;
|
2005-02-25 21:11:46 +00:00
|
|
|
|
2001-01-10 20:22:17 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2005-02-22 21:49:45 +00:00
|
|
|
nsresult
|
|
|
|
nsChromeRegistry::GetProviderAndPath(nsIURL* aChromeURL,
|
|
|
|
nsACString& aProvider, nsACString& aPath)
|
2000-01-06 00:31:06 +00:00
|
|
|
{
|
2000-03-21 10:42:22 +00:00
|
|
|
nsresult rv;
|
2001-09-06 00:45:16 +00:00
|
|
|
|
2005-02-22 21:49:45 +00:00
|
|
|
#ifdef DEBUG
|
2011-09-29 06:19:26 +00:00
|
|
|
bool isChrome;
|
2005-02-22 21:49:45 +00:00
|
|
|
aChromeURL->SchemeIs("chrome", &isChrome);
|
|
|
|
NS_ASSERTION(isChrome, "Non-chrome URI?");
|
|
|
|
#endif
|
1999-04-02 00:52:35 +00:00
|
|
|
|
2012-09-02 02:35:17 +00:00
|
|
|
nsAutoCString path;
|
2005-02-22 21:49:45 +00:00
|
|
|
rv = aChromeURL->GetPath(path);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
1999-07-30 00:53:42 +00:00
|
|
|
|
2005-04-05 15:20:20 +00:00
|
|
|
if (path.Length() < 3) {
|
|
|
|
LogMessage("Invalid chrome URI: %s", path.get());
|
2005-02-22 21:49:45 +00:00
|
|
|
return NS_ERROR_FAILURE;
|
2005-04-05 15:20:20 +00:00
|
|
|
}
|
2005-02-20 01:47:13 +00:00
|
|
|
|
2005-02-22 21:49:45 +00:00
|
|
|
path.SetLength(nsUnescapeCount(path.BeginWriting()));
|
|
|
|
NS_ASSERTION(path.First() == '/', "Path should always begin with a slash!");
|
2005-02-20 01:47:13 +00:00
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t slash = path.FindChar('/', 1);
|
2005-04-05 15:20:20 +00:00
|
|
|
if (slash == 1) {
|
|
|
|
LogMessage("Invalid chrome URI: %s", path.get());
|
2005-02-22 21:49:45 +00:00
|
|
|
return NS_ERROR_FAILURE;
|
2005-04-05 15:20:20 +00:00
|
|
|
}
|
2005-02-20 01:47:13 +00:00
|
|
|
|
2005-02-22 21:49:45 +00:00
|
|
|
if (slash == -1) {
|
|
|
|
aPath.Truncate();
|
2005-02-20 01:47:13 +00:00
|
|
|
}
|
2005-02-22 21:49:45 +00:00
|
|
|
else {
|
2012-08-22 15:56:38 +00:00
|
|
|
if (slash == (int32_t) path.Length() - 1)
|
2005-02-22 21:49:45 +00:00
|
|
|
aPath.Truncate();
|
|
|
|
else
|
|
|
|
aPath.Assign(path.get() + slash + 1, path.Length() - slash - 1);
|
2005-02-20 01:47:13 +00:00
|
|
|
|
2005-02-22 21:49:45 +00:00
|
|
|
--slash;
|
2005-02-20 01:47:13 +00:00
|
|
|
}
|
|
|
|
|
2005-02-22 21:49:45 +00:00
|
|
|
aProvider.Assign(path.get() + 1, slash);
|
2005-02-20 01:47:13 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
nsresult
|
2005-02-22 21:49:45 +00:00
|
|
|
nsChromeRegistry::Canonify(nsIURL* aChromeURL)
|
2005-02-20 01:47:13 +00:00
|
|
|
{
|
2005-02-23 00:01:54 +00:00
|
|
|
NS_NAMED_LITERAL_CSTRING(kSlash, "/");
|
|
|
|
|
2005-02-20 01:47:13 +00:00
|
|
|
nsresult rv;
|
|
|
|
|
2012-09-02 02:35:17 +00:00
|
|
|
nsAutoCString provider, path;
|
2005-02-22 21:49:45 +00:00
|
|
|
rv = GetProviderAndPath(aChromeURL, provider, path);
|
2005-02-20 01:47:13 +00:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
2005-02-22 21:49:45 +00:00
|
|
|
if (path.IsEmpty()) {
|
2012-09-02 02:35:17 +00:00
|
|
|
nsAutoCString package;
|
2005-02-22 21:49:45 +00:00
|
|
|
rv = aChromeURL->GetHost(package);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2005-02-20 01:47:13 +00:00
|
|
|
|
2005-02-22 21:49:45 +00:00
|
|
|
// we re-use the "path" local string to build a new URL path
|
|
|
|
path.Assign(kSlash + provider + kSlash + package);
|
|
|
|
if (provider.EqualsLiteral("content")) {
|
|
|
|
path.AppendLiteral(".xul");
|
2005-02-20 01:47:13 +00:00
|
|
|
}
|
2005-02-22 21:49:45 +00:00
|
|
|
else if (provider.EqualsLiteral("locale")) {
|
|
|
|
path.AppendLiteral(".dtd");
|
|
|
|
}
|
|
|
|
else if (provider.EqualsLiteral("skin")) {
|
|
|
|
path.AppendLiteral(".css");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return NS_ERROR_INVALID_ARG;
|
2005-02-20 01:47:13 +00:00
|
|
|
}
|
2005-02-22 21:49:45 +00:00
|
|
|
aChromeURL->SetPath(path);
|
2004-09-21 20:19:48 +00:00
|
|
|
}
|
2006-05-19 23:32:49 +00:00
|
|
|
else {
|
2008-02-01 01:59:12 +00:00
|
|
|
// prevent directory traversals ("..")
|
|
|
|
// path is already unescaped once, but uris can get unescaped twice
|
2008-02-02 19:50:09 +00:00
|
|
|
const char* pos = path.BeginReading();
|
2008-02-01 01:59:12 +00:00
|
|
|
const char* end = path.EndReading();
|
2008-02-02 19:50:09 +00:00
|
|
|
while (pos < end) {
|
|
|
|
switch (*pos) {
|
2008-02-01 01:59:12 +00:00
|
|
|
case ':':
|
|
|
|
return NS_ERROR_DOM_BAD_URI;
|
|
|
|
case '.':
|
2008-02-02 19:50:09 +00:00
|
|
|
if (pos[1] == '.')
|
2008-02-01 01:59:12 +00:00
|
|
|
return NS_ERROR_DOM_BAD_URI;
|
2008-02-02 19:50:09 +00:00
|
|
|
break;
|
2008-02-01 01:59:12 +00:00
|
|
|
case '%':
|
|
|
|
// chrome: URIs with double-escapes are trying to trick us.
|
|
|
|
// watch for %2e, and %25 in case someone triple unescapes
|
2008-02-02 19:50:09 +00:00
|
|
|
if (pos[1] == '2' &&
|
|
|
|
( pos[2] == 'e' || pos[2] == 'E' ||
|
|
|
|
pos[2] == '5' ))
|
2008-02-01 01:59:12 +00:00
|
|
|
return NS_ERROR_DOM_BAD_URI;
|
2008-02-02 19:50:09 +00:00
|
|
|
break;
|
|
|
|
case '?':
|
2008-03-07 01:20:44 +00:00
|
|
|
case '#':
|
2008-02-02 19:50:09 +00:00
|
|
|
pos = end;
|
|
|
|
continue;
|
2008-02-01 01:59:12 +00:00
|
|
|
}
|
2008-02-02 19:50:09 +00:00
|
|
|
++pos;
|
2006-05-19 23:32:49 +00:00
|
|
|
}
|
2002-08-21 20:58:05 +00:00
|
|
|
}
|
|
|
|
|
2005-02-20 01:47:13 +00:00
|
|
|
return NS_OK;
|
2004-09-25 16:14:52 +00:00
|
|
|
}
|
|
|
|
|
2005-02-22 21:49:45 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsChromeRegistry::ConvertChromeURL(nsIURI* aChromeURI, nsIURI* *aResult)
|
2000-05-13 21:42:56 +00:00
|
|
|
{
|
2005-02-20 01:47:13 +00:00
|
|
|
nsresult rv;
|
2005-02-22 21:49:45 +00:00
|
|
|
NS_ASSERTION(aChromeURI, "null url!");
|
2004-09-21 20:19:48 +00:00
|
|
|
|
2005-06-01 19:09:44 +00:00
|
|
|
if (mOverrideTable.Get(aChromeURI, aResult))
|
|
|
|
return NS_OK;
|
|
|
|
|
2005-02-22 21:49:45 +00:00
|
|
|
nsCOMPtr<nsIURL> chromeURL (do_QueryInterface(aChromeURI));
|
|
|
|
NS_ENSURE_TRUE(chromeURL, NS_NOINTERFACE);
|
2005-02-20 01:47:13 +00:00
|
|
|
|
2012-09-02 02:35:17 +00:00
|
|
|
nsAutoCString package, provider, path;
|
2005-02-22 21:49:45 +00:00
|
|
|
rv = chromeURL->GetHostPort(package);
|
2005-02-20 01:47:13 +00:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
2005-02-22 21:49:45 +00:00
|
|
|
rv = GetProviderAndPath(chromeURL, provider, path);
|
2005-02-20 01:47:13 +00:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
2010-10-13 19:46:05 +00:00
|
|
|
nsIURI* baseURI = GetBaseURIFromPackage(package, provider, path);
|
2005-06-07 19:28:23 +00:00
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t flags;
|
2010-03-11 05:33:00 +00:00
|
|
|
rv = GetFlagsFromPackage(package, &flags);
|
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return rv;
|
2005-02-20 01:47:13 +00:00
|
|
|
|
2010-03-11 05:33:00 +00:00
|
|
|
if (flags & PLATFORM_PACKAGE) {
|
2014-02-10 22:57:01 +00:00
|
|
|
#if defined(XP_WIN)
|
2005-02-22 21:49:45 +00:00
|
|
|
path.Insert("win/", 0);
|
|
|
|
#elif defined(XP_MACOSX)
|
|
|
|
path.Insert("mac/", 0);
|
|
|
|
#else
|
|
|
|
path.Insert("unix/", 0);
|
|
|
|
#endif
|
2005-02-20 01:47:13 +00:00
|
|
|
}
|
|
|
|
|
2005-04-05 15:20:20 +00:00
|
|
|
if (!baseURI) {
|
2007-11-13 08:50:30 +00:00
|
|
|
LogMessage("No chrome package registered for chrome://%s/%s/%s",
|
2005-04-05 15:20:20 +00:00
|
|
|
package.get(), provider.get(), path.get());
|
2014-06-20 23:50:58 +00:00
|
|
|
return NS_ERROR_FILE_NOT_FOUND;
|
2005-04-05 15:20:20 +00:00
|
|
|
}
|
2004-09-25 16:14:52 +00:00
|
|
|
|
2012-07-30 14:20:58 +00:00
|
|
|
return NS_NewURI(aResult, path, nullptr, baseURI);
|
2000-05-13 21:42:56 +00:00
|
|
|
}
|
|
|
|
|
1999-08-05 04:33:41 +00:00
|
|
|
////////////////////////////////////////////////////////////////////////
|
|
|
|
|
1999-10-27 09:24:23 +00:00
|
|
|
// theme stuff
|
|
|
|
|
2001-12-17 22:51:39 +00:00
|
|
|
|
2011-07-15 10:31:34 +00:00
|
|
|
static void FlushSkinBindingsForWindow(nsIDOMWindow* aWindow)
|
1999-11-24 01:12:35 +00:00
|
|
|
{
|
2001-12-17 22:51:39 +00:00
|
|
|
// Get the DOM document.
|
|
|
|
nsCOMPtr<nsIDOMDocument> domDocument;
|
|
|
|
aWindow->GetDocument(getter_AddRefs(domDocument));
|
|
|
|
if (!domDocument)
|
|
|
|
return;
|
1999-11-24 01:12:35 +00:00
|
|
|
|
2001-12-17 22:51:39 +00:00
|
|
|
nsCOMPtr<nsIDocument> document = do_QueryInterface(domDocument);
|
|
|
|
if (!document)
|
|
|
|
return;
|
Bit checkin for bug 68045, r/sr=waterson&shaver, second attempt. It all works
for me on optimized and debug gcc2.96, rh7.1.
- Better failure codes from nsXULPrototypeScript::Deserialize.
- Call nsXULDocument::AbortFastLoads after nsXULPrototypeScript::Serialize
failure, instead of just nulling the FastLoad service's output stream.
- Expose nsXULDocument::AbortFastLoads via nsIXULPrototypeCache, for use from
nsChromeProtocolHandler.cpp. AbortFastLoads flushes the XUL cache now, for
good measure.
- The needless "Current" adjective in nsIFastLoadService attribute and method
names is no more.
- Add a do_GetFastLoadService() helper, to use CID instead of contractid, and
to let the compiler consolidate the static inline CID.
- Add "nglayout.debug.checksum_xul_fastload_file" pref so people can do without
the checksum verification step when reading a FastLoad file.
- Verify the FastLoad file checksum, by default. Also, cache it in the FastLoad
service so we don't recompute it when re-opening the FastLoad file as mailnews
and other top-levels start up. Fill the checksum cache in EndFastLoad, when
the last pseudo-concurrent top-level finishes loading.
My hope to compute the checksum while writing the FastLoad file ran afoul of
misordered writes. The old code to checksum the in-memory nsFastLoadHeader
also was broken on little endian platforms. Now all checksumming is done via
a separate read pass over the complete file, save for the header's checksum
field, which is summed as if it contained zero.
- Track and check FastLoad file dependencies. This required groveling with a
bunch of Necko interfaces in nsChromeProtocolHandler::NewChannel -- read it
and weep. Dependency checking, as well as checksum access and computation,
use better-factored nsIFastLoad{File,Read,Write}Control interfaces.
- nsBufferedStream::Seek wasn't flushing the buffer when seeking backward
within the buffer, but it must, because mCursor bounds the amount to write
if the buffer contains the end of file.
- Add an unbufferedStream readonly attribute to nsIStreamBufferAccess, so we
don't have to screw around with the bufferying layer when checksumming. Also
implement nsIStreamBufferAccess in nsBufferedOutputStream.
- nsISeekableOutputStream was bogus, based on a bad state I had put the
nsBufferedOutputStream code in on its way from being completely broken when
you seek backwards outside of the buffer. Removing this interface required
using nsIFastLoadFileIO in nsFastLoadFileWriter, and it also required careful
ordering of Close calls (the Reader must close after the Writer or Updater,
so that the Reader's underlying, unbuffered input stream can be read by
nsFastLoadFileWriter::Close to compute the checksum.
- Miscellaneous tab/indentation, comment typo, bracing, if( => if ( style,
nsnull vs. 0, useless variable elimination, tortured control flow,
AutoString instead of String, and gratuitous ; after nsISupportsUtils.h
macro call cleanups.
2001-08-21 20:51:34 +00:00
|
|
|
|
2001-12-17 22:51:39 +00:00
|
|
|
// Annihilate all XBL bindings.
|
2007-02-16 22:59:06 +00:00
|
|
|
document->FlushSkinBindings();
|
2001-12-17 22:51:39 +00:00
|
|
|
}
|
1999-11-24 01:12:35 +00:00
|
|
|
|
2004-03-09 19:59:09 +00:00
|
|
|
// XXXbsmedberg: move this to nsIWindowMediator
|
2001-12-17 22:51:39 +00:00
|
|
|
NS_IMETHODIMP nsChromeRegistry::RefreshSkins()
|
|
|
|
{
|
2005-02-22 21:49:45 +00:00
|
|
|
nsCOMPtr<nsIWindowMediator> windowMediator
|
|
|
|
(do_GetService(NS_WINDOWMEDIATOR_CONTRACTID));
|
2001-12-17 22:51:39 +00:00
|
|
|
if (!windowMediator)
|
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
nsCOMPtr<nsISimpleEnumerator> windowEnumerator;
|
2012-07-30 14:20:58 +00:00
|
|
|
windowMediator->GetEnumerator(nullptr, getter_AddRefs(windowEnumerator));
|
2011-09-29 06:19:26 +00:00
|
|
|
bool more;
|
2001-12-17 22:51:39 +00:00
|
|
|
windowEnumerator->HasMoreElements(&more);
|
|
|
|
while (more) {
|
|
|
|
nsCOMPtr<nsISupports> protoWindow;
|
|
|
|
windowEnumerator->GetNext(getter_AddRefs(protoWindow));
|
|
|
|
if (protoWindow) {
|
2011-07-15 10:31:34 +00:00
|
|
|
nsCOMPtr<nsIDOMWindow> domWindow = do_QueryInterface(protoWindow);
|
2001-12-17 22:51:39 +00:00
|
|
|
if (domWindow)
|
|
|
|
FlushSkinBindingsForWindow(domWindow);
|
1999-11-24 01:12:35 +00:00
|
|
|
}
|
2001-12-17 22:51:39 +00:00
|
|
|
windowEnumerator->HasMoreElements(&more);
|
1999-11-24 01:12:35 +00:00
|
|
|
}
|
|
|
|
|
2004-03-09 19:59:09 +00:00
|
|
|
FlushSkinCaches();
|
2010-03-02 21:00:39 +00:00
|
|
|
|
2012-07-30 14:20:58 +00:00
|
|
|
windowMediator->GetEnumerator(nullptr, getter_AddRefs(windowEnumerator));
|
2001-12-17 22:51:39 +00:00
|
|
|
windowEnumerator->HasMoreElements(&more);
|
|
|
|
while (more) {
|
|
|
|
nsCOMPtr<nsISupports> protoWindow;
|
|
|
|
windowEnumerator->GetNext(getter_AddRefs(protoWindow));
|
|
|
|
if (protoWindow) {
|
2011-07-15 10:31:34 +00:00
|
|
|
nsCOMPtr<nsIDOMWindow> domWindow = do_QueryInterface(protoWindow);
|
2001-12-17 22:51:39 +00:00
|
|
|
if (domWindow)
|
2010-03-02 21:00:39 +00:00
|
|
|
RefreshWindow(domWindow);
|
2001-12-17 22:51:39 +00:00
|
|
|
}
|
|
|
|
windowEnumerator->HasMoreElements(&more);
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
2001-05-10 23:18:49 +00:00
|
|
|
}
|
|
|
|
|
2004-03-09 19:59:09 +00:00
|
|
|
void
|
|
|
|
nsChromeRegistry::FlushSkinCaches()
|
2001-05-10 23:18:49 +00:00
|
|
|
{
|
2004-03-09 19:59:09 +00:00
|
|
|
nsCOMPtr<nsIObserverService> obsSvc =
|
Bug 560095 - Use mozilla::services::GetObserverService(). r=biesi,dveditz,gavin,josh,jst,mrbkap,roc,sdwilsh,shaver,sicking,smontagu,surkov
2010-04-29 16:59:13 +00:00
|
|
|
mozilla::services::GetObserverService();
|
2004-03-09 19:59:09 +00:00
|
|
|
NS_ASSERTION(obsSvc, "Couldn't get observer service.");
|
2000-05-27 20:03:14 +00:00
|
|
|
|
2007-07-08 07:08:04 +00:00
|
|
|
obsSvc->NotifyObservers(static_cast<nsIChromeRegistry*>(this),
|
2012-07-30 14:20:58 +00:00
|
|
|
NS_CHROME_FLUSH_SKINS_TOPIC, nullptr);
|
1999-11-24 01:12:35 +00:00
|
|
|
}
|
|
|
|
|
2004-03-09 19:59:09 +00:00
|
|
|
// XXXbsmedberg: move this to windowmediator
|
2011-07-15 10:31:34 +00:00
|
|
|
nsresult nsChromeRegistry::RefreshWindow(nsIDOMWindow* aWindow)
|
1999-10-27 09:24:23 +00:00
|
|
|
{
|
2001-12-17 22:51:39 +00:00
|
|
|
// Deal with our subframes first.
|
|
|
|
nsCOMPtr<nsIDOMWindowCollection> frames;
|
|
|
|
aWindow->GetFrames(getter_AddRefs(frames));
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t length;
|
2001-12-17 22:51:39 +00:00
|
|
|
frames->GetLength(&length);
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t j;
|
2002-12-03 06:39:59 +00:00
|
|
|
for (j = 0; j < length; j++) {
|
2001-12-17 22:51:39 +00:00
|
|
|
nsCOMPtr<nsIDOMWindow> childWin;
|
2002-12-03 06:39:59 +00:00
|
|
|
frames->Item(j, getter_AddRefs(childWin));
|
2011-07-15 10:31:34 +00:00
|
|
|
RefreshWindow(childWin);
|
2001-12-17 22:51:39 +00:00
|
|
|
}
|
|
|
|
|
2000-08-21 07:50:39 +00:00
|
|
|
nsresult rv;
|
1999-11-24 01:12:35 +00:00
|
|
|
// Get the DOM document.
|
1999-11-24 03:45:45 +00:00
|
|
|
nsCOMPtr<nsIDOMDocument> domDocument;
|
|
|
|
aWindow->GetDocument(getter_AddRefs(domDocument));
|
|
|
|
if (!domDocument)
|
|
|
|
return NS_OK;
|
1999-11-24 01:12:35 +00:00
|
|
|
|
2000-08-21 07:50:39 +00:00
|
|
|
nsCOMPtr<nsIDocument> document = do_QueryInterface(domDocument);
|
|
|
|
if (!document)
|
|
|
|
return NS_OK;
|
1999-11-24 01:12:35 +00:00
|
|
|
|
2002-12-03 05:48:14 +00:00
|
|
|
// Deal with the agent sheets first. Have to do all the style sets by hand.
|
2010-06-25 13:59:57 +00:00
|
|
|
nsCOMPtr<nsIPresShell> shell = document->GetShell();
|
2010-01-07 10:36:11 +00:00
|
|
|
if (shell) {
|
2004-01-07 22:30:53 +00:00
|
|
|
// Reload only the chrome URL agent style sheets.
|
|
|
|
nsCOMArray<nsIStyleSheet> agentSheets;
|
|
|
|
rv = shell->GetAgentStyleSheets(agentSheets);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
nsCOMArray<nsIStyleSheet> newAgentSheets;
|
2012-08-22 15:56:38 +00:00
|
|
|
for (int32_t l = 0; l < agentSheets.Count(); ++l) {
|
2004-01-07 22:30:53 +00:00
|
|
|
nsIStyleSheet *sheet = agentSheets[l];
|
2003-09-27 18:49:39 +00:00
|
|
|
|
2010-05-18 04:00:40 +00:00
|
|
|
nsIURI* uri = sheet->GetSheetURI();
|
2002-12-11 00:09:28 +00:00
|
|
|
|
2004-12-02 02:13:20 +00:00
|
|
|
if (IsChromeURI(uri)) {
|
|
|
|
// Reload the sheet.
|
2014-06-20 10:32:49 +00:00
|
|
|
nsRefPtr<CSSStyleSheet> newSheet;
|
2011-10-17 14:59:28 +00:00
|
|
|
rv = document->LoadChromeSheetSync(uri, true,
|
2010-03-02 21:00:39 +00:00
|
|
|
getter_AddRefs(newSheet));
|
2002-12-11 00:09:28 +00:00
|
|
|
if (NS_FAILED(rv)) return rv;
|
2004-01-07 22:30:53 +00:00
|
|
|
if (newSheet) {
|
|
|
|
rv = newAgentSheets.AppendObject(newSheet) ? NS_OK : NS_ERROR_FAILURE;
|
2003-09-27 18:49:39 +00:00
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
}
|
2000-05-27 20:03:14 +00:00
|
|
|
}
|
2004-01-07 22:30:53 +00:00
|
|
|
else { // Just use the same sheet.
|
|
|
|
rv = newAgentSheets.AppendObject(sheet) ? NS_OK : NS_ERROR_FAILURE;
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
}
|
2000-05-27 20:03:14 +00:00
|
|
|
}
|
2004-01-07 22:30:53 +00:00
|
|
|
|
|
|
|
rv = shell->SetAgentStyleSheets(newAgentSheets);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2002-12-03 05:48:14 +00:00
|
|
|
}
|
2000-05-27 20:03:14 +00:00
|
|
|
|
2002-12-03 05:48:14 +00:00
|
|
|
// Build an array of nsIURIs of style sheets we need to load.
|
|
|
|
nsCOMArray<nsIStyleSheet> oldSheets;
|
|
|
|
nsCOMArray<nsIStyleSheet> newSheets;
|
2000-05-27 20:03:14 +00:00
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t count = document->GetNumberOfStyleSheets();
|
2000-05-27 20:03:14 +00:00
|
|
|
|
2002-12-03 05:48:14 +00:00
|
|
|
// Iterate over the style sheets.
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t i;
|
2002-12-03 05:48:14 +00:00
|
|
|
for (i = 0; i < count; i++) {
|
|
|
|
// Get the style sheet
|
2004-07-28 07:08:41 +00:00
|
|
|
nsIStyleSheet *styleSheet = document->GetStyleSheetAt(i);
|
2010-03-02 21:00:39 +00:00
|
|
|
|
2002-12-03 05:48:14 +00:00
|
|
|
if (!oldSheets.AppendObject(styleSheet)) {
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
2000-08-21 07:50:39 +00:00
|
|
|
}
|
2002-12-03 05:48:14 +00:00
|
|
|
}
|
Bit checkin for bug 68045, r/sr=waterson&shaver, second attempt. It all works
for me on optimized and debug gcc2.96, rh7.1.
- Better failure codes from nsXULPrototypeScript::Deserialize.
- Call nsXULDocument::AbortFastLoads after nsXULPrototypeScript::Serialize
failure, instead of just nulling the FastLoad service's output stream.
- Expose nsXULDocument::AbortFastLoads via nsIXULPrototypeCache, for use from
nsChromeProtocolHandler.cpp. AbortFastLoads flushes the XUL cache now, for
good measure.
- The needless "Current" adjective in nsIFastLoadService attribute and method
names is no more.
- Add a do_GetFastLoadService() helper, to use CID instead of contractid, and
to let the compiler consolidate the static inline CID.
- Add "nglayout.debug.checksum_xul_fastload_file" pref so people can do without
the checksum verification step when reading a FastLoad file.
- Verify the FastLoad file checksum, by default. Also, cache it in the FastLoad
service so we don't recompute it when re-opening the FastLoad file as mailnews
and other top-levels start up. Fill the checksum cache in EndFastLoad, when
the last pseudo-concurrent top-level finishes loading.
My hope to compute the checksum while writing the FastLoad file ran afoul of
misordered writes. The old code to checksum the in-memory nsFastLoadHeader
also was broken on little endian platforms. Now all checksumming is done via
a separate read pass over the complete file, save for the header's checksum
field, which is summed as if it contained zero.
- Track and check FastLoad file dependencies. This required groveling with a
bunch of Necko interfaces in nsChromeProtocolHandler::NewChannel -- read it
and weep. Dependency checking, as well as checksum access and computation,
use better-factored nsIFastLoad{File,Read,Write}Control interfaces.
- nsBufferedStream::Seek wasn't flushing the buffer when seeking backward
within the buffer, but it must, because mCursor bounds the amount to write
if the buffer contains the end of file.
- Add an unbufferedStream readonly attribute to nsIStreamBufferAccess, so we
don't have to screw around with the bufferying layer when checksumming. Also
implement nsIStreamBufferAccess in nsBufferedOutputStream.
- nsISeekableOutputStream was bogus, based on a bad state I had put the
nsBufferedOutputStream code in on its way from being completely broken when
you seek backwards outside of the buffer. Removing this interface required
using nsIFastLoadFileIO in nsFastLoadFileWriter, and it also required careful
ordering of Close calls (the Reader must close after the Writer or Updater,
so that the Reader's underlying, unbuffered input stream can be read by
nsFastLoadFileWriter::Close to compute the checksum.
- Miscellaneous tab/indentation, comment typo, bracing, if( => if ( style,
nsnull vs. 0, useless variable elimination, tortured control flow,
AutoString instead of String, and gratuitous ; after nsISupportsUtils.h
macro call cleanups.
2001-08-21 20:51:34 +00:00
|
|
|
|
2010-03-02 21:00:39 +00:00
|
|
|
// Iterate over our old sheets and kick off a sync load of the new
|
2002-12-03 05:48:14 +00:00
|
|
|
// sheet if and only if it's a chrome URL.
|
|
|
|
for (i = 0; i < count; i++) {
|
2014-06-20 10:32:49 +00:00
|
|
|
nsRefPtr<CSSStyleSheet> sheet = do_QueryObject(oldSheets[i]);
|
2012-07-30 14:20:58 +00:00
|
|
|
nsIURI* uri = sheet ? sheet->GetOriginalURI() : nullptr;
|
2001-12-17 22:51:39 +00:00
|
|
|
|
2009-03-10 13:52:23 +00:00
|
|
|
if (uri && IsChromeURI(uri)) {
|
2002-12-03 05:48:14 +00:00
|
|
|
// Reload the sheet.
|
2014-06-20 10:32:49 +00:00
|
|
|
nsRefPtr<CSSStyleSheet> newSheet;
|
2002-12-03 05:48:14 +00:00
|
|
|
// XXX what about chrome sheets that have a title or are disabled? This
|
|
|
|
// only works by sheer dumb luck.
|
2011-10-17 14:59:28 +00:00
|
|
|
document->LoadChromeSheetSync(uri, false, getter_AddRefs(newSheet));
|
2002-12-03 05:48:14 +00:00
|
|
|
// Even if it's null, we put in in there.
|
|
|
|
newSheets.AppendObject(newSheet);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// Just use the same sheet.
|
|
|
|
newSheets.AppendObject(sheet);
|
2000-08-21 07:50:39 +00:00
|
|
|
}
|
|
|
|
}
|
1999-11-24 07:37:38 +00:00
|
|
|
|
2002-12-03 05:48:14 +00:00
|
|
|
// Now notify the document that multiple sheets have been added and removed.
|
|
|
|
document->UpdateStyleSheets(oldSheets, newSheets);
|
1999-10-27 09:24:23 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2005-02-22 21:49:45 +00:00
|
|
|
void
|
|
|
|
nsChromeRegistry::FlushAllCaches()
|
1999-10-27 09:24:23 +00:00
|
|
|
{
|
2005-02-22 21:49:45 +00:00
|
|
|
nsCOMPtr<nsIObserverService> obsSvc =
|
Bug 560095 - Use mozilla::services::GetObserverService(). r=biesi,dveditz,gavin,josh,jst,mrbkap,roc,sdwilsh,shaver,sicking,smontagu,surkov
2010-04-29 16:59:13 +00:00
|
|
|
mozilla::services::GetObserverService();
|
2005-02-22 21:49:45 +00:00
|
|
|
NS_ASSERTION(obsSvc, "Couldn't get observer service.");
|
2005-02-20 01:47:13 +00:00
|
|
|
|
2005-02-22 21:49:45 +00:00
|
|
|
obsSvc->NotifyObservers((nsIChromeRegistry*) this,
|
2012-07-30 14:20:58 +00:00
|
|
|
NS_CHROME_FLUSH_TOPIC, nullptr);
|
2005-02-22 21:49:45 +00:00
|
|
|
}
|
2005-02-20 01:47:13 +00:00
|
|
|
|
2005-02-22 21:49:45 +00:00
|
|
|
// xxxbsmedberg Move me to nsIWindowMediator
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsChromeRegistry::ReloadChrome()
|
|
|
|
{
|
2010-11-30 14:02:23 +00:00
|
|
|
UpdateSelectedLocale();
|
2005-02-22 21:49:45 +00:00
|
|
|
FlushAllCaches();
|
|
|
|
// Do a reload of all top level windows.
|
|
|
|
nsresult rv = NS_OK;
|
2005-02-20 01:47:13 +00:00
|
|
|
|
2005-02-22 21:49:45 +00:00
|
|
|
// Get the window mediator
|
|
|
|
nsCOMPtr<nsIWindowMediator> windowMediator
|
|
|
|
(do_GetService(NS_WINDOWMEDIATOR_CONTRACTID));
|
|
|
|
if (windowMediator) {
|
|
|
|
nsCOMPtr<nsISimpleEnumerator> windowEnumerator;
|
2005-02-20 01:47:13 +00:00
|
|
|
|
2012-07-30 14:20:58 +00:00
|
|
|
rv = windowMediator->GetEnumerator(nullptr, getter_AddRefs(windowEnumerator));
|
2005-02-22 21:49:45 +00:00
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
// Get each dom window
|
2011-09-29 06:19:26 +00:00
|
|
|
bool more;
|
2005-02-22 21:49:45 +00:00
|
|
|
rv = windowEnumerator->HasMoreElements(&more);
|
2004-09-21 20:19:48 +00:00
|
|
|
if (NS_FAILED(rv)) return rv;
|
2005-02-22 21:49:45 +00:00
|
|
|
while (more) {
|
|
|
|
nsCOMPtr<nsISupports> protoWindow;
|
|
|
|
rv = windowEnumerator->GetNext(getter_AddRefs(protoWindow));
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
2011-07-15 10:31:34 +00:00
|
|
|
nsCOMPtr<nsIDOMWindow> domWindow = do_QueryInterface(protoWindow);
|
2005-02-22 21:49:45 +00:00
|
|
|
if (domWindow) {
|
|
|
|
nsCOMPtr<nsIDOMLocation> location;
|
|
|
|
domWindow->GetLocation(getter_AddRefs(location));
|
|
|
|
if (location) {
|
2011-10-17 14:59:28 +00:00
|
|
|
rv = location->Reload(false);
|
2005-02-22 21:49:45 +00:00
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
rv = windowEnumerator->HasMoreElements(&more);
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
}
|
2004-09-21 20:19:48 +00:00
|
|
|
}
|
|
|
|
}
|
2000-08-21 07:50:39 +00:00
|
|
|
return rv;
|
1999-11-24 01:12:35 +00:00
|
|
|
}
|
|
|
|
|
2005-02-22 21:49:45 +00:00
|
|
|
NS_IMETHODIMP
|
2011-09-29 06:19:26 +00:00
|
|
|
nsChromeRegistry::AllowScriptsForPackage(nsIURI* aChromeURI, bool *aResult)
|
2001-03-08 01:50:36 +00:00
|
|
|
{
|
2004-09-21 20:19:48 +00:00
|
|
|
nsresult rv;
|
2011-10-17 14:59:28 +00:00
|
|
|
*aResult = false;
|
2001-03-08 01:50:36 +00:00
|
|
|
|
2005-02-22 21:49:45 +00:00
|
|
|
#ifdef DEBUG
|
2011-09-29 06:19:26 +00:00
|
|
|
bool isChrome;
|
2005-02-22 21:49:45 +00:00
|
|
|
aChromeURI->SchemeIs("chrome", &isChrome);
|
|
|
|
NS_ASSERTION(isChrome, "Non-chrome URI passed to AllowScriptsForPackage!");
|
|
|
|
#endif
|
2005-02-20 01:47:13 +00:00
|
|
|
|
2005-02-22 21:49:45 +00:00
|
|
|
nsCOMPtr<nsIURL> url (do_QueryInterface(aChromeURI));
|
|
|
|
NS_ENSURE_TRUE(url, NS_NOINTERFACE);
|
2005-02-20 01:47:13 +00:00
|
|
|
|
2012-09-02 02:35:17 +00:00
|
|
|
nsAutoCString provider, file;
|
2005-02-22 21:49:45 +00:00
|
|
|
rv = GetProviderAndPath(url, provider, file);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2005-02-20 01:47:13 +00:00
|
|
|
|
2005-02-22 21:49:45 +00:00
|
|
|
if (!provider.EqualsLiteral("skin"))
|
2011-10-17 14:59:28 +00:00
|
|
|
*aResult = true;
|
2001-03-08 01:50:36 +00:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2008-04-11 13:39:43 +00:00
|
|
|
NS_IMETHODIMP
|
2011-09-29 06:19:26 +00:00
|
|
|
nsChromeRegistry::AllowContentToAccess(nsIURI *aURI, bool *aResult)
|
2008-04-11 13:39:43 +00:00
|
|
|
{
|
|
|
|
nsresult rv;
|
|
|
|
|
2011-10-17 14:59:28 +00:00
|
|
|
*aResult = false;
|
2008-04-11 13:39:43 +00:00
|
|
|
|
|
|
|
#ifdef DEBUG
|
2011-09-29 06:19:26 +00:00
|
|
|
bool isChrome;
|
2008-04-11 13:39:43 +00:00
|
|
|
aURI->SchemeIs("chrome", &isChrome);
|
|
|
|
NS_ASSERTION(isChrome, "Non-chrome URI passed to AllowContentToAccess!");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
nsCOMPtr<nsIURL> url = do_QueryInterface(aURI);
|
|
|
|
if (!url) {
|
|
|
|
NS_ERROR("Chrome URL doesn't implement nsIURL.");
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
}
|
|
|
|
|
2012-09-02 02:35:17 +00:00
|
|
|
nsAutoCString package;
|
2008-04-11 13:39:43 +00:00
|
|
|
rv = url->GetHostPort(package);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t flags;
|
2010-03-11 05:33:00 +00:00
|
|
|
rv = GetFlagsFromPackage(package, &flags);
|
2008-04-11 13:39:43 +00:00
|
|
|
|
2010-03-11 05:33:00 +00:00
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
*aResult = !!(flags & CONTENT_ACCESSIBLE);
|
2008-04-11 13:39:43 +00:00
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2015-02-05 16:09:15 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsChromeRegistry::CanLoadURLRemotely(nsIURI *aURI, bool *aResult)
|
|
|
|
{
|
|
|
|
nsresult rv;
|
|
|
|
|
|
|
|
*aResult = false;
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
bool isChrome;
|
|
|
|
aURI->SchemeIs("chrome", &isChrome);
|
|
|
|
NS_ASSERTION(isChrome, "Non-chrome URI passed to CanLoadURLRemotely!");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
nsCOMPtr<nsIURL> url = do_QueryInterface(aURI);
|
|
|
|
if (!url) {
|
|
|
|
NS_ERROR("Chrome URL doesn't implement nsIURL.");
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsAutoCString package;
|
|
|
|
rv = url->GetHostPort(package);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
uint32_t flags;
|
|
|
|
rv = GetFlagsFromPackage(package, &flags);
|
|
|
|
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
*aResult = !!(flags & REMOTE_ALLOWED);
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsChromeRegistry::MustLoadURLRemotely(nsIURI *aURI, bool *aResult)
|
|
|
|
{
|
|
|
|
nsresult rv;
|
|
|
|
|
|
|
|
*aResult = false;
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
bool isChrome;
|
|
|
|
aURI->SchemeIs("chrome", &isChrome);
|
|
|
|
NS_ASSERTION(isChrome, "Non-chrome URI passed to MustLoadURLRemotely!");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
nsCOMPtr<nsIURL> url = do_QueryInterface(aURI);
|
|
|
|
if (!url) {
|
|
|
|
NS_ERROR("Chrome URL doesn't implement nsIURL.");
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsAutoCString package;
|
|
|
|
rv = url->GetHostPort(package);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
uint32_t flags;
|
|
|
|
rv = GetFlagsFromPackage(package, &flags);
|
|
|
|
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
*aResult = !!(flags & REMOTE_REQUIRED);
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
NS_IMETHODIMP_(bool)
|
2008-11-14 00:00:11 +00:00
|
|
|
nsChromeRegistry::WrappersEnabled(nsIURI *aURI)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIURL> chromeURL (do_QueryInterface(aURI));
|
|
|
|
if (!chromeURL)
|
2011-10-17 14:59:28 +00:00
|
|
|
return false;
|
2008-11-14 00:00:11 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool isChrome = false;
|
2008-11-14 00:00:11 +00:00
|
|
|
nsresult rv = chromeURL->SchemeIs("chrome", &isChrome);
|
|
|
|
if (NS_FAILED(rv) || !isChrome)
|
2011-10-17 14:59:28 +00:00
|
|
|
return false;
|
2008-11-14 00:00:11 +00:00
|
|
|
|
2012-09-02 02:35:17 +00:00
|
|
|
nsAutoCString package;
|
2008-11-14 00:00:11 +00:00
|
|
|
rv = chromeURL->GetHostPort(package);
|
|
|
|
if (NS_FAILED(rv))
|
2011-10-17 14:59:28 +00:00
|
|
|
return false;
|
2008-11-14 00:00:11 +00:00
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t flags;
|
2010-06-07 22:49:12 +00:00
|
|
|
rv = GetFlagsFromPackage(package, &flags);
|
|
|
|
return NS_SUCCEEDED(rv) && (flags & XPCNATIVEWRAPPERS);
|
2008-11-14 00:00:11 +00:00
|
|
|
}
|
|
|
|
|
2010-07-01 15:55:57 +00:00
|
|
|
already_AddRefed<nsChromeRegistry>
|
|
|
|
nsChromeRegistry::GetSingleton()
|
2009-11-02 18:04:45 +00:00
|
|
|
{
|
2010-07-01 15:55:57 +00:00
|
|
|
if (gChromeRegistry) {
|
2013-04-22 11:15:59 +00:00
|
|
|
nsRefPtr<nsChromeRegistry> registry = gChromeRegistry;
|
|
|
|
return registry.forget();
|
2009-11-02 18:04:45 +00:00
|
|
|
}
|
|
|
|
|
2010-07-01 15:55:57 +00:00
|
|
|
nsRefPtr<nsChromeRegistry> cr;
|
|
|
|
if (GeckoProcessType_Content == XRE_GetProcessType())
|
|
|
|
cr = new nsChromeRegistryContent();
|
|
|
|
else
|
|
|
|
cr = new nsChromeRegistryChrome();
|
2005-07-14 15:40:25 +00:00
|
|
|
|
2010-07-01 15:55:57 +00:00
|
|
|
if (NS_FAILED(cr->Init()))
|
2013-04-03 00:15:07 +00:00
|
|
|
return nullptr;
|
2005-07-14 15:40:25 +00:00
|
|
|
|
2010-07-01 15:55:57 +00:00
|
|
|
return cr.forget();
|
2001-05-17 02:02:51 +00:00
|
|
|
}
|