Block scripting in plugin teardown during Document unload.

Eventually, this should eliminate the need to run a nested message
loop in some situations when plugins are destroyed...

BUG=498088

Review URL: https://codereview.chromium.org/1172143004

Cr-Commit-Position: refs/heads/master@{#334047}
diff --git a/content/renderer/pepper/ppb_var_deprecated_impl.cc b/content/renderer/pepper/ppb_var_deprecated_impl.cc
index 4188ee6e..dd2c80b 100644
--- a/content/renderer/pepper/ppb_var_deprecated_impl.cc
+++ b/content/renderer/pepper/ppb_var_deprecated_impl.cc
@@ -20,6 +20,7 @@
 #include "third_party/WebKit/public/web/WebElement.h"
 #include "third_party/WebKit/public/web/WebLocalFrame.h"
 #include "third_party/WebKit/public/web/WebPluginContainer.h"
+#include "third_party/WebKit/public/web/WebPluginScriptForbiddenScope.h"
 #include "third_party/WebKit/public/web/WebScopedUserGesture.h"
 
 using ppapi::V8ObjectVar;
@@ -56,7 +57,8 @@
     if (exception && exception->type != PP_VARTYPE_UNDEFINED)
       return false;
     if (instance_)
-      return true;
+      return !instance_->is_deleted() ||
+             !blink::WebPluginScriptForbiddenScope::isForbidden();
     if (exception)
       *exception = ppapi::StringVar::StringToPPVar(kInvalidObjectException);
     return false;