2001-09-29 00:14:13 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
2004-04-19 02:01:16 +04:00
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
2000-09-14 09:56:28 +04:00
|
|
|
*
|
2004-04-19 02:01:16 +04:00
|
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
* the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/MPL/
|
2000-09-14 09:56:28 +04:00
|
|
|
*
|
2001-09-29 00:14:13 +04:00
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
2000-09-14 09:56:28 +04:00
|
|
|
*
|
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
2004-04-19 02:01:16 +04:00
|
|
|
* The Initial Developer of the Original Code is
|
2001-09-29 00:14:13 +04:00
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
2000-09-14 09:56:28 +04:00
|
|
|
*
|
2001-09-29 00:14:13 +04:00
|
|
|
* Contributor(s):
|
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
2004-04-19 02:01:16 +04:00
|
|
|
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
2001-09-29 00:14:13 +04:00
|
|
|
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
2004-04-19 02:01:16 +04:00
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
2001-09-29 00:14:13 +04:00
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
2004-04-19 02:01:16 +04:00
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
2001-09-29 00:14:13 +04:00
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
2000-09-14 09:56:28 +04:00
|
|
|
|
2009-03-18 00:20:02 +03:00
|
|
|
#ifndef nsPluginSafety_h_
|
|
|
|
#define nsPluginSafety_h_
|
2000-09-14 09:56:28 +04:00
|
|
|
|
2002-09-26 06:53:27 +04:00
|
|
|
#include "npapi.h"
|
2011-05-18 05:48:34 +04:00
|
|
|
#include "nsPluginHost.h"
|
2008-04-24 03:24:21 +04:00
|
|
|
#include <prinrval.h>
|
2002-09-26 06:53:27 +04:00
|
|
|
|
2011-05-08 21:45:56 +04:00
|
|
|
#if defined(XP_WIN)
|
2000-09-14 09:56:28 +04:00
|
|
|
#define CALL_SAFETY_ON
|
|
|
|
#endif
|
|
|
|
|
2008-04-24 03:24:21 +04:00
|
|
|
void NS_NotifyPluginCall(PRIntervalTime);
|
|
|
|
|
2000-09-14 09:56:28 +04:00
|
|
|
#ifdef CALL_SAFETY_ON
|
|
|
|
|
2012-04-04 08:09:20 +04:00
|
|
|
#include "mozilla/Preferences.h"
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
extern bool gSkipPluginSafeCalls;
|
2001-10-11 08:51:06 +04:00
|
|
|
|
2012-04-04 08:09:20 +04:00
|
|
|
#define NS_INIT_PLUGIN_SAFE_CALLS \
|
|
|
|
PR_BEGIN_MACRO \
|
|
|
|
gSkipPluginSafeCalls = \
|
|
|
|
::mozilla::Preferences::GetBool("plugin.dont_try_safe_calls", \
|
|
|
|
gSkipPluginSafeCalls); \
|
2001-10-11 08:51:06 +04:00
|
|
|
PR_END_MACRO
|
|
|
|
|
2010-10-15 01:06:31 +04:00
|
|
|
#define NS_TRY_SAFE_CALL_RETURN(ret, fun, pluginInst) \
|
2000-09-14 09:56:28 +04:00
|
|
|
PR_BEGIN_MACRO \
|
2008-04-24 03:24:21 +04:00
|
|
|
PRIntervalTime startTime = PR_IntervalNow(); \
|
2001-10-11 08:51:06 +04:00
|
|
|
if(gSkipPluginSafeCalls) \
|
2000-09-14 09:56:28 +04:00
|
|
|
ret = fun; \
|
|
|
|
else \
|
|
|
|
{ \
|
2011-01-11 13:16:59 +03:00
|
|
|
MOZ_SEH_TRY \
|
2000-09-14 09:56:28 +04:00
|
|
|
{ \
|
|
|
|
ret = fun; \
|
|
|
|
} \
|
2011-09-30 10:02:59 +04:00
|
|
|
MOZ_SEH_EXCEPT(true) \
|
2000-09-14 09:56:28 +04:00
|
|
|
{ \
|
2001-10-11 08:51:06 +04:00
|
|
|
nsresult res; \
|
2009-06-26 01:45:35 +04:00
|
|
|
nsCOMPtr<nsIPluginHost> host(do_GetService(MOZ_PLUGIN_HOST_CONTRACTID, &res));\
|
2000-09-14 09:56:28 +04:00
|
|
|
if(NS_SUCCEEDED(res) && (host != nsnull)) \
|
2011-05-18 05:48:34 +04:00
|
|
|
static_cast<nsPluginHost*>(host.get())->HandleBadPlugin(nsnull, pluginInst); \
|
2000-09-14 09:56:28 +04:00
|
|
|
ret = (NPError)NS_ERROR_FAILURE; \
|
|
|
|
} \
|
|
|
|
} \
|
2008-04-24 03:24:21 +04:00
|
|
|
NS_NotifyPluginCall(startTime); \
|
2000-09-14 09:56:28 +04:00
|
|
|
PR_END_MACRO
|
|
|
|
|
2010-10-15 01:06:31 +04:00
|
|
|
#define NS_TRY_SAFE_CALL_VOID(fun, pluginInst) \
|
2000-09-14 09:56:28 +04:00
|
|
|
PR_BEGIN_MACRO \
|
2008-04-24 03:24:21 +04:00
|
|
|
PRIntervalTime startTime = PR_IntervalNow(); \
|
2001-10-11 08:51:06 +04:00
|
|
|
if(gSkipPluginSafeCalls) \
|
2000-09-14 09:56:28 +04:00
|
|
|
fun; \
|
|
|
|
else \
|
|
|
|
{ \
|
2011-01-11 13:16:59 +03:00
|
|
|
MOZ_SEH_TRY \
|
2000-09-14 09:56:28 +04:00
|
|
|
{ \
|
|
|
|
fun; \
|
|
|
|
} \
|
2011-09-30 10:02:59 +04:00
|
|
|
MOZ_SEH_EXCEPT(true) \
|
2000-09-14 09:56:28 +04:00
|
|
|
{ \
|
2001-10-11 08:51:06 +04:00
|
|
|
nsresult res; \
|
2009-06-26 01:45:35 +04:00
|
|
|
nsCOMPtr<nsIPluginHost> host(do_GetService(MOZ_PLUGIN_HOST_CONTRACTID, &res));\
|
2000-09-14 09:56:28 +04:00
|
|
|
if(NS_SUCCEEDED(res) && (host != nsnull))\
|
2011-05-18 05:48:34 +04:00
|
|
|
static_cast<nsPluginHost*>(host.get())->HandleBadPlugin(nsnull, pluginInst);\
|
2000-09-14 09:56:28 +04:00
|
|
|
} \
|
|
|
|
} \
|
2008-04-24 03:24:21 +04:00
|
|
|
NS_NotifyPluginCall(startTime); \
|
2000-09-14 09:56:28 +04:00
|
|
|
PR_END_MACRO
|
|
|
|
|
|
|
|
#else // vanilla calls
|
|
|
|
|
2010-10-15 01:06:31 +04:00
|
|
|
#define NS_TRY_SAFE_CALL_RETURN(ret, fun, pluginInst) \
|
2000-09-14 09:56:28 +04:00
|
|
|
PR_BEGIN_MACRO \
|
2008-04-24 03:24:21 +04:00
|
|
|
PRIntervalTime startTime = PR_IntervalNow(); \
|
2000-09-14 09:56:28 +04:00
|
|
|
ret = fun; \
|
2008-04-24 03:24:21 +04:00
|
|
|
NS_NotifyPluginCall(startTime); \
|
2000-09-14 09:56:28 +04:00
|
|
|
PR_END_MACRO
|
|
|
|
|
2010-10-15 01:06:31 +04:00
|
|
|
#define NS_TRY_SAFE_CALL_VOID(fun, pluginInst) \
|
2000-09-14 09:56:28 +04:00
|
|
|
PR_BEGIN_MACRO \
|
2008-04-24 03:24:21 +04:00
|
|
|
PRIntervalTime startTime = PR_IntervalNow(); \
|
2000-09-14 09:56:28 +04:00
|
|
|
fun; \
|
2008-04-24 03:24:21 +04:00
|
|
|
NS_NotifyPluginCall(startTime); \
|
2000-09-14 09:56:28 +04:00
|
|
|
PR_END_MACRO
|
|
|
|
|
|
|
|
#endif // CALL_SAFETY_ON
|
|
|
|
|
2009-03-18 00:20:02 +03:00
|
|
|
#endif //nsPluginSafety_h_
|