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

Side by Side Diff: content/renderer/pepper/ppb_var_deprecated_impl.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, 2 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 unified diff | Download patch
« no previous file with comments | « content/renderer/pepper/pepper_try_catch.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/renderer/pepper/ppb_var_deprecated_impl.h" 5 #include "content/renderer/pepper/ppb_var_deprecated_impl.h"
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "content/renderer/pepper/host_globals.h" 9 #include "content/renderer/pepper/host_globals.h"
10 #include "content/renderer/pepper/message_channel.h" 10 #include "content/renderer/pepper/message_channel.h"
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 if (try_catch.HasException()) 213 if (try_catch.HasException())
214 return PP_MakeUndefined(); 214 return PP_MakeUndefined();
215 215
216 if (!v8_method_name->IsString()) { 216 if (!v8_method_name->IsString()) {
217 try_catch.SetException(kUnableToCallMethodException); 217 try_catch.SetException(kUnableToCallMethodException);
218 return PP_MakeUndefined(); 218 return PP_MakeUndefined();
219 } 219 }
220 220
221 v8::Handle<v8::Object> function = accessor.GetObject(); 221 v8::Handle<v8::Object> function = accessor.GetObject();
222 v8::Handle<v8::Object> recv = 222 v8::Handle<v8::Object> recv =
223 accessor.instance()->GetContext()->Global(); 223 accessor.instance()->GetMainWorldContext()->Global();
224 if (v8_method_name.As<v8::String>()->Length() != 0) { 224 if (v8_method_name.As<v8::String>()->Length() != 0) {
225 function = function->Get(v8_method_name)->ToObject(); 225 function = function->Get(v8_method_name)->ToObject();
226 recv = accessor.GetObject(); 226 recv = accessor.GetObject();
227 } 227 }
228 228
229 if (try_catch.HasException()) 229 if (try_catch.HasException())
230 return PP_MakeUndefined(); 230 return PP_MakeUndefined();
231 231
232 if (!function->IsFunction()) { 232 if (!function->IsFunction()) {
233 try_catch.SetException(kUnableToCallMethodException); 233 try_catch.SetException(kUnableToCallMethodException);
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 } 283 }
284 284
285 bool IsInstanceOfDeprecated(PP_Var var, 285 bool IsInstanceOfDeprecated(PP_Var var,
286 const PPP_Class_Deprecated* ppp_class, 286 const PPP_Class_Deprecated* ppp_class,
287 void** ppp_class_data) { 287 void** ppp_class_data) {
288 scoped_refptr<V8ObjectVar> object(V8ObjectVar::FromPPVar(var)); 288 scoped_refptr<V8ObjectVar> object(V8ObjectVar::FromPPVar(var));
289 if (!object.get()) 289 if (!object.get())
290 return false; // Not an object at all. 290 return false; // Not an object at all.
291 291
292 v8::HandleScope handle_scope(object->instance()->GetIsolate()); 292 v8::HandleScope handle_scope(object->instance()->GetIsolate());
293 v8::Context::Scope context_scope(object->instance()->GetContext()); 293 v8::Context::Scope context_scope(object->instance()->GetMainWorldContext());
294 PluginObject* plugin_object = PluginObject::FromV8Object( 294 PluginObject* plugin_object = PluginObject::FromV8Object(
295 object->instance()->GetIsolate(), object->GetHandle()); 295 object->instance()->GetIsolate(), object->GetHandle());
296 if (plugin_object && plugin_object->ppp_class() == ppp_class) { 296 if (plugin_object && plugin_object->ppp_class() == ppp_class) {
297 if (ppp_class_data) 297 if (ppp_class_data)
298 *ppp_class_data = plugin_object->ppp_class_data(); 298 *ppp_class_data = plugin_object->ppp_class_data();
299 return true; 299 return true;
300 } 300 }
301 301
302 return false; 302 return false;
303 } 303 }
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 &CallDeprecated, 342 &CallDeprecated,
343 &Construct, 343 &Construct,
344 &IsInstanceOfDeprecated, 344 &IsInstanceOfDeprecated,
345 &CreateObjectDeprecated, 345 &CreateObjectDeprecated,
346 &CreateObjectWithModuleDeprecated, }; 346 &CreateObjectWithModuleDeprecated, };
347 347
348 return &var_deprecated_interface; 348 return &var_deprecated_interface;
349 } 349 }
350 350
351 } // namespace content 351 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/pepper/pepper_try_catch.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698