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 "webkit/plugins/ppapi/ppapi_plugin_instance.h" | 5 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/debug/trace_event.h" | 8 #include "base/debug/trace_event.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 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
395 // then it needs to keep its own reference on the stack. | 395 // then it needs to keep its own reference on the stack. |
396 | 396 |
397 void PluginInstance::Delete() { | 397 void PluginInstance::Delete() { |
398 // Keep a reference on the stack. See NOTE above. | 398 // Keep a reference on the stack. See NOTE above. |
399 scoped_refptr<PluginInstance> ref(this); | 399 scoped_refptr<PluginInstance> ref(this); |
400 // Force the MessageChannel to release its "passthrough object" which should | 400 // Force the MessageChannel to release its "passthrough object" which should |
401 // release our last reference to the "InstanceObject" and will probably | 401 // release our last reference to the "InstanceObject" and will probably |
402 // destroy it. We want to do this prior to calling DidDestroy in case the | 402 // destroy it. We want to do this prior to calling DidDestroy in case the |
403 // destructor of the instance object tries to use the instance. | 403 // destructor of the instance object tries to use the instance. |
404 message_channel_->SetPassthroughObject(NULL); | 404 message_channel_->SetPassthroughObject(NULL); |
405 instance_interface_->DidDestroy(pp_instance()); | 405 // If this is a NaCl plugin instance, shut down the NaCl plugin by calling |
| 406 // its DidDestroy. Don't call DidDestroy on the untrusted plugin instance, |
| 407 // since there is little that it can do at this point. |
406 if (nacl_plugin_instance_interface_.get()) | 408 if (nacl_plugin_instance_interface_.get()) |
407 nacl_plugin_instance_interface_->DidDestroy(pp_instance()); | 409 nacl_plugin_instance_interface_->DidDestroy(pp_instance()); |
| 410 else |
| 411 instance_interface_->DidDestroy(pp_instance()); |
408 | 412 |
409 if (fullscreen_container_) { | 413 if (fullscreen_container_) { |
410 fullscreen_container_->Destroy(); | 414 fullscreen_container_->Destroy(); |
411 fullscreen_container_ = NULL; | 415 fullscreen_container_ = NULL; |
412 } | 416 } |
413 container_ = NULL; | 417 container_ = NULL; |
414 } | 418 } |
415 | 419 |
416 void PluginInstance::Paint(WebCanvas* canvas, | 420 void PluginInstance::Paint(WebCanvas* canvas, |
417 const gfx::Rect& plugin_rect, | 421 const gfx::Rect& plugin_rect, |
(...skipping 1717 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2135 } | 2139 } |
2136 | 2140 |
2137 PP_Var PluginInstance::GetPluginInstanceURL( | 2141 PP_Var PluginInstance::GetPluginInstanceURL( |
2138 PP_Instance instance, | 2142 PP_Instance instance, |
2139 PP_URLComponents_Dev* components) { | 2143 PP_URLComponents_Dev* components) { |
2140 return ::ppapi::PPB_URLUtil_Shared::GenerateURLReturn(plugin_url_, | 2144 return ::ppapi::PPB_URLUtil_Shared::GenerateURLReturn(plugin_url_, |
2141 components); | 2145 components); |
2142 } | 2146 } |
2143 | 2147 |
2144 bool PluginInstance::ResetAsProxied() { | 2148 bool PluginInstance::ResetAsProxied() { |
2145 // Remember the existing instance interface, so we can call DidDestroy in | 2149 // For NaCl instances, remember the NaCl plugin instance interface, so we |
2146 // our Delete() method. This will delete the NaCl plugin instance, which | 2150 // can shut it down by calling its DidDestroy in our Delete() method. |
2147 // will shut down the NaCl process. | |
2148 nacl_plugin_instance_interface_.reset(instance_interface_.release()); | 2151 nacl_plugin_instance_interface_.reset(instance_interface_.release()); |
2149 | 2152 |
2150 base::Callback<const void*(const char*)> get_plugin_interface_func = | 2153 base::Callback<const void*(const char*)> get_plugin_interface_func = |
2151 base::Bind(&PluginModule::GetPluginInterface, module_.get()); | 2154 base::Bind(&PluginModule::GetPluginInterface, module_.get()); |
2152 PPP_Instance_Combined* ppp_instance_combined = | 2155 PPP_Instance_Combined* ppp_instance_combined = |
2153 PPP_Instance_Combined::Create(get_plugin_interface_func); | 2156 PPP_Instance_Combined::Create(get_plugin_interface_func); |
2154 if (!ppp_instance_combined) { | 2157 if (!ppp_instance_combined) { |
2155 // The proxy must support at least one usable PPP_Instance interface. | 2158 // The proxy must support at least one usable PPP_Instance interface. |
2156 NOTREACHED(); | 2159 NOTREACHED(); |
2157 return false; | 2160 return false; |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2255 screen_size_for_fullscreen_ = gfx::Size(); | 2258 screen_size_for_fullscreen_ = gfx::Size(); |
2256 WebElement element = container_->element(); | 2259 WebElement element = container_->element(); |
2257 element.setAttribute(WebString::fromUTF8(kWidth), width_before_fullscreen_); | 2260 element.setAttribute(WebString::fromUTF8(kWidth), width_before_fullscreen_); |
2258 element.setAttribute(WebString::fromUTF8(kHeight), height_before_fullscreen_); | 2261 element.setAttribute(WebString::fromUTF8(kHeight), height_before_fullscreen_); |
2259 element.setAttribute(WebString::fromUTF8(kBorder), border_before_fullscreen_); | 2262 element.setAttribute(WebString::fromUTF8(kBorder), border_before_fullscreen_); |
2260 element.setAttribute(WebString::fromUTF8(kStyle), style_before_fullscreen_); | 2263 element.setAttribute(WebString::fromUTF8(kStyle), style_before_fullscreen_); |
2261 } | 2264 } |
2262 | 2265 |
2263 } // namespace ppapi | 2266 } // namespace ppapi |
2264 } // namespace webkit | 2267 } // namespace webkit |
OLD | NEW |