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

Side by Side Diff: content/renderer/pepper/pepper_plugin_instance_impl.cc

Issue 635593004: PPAPI: Make V8VarConverter longer-lived (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merge 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/message_channel.cc ('k') | content/renderer/pepper/pepper_try_catch.h » ('j') | 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/pepper_plugin_instance_impl.h" 5 #include "content/renderer/pepper/pepper_plugin_instance_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback_helpers.h" 8 #include "base/callback_helpers.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
(...skipping 2286 matching lines...) Expand 10 before | Expand all | Expand 10 after
2297 } 2297 }
2298 2298
2299 PP_Bool PepperPluginInstanceImpl::FlashIsFullscreen(PP_Instance instance) { 2299 PP_Bool PepperPluginInstanceImpl::FlashIsFullscreen(PP_Instance instance) {
2300 return PP_FromBool(flash_fullscreen_); 2300 return PP_FromBool(flash_fullscreen_);
2301 } 2301 }
2302 2302
2303 PP_Var PepperPluginInstanceImpl::GetWindowObject(PP_Instance instance) { 2303 PP_Var PepperPluginInstanceImpl::GetWindowObject(PP_Instance instance) {
2304 if (!container_) 2304 if (!container_)
2305 return PP_MakeUndefined(); 2305 return PP_MakeUndefined();
2306 2306
2307 PepperTryCatchVar try_catch(this, NULL); 2307 V8VarConverter converter(pp_instance_, V8VarConverter::kAllowObjectVars);
2308 PepperTryCatchVar try_catch(this, &converter, NULL);
2308 WebLocalFrame* frame = container_->element().document().frame(); 2309 WebLocalFrame* frame = container_->element().document().frame();
2309 if (!frame) { 2310 if (!frame) {
2310 try_catch.SetException("No frame exists for window object."); 2311 try_catch.SetException("No frame exists for window object.");
2311 return PP_MakeUndefined(); 2312 return PP_MakeUndefined();
2312 } 2313 }
2313 2314
2314 ScopedPPVar result = 2315 ScopedPPVar result =
2315 try_catch.FromV8(frame->mainWorldScriptContext()->Global()); 2316 try_catch.FromV8(frame->mainWorldScriptContext()->Global());
2316 DCHECK(!try_catch.HasException()); 2317 DCHECK(!try_catch.HasException());
2317 return result.Release(); 2318 return result.Release();
2318 } 2319 }
2319 2320
2320 PP_Var PepperPluginInstanceImpl::GetOwnerElementObject(PP_Instance instance) { 2321 PP_Var PepperPluginInstanceImpl::GetOwnerElementObject(PP_Instance instance) {
2321 if (!container_) 2322 if (!container_)
2322 return PP_MakeUndefined(); 2323 return PP_MakeUndefined();
2323 PepperTryCatchVar try_catch(this, NULL); 2324 V8VarConverter converter(pp_instance_, V8VarConverter::kAllowObjectVars);
2325 PepperTryCatchVar try_catch(this, &converter, NULL);
2324 ScopedPPVar result = try_catch.FromV8(container_->v8ObjectForElement()); 2326 ScopedPPVar result = try_catch.FromV8(container_->v8ObjectForElement());
2325 DCHECK(!try_catch.HasException()); 2327 DCHECK(!try_catch.HasException());
2326 return result.Release(); 2328 return result.Release();
2327 } 2329 }
2328 2330
2329 PP_Var PepperPluginInstanceImpl::ExecuteScript(PP_Instance instance, 2331 PP_Var PepperPluginInstanceImpl::ExecuteScript(PP_Instance instance,
2330 PP_Var script_var, 2332 PP_Var script_var,
2331 PP_Var* exception) { 2333 PP_Var* exception) {
2332 if (!container_) 2334 if (!container_)
2333 return PP_MakeUndefined(); 2335 return PP_MakeUndefined();
2334 2336
2335 // Executing the script may remove the plugin from the DOM, so we need to keep 2337 // Executing the script may remove the plugin from the DOM, so we need to keep
2336 // a reference to ourselves so that we can still process the result after the 2338 // a reference to ourselves so that we can still process the result after the
2337 // WebBindings::evaluate() below. 2339 // WebBindings::evaluate() below.
2338 scoped_refptr<PepperPluginInstanceImpl> ref(this); 2340 scoped_refptr<PepperPluginInstanceImpl> ref(this);
2339 PepperTryCatchVar try_catch(this, exception); 2341 V8VarConverter converter(pp_instance_, V8VarConverter::kAllowObjectVars);
2342 PepperTryCatchVar try_catch(this, &converter, exception);
2340 2343
2341 // Check for an exception due to the context being destroyed. 2344 // Check for an exception due to the context being destroyed.
2342 if (try_catch.HasException()) 2345 if (try_catch.HasException())
2343 return PP_MakeUndefined(); 2346 return PP_MakeUndefined();
2344 2347
2345 WebLocalFrame* frame = container_->element().document().frame(); 2348 WebLocalFrame* frame = container_->element().document().frame();
2346 if (!frame) { 2349 if (!frame) {
2347 try_catch.SetException("No frame to execute script in."); 2350 try_catch.SetException("No frame to execute script in.");
2348 return PP_MakeUndefined(); 2351 return PP_MakeUndefined();
2349 } 2352 }
(...skipping 950 matching lines...) Expand 10 before | Expand all | Expand 10 after
3300 void PepperPluginInstanceImpl::SetPluginThrottled(bool throttled) { 3303 void PepperPluginInstanceImpl::SetPluginThrottled(bool throttled) {
3301 // Do not throttle if we've already disabled power saver. 3304 // Do not throttle if we've already disabled power saver.
3302 if (!power_saver_enabled_ && throttled) 3305 if (!power_saver_enabled_ && throttled)
3303 return; 3306 return;
3304 3307
3305 plugin_throttled_ = throttled; 3308 plugin_throttled_ = throttled;
3306 SendDidChangeView(); 3309 SendDidChangeView();
3307 } 3310 }
3308 3311
3309 } // namespace content 3312 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/pepper/message_channel.cc ('k') | content/renderer/pepper/pepper_try_catch.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698