2001-09-29 00:14:13 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2004-09-07 22:59:07 +04:00
|
|
|
/* vim:set ts=4 sw=4 sts=4 et cin: */
|
2012-05-21 15:12:37 +04: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/. */
|
2000-02-06 04:30:16 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
A protocol handler for ``chrome:''
|
|
|
|
|
|
|
|
*/
|
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-22 00:51:34 +04:00
|
|
|
|
2004-10-13 23:05:48 +04:00
|
|
|
#include "nsChromeProtocolHandler.h"
|
2005-02-23 00:49:45 +03:00
|
|
|
#include "nsChromeRegistry.h"
|
1999-12-04 10:45:57 +03:00
|
|
|
#include "nsCOMPtr.h"
|
2006-05-10 21:30:15 +04:00
|
|
|
#include "nsThreadUtils.h"
|
1999-08-30 01:58:42 +04:00
|
|
|
#include "nsIChannel.h"
|
2004-10-13 23:05:48 +04:00
|
|
|
#include "nsIChromeRegistry.h"
|
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-22 00:51:34 +04:00
|
|
|
#include "nsIFile.h"
|
|
|
|
#include "nsIFileChannel.h"
|
1999-12-04 10:45:57 +03:00
|
|
|
#include "nsIIOService.h"
|
|
|
|
#include "nsILoadGroup.h"
|
1999-09-01 04:54:35 +04:00
|
|
|
#include "nsIScriptSecurityManager.h"
|
2004-12-02 05:13:20 +03:00
|
|
|
#include "nsIStandardURL.h"
|
2004-09-07 22:59:07 +04:00
|
|
|
#include "nsNetUtil.h"
|
2015-07-07 05:17:00 +03:00
|
|
|
#include "nsNetCID.h"
|
|
|
|
#include "nsIURL.h"
|
2002-03-06 10:48:55 +03:00
|
|
|
#include "nsString.h"
|
2015-04-02 17:12:27 +03:00
|
|
|
#include "nsStandardURL.h"
|
2000-02-06 04:30:16 +03:00
|
|
|
|
2004-10-13 23:05:48 +04:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2014-04-27 11:06:00 +04:00
|
|
|
NS_IMPL_ISUPPORTS(nsChromeProtocolHandler,
|
|
|
|
nsIProtocolHandler,
|
|
|
|
nsISupportsWeakReference)
|
2004-10-13 23:05:48 +04:00
|
|
|
|
1999-07-02 08:15:43 +04:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// nsIProtocolHandler methods:
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2004-10-13 23:05:48 +04:00
|
|
|
nsChromeProtocolHandler::GetScheme(nsACString &result)
|
1999-07-02 08:15:43 +04:00
|
|
|
{
|
2004-09-07 22:59:07 +04:00
|
|
|
result.AssignLiteral("chrome");
|
1999-07-02 08:15:43 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 19:56:38 +04:00
|
|
|
nsChromeProtocolHandler::GetDefaultPort(int32_t *result)
|
1999-07-02 08:15:43 +04:00
|
|
|
{
|
|
|
|
*result = -1; // no port for chrome: URLs
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
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-22 00:51:34 +04:00
|
|
|
NS_IMETHODIMP
|
2012-08-22 19:56:38 +04:00
|
|
|
nsChromeProtocolHandler::AllowPort(int32_t port, const char *scheme, bool *_retval)
|
2001-06-06 04:10:09 +04: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-22 00:51:34 +04:00
|
|
|
// don't override anything.
|
2011-10-17 18:59:28 +04:00
|
|
|
*_retval = false;
|
2001-06-06 04:10:09 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2001-08-08 00:42:57 +04:00
|
|
|
NS_IMETHODIMP
|
2012-08-22 19:56:38 +04:00
|
|
|
nsChromeProtocolHandler::GetProtocolFlags(uint32_t *result)
|
2001-08-08 00:42:57 +04:00
|
|
|
{
|
2008-12-10 00:27:42 +03:00
|
|
|
*result = URI_STD | URI_IS_UI_RESOURCE | URI_IS_LOCAL_RESOURCE;
|
2001-08-08 00:42:57 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-07-02 08:15:43 +04:00
|
|
|
NS_IMETHODIMP
|
2004-10-13 23:05:48 +04:00
|
|
|
nsChromeProtocolHandler::NewURI(const nsACString &aSpec,
|
|
|
|
const char *aCharset,
|
|
|
|
nsIURI *aBaseURI,
|
|
|
|
nsIURI **result)
|
1999-07-02 08:15:43 +04:00
|
|
|
{
|
2004-12-02 05:13:20 +03:00
|
|
|
|
|
|
|
// Chrome: URLs (currently) have no additional structure beyond that provided
|
|
|
|
// by standard URLs, so there is no "outer" given to CreateInstance
|
|
|
|
|
2016-05-19 05:02:57 +03:00
|
|
|
RefPtr<mozilla::net::nsStandardURL> surl = new mozilla::net::nsStandardURL();
|
2004-10-13 23:05:48 +04:00
|
|
|
|
2015-04-02 17:12:27 +03:00
|
|
|
nsresult rv = surl->Init(nsIStandardURL::URLTYPE_STANDARD, -1, aSpec,
|
|
|
|
aCharset, aBaseURI);
|
2003-01-05 19:26:59 +03:00
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return rv;
|
|
|
|
|
2004-12-02 05:13:20 +03:00
|
|
|
// Canonify the "chrome:" URL; e.g., so that we collapse
|
|
|
|
// "chrome://navigator/content/" and "chrome://navigator/content"
|
|
|
|
// and "chrome://navigator/content/navigator.xul".
|
|
|
|
|
2015-04-02 17:12:27 +03:00
|
|
|
rv = nsChromeRegistry::Canonify(surl);
|
2004-12-02 05:13:20 +03:00
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return rv;
|
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
surl->SetMutable(false);
|
2005-02-23 00:49:45 +03:00
|
|
|
|
2015-04-02 17:12:27 +03:00
|
|
|
surl.forget(result);
|
2003-01-05 19:26:59 +03:00
|
|
|
return NS_OK;
|
1999-07-02 08:15:43 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2014-10-23 04:16:57 +04:00
|
|
|
nsChromeProtocolHandler::NewChannel2(nsIURI* aURI,
|
2014-12-12 20:05:34 +03:00
|
|
|
nsILoadInfo* aLoadInfo,
|
2014-10-23 04:16:57 +04:00
|
|
|
nsIChannel** aResult)
|
1999-07-02 08:15:43 +04:00
|
|
|
{
|
2006-01-25 23:23:24 +03:00
|
|
|
nsresult rv;
|
|
|
|
|
2003-01-05 19:26:59 +03:00
|
|
|
NS_ENSURE_ARG_POINTER(aURI);
|
|
|
|
NS_PRECONDITION(aResult, "Null out param");
|
2008-12-10 00:27:42 +03:00
|
|
|
|
2004-12-02 05:13:20 +03:00
|
|
|
#ifdef DEBUG
|
|
|
|
// Check that the uri we got is already canonified
|
|
|
|
nsresult debug_rv;
|
2005-02-23 00:49:45 +03:00
|
|
|
nsCOMPtr<nsIURI> debugClone;
|
|
|
|
debug_rv = aURI->Clone(getter_AddRefs(debugClone));
|
2004-12-02 05:13:20 +03:00
|
|
|
if (NS_SUCCEEDED(debug_rv)) {
|
2005-02-23 00:49:45 +03:00
|
|
|
nsCOMPtr<nsIURL> debugURL (do_QueryInterface(debugClone));
|
|
|
|
debug_rv = nsChromeRegistry::Canonify(debugURL);
|
2004-12-02 05:13:20 +03:00
|
|
|
if (NS_SUCCEEDED(debug_rv)) {
|
2011-09-29 10:19:26 +04:00
|
|
|
bool same;
|
2005-02-23 00:49:45 +03:00
|
|
|
debug_rv = aURI->Equals(debugURL, &same);
|
2004-12-02 05:13:20 +03:00
|
|
|
if (NS_SUCCEEDED(debug_rv)) {
|
2005-02-23 00:49:45 +03:00
|
|
|
NS_ASSERTION(same, "Non-canonified chrome uri passed to nsChromeProtocolHandler::NewChannel!");
|
2004-12-02 05:13:20 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
2003-01-05 19:26:59 +03:00
|
|
|
|
1999-12-04 10:45:57 +03:00
|
|
|
nsCOMPtr<nsIChannel> result;
|
1999-07-02 08:15:43 +04:00
|
|
|
|
2009-01-30 02:34:24 +03:00
|
|
|
if (!nsChromeRegistry::gChromeRegistry) {
|
|
|
|
// We don't actually want this ref, we just want the service to
|
|
|
|
// initialize if it hasn't already.
|
2010-05-14 13:24:41 +04:00
|
|
|
nsCOMPtr<nsIChromeRegistry> reg =
|
|
|
|
mozilla::services::GetChromeRegistryService();
|
2005-02-26 00:11:46 +03:00
|
|
|
NS_ENSURE_TRUE(nsChromeRegistry::gChromeRegistry, NS_ERROR_FAILURE);
|
2009-01-30 02:34:24 +03:00
|
|
|
}
|
2004-12-02 05:13:20 +03:00
|
|
|
|
2009-01-30 02:34:24 +03:00
|
|
|
nsCOMPtr<nsIURI> resolvedURI;
|
|
|
|
rv = nsChromeRegistry::gChromeRegistry->ConvertChromeURL(aURI, getter_AddRefs(resolvedURI));
|
|
|
|
if (NS_FAILED(rv)) {
|
2004-12-02 05:13:20 +03:00
|
|
|
#ifdef DEBUG
|
2012-09-02 06:35:17 +04:00
|
|
|
nsAutoCString spec;
|
2009-01-30 02:34:24 +03:00
|
|
|
aURI->GetSpec(spec);
|
|
|
|
printf("Couldn't convert chrome URL: %s\n", spec.get());
|
2004-12-02 05:13:20 +03:00
|
|
|
#endif
|
2009-01-30 02:34:24 +03:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2015-02-19 22:47:59 +03:00
|
|
|
rv = NS_NewChannelInternal(getter_AddRefs(result),
|
|
|
|
resolvedURI,
|
|
|
|
aLoadInfo);
|
2009-01-30 02:34:24 +03:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
1999-12-04 10:45:57 +03:00
|
|
|
|
2009-01-30 02:34:24 +03:00
|
|
|
#ifdef DEBUG
|
|
|
|
nsCOMPtr<nsIFileChannel> fileChan(do_QueryInterface(result));
|
|
|
|
if (fileChan) {
|
|
|
|
nsCOMPtr<nsIFile> file;
|
|
|
|
fileChan->GetFile(getter_AddRefs(file));
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool exists = false;
|
2009-01-30 02:34:24 +03:00
|
|
|
file->Exists(&exists);
|
|
|
|
if (!exists) {
|
2012-09-02 06:35:17 +04:00
|
|
|
nsAutoCString path;
|
2009-01-30 02:34:24 +03:00
|
|
|
file->GetNativePath(path);
|
|
|
|
printf("Chrome file doesn't exist: %s\n", path.get());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// Make sure that the channel remembers where it was
|
|
|
|
// originally loaded from.
|
2012-05-05 05:46:02 +04:00
|
|
|
nsLoadFlags loadFlags = 0;
|
|
|
|
result->GetLoadFlags(&loadFlags);
|
|
|
|
result->SetLoadFlags(loadFlags & ~nsIChannel::LOAD_REPLACE);
|
2009-01-30 02:34:24 +03:00
|
|
|
rv = result->SetOriginalURI(aURI);
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
|
|
|
|
// Get a system principal for content files and set the owner
|
|
|
|
// property of the result
|
|
|
|
nsCOMPtr<nsIURL> url = do_QueryInterface(aURI);
|
2012-09-02 06:35:17 +04:00
|
|
|
nsAutoCString path;
|
2009-01-30 02:34:24 +03:00
|
|
|
rv = url->GetPath(path);
|
|
|
|
if (StringBeginsWith(path, NS_LITERAL_CSTRING("/content/")))
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIScriptSecurityManager> securityManager =
|
|
|
|
do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID, &rv);
|
2004-10-13 23:05:48 +04:00
|
|
|
if (NS_FAILED(rv)) return rv;
|
1999-12-04 10:45:57 +03:00
|
|
|
|
2009-01-30 02:34:24 +03:00
|
|
|
nsCOMPtr<nsIPrincipal> principal;
|
|
|
|
rv = securityManager->GetSystemPrincipal(getter_AddRefs(principal));
|
2004-10-13 23:05:48 +04:00
|
|
|
if (NS_FAILED(rv)) return rv;
|
2000-06-02 07:47:49 +04:00
|
|
|
|
2009-01-30 02:34:24 +03:00
|
|
|
nsCOMPtr<nsISupports> owner = do_QueryInterface(principal);
|
|
|
|
result->SetOwner(owner);
|
|
|
|
}
|
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-22 00:51:34 +04:00
|
|
|
|
2010-08-12 23:42:36 +04:00
|
|
|
// XXX Removed dependency-tracking code from here, because we're not
|
|
|
|
// tracking them anyways (with fastload we checked only in DEBUG
|
|
|
|
// and with startupcache not at all), but this is where we would start
|
|
|
|
// if we need to re-add.
|
|
|
|
// See bug 531886, bug 533038.
|
2010-12-23 03:49:52 +03:00
|
|
|
result->SetContentCharset(NS_LITERAL_CSTRING("UTF-8"));
|
1999-08-30 01:58:42 +04:00
|
|
|
|
1999-12-04 10:45:57 +03:00
|
|
|
*aResult = result;
|
|
|
|
NS_ADDREF(*aResult);
|
|
|
|
return NS_OK;
|
1999-07-02 08:15:43 +04:00
|
|
|
}
|
|
|
|
|
2014-10-23 04:16:57 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsChromeProtocolHandler::NewChannel(nsIURI* aURI,
|
|
|
|
nsIChannel* *aResult)
|
|
|
|
{
|
|
|
|
return NewChannel2(aURI, nullptr, aResult);
|
|
|
|
}
|
|
|
|
|
1999-07-02 08:15:43 +04:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|