mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 11:25:00 +00:00
fixes bug 157135 "nsIFileURL need to be frozen" r=dougt sr=bzbarsky
This commit is contained in:
parent
15b32e837f
commit
7f1956b180
@ -342,19 +342,18 @@ nsHelperAppDialog.prototype = {
|
||||
var pathString = this.mSourcePath;
|
||||
try
|
||||
{
|
||||
var fileURL = url.QueryInterface( Components.interfaces.nsIFileURL);
|
||||
// All URLs will QI to nsIFileURL. Need to check the scheme to determine type
|
||||
if (fileURL.schemeIs("file"))
|
||||
var fileURL = url.QueryInterface(Components.interfaces.nsIFileURL);
|
||||
if (fileURL)
|
||||
{
|
||||
var fileObject = fileURL.file;
|
||||
if (fileObject)
|
||||
{
|
||||
var parentObject = fileObject.parent;
|
||||
if (parentObject)
|
||||
{
|
||||
pathString = parentObject.path;
|
||||
}
|
||||
}
|
||||
var fileObject = fileURL.file;
|
||||
if (fileObject)
|
||||
{
|
||||
var parentObject = fileObject.parent;
|
||||
if (parentObject)
|
||||
{
|
||||
pathString = parentObject.path;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch(ex) {}
|
||||
|
||||
|
@ -995,24 +995,9 @@ nsresult nsWebBrowserPersist::GetValidURIFromObject(nsISupports *aObject, nsIURI
|
||||
nsCOMPtr<nsIURI> objAsURI = do_QueryInterface(aObject);
|
||||
if (objAsURI)
|
||||
{
|
||||
PRBool isFile = PR_FALSE;
|
||||
objAsURI->SchemeIs("file", &isFile);
|
||||
if (isFile)
|
||||
{
|
||||
nsCOMPtr<nsIFileURL> objAsFileURL = do_QueryInterface(objAsURI);
|
||||
if (objAsFileURL)
|
||||
{
|
||||
*aURI = objAsFileURL;
|
||||
NS_ADDREF(*aURI);
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
*aURI = objAsURI;
|
||||
NS_ADDREF(*aURI);
|
||||
return NS_OK;
|
||||
}
|
||||
*aURI = objAsURI;
|
||||
NS_ADDREF(*aURI);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return NS_ERROR_FAILURE;
|
||||
|
@ -48,14 +48,12 @@
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
#include "nsILocalFile.h"
|
||||
#include "nsNetCID.h"
|
||||
#include "nsIFileURL.h"
|
||||
#include "nsNetUtil.h"
|
||||
|
||||
#include "nsContentCID.h"
|
||||
#include "nsICSSLoader.h"
|
||||
#include "nsICSSStyleSheet.h"
|
||||
|
||||
static NS_DEFINE_CID(kStandardURLCID, NS_STANDARDURL_CID);
|
||||
static NS_DEFINE_CID(kCSSLoaderCID, NS_CSS_LOADER_CID);
|
||||
|
||||
static already_AddRefed<nsIURI>
|
||||
@ -65,11 +63,9 @@ FileToURI(const char *aFilename)
|
||||
// XXX Handle relative paths somehow.
|
||||
lf->InitWithNativePath(nsDependentCString(aFilename));
|
||||
|
||||
nsIFileURL *url;
|
||||
CallCreateInstance(kStandardURLCID, &url);
|
||||
if (url)
|
||||
url->SetFile(lf);
|
||||
return url;
|
||||
nsIURI *uri = nsnull;
|
||||
NS_NewFileURI(&uri, lf);
|
||||
return uri;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -32,7 +32,6 @@ gPrefs = gPrefs.getService();
|
||||
gPrefs = gPrefs.QueryInterface(Components.interfaces.nsIPrefBranch);
|
||||
|
||||
var gProfileDirURL;
|
||||
var gIconFileURL;
|
||||
|
||||
var gMapItURLFormat = gPrefs.getComplexValue("mail.addr_book.mapit_url.format",
|
||||
Components.interfaces.nsIPrefLocalizedString).data;
|
||||
@ -40,6 +39,7 @@ var gMapItURLFormat = gPrefs.getComplexValue("mail.addr_book.mapit_url.format",
|
||||
var gAddrbookSession = Components.classes["@mozilla.org/addressbook/services/session;1"].getService().QueryInterface(Components.interfaces.nsIAddrBookSession);
|
||||
|
||||
var gIOService = Components.classes["@mozilla.org/network/io-service;1"].getService(Components.interfaces.nsIIOService);
|
||||
var gFileHandler = gIOService.getProtocolHandler("file").QueryInterface(Components.interfaces.nsIFileProtocolHandler);
|
||||
|
||||
var zListName;
|
||||
var zPrimaryEmail;
|
||||
@ -338,21 +338,19 @@ function setBuddyIcon(card, buddyIcon)
|
||||
if (myScreenName && card.primaryEmail) {
|
||||
if (!gProfileDirURL) {
|
||||
// lazily create these file urls, and keep them around
|
||||
gProfileDirURL = Components.classes["@mozilla.org/network/standard-url;1"].createInstance(Components.interfaces.nsIFileURL);
|
||||
gIconFileURL = Components.classes["@mozilla.org/network/standard-url;1"].createInstance(Components.interfaces.nsIFileURL);
|
||||
var profile = Components.classes["@mozilla.org/profile/manager;1"].getService(Components.interfaces.nsIProfileInternal);
|
||||
gProfileDirURL.file = profile.getProfileDir(profile.currentProfile);
|
||||
gProfileDirURL = gIOService.newFileURI(profile.getProfileDir(profile.currentProfile));
|
||||
}
|
||||
|
||||
// if we did have a buddy icon on disk for this screenname, this would be the file url spec for it
|
||||
var iconURLStr = gProfileDirURL.spec + "/NIM/" + myScreenName + "/picture/" + card.aimScreenName + ".gif";
|
||||
|
||||
// check if the file exists
|
||||
gIconFileURL.spec = iconURLStr;
|
||||
var file = gFileHandler.getFileFromURLSpec(iconURLStr);
|
||||
|
||||
// check if the file exists
|
||||
// is this a perf hit? (how expensive is stat()?)
|
||||
if (gIconFileURL.file.exists()) {
|
||||
if (file.exists()) {
|
||||
buddyIcon.setAttribute("src", iconURLStr);
|
||||
return true;
|
||||
}
|
||||
|
@ -59,7 +59,7 @@
|
||||
#include "nsMsgSimulateError.h"
|
||||
#include "nsITextToSubURI.h"
|
||||
#include "nsEscape.h"
|
||||
#include "nsIFileURL.h"
|
||||
#include "nsIURL.h"
|
||||
#include "nsNetCID.h"
|
||||
|
||||
|
||||
@ -672,7 +672,7 @@ nsMsgAttachmentHandler::SnarfAttachment(nsMsgCompFields *compFields)
|
||||
// then, if we have a resource fork, check the filename extension, maybe we don't need the resource fork!
|
||||
if (sendResourceFork)
|
||||
{
|
||||
nsCOMPtr<nsIFileURL> fileUrl(do_CreateInstance(NS_STANDARDURL_CONTRACTID));
|
||||
nsCOMPtr<nsIURL> fileUrl(do_CreateInstance(NS_STANDARDURL_CONTRACTID));
|
||||
if (fileUrl)
|
||||
{
|
||||
nsresult rv = fileUrl->SetSpec(url_string);
|
||||
|
@ -90,7 +90,7 @@
|
||||
#include "nsIWindowMediator.h"
|
||||
#include "nsISupportsArray.h"
|
||||
#include "nsIIOService.h"
|
||||
#include "nsIFileURL.h"
|
||||
#include "nsIURL.h"
|
||||
#include "nsIMsgMailSession.h"
|
||||
#include "nsMsgBaseCID.h"
|
||||
#include "nsIPrompt.h"
|
||||
@ -3270,7 +3270,7 @@ nsMsgCompose::ProcessSignature(nsIMsgIdentity *identity, nsString *aMsgBody)
|
||||
// Once we get here, we need to figure out if we have the correct file
|
||||
// type for the editor.
|
||||
//
|
||||
nsCOMPtr<nsIFileURL> fileUrl(do_CreateInstance(NS_STANDARDURL_CONTRACTID));
|
||||
nsCOMPtr<nsIURL> fileUrl(do_CreateInstance(NS_STANDARDURL_CONTRACTID));
|
||||
if (fileUrl)
|
||||
{
|
||||
fileUrl->SetFilePath(sigNativePath);
|
||||
|
@ -60,6 +60,7 @@
|
||||
#include "nsIMsgSendListener.h"
|
||||
#include "nsIMsgCopyServiceListener.h"
|
||||
#include "nsIFileSpec.h"
|
||||
#include "nsIURL.h"
|
||||
#include "nsIFileURL.h"
|
||||
#include "nsMsgCopy.h"
|
||||
#include "nsXPIDLString.h"
|
||||
@ -2202,7 +2203,7 @@ nsMsgComposeAndSend::AddCompFieldLocalAttachments()
|
||||
nsCOMPtr<nsIMIMEService> mimeFinder (do_GetService(NS_MIMESERVICE_CONTRACTID, &rv));
|
||||
if (NS_SUCCEEDED(rv) && mimeFinder)
|
||||
{
|
||||
nsCOMPtr<nsIFileURL> fileUrl(do_CreateInstance(NS_STANDARDURL_CONTRACTID));
|
||||
nsCOMPtr<nsIURL> fileUrl(do_CreateInstance(NS_STANDARDURL_CONTRACTID));
|
||||
if (fileUrl)
|
||||
{
|
||||
nsCAutoString fileExt;
|
||||
|
@ -41,17 +41,24 @@
|
||||
interface nsIFile;
|
||||
|
||||
/**
|
||||
* nsIFileURL is used for the file: protocol, and gives access to the
|
||||
* underlying nsIFile object.
|
||||
* nsIFileURL provides access to the underlying nsIFile object corresponding to
|
||||
* an URL. The URL scheme need not be file:, since other local protocols may
|
||||
* map URLs to files (e.g., resource:).
|
||||
*
|
||||
* @status UNDER_REVIEW
|
||||
* @status FROZEN
|
||||
*/
|
||||
[scriptable, uuid(d26b2e2e-1dd1-11b2-88f3-8545a7ba7949)]
|
||||
interface nsIFileURL : nsIURL
|
||||
{
|
||||
/**
|
||||
* setter clones and getter references, meaning that you must clone the
|
||||
* resulting nsIFile if you wish to modify it.
|
||||
* Get/Set nsIFile corresponding to this URL.
|
||||
*
|
||||
* - Getter returns a reference to an immutable object. Callers must clone
|
||||
* before attempting to modify the returned nsIFile object. NOTE: this
|
||||
* constraint might not be enforced at runtime, so beware!!
|
||||
*
|
||||
* - Setter clones the nsIFile object (allowing the caller to safely modify
|
||||
* the nsIFile object after setting it on this interface).
|
||||
*/
|
||||
attribute nsIFile file;
|
||||
};
|
||||
|
@ -42,11 +42,10 @@
|
||||
interface nsIURI;
|
||||
|
||||
/**
|
||||
* Protocol writers can obtain a default nsIURL implementation by calling the
|
||||
* component manager with NS_STANDARDURL_CID. The implementation returned will
|
||||
* implement only the set of accessors specified by nsIURL. After obtaining the
|
||||
* instance from the component manager, the Init routine must be called on the
|
||||
* new instance to initialize it from the user's URL spec.
|
||||
* nsIStandardURL defines the interface to an URL with the standard
|
||||
* file path format common to protocols like http, ftp, and file.
|
||||
* It supports initialization from a relative path and provides
|
||||
* some customization on how URLs are normalized.
|
||||
*
|
||||
* @status UNDER_REVIEW
|
||||
*/
|
||||
@ -80,7 +79,7 @@ interface nsIStandardURL : nsISupports
|
||||
/**
|
||||
* Initialize a standard URL.
|
||||
*
|
||||
* @param aUrlType - one of the URLTYPE_XXX flags.
|
||||
* @param aUrlType - one of the URLTYPE_ flags listed above.
|
||||
* @param aDefaultPort - if the port parsed from the URL string matches
|
||||
* this port, then the port will be removed from the
|
||||
* canonical form of the URL.
|
||||
|
@ -301,7 +301,7 @@ nsSegmentEncoder::EncodeSegment(const nsASingleFragmentCString &str,
|
||||
// nsStandardURL <public>
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
nsStandardURL::nsStandardURL()
|
||||
nsStandardURL::nsStandardURL(PRBool aSupportsFileURL)
|
||||
: mDefaultPort(-1)
|
||||
, mPort(-1)
|
||||
, mURLType(URLTYPE_STANDARD)
|
||||
@ -309,6 +309,7 @@ nsStandardURL::nsStandardURL()
|
||||
, mHostEncoding(eEncoding_Unknown)
|
||||
, mSpecEncoding(eEncoding_Unknown)
|
||||
, mMutable(PR_TRUE)
|
||||
, mSupportsFileURL(aSupportsFileURL)
|
||||
{
|
||||
#if defined(PR_LOGGING)
|
||||
if (!gStandardURLLog)
|
||||
@ -804,7 +805,9 @@ NS_INTERFACE_MAP_BEGIN(nsStandardURL)
|
||||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIStandardURL)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIURI)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIURL)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIFileURL)
|
||||
if (mSupportsFileURL && aIID.Equals(NS_GET_IID(nsIFileURL)))
|
||||
foundInterface = NS_STATIC_CAST(nsIFileURL *, this);
|
||||
else
|
||||
NS_INTERFACE_MAP_ENTRY(nsIStandardURL)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISerializable)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIClassInfo)
|
||||
@ -1423,6 +1426,9 @@ nsStandardURL::Equals(nsIURI *unknownOther, PRBool *result)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// XXX this needs to allow for case insensitive paths in some cases (e.g.,
|
||||
// file: URLs under windows).
|
||||
|
||||
*result =
|
||||
SegmentIs(mScheme, other->mSpec.get(), other->mScheme) &&
|
||||
SegmentIs(mDirectory, other->mSpec.get(), other->mDirectory) &&
|
||||
@ -2249,6 +2255,7 @@ nsStandardURL::Init(PRUint32 urlType,
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
mDefaultPort = defaultPort;
|
||||
mURLType = urlType;
|
||||
|
||||
if (charset == nsnull || *charset == '\0') {
|
||||
mOriginCharset.Truncate();
|
||||
|
@ -75,7 +75,7 @@ public:
|
||||
NS_DECL_NSISERIALIZABLE
|
||||
NS_DECL_NSICLASSINFO
|
||||
|
||||
nsStandardURL();
|
||||
nsStandardURL(PRBool aSupportsFileURL = PR_FALSE);
|
||||
virtual ~nsStandardURL();
|
||||
|
||||
static void InitGlobalObjects();
|
||||
@ -236,7 +236,8 @@ private:
|
||||
nsEncodingType mHostEncoding;
|
||||
nsEncodingType mSpecEncoding;
|
||||
|
||||
PRPackedBool mMutable; // nsIStandardURL::mutable
|
||||
PRPackedBool mMutable; // nsIStandardURL::mutable
|
||||
PRPackedBool mSupportsFileURL; // QI to nsIFileURL?
|
||||
|
||||
// global objects. don't use COMPtr as its destructor will cause a
|
||||
// coredump if we leak it.
|
||||
|
@ -70,7 +70,7 @@
|
||||
{0x8c, 0xce, 0x00, 0x60, 0xb0, 0xfc, 0x14, 0xa3} \
|
||||
}
|
||||
|
||||
// component implementing nsIURI and nsISerializable.
|
||||
// component implementing nsIURI, nsISerializable, and nsIClassInfo.
|
||||
#define NS_SIMPLEURI_CLASSNAME \
|
||||
"nsSimpleURI"
|
||||
#define NS_SIMPLEURI_CONTRACTID \
|
||||
@ -83,7 +83,8 @@
|
||||
{0x8c, 0xd0, 0x00, 0x60, 0xb0, 0xfc, 0x14, 0xa3} \
|
||||
}
|
||||
|
||||
// component implementing nsIStandardURL, nsIFileURL, and nsISerializable.
|
||||
// component implementing nsIStandardURL, nsIURI, nsIURL, nsISerializable,
|
||||
// and nsIClassInfo.
|
||||
#define NS_STANDARDURL_CLASSNAME \
|
||||
"nsStandardURL"
|
||||
#define NS_STANDARDURL_CONTRACTID \
|
||||
|
@ -33,6 +33,7 @@ REQUIRES = xpcom \
|
||||
exthandler \
|
||||
mimetype \
|
||||
pref \
|
||||
uconv \
|
||||
$(NULL)
|
||||
|
||||
CPPSRCS = \
|
||||
@ -45,7 +46,7 @@ CPPSRCS = \
|
||||
FORCE_STATIC_LIB = 1
|
||||
|
||||
LOCAL_INCLUDES = \
|
||||
-I$(topsrcdir)/netwerk/base/src \
|
||||
-I$(srcdir)/../../../base/src \
|
||||
$(NULL)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
@ -40,14 +40,16 @@
|
||||
#include "nsIStreamConverterService.h"
|
||||
#include "nsIFileURL.h"
|
||||
#include "nsIURL.h"
|
||||
#include "nsXPIDLString.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsCExternalHandlerService.h"
|
||||
#include "nsIMIMEService.h"
|
||||
#include "nsIFileTransportService.h"
|
||||
#include "nsIFile.h"
|
||||
#include "nsIEventQueueService.h"
|
||||
#include "nsIOutputStream.h"
|
||||
#include "nsXPIDLString.h"
|
||||
#include "nsStandardURL.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsInt64.h"
|
||||
#include "nsMimeTypes.h"
|
||||
#include "nsNetUtil.h"
|
||||
@ -715,11 +717,11 @@ nsFileChannel::Init(nsIFile* file,
|
||||
PRInt32 perm)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIFileURL> url;
|
||||
rv = nsComponentManager::CreateInstance(kStandardURLCID, nsnull,
|
||||
NS_GET_IID(nsIFileURL),
|
||||
getter_AddRefs(url));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
nsCOMPtr<nsIFileURL> url = new nsStandardURL(PR_TRUE);
|
||||
if (!url)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
// XXX shouldn't we set nsIURI::originCharset ??
|
||||
|
||||
rv = url->SetFile(file);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
@ -44,21 +44,16 @@
|
||||
#include "nsILoadGroup.h"
|
||||
#include "nsIStreamListener.h"
|
||||
#include "nsIStreamProvider.h"
|
||||
#include "nsFileSpec.h"
|
||||
#include "nsIURI.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIRunnable.h"
|
||||
#include "nsIThread.h"
|
||||
#include "prlock.h"
|
||||
#include "nsIEventQueueService.h"
|
||||
#include "nsIPipe.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIFile.h" /* Solaris/gcc needed this here. */
|
||||
#include "nsIFileChannel.h"
|
||||
#include "nsIUploadChannel.h"
|
||||
#include "nsIInputStream.h"
|
||||
#include "nsIProgressEventSink.h"
|
||||
#include "nsITransport.h"
|
||||
#include "nsString.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "prthread.h"
|
||||
|
||||
class nsFileChannel : public nsIFileChannel,
|
||||
public nsIUploadChannel,
|
||||
|
@ -41,7 +41,6 @@
|
||||
#include "nsIURLParser.h"
|
||||
#include "nsIStandardURL.h"
|
||||
#include "nsIFileURL.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nsIPref.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsIServiceManager.h"
|
||||
@ -51,11 +50,11 @@
|
||||
#include "nsIThread.h"
|
||||
#include "nsIThreadPool.h"
|
||||
#include "nsISupportsArray.h"
|
||||
#include "nsFileSpec.h"
|
||||
#include "nsAutoLock.h"
|
||||
#include "nsXPIDLString.h"
|
||||
#include "nsStandardURL.h"
|
||||
#include "nsNetCID.h"
|
||||
#include "nsURLHelper.h"
|
||||
#include "nsCRT.h"
|
||||
|
||||
static NS_DEFINE_CID(kStandardURLCID, NS_STANDARDURL_CID);
|
||||
static NS_DEFINE_CID(kPrefCID, NS_PREF_CID);
|
||||
@ -139,15 +138,9 @@ nsFileProtocolHandler::NewURI(const nsACString &aSpec,
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
// file: URLs (currently) have no additional structure beyond that provided by standard
|
||||
// URLs, so there is no "outer" given to CreateInstance
|
||||
|
||||
nsCOMPtr<nsIStandardURL> url;
|
||||
|
||||
rv = nsComponentManager::CreateInstance(kStandardURLCID,
|
||||
nsnull, NS_GET_IID(nsIStandardURL),
|
||||
getter_AddRefs(url));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
nsCOMPtr<nsIStandardURL> url = new nsStandardURL(PR_TRUE);
|
||||
if (!url)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
rv = url->Init(nsIStandardURL::URLTYPE_NO_AUTHORITY, -1, aSpec, aCharset, aBaseURI);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
@ -193,12 +186,11 @@ nsFileProtocolHandler::NewFileURI(nsIFile *file, nsIURI **result)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsIFileURL> url;
|
||||
nsCOMPtr<nsIFileURL> url = new nsStandardURL(PR_TRUE);
|
||||
if (!url)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
rv = nsComponentManager::CreateInstance(kStandardURLCID,
|
||||
nsnull, NS_GET_IID(nsIFileURL),
|
||||
getter_AddRefs(url));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
// XXX shouldn't we set nsIURI::originCharset ??
|
||||
|
||||
rv = url->SetFile(file);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
@ -38,6 +38,7 @@ REQUIRES = xpcom \
|
||||
caps \
|
||||
xpconnect \
|
||||
js \
|
||||
uconv \
|
||||
$(NULL)
|
||||
|
||||
CPPSRCS = \
|
||||
@ -56,7 +57,7 @@ CPPSRCS = \
|
||||
nsHttpPipeline.cpp \
|
||||
$(NULL)
|
||||
|
||||
LOCAL_INCLUDES=-I$(srcdir)/../../../streamconv/converters
|
||||
LOCAL_INCLUDES=-I$(srcdir)/../../../base/src
|
||||
|
||||
# we don't want the shared lib, but we want to force the creation of a
|
||||
# static lib.
|
||||
|
@ -35,6 +35,7 @@
|
||||
#include "nsHttpTransaction.h"
|
||||
#include "nsHttpAuthCache.h"
|
||||
#include "nsHttpPipeline.h"
|
||||
#include "nsStandardURL.h"
|
||||
#include "nsIHttpChannel.h"
|
||||
#include "nsIHttpNotify.h"
|
||||
#include "nsIURL.h"
|
||||
@ -1830,11 +1831,17 @@ nsHttpHandler::NewURI(const nsACString &aSpec,
|
||||
|
||||
LOG(("nsHttpHandler::NewURI\n"));
|
||||
|
||||
nsCOMPtr<nsIStandardURL> url = do_CreateInstance(kStandardURLCID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
nsCOMPtr<nsIStandardURL> url;
|
||||
NS_NEWXPCOM(url, nsStandardURL);
|
||||
if (!url)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
// XXX need to choose the default port based on the scheme
|
||||
rv = url->Init(nsIStandardURL::URLTYPE_AUTHORITY, 80, aSpec, aCharset, aBaseURI);
|
||||
// use the correct default port
|
||||
PRInt32 defaultPort;
|
||||
GetDefaultPort(&defaultPort);
|
||||
|
||||
rv = url->Init(nsIStandardURL::URLTYPE_AUTHORITY,
|
||||
defaultPort, aSpec, aCharset, aBaseURI);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
return CallQueryInterface(url, aURI);
|
||||
@ -2207,7 +2214,6 @@ nsHttpsHandler::GetScheme(nsACString &aScheme)
|
||||
NS_IMETHODIMP
|
||||
nsHttpsHandler::GetDefaultPort(PRInt32 *aPort)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aPort);
|
||||
*aPort = 443;
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -78,6 +78,7 @@ static PRLogModuleInfo *gResLog;
|
||||
class nsResURL : public nsStandardURL
|
||||
{
|
||||
public:
|
||||
nsResURL() : nsStandardURL(PR_TRUE) {}
|
||||
NS_IMETHOD GetFile(nsIFile **);
|
||||
};
|
||||
|
||||
|
@ -2019,17 +2019,13 @@ NS_IMETHODIMP nsExternalHelperAppService::GetTypeFromURI(nsIURI *aURI, char **aC
|
||||
nsCOMPtr<nsIFileURL> fileurl = do_QueryInterface( url, &rv2 );
|
||||
if ( NS_SUCCEEDED ( rv2 ) )
|
||||
{
|
||||
PRBool isFileScheme = PR_FALSE;
|
||||
if (NS_SUCCEEDED(fileurl->SchemeIs("file", &isFileScheme)) && isFileScheme)
|
||||
nsCOMPtr <nsIFile> file;
|
||||
rv2 = fileurl->GetFile(getter_AddRefs(file));
|
||||
if (NS_SUCCEEDED(rv2))
|
||||
{
|
||||
nsCOMPtr <nsIFile> file;
|
||||
rv2 = fileurl->GetFile(getter_AddRefs(file));
|
||||
rv2 = GetTypeFromFile(file, aContentType);
|
||||
if (NS_SUCCEEDED(rv2))
|
||||
{
|
||||
rv2 = GetTypeFromFile(file, aContentType);
|
||||
if (NS_SUCCEEDED(rv2))
|
||||
return rv2;
|
||||
}
|
||||
return rv2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -40,9 +40,9 @@
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsIURL.h"
|
||||
#include "nsIChannel.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsIDOMWindowInternal.h"
|
||||
#include "nsIFilePicker.h"
|
||||
#include "nsIFileURL.h"
|
||||
#include "nsILookAndFeel.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsIFactory.h"
|
||||
@ -1138,16 +1138,15 @@ nsBrowserWindow::DoFileOpen()
|
||||
|
||||
if (GetFileFromFileSelector(parentWindow, getter_AddRefs(file),
|
||||
getter_AddRefs(mOpenFileDirectory))) {
|
||||
nsCOMPtr<nsIFileURL> fileURL = do_CreateInstance(NS_STANDARDURL_CONTRACTID);
|
||||
if (fileURL) {
|
||||
fileURL->SetFile(file);
|
||||
|
||||
nsCAutoString url;
|
||||
fileURL->GetSpec(url);
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
NS_NewFileURI(getter_AddRefs(uri), file);
|
||||
if (uri) {
|
||||
nsCAutoString spec;
|
||||
uri->GetSpec(spec);
|
||||
|
||||
// Ask the Web widget to load the file URL
|
||||
nsCOMPtr<nsIWebNavigation> webNav(do_QueryInterface(mWebBrowser));
|
||||
webNav->LoadURI(NS_ConvertUTF8toUCS2(url).get(),
|
||||
webNav->LoadURI(NS_ConvertUTF8toUCS2(spec).get(),
|
||||
nsIWebNavigation::LOAD_FLAGS_NONE,
|
||||
nsnull,
|
||||
nsnull,
|
||||
|
@ -3258,9 +3258,6 @@ nsBookmarksService::ParseFavoritesFolder(nsIFile* aDirectory, nsIRDFResource* aP
|
||||
if (NS_FAILED(rv))
|
||||
break;
|
||||
|
||||
nsCOMPtr<nsIFileURL> fileURL(do_QueryInterface(uri));
|
||||
fileURL->SetFile(currFile);
|
||||
|
||||
nsAutoString bookmarkName;
|
||||
currFile->GetLeafName(bookmarkName);
|
||||
|
||||
@ -3277,8 +3274,10 @@ nsBookmarksService::ParseFavoritesFolder(nsIFile* aDirectory, nsIRDFResource* aP
|
||||
continue;
|
||||
}
|
||||
else {
|
||||
nsCOMPtr<nsIURL> url(do_QueryInterface(uri));
|
||||
|
||||
nsCAutoString extension;
|
||||
fileURL->GetFileExtension(extension);
|
||||
url->GetFileExtension(extension);
|
||||
ToLowerCase(extension);
|
||||
if (!extension.Equals(NS_LITERAL_CSTRING("url")))
|
||||
continue;
|
||||
@ -3289,11 +3288,11 @@ nsBookmarksService::ParseFavoritesFolder(nsIFile* aDirectory, nsIRDFResource* aP
|
||||
nsAutoString path;
|
||||
currFile->GetPath(path);
|
||||
|
||||
nsXPIDLCString url;
|
||||
ResolveShortcut(path, getter_Copies(url));
|
||||
nsXPIDLCString resolvedURL;
|
||||
ResolveShortcut(path, getter_Copies(resolvedURL));
|
||||
|
||||
nsCOMPtr<nsIRDFResource> bookmark;
|
||||
rv = CreateBookmarkInContainer(name.get(), url.get(), nsnull, aParentResource, -1, getter_AddRefs(bookmark));
|
||||
rv = CreateBookmarkInContainer(name.get(), resolvedURL.get(), nsnull, aParentResource, -1, getter_AddRefs(bookmark));
|
||||
if (NS_FAILED(rv))
|
||||
continue;
|
||||
}
|
||||
|
@ -26,7 +26,6 @@
|
||||
#include "nsRegisterItem.h"
|
||||
#include "nsInstallResources.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsIFileURL.h"
|
||||
#include "nsXPIDLString.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsInstallTrigger.h"
|
||||
@ -458,27 +457,14 @@ nsRegisterItem::GetURLFromIFile(nsIFile* aFile, char** aOutURL)
|
||||
// it will for the install wizards which don't have Necko)
|
||||
// then use warren's local hack.
|
||||
|
||||
nsCOMPtr<nsIURI> pURL;
|
||||
nsresult rv = NS_NewURI(getter_AddRefs(pURL), "file:");
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
nsCOMPtr<nsIFileURL> fileURL( do_QueryInterface(pURL) );
|
||||
if (fileURL)
|
||||
{
|
||||
rv = fileURL->SetFile(aFile);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
nsCAutoString spec;
|
||||
rv = fileURL->GetSpec(spec);
|
||||
*aOutURL = ToNewCString(spec);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( NS_FAILED(rv))
|
||||
{
|
||||
// Necko couldn't do it (wasn't present?), try the hack
|
||||
nsCAutoString spec;
|
||||
nsresult rv = NS_GetURLSpecFromFile(aFile, spec);
|
||||
if (NS_FAILED(rv))
|
||||
rv = hack_nsIFile2URL(aFile, aOutURL);
|
||||
else {
|
||||
*aOutURL = ToNewCString(spec);
|
||||
if (!*aOutURL)
|
||||
rv = NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
return rv;
|
||||
|
@ -530,23 +530,11 @@ extern "C" void RunChromeInstallOnThread(void *data)
|
||||
spec.SetCapacity(200);
|
||||
spec = "jar:";
|
||||
|
||||
nsCOMPtr<nsIURI> pURL;
|
||||
rv = NS_NewURI(getter_AddRefs(pURL), "file:");
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
nsCOMPtr<nsIFileURL> fileURL = do_QueryInterface(pURL);
|
||||
if (fileURL)
|
||||
rv = fileURL->SetFile(info->GetFile());
|
||||
else
|
||||
rv = NS_ERROR_NO_INTERFACE;
|
||||
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
nsCAutoString localURL;
|
||||
rv = fileURL->GetSpec(localURL);
|
||||
spec.Append(localURL);
|
||||
spec.Append("!/");
|
||||
}
|
||||
nsCAutoString localURL;
|
||||
rv = NS_GetURLSpecFromFile(info->GetFile(), localURL);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
spec.Append(localURL);
|
||||
spec.Append("!/");
|
||||
}
|
||||
|
||||
// Now register the new chrome
|
||||
|
Loading…
Reference in New Issue
Block a user