From f701c0ab42e381b9215fac9c727fa03339dc6034 Mon Sep 17 00:00:00 2001 From: "peterlubczynski%netscape.com" Date: Thu, 11 Oct 2001 04:51:06 +0000 Subject: [PATCH] Do not check the "plugin safety pref" on every NPP call bug 96103 patch by av r=peterl sr=brendan git-svn-id: svn://10.0.0.236/trunk@105143 18797224-902f-48f8-a5cc-f745e15eee43 --- .../plugin/base/src/nsPluginHostImpl.cpp | 5 +++ .../modules/plugin/base/src/nsPluginSafety.h | 34 ++++++++----------- 2 files changed, 19 insertions(+), 20 deletions(-) diff --git a/mozilla/modules/plugin/base/src/nsPluginHostImpl.cpp b/mozilla/modules/plugin/base/src/nsPluginHostImpl.cpp index 9f7c9d7223a..f2d8dd7330a 100644 --- a/mozilla/modules/plugin/base/src/nsPluginHostImpl.cpp +++ b/mozilla/modules/plugin/base/src/nsPluginHostImpl.cpp @@ -126,6 +126,8 @@ #include "nsILocalFile.h" #include "nsIFileChannel.h" +#include "nsPluginSafety.h" + #ifdef XP_WIN #include "nsIDirectoryService.h" #include "nsDirectoryServiceDefs.h" @@ -4378,6 +4380,9 @@ NS_IMETHODIMP nsPluginHostImpl::LoadPlugins() if(mPluginsLoaded) return NS_OK; + // check preferences on whether or not we want to try safe calls to plugins + NS_INIT_PLUGIN_SAFE_CALLS; + // retrieve a path for layout module. Needed for plugin mime types registration nsCOMPtr path; PRBool isLayoutPath = PR_FALSE; diff --git a/mozilla/modules/plugin/base/src/nsPluginSafety.h b/mozilla/modules/plugin/base/src/nsPluginSafety.h index 55e47331e53..c80d076de09 100644 --- a/mozilla/modules/plugin/base/src/nsPluginSafety.h +++ b/mozilla/modules/plugin/base/src/nsPluginSafety.h @@ -44,18 +44,19 @@ #ifdef CALL_SAFETY_ON +static PRBool gSkipPluginSafeCalls = PR_FALSE; + +#define NS_INIT_PLUGIN_SAFE_CALLS \ +PR_BEGIN_MACRO \ + nsresult res; \ + nsCOMPtr pref(do_GetService(kPrefServiceCID, &res)); \ + if(NS_SUCCEEDED(res) && pref) \ + res = pref->GetBoolPref("plugin.dont_try_safe_calls", &gSkipPluginSafeCalls);\ +PR_END_MACRO + #define NS_TRY_SAFE_CALL_RETURN(ret, fun, library) \ PR_BEGIN_MACRO \ - nsresult res; \ - PRBool dontdoit = PR_FALSE; \ - nsCOMPtr prefs(do_GetService(kPrefServiceCID, &res));\ - if(NS_SUCCEEDED(res) && (prefs != nsnull)) \ - { \ - res = prefs->GetBoolPref("plugin.dont_try_safe_calls", &dontdoit);\ - if(NS_FAILED(res)) \ - dontdoit = FALSE; \ - } \ - if(dontdoit) \ + if(gSkipPluginSafeCalls) \ ret = fun; \ else \ { \ @@ -65,6 +66,7 @@ PR_BEGIN_MACRO \ } \ catch(...) \ { \ + nsresult res; \ nsCOMPtr host(do_GetService(kCPluginManagerCID, &res));\ if(NS_SUCCEEDED(res) && (host != nsnull)) \ host->HandleBadPlugin(library); \ @@ -75,16 +77,7 @@ PR_END_MACRO #define NS_TRY_SAFE_CALL_VOID(fun, library) \ PR_BEGIN_MACRO \ - nsresult res; \ - PRBool dontdoit = PR_FALSE; \ - nsCOMPtr prefs(do_GetService(kPrefServiceCID, &res));\ - if(NS_SUCCEEDED(res) && (prefs != nsnull))\ - { \ - res = prefs->GetBoolPref("plugin.dont_try_safe_calls", &dontdoit);\ - if(NS_FAILED(res)) \ - dontdoit = FALSE; \ - } \ - if(dontdoit) \ + if(gSkipPluginSafeCalls) \ fun; \ else \ { \ @@ -94,6 +87,7 @@ PR_BEGIN_MACRO \ } \ catch(...) \ { \ + nsresult res; \ nsCOMPtr host(do_GetService(kCPluginManagerCID, &res));\ if(NS_SUCCEEDED(res) && (host != nsnull))\ host->HandleBadPlugin(library); \