OLD | NEW |
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/logging.h" | 9 #include "base/logging.h" |
10 #include "base/memory/linked_ptr.h" | 10 #include "base/memory/linked_ptr.h" |
(...skipping 625 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
636 return v8::Local<v8::Object>::New(isolate_, message_channel_object_); | 636 return v8::Local<v8::Object>::New(isolate_, message_channel_object_); |
637 } | 637 } |
638 | 638 |
639 void PepperPluginInstanceImpl::MessageChannelDestroyed() { | 639 void PepperPluginInstanceImpl::MessageChannelDestroyed() { |
640 message_channel_ = NULL; | 640 message_channel_ = NULL; |
641 message_channel_object_.Reset(); | 641 message_channel_object_.Reset(); |
642 } | 642 } |
643 | 643 |
644 v8::Local<v8::Context> PepperPluginInstanceImpl::GetMainWorldContext() { | 644 v8::Local<v8::Context> PepperPluginInstanceImpl::GetMainWorldContext() { |
645 if (!container_) | 645 if (!container_) |
646 return v8::Handle<v8::Context>(); | 646 return v8::Local<v8::Context>(); |
647 | 647 |
648 if (container_->element().isNull()) | 648 if (container_->element().isNull()) |
649 return v8::Handle<v8::Context>(); | 649 return v8::Local<v8::Context>(); |
650 | 650 |
651 if (container_->element().document().isNull()) | 651 if (container_->element().document().isNull()) |
652 return v8::Handle<v8::Context>(); | 652 return v8::Local<v8::Context>(); |
653 | 653 |
654 if (!container_->element().document().frame()) | 654 if (!container_->element().document().frame()) |
655 return v8::Handle<v8::Context>(); | 655 return v8::Local<v8::Context>(); |
656 | 656 |
657 v8::Local<v8::Context> context = | 657 v8::Local<v8::Context> context = |
658 container_->element().document().frame()->mainWorldScriptContext(); | 658 container_->element().document().frame()->mainWorldScriptContext(); |
659 DCHECK(context->GetIsolate() == isolate_); | 659 DCHECK(context->GetIsolate() == isolate_); |
660 return context; | 660 return context; |
661 } | 661 } |
662 | 662 |
663 void PepperPluginInstanceImpl::Delete() { | 663 void PepperPluginInstanceImpl::Delete() { |
664 is_deleted_ = true; | 664 is_deleted_ = true; |
665 | 665 |
666 if (render_frame_ && | 666 if (render_frame_ && |
667 render_frame_->render_view()->plugin_find_handler() == this) { | 667 render_frame_->render_view()->plugin_find_handler() == this) { |
668 render_frame_->render_view()->set_plugin_find_handler(NULL); | 668 render_frame_->render_view()->set_plugin_find_handler(NULL); |
669 } | 669 } |
670 | 670 |
671 // Keep a reference on the stack. See NOTE above. | 671 // Keep a reference on the stack. See NOTE above. |
672 scoped_refptr<PepperPluginInstanceImpl> ref(this); | 672 scoped_refptr<PepperPluginInstanceImpl> ref(this); |
673 // Force the MessageChannel to release its "passthrough object" which should | 673 // Force the MessageChannel to release its "passthrough object" which should |
674 // release our last reference to the "InstanceObject" and will probably | 674 // release our last reference to the "InstanceObject" and will probably |
675 // destroy it. We want to do this prior to calling DidDestroy in case the | 675 // destroy it. We want to do this prior to calling DidDestroy in case the |
676 // destructor of the instance object tries to use the instance. | 676 // destructor of the instance object tries to use the instance. |
677 if (message_channel_) | 677 if (message_channel_) |
678 message_channel_->SetPassthroughObject(v8::Handle<v8::Object>()); | 678 message_channel_->SetPassthroughObject(v8::Local<v8::Object>()); |
679 // If this is a NaCl plugin instance, shut down the NaCl plugin by calling | 679 // If this is a NaCl plugin instance, shut down the NaCl plugin by calling |
680 // its DidDestroy. Don't call DidDestroy on the untrusted plugin instance, | 680 // its DidDestroy. Don't call DidDestroy on the untrusted plugin instance, |
681 // since there is little that it can do at this point. | 681 // since there is little that it can do at this point. |
682 if (original_instance_interface_) { | 682 if (original_instance_interface_) { |
683 base::TimeTicks start = base::TimeTicks::Now(); | 683 base::TimeTicks start = base::TimeTicks::Now(); |
684 original_instance_interface_->DidDestroy(pp_instance()); | 684 original_instance_interface_->DidDestroy(pp_instance()); |
685 UMA_HISTOGRAM_CUSTOM_TIMES("NaCl.Perf.ShutdownTime.Total", | 685 UMA_HISTOGRAM_CUSTOM_TIMES("NaCl.Perf.ShutdownTime.Total", |
686 base::TimeTicks::Now() - start, | 686 base::TimeTicks::Now() - start, |
687 base::TimeDelta::FromMilliseconds(1), | 687 base::TimeDelta::FromMilliseconds(1), |
688 base::TimeDelta::FromSeconds(20), | 688 base::TimeDelta::FromSeconds(20), |
(...skipping 1712 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2401 | 2401 |
2402 StringVar* script_string_var = StringVar::FromPPVar(script_var); | 2402 StringVar* script_string_var = StringVar::FromPPVar(script_var); |
2403 if (!script_string_var) { | 2403 if (!script_string_var) { |
2404 try_catch.SetException("Script param to ExecuteScript must be a string."); | 2404 try_catch.SetException("Script param to ExecuteScript must be a string."); |
2405 return PP_MakeUndefined(); | 2405 return PP_MakeUndefined(); |
2406 } | 2406 } |
2407 | 2407 |
2408 std::string script_string = script_string_var->value(); | 2408 std::string script_string = script_string_var->value(); |
2409 blink::WebScriptSource script( | 2409 blink::WebScriptSource script( |
2410 blink::WebString::fromUTF8(script_string.c_str())); | 2410 blink::WebString::fromUTF8(script_string.c_str())); |
2411 v8::Handle<v8::Value> result; | 2411 v8::Local<v8::Value> result; |
2412 if (IsProcessingUserGesture()) { | 2412 if (IsProcessingUserGesture()) { |
2413 blink::WebScopedUserGesture user_gesture(CurrentUserGestureToken()); | 2413 blink::WebScopedUserGesture user_gesture(CurrentUserGestureToken()); |
2414 result = frame->executeScriptAndReturnValue(script); | 2414 result = frame->executeScriptAndReturnValue(script); |
2415 } else { | 2415 } else { |
2416 result = frame->executeScriptAndReturnValue(script); | 2416 result = frame->executeScriptAndReturnValue(script); |
2417 } | 2417 } |
2418 | 2418 |
2419 ScopedPPVar var_result = try_catch.FromV8(result); | 2419 ScopedPPVar var_result = try_catch.FromV8(result); |
2420 if (try_catch.HasException()) | 2420 if (try_catch.HasException()) |
2421 return PP_MakeUndefined(); | 2421 return PP_MakeUndefined(); |
(...skipping 920 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3342 | 3342 |
3343 void PepperPluginInstanceImpl::RecordFlashJavaScriptUse() { | 3343 void PepperPluginInstanceImpl::RecordFlashJavaScriptUse() { |
3344 if (initialized_ && !javascript_used_ && is_flash_plugin_) { | 3344 if (initialized_ && !javascript_used_ && is_flash_plugin_) { |
3345 javascript_used_ = true; | 3345 javascript_used_ = true; |
3346 RenderThread::Get()->RecordAction( | 3346 RenderThread::Get()->RecordAction( |
3347 base::UserMetricsAction("Flash.JavaScriptUsed")); | 3347 base::UserMetricsAction("Flash.JavaScriptUsed")); |
3348 } | 3348 } |
3349 } | 3349 } |
3350 | 3350 |
3351 } // namespace content | 3351 } // namespace content |
OLD | NEW |