From 5807a1617f99bb4316f844b1d24b19f79d1bb804 Mon Sep 17 00:00:00 2001 From: Mike Kristoffersen Date: Wed, 29 Sep 2010 18:56:46 +0200 Subject: [PATCH] Bug 561244 - e10s: forward JS 'crypto' calls from content->chrome (Part 1/3 - Adding unique define to disable crypto object) r=jst a=blocking-fennec --HG-- extra : rebase_source : 4ad7c331127b5fc75aebbad45a6a529aabe4f5e6 --- dom/base/nsGlobalWindow.cpp | 14 ++++++++++---- dom/base/nsGlobalWindow.h | 10 ++++++++-- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/dom/base/nsGlobalWindow.cpp b/dom/base/nsGlobalWindow.cpp index 1e95b382bbe5..1d502cfef285 100644 --- a/dom/base/nsGlobalWindow.cpp +++ b/dom/base/nsGlobalWindow.cpp @@ -104,7 +104,9 @@ #include "nsIHTMLDocument.h" #include "nsIDOMHTMLDocument.h" #include "nsIDOMHTMLElement.h" +#ifndef MOZ_DISABLE_DOMCRYPTO #include "nsIDOMCrypto.h" +#endif #include "nsIDOMDocument.h" #include "nsIDOM3Document.h" #include "nsIDOMNSDocument.h" @@ -391,10 +393,10 @@ static PRBool gDOMWindowDumpEnabled = PR_FALSE; static NS_DEFINE_CID(kXULControllersCID, NS_XULCONTROLLERS_CID); static const char sJSStackContractID[] = "@mozilla.org/js/xpc/ContextStack;1"; - +#ifndef MOZ_DISABLE_DOMCRYPTO static const char kCryptoContractID[] = NS_CRYPTO_CONTRACTID; static const char kPkcs11ContractID[] = NS_PKCS11_CONTRACTID; - +#endif static const char sPopStatePrefStr[] = "browser.history.allowPopState"; static PRBool @@ -1652,12 +1654,12 @@ nsGlobalWindow::SetNewDocument(nsIDocument* aDocument, NS_ENSURE_TRUE(scx, NS_ERROR_NOT_INITIALIZED); JSContext *cx = (JSContext *)scx->GetNativeContext(); - +#ifndef MOZ_DISABLE_DOMCRYPTO // clear smartcard events, our document has gone away. if (mCrypto) { mCrypto->SetEnableSmartCardEvents(PR_FALSE); } - +#endif if (!mDocument) { // First document load. @@ -3091,6 +3093,9 @@ nsGlobalWindow::RevokeBlobURL(const nsAString& aURL) NS_IMETHODIMP nsGlobalWindow::GetCrypto(nsIDOMCrypto** aCrypto) { +#ifdef MOZ_DISABLE_DOMCRYPTO + return NS_ERROR_NOT_IMPLEMENTED; +#else FORWARD_TO_OUTER(GetCrypto, (aCrypto), NS_ERROR_NOT_INITIALIZED); if (!mCrypto) { @@ -3100,6 +3105,7 @@ nsGlobalWindow::GetCrypto(nsIDOMCrypto** aCrypto) NS_IF_ADDREF(*aCrypto = mCrypto); return NS_OK; +#endif } NS_IMETHODIMP diff --git a/dom/base/nsGlobalWindow.h b/dom/base/nsGlobalWindow.h index 2b14526cfab2..c5ef09447f74 100644 --- a/dom/base/nsGlobalWindow.h +++ b/dom/base/nsGlobalWindow.h @@ -86,7 +86,9 @@ #include "nsIScriptSecurityManager.h" #include "nsIEventListenerManager.h" #include "nsIDOMDocument.h" +#ifndef MOZ_DISABLE_DOMCRYPTO #include "nsIDOMCrypto.h" +#endif #include "nsIPrincipal.h" #include "nsPluginArray.h" #include "nsMimeTypeArray.h" @@ -142,6 +144,10 @@ class nsRunnable; class nsDOMOfflineResourceList; class nsGeolocation; +#ifdef MOZ_DISABLE_DOMCRYPTO +class nsIDOMCrypto; +#endif + extern nsresult NS_CreateJSTimeoutHandler(nsGlobalWindow *aWindow, PRBool *aIsInterval, @@ -845,9 +851,9 @@ protected: nsString mDefaultStatus; // index 0->language_id 1, so index MAX-1 == language_id MAX nsGlobalWindowObserver* mObserver; - +#ifndef MOZ_DISABLE_DOMCRYPTO nsCOMPtr mCrypto; - +#endif nsCOMPtr mLocalStorage; nsCOMPtr mSessionStorage;