mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-27 14:52:16 +00:00
fixes bug 118651 "nsIFileURL.file needs to return nsIFile that was set"
r=dougt, sr=rpotts
This commit is contained in:
parent
55a5667dd2
commit
1904aa83de
@ -37,6 +37,7 @@
|
||||
|
||||
#include "nsIOService.h"
|
||||
#include "nsIProtocolHandler.h"
|
||||
#include "nsIFileProtocolHandler.h"
|
||||
#include "nscore.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIEventQueueService.h"
|
||||
@ -748,16 +749,20 @@ nsIOService::NewURI(const char* aSpec, nsIURI* aBaseURI, nsIURI* *result)
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsIOService::NewFileURI(nsIFile *aSpec, nsIURI **_retval)
|
||||
nsIOService::NewFileURI(nsIFile *file, nsIURI **result)
|
||||
{
|
||||
nsresult rv;
|
||||
NS_ENSURE_ARG_POINTER(aSpec);
|
||||
|
||||
nsXPIDLCString urlString;
|
||||
rv = GetURLSpecFromFile(aSpec, getter_Copies(urlString));
|
||||
NS_ENSURE_ARG_POINTER(file);
|
||||
|
||||
nsCOMPtr<nsIProtocolHandler> handler;
|
||||
|
||||
rv = GetProtocolHandler("file", getter_AddRefs(handler));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
return NewURI(urlString, nsnull, _retval);
|
||||
nsCOMPtr<nsIFileProtocolHandler> fileHandler( do_QueryInterface(handler, &rv) );
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
return fileHandler->NewFileURI(file, result);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -205,6 +205,16 @@
|
||||
<SETTING><NAME>FrameworkPath</NAME><VALUE>false</VALUE></SETTING>
|
||||
<SETTING><NAME>HostFlags</NAME><VALUE>All</VALUE></SETTING>
|
||||
</SETTING>
|
||||
<SETTING>
|
||||
<SETTING><NAME>SearchPath</NAME>
|
||||
<SETTING><NAME>Path</NAME><VALUE>::protocol:file:public:</VALUE></SETTING>
|
||||
<SETTING><NAME>PathFormat</NAME><VALUE>MacOS</VALUE></SETTING>
|
||||
<SETTING><NAME>PathRoot</NAME><VALUE>Project</VALUE></SETTING>
|
||||
</SETTING>
|
||||
<SETTING><NAME>Recursive</NAME><VALUE>true</VALUE></SETTING>
|
||||
<SETTING><NAME>FrameworkPath</NAME><VALUE>false</VALUE></SETTING>
|
||||
<SETTING><NAME>HostFlags</NAME><VALUE>All</VALUE></SETTING>
|
||||
</SETTING>
|
||||
</SETTING>
|
||||
<SETTING><NAME>SystemSearchPaths</NAME>
|
||||
<SETTING>
|
||||
@ -1397,6 +1407,13 @@
|
||||
<FILEKIND>Text</FILEKIND>
|
||||
<FILEFLAGS></FILEFLAGS>
|
||||
</FILE>
|
||||
<FILE>
|
||||
<PATHTYPE>Name</PATHTYPE>
|
||||
<PATH>nsIFileProtocolHandler.idl</PATH>
|
||||
<PATHFORMAT>MacOS</PATHFORMAT>
|
||||
<FILEKIND>Text</FILEKIND>
|
||||
<FILEFLAGS></FILEFLAGS>
|
||||
</FILE>
|
||||
</FILELIST>
|
||||
<LINKORDER>
|
||||
<FILEREF>
|
||||
@ -1804,6 +1821,11 @@
|
||||
<PATH>nsIMultiPartChannel.idl</PATH>
|
||||
<PATHFORMAT>MacOS</PATHFORMAT>
|
||||
</FILEREF>
|
||||
<FILEREF>
|
||||
<PATHTYPE>Name</PATHTYPE>
|
||||
<PATH>nsIFileProtocolHandler.idl</PATH>
|
||||
<PATHFORMAT>MacOS</PATHFORMAT>
|
||||
</FILEREF>
|
||||
</LINKORDER>
|
||||
</TARGET>
|
||||
<TARGET>
|
||||
@ -1958,6 +1980,16 @@
|
||||
<SETTING><NAME>FrameworkPath</NAME><VALUE>false</VALUE></SETTING>
|
||||
<SETTING><NAME>HostFlags</NAME><VALUE>All</VALUE></SETTING>
|
||||
</SETTING>
|
||||
<SETTING>
|
||||
<SETTING><NAME>SearchPath</NAME>
|
||||
<SETTING><NAME>Path</NAME><VALUE>::protocol:file:public:</VALUE></SETTING>
|
||||
<SETTING><NAME>PathFormat</NAME><VALUE>MacOS</VALUE></SETTING>
|
||||
<SETTING><NAME>PathRoot</NAME><VALUE>Project</VALUE></SETTING>
|
||||
</SETTING>
|
||||
<SETTING><NAME>Recursive</NAME><VALUE>true</VALUE></SETTING>
|
||||
<SETTING><NAME>FrameworkPath</NAME><VALUE>false</VALUE></SETTING>
|
||||
<SETTING><NAME>HostFlags</NAME><VALUE>All</VALUE></SETTING>
|
||||
</SETTING>
|
||||
</SETTING>
|
||||
<SETTING><NAME>SystemSearchPaths</NAME>
|
||||
<SETTING>
|
||||
@ -3143,6 +3175,13 @@
|
||||
<FILEKIND>Text</FILEKIND>
|
||||
<FILEFLAGS></FILEFLAGS>
|
||||
</FILE>
|
||||
<FILE>
|
||||
<PATHTYPE>Name</PATHTYPE>
|
||||
<PATH>nsIFileProtocolHandler.idl</PATH>
|
||||
<PATHFORMAT>MacOS</PATHFORMAT>
|
||||
<FILEKIND>Text</FILEKIND>
|
||||
<FILEFLAGS></FILEFLAGS>
|
||||
</FILE>
|
||||
</FILELIST>
|
||||
<LINKORDER>
|
||||
<FILEREF>
|
||||
@ -3545,6 +3584,11 @@
|
||||
<PATH>nsIMultiPartChannel.idl</PATH>
|
||||
<PATHFORMAT>MacOS</PATHFORMAT>
|
||||
</FILEREF>
|
||||
<FILEREF>
|
||||
<PATHTYPE>Name</PATHTYPE>
|
||||
<PATH>nsIFileProtocolHandler.idl</PATH>
|
||||
<PATHFORMAT>MacOS</PATHFORMAT>
|
||||
</FILEREF>
|
||||
</LINKORDER>
|
||||
</TARGET>
|
||||
</TARGETLIST>
|
||||
@ -3982,6 +4026,14 @@
|
||||
<PATHFORMAT>MacOS</PATHFORMAT>
|
||||
</FILEREF>
|
||||
</GROUP>
|
||||
<GROUP><NAME>file</NAME>
|
||||
<FILEREF>
|
||||
<TARGETNAME>headers</TARGETNAME>
|
||||
<PATHTYPE>Name</PATHTYPE>
|
||||
<PATH>nsIFileProtocolHandler.idl</PATH>
|
||||
<PATHFORMAT>MacOS</PATHFORMAT>
|
||||
</FILEREF>
|
||||
</GROUP>
|
||||
<GROUP><NAME>ftp</NAME>
|
||||
<FILEREF>
|
||||
<TARGETNAME>headers</TARGETNAME>
|
||||
|
@ -1 +1 @@
|
||||
|
||||
nsIFileProtocolHandler.idl
|
||||
|
@ -30,6 +30,7 @@ MODULE = necko
|
||||
XPIDL_MODULE = necko_file
|
||||
|
||||
XPIDLSRCS = \
|
||||
nsIFileProtocolHandler.idl \
|
||||
$(NULL)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
@ -27,6 +27,7 @@ include <$(DEPTH)/config/config.mak>
|
||||
XPIDL_MODULE = necko_file
|
||||
|
||||
XPIDLSRCS = \
|
||||
nsIFileProtocolHandler.idl \
|
||||
$(NULL)
|
||||
|
||||
include <$(DEPTH)/config/rules.mak>
|
||||
|
@ -1 +1,53 @@
|
||||
/* remove */
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Darin Fisher <darin@netscape.com> (original author)
|
||||
*
|
||||
* 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 NPL, 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 NPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsIProtocolHandler.idl"
|
||||
|
||||
interface nsIFile;
|
||||
|
||||
[scriptable, uuid(987fb083-d7ff-46dc-9ee3-ab6e52501d53)]
|
||||
interface nsIFileProtocolHandler : nsIProtocolHandler
|
||||
{
|
||||
/**
|
||||
* This method constructs a new file URI
|
||||
*
|
||||
* @param aFile nsIFile
|
||||
* @return reference to a new nsIURI object
|
||||
*/
|
||||
nsIURI newFileURI(in nsIFile aFile);
|
||||
};
|
||||
|
@ -72,7 +72,10 @@ nsFileProtocolHandler::~nsFileProtocolHandler()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMPL_THREADSAFE_ISUPPORTS2(nsFileProtocolHandler, nsIProtocolHandler, nsISupportsWeakReference);
|
||||
NS_IMPL_THREADSAFE_ISUPPORTS3(nsFileProtocolHandler,
|
||||
nsIFileProtocolHandler,
|
||||
nsIProtocolHandler,
|
||||
nsISupportsWeakReference);
|
||||
|
||||
NS_METHOD
|
||||
nsFileProtocolHandler::Create(nsISupports *aOuter, REFNSIID aIID, void **aResult)
|
||||
@ -167,4 +170,24 @@ nsFileProtocolHandler::AllowPort(PRInt32 port, const char *scheme, PRBool *_retv
|
||||
*_retval = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// nsIFileProtocolHandler methods:
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFileProtocolHandler::NewFileURI(nsIFile *file, nsIURI **result)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsIFileURL> url;
|
||||
|
||||
rv = nsComponentManager::CreateInstance(kStandardURLCID,
|
||||
nsnull, NS_GET_IID(nsIFileURL),
|
||||
getter_AddRefs(url));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = url->SetFile(file);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
return CallQueryInterface(url, result);
|
||||
}
|
||||
|
@ -38,7 +38,7 @@
|
||||
#ifndef nsFileProtocolHandler_h___
|
||||
#define nsFileProtocolHandler_h___
|
||||
|
||||
#include "nsIProtocolHandler.h"
|
||||
#include "nsIFileProtocolHandler.h"
|
||||
#include "nsWeakReference.h"
|
||||
|
||||
class nsISupportsArray;
|
||||
@ -57,11 +57,12 @@ class nsIThreadPool;
|
||||
{0x93, 0x44, 0x00, 0x10, 0x4b, 0xa0, 0xfd, 0x40} \
|
||||
}
|
||||
|
||||
class nsFileProtocolHandler : public nsIProtocolHandler, public nsSupportsWeakReference
|
||||
class nsFileProtocolHandler : public nsIFileProtocolHandler, public nsSupportsWeakReference
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIPROTOCOLHANDLER
|
||||
NS_DECL_NSIFILEPROTOCOLHANDLER
|
||||
|
||||
nsFileProtocolHandler();
|
||||
virtual ~nsFileProtocolHandler();
|
||||
|
Loading…
Reference in New Issue
Block a user