зеркало из https://github.com/mozilla/gecko-dev.git
Bug #30157 --> add the ability to launch urls using OS default protocol handlers. You must set a pref to
enable this behavior. r=valeski
This commit is contained in:
Родитель
5ce6a320cc
Коммит
30fc5701b2
|
@ -71,6 +71,10 @@
|
|||
#include "nsIConsoleService.h"
|
||||
#include "nsIScriptError.h"
|
||||
|
||||
// used to dispatch urls to default protocol handlers
|
||||
#include "nsCExternalHandlerService.h"
|
||||
#include "nsIExternalProtocolService.h"
|
||||
|
||||
static NS_DEFINE_IID(kDeviceContextCID, NS_DEVICE_CONTEXT_CID);
|
||||
static NS_DEFINE_CID(kPlatformCharsetCID, NS_PLATFORMCHARSET_CID);
|
||||
static NS_DEFINE_CID(kCharsetConverterManagerCID, NS_ICHARSETCONVERTERMANAGER_CID);
|
||||
|
@ -91,6 +95,7 @@ nsDocShell::nsDocShell() :
|
|||
mAllowPlugins(PR_TRUE),
|
||||
mViewMode(viewNormal),
|
||||
mEODForCurrentDocument (PR_FALSE),
|
||||
mUseExternalProtocolHandler (PR_FALSE),
|
||||
mParent(nsnull),
|
||||
mTreeOwner(nsnull),
|
||||
mChromeEventHandler(nsnull)
|
||||
|
@ -1167,6 +1172,10 @@ NS_IMETHODIMP nsDocShell::Create()
|
|||
mPrefs = do_GetService(NS_PREF_PROGID);
|
||||
mGlobalHistory = do_GetService(NS_GLOBALHISTORY_PROGID);
|
||||
|
||||
// i don't want to read this pref in every time we load a url
|
||||
// so read it in once here and be done with it...
|
||||
mPrefs->GetBoolPref("network.protocols.useSystemDefaults", &mUseExternalProtocolHandler);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -2574,6 +2583,20 @@ NS_IMETHODIMP nsDocShell::DoURILoad(nsIURI* aURI, nsIURI* aReferrerURI,
|
|||
nsISupports* aOwner, nsURILoadCommand aLoadCmd, const char* aWindowTarget,
|
||||
nsIInputStream* aPostData)
|
||||
{
|
||||
|
||||
// if the load cmd is a user click....and we are supposed to try using
|
||||
// external default protocol handlers....then try to see if we have one for
|
||||
// this protocol
|
||||
if (mUseExternalProtocolHandler && aLoadCmd == nsIURILoader::viewUserClick)
|
||||
{
|
||||
nsXPIDLCString urlScheme;
|
||||
aURI->GetScheme(getter_Copies(urlScheme));
|
||||
nsCOMPtr<nsIExternalProtocolService> extProtService (do_GetService(NS_EXTERNALPROTOCOLSERVICE_PROGID));
|
||||
PRBool haveHandler = PR_FALSE;
|
||||
extProtService->ExternalProtocolHandlerExists(urlScheme, &haveHandler);
|
||||
if (haveHandler)
|
||||
return extProtService->LoadUrl(aURI);
|
||||
}
|
||||
nsCOMPtr<nsIURILoader> uriLoader(do_GetService(NS_URI_LOADER_PROGID));
|
||||
NS_ENSURE_TRUE(uriLoader, NS_ERROR_FAILURE);
|
||||
|
||||
|
|
|
@ -272,6 +272,12 @@ protected:
|
|||
// content viewer.
|
||||
PRBool mEODForCurrentDocument;
|
||||
|
||||
// used to keep track of whether user click links should be handle by us
|
||||
// or immediately kicked out to an external application. mscott: eventually
|
||||
// i'm going to try to fold this up into the uriloader where it belongs but i haven't
|
||||
// figured out how to do that yet.
|
||||
PRBool mUseExternalProtocolHandler;
|
||||
|
||||
/* WEAK REFERENCES BELOW HERE.
|
||||
Note these are intentionally not addrefd. Doing so will create a cycle.
|
||||
For that reasons don't use nsCOMPtr.*/
|
||||
|
|
Загрузка…
Ссылка в новой задаче