Fix path/URL confusion in wxLaunchDefaultBrowser()

Add a helper wxLaunchBrowserParams struct with clearly distinct "url" and
"path" fields and GetPathOrURL() accessor which returns whichever is
appropriate.

This makes the code more clear and ensures that we never pass URLs (but only
file paths) to xdg-open under Unix as it doesn't handle them.

See #17227.
This commit is contained in:
Vadim Zeitlin
2016-02-07 19:32:18 +01:00
parent 36b5df11a5
commit 026659297b
6 changed files with 109 additions and 85 deletions

View File

@@ -36,6 +36,10 @@
#include <AudioToolbox/AudioServices.h>
#if wxUSE_GUI
#include "wx/private/launchbrowser.h"
#endif
#include "wx/osx/private.h"
#include "wx/osx/private/timer.h"
@@ -130,11 +134,10 @@ bool wxLaunchDefaultApplication(const wxString& document, int flags)
// Launch default browser
// ----------------------------------------------------------------------------
bool wxDoLaunchDefaultBrowser(const wxString& url, int flags)
bool wxDoLaunchDefaultBrowser(const wxLaunchBrowserParams& params)
{
wxUnusedVar(flags);
wxCFRef< CFURLRef > curl( CFURLCreateWithString( kCFAllocatorDefault,
wxCFStringRef( url ), NULL ) );
wxCFStringRef( params.url ), NULL ) );
OSStatus err = LSOpenCFURLRef( curl , NULL );
if (err == noErr)