зеркало из https://github.com/mozilla/pjs.git
Bug 312287 Cannot open local htm file if its path has non-ASCII character / Cannot open IDN from command line r=jshin, sr=neil
This commit is contained in:
Родитель
f08e03d05c
Коммит
277e8a95a5
|
@ -22,6 +22,7 @@
|
|||
* Contributor(s):
|
||||
* Roland Mainz <roland.mainz@informatik.med.uni-giessen.de>
|
||||
* Fredrik Holmqvist <thesuckiestemail@yahoo.se>
|
||||
* Masayuki Nakano <masayuki@d-toybox.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
|
@ -706,7 +707,8 @@ nsresult DoCommandLines(nsICmdLineService* cmdLineArgs, PRBool *windowOpened)
|
|||
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
// convert the cmdLine URL to Unicode
|
||||
NS_ConvertUTF8toUTF16 url(urlToLoad);
|
||||
nsAutoString url;
|
||||
NS_CopyNativeToUnicode(urlToLoad, url);
|
||||
rv = OpenWindow(chromeUrlForTask, url, width, height);
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,8 @@
|
|||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Bill Law law@netscape.com
|
||||
* Bill Law <law@netscape.com>
|
||||
* Masayuki Nakano <masayuki@d-toybox.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
|
@ -78,6 +79,8 @@
|
|||
#include "nsXPCOM.h"
|
||||
#include "nsXPFEComponentsCID.h"
|
||||
#include "nsEmbedCID.h"
|
||||
#include "nsIURIFixup.h"
|
||||
#include "nsCDefaultURIFixup.h"
|
||||
|
||||
struct JSContext;
|
||||
|
||||
|
@ -398,8 +401,12 @@ private:
|
|||
static PRBool InitTopicStrings();
|
||||
static int FindTopic( HSZ topic );
|
||||
static nsresult GetCmdLineArgs( LPBYTE request, nsICmdLineService **aResult );
|
||||
static nsresult OpenWindow( const char *urlstr, const char *args, nsIDOMWindow **aResult );
|
||||
static nsresult OpenBrowserWindow( const char *args, PRBool newWindow, nsIDOMWindow **aResult );
|
||||
static nsresult OpenWindow( const char *urlstr,
|
||||
const nsAString& aArgs,
|
||||
nsIDOMWindow **aResult );
|
||||
static nsresult OpenBrowserWindow( const nsAString& aArgs,
|
||||
PRBool newWindow,
|
||||
nsIDOMWindow **aResult );
|
||||
static nsresult ReParent( nsISupports *window, HWND newParent );
|
||||
static nsresult GetStartupURL(nsICmdLineService *args, nsCString& taskURL);
|
||||
static void SetupSysTrayIcon();
|
||||
|
@ -1761,7 +1768,8 @@ void nsNativeAppSupportWin::ActivateLastWindow() {
|
|||
} else {
|
||||
// Need to create a Navigator window, then.
|
||||
nsCOMPtr<nsIDOMWindow> newWin;
|
||||
OpenBrowserWindow( "about:blank", PR_TRUE, getter_AddRefs( newWin ) );
|
||||
OpenBrowserWindow( NS_LITERAL_STRING( "about:blank" ),
|
||||
PR_TRUE, getter_AddRefs( newWin ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1822,8 +1830,11 @@ nsNativeAppSupportWin::HandleRequest( LPBYTE request, PRBool newWindow, nsIDOMWi
|
|||
printf( "Launching browser on url [%s]...\n", arg.get() );
|
||||
#endif
|
||||
rv = nativeApp->EnsureProfile(args);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
rv = OpenBrowserWindow( arg.get(), newWindow, aResult );
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
nsAutoString tmpArg;
|
||||
NS_CopyNativeToUnicode( arg, tmpArg );
|
||||
rv = OpenBrowserWindow( tmpArg, newWindow, aResult );
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
@ -1837,7 +1848,7 @@ nsNativeAppSupportWin::HandleRequest( LPBYTE request, PRBool newWindow, nsIDOMWi
|
|||
#endif
|
||||
rv = nativeApp->EnsureProfile(args);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
rv = OpenWindow( arg.get(), "", aResult );
|
||||
rv = OpenWindow( arg.get(), EmptyString(), aResult );
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
@ -1916,8 +1927,7 @@ nsNativeAppSupportWin::HandleRequest( LPBYTE request, PRBool newWindow, nsIDOMWi
|
|||
if (FindCharInString(defaultArgs, '\n') != kNotFound)
|
||||
newWindow = PR_TRUE;
|
||||
|
||||
NS_ConvertUTF16toUTF8 url( defaultArgs );
|
||||
return OpenBrowserWindow(url.get(), newWindow, aResult);
|
||||
return OpenBrowserWindow(defaultArgs, newWindow, aResult);
|
||||
}
|
||||
|
||||
// Parse command line args according to MS spec
|
||||
|
@ -2173,14 +2183,18 @@ printf( "Setting ddexec subkey entries\n" );
|
|||
}
|
||||
|
||||
nsresult
|
||||
nsNativeAppSupportWin::OpenWindow( const char*urlstr, const char *args, nsIDOMWindow **aResult ) {
|
||||
nsNativeAppSupportWin::OpenWindow( const char *urlstr,
|
||||
const nsAString& aArgs,
|
||||
nsIDOMWindow **aResult )
|
||||
{
|
||||
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIWindowWatcher> wwatch(do_GetService(NS_WINDOWWATCHER_CONTRACTID));
|
||||
nsCOMPtr<nsISupportsCString> sarg(do_CreateInstance(NS_SUPPORTS_CSTRING_CONTRACTID));
|
||||
nsCOMPtr<nsISupportsString>
|
||||
sarg(do_CreateInstance(NS_SUPPORTS_STRING_CONTRACTID));
|
||||
if (sarg)
|
||||
sarg->SetData(nsDependentCString(args));
|
||||
sarg->SetData(aArgs);
|
||||
|
||||
if (wwatch && sarg) {
|
||||
rv = wwatch->OpenWindow(0, urlstr, "_blank", "chrome,dialog=no,all",
|
||||
|
@ -2314,7 +2328,10 @@ nsresult SafeJSContext::Push() {
|
|||
|
||||
|
||||
nsresult
|
||||
nsNativeAppSupportWin::OpenBrowserWindow( const char *args, PRBool newWindow, nsIDOMWindow **aResult ) {
|
||||
nsNativeAppSupportWin::OpenBrowserWindow( const nsAString& aArgs,
|
||||
PRBool newWindow,
|
||||
nsIDOMWindow **aResult )
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
// Open the argument URL according to the external link preference.
|
||||
// If there is no Nav window, or newWindow is PR_TRUE, open a new one.
|
||||
|
@ -2343,13 +2360,15 @@ nsNativeAppSupportWin::OpenBrowserWindow( const char *args, PRBool newWindow, ns
|
|||
if ( !bwin ) {
|
||||
break;
|
||||
}
|
||||
nsCOMPtr<nsIIOService> io( do_GetService( "@mozilla.org/network/io-service;1" ) );
|
||||
if ( !io ) {
|
||||
nsCOMPtr<nsIURIFixup> fixup( do_GetService( NS_URIFIXUP_CONTRACTID ) );
|
||||
if ( !fixup ) {
|
||||
break;
|
||||
}
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
io->NewURI( nsDependentCString( args ), nsnull, nsnull, getter_AddRefs( uri ) );
|
||||
if ( !uri ) {
|
||||
rv = fixup->CreateFixupURI( NS_ConvertUTF16toUTF8( aArgs ),
|
||||
nsIURIFixup::FIXUP_FLAG_NONE,
|
||||
getter_AddRefs( uri ) );
|
||||
if ( NS_FAILED(rv) || !uri ) {
|
||||
break;
|
||||
}
|
||||
return bwin->OpenURI( uri, nsnull, nsIBrowserDOMWindow::OPEN_DEFAULTWINDOW, nsIBrowserDOMWindow::OPEN_EXTERNAL, aResult );
|
||||
|
@ -2363,7 +2382,7 @@ nsNativeAppSupportWin::OpenBrowserWindow( const char *args, PRBool newWindow, ns
|
|||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// Last resort is to open a brand new window.
|
||||
return OpenWindow( chromeUrlForTask.get(), args, aResult );
|
||||
return OpenWindow( chromeUrlForTask.get(), aArgs, aResult );
|
||||
}
|
||||
|
||||
void AppendMenuItem( HMENU& menu, PRInt32 aIdentifier, const nsString& aText ) {
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
*
|
||||
* Contributor(s):
|
||||
* Darin Fisher <darin@meer.net>
|
||||
* Masayuki Nakano <masayuki@d-toybox.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
|
@ -95,6 +96,12 @@ NS_CopyUnicodeToNative(const nsAString &input, nsACString &output)
|
|||
NS_UTF16ToCString(input, NS_CSTRING_ENCODING_NATIVE_FILESYSTEM, output);
|
||||
}
|
||||
|
||||
inline void
|
||||
NS_CopyNativeToUnicode(const nsACString &input, nsAString &output)
|
||||
{
|
||||
NS_CStringToUTF16(input, NS_CSTRING_ENCODING_NATIVE_FILESYSTEM, output);
|
||||
}
|
||||
|
||||
inline void
|
||||
CopyUTF16toUTF8(const nsAString &input, nsACString &output)
|
||||
{
|
||||
|
|
Загрузка…
Ссылка в новой задаче