Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1291)

Unified Diff: content/renderer/pepper/pepper_try_catch.cc

Issue 588083002: Use the correct v8 context for conversions when calling into the plugin from JS (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/renderer/pepper/pepper_try_catch.h ('k') | content/renderer/pepper/ppb_var_deprecated_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/pepper/pepper_try_catch.cc
diff --git a/content/renderer/pepper/pepper_try_catch.cc b/content/renderer/pepper/pepper_try_catch.cc
index 4c05a9a8540bdd790d0b7c7015fa6d67d1f6e0b9..2462cbf458b28b3865f0ac707aeac8be750f28a5 100644
--- a/content/renderer/pepper/pepper_try_catch.cc
+++ b/content/renderer/pepper/pepper_try_catch.cc
@@ -26,10 +26,6 @@ PepperTryCatch::PepperTryCatch(PepperPluginInstanceImpl* instance,
PepperTryCatch::~PepperTryCatch() {}
-v8::Handle<v8::Context> PepperTryCatch::GetContext() {
- return instance_->GetContext();
-}
-
v8::Handle<v8::Value> PepperTryCatch::ToV8(PP_Var var) {
if (HasException()) {
SetException(kConversionException);
@@ -85,12 +81,17 @@ bool PepperTryCatchV8::HasException() {
return GetContext().IsEmpty() || exception_.type != PP_VARTYPE_UNDEFINED;
}
+v8::Handle<v8::Context> PepperTryCatchV8::GetContext() {
+ // When calling from JS into the plugin always use the current context.
+ return instance_->GetIsolate()->GetCurrentContext();
+}
+
bool PepperTryCatchV8::ThrowException() {
if (!HasException())
return false;
- // If the plugin context is gone, then we have an exception but we don't try
- // to throw it into v8.
+ // If there is no context then we have an exception but we don't try to throw
+ // it into v8.
if (GetContext().IsEmpty())
return true;
@@ -156,6 +157,11 @@ bool PepperTryCatchVar::HasException() {
return exception_is_set_;
}
+v8::Handle<v8::Context> PepperTryCatchVar::GetContext() {
+ // When calling into JS from the plugin, always use the plugin context.
+ return instance_->GetMainWorldContext();
+}
+
void PepperTryCatchVar::SetException(const char* message) {
if (exception_is_set_)
return;
« no previous file with comments | « content/renderer/pepper/pepper_try_catch.h ('k') | content/renderer/pepper/ppb_var_deprecated_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698