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/plugin_module.h" | 5 #include "content/renderer/pepper/plugin_module.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "base/message_loop/message_loop.h" | 13 #include "base/message_loop/message_loop.h" |
14 #include "base/message_loop/message_loop_proxy.h" | 14 #include "base/message_loop/message_loop_proxy.h" |
15 #include "base/time/time.h" | 15 #include "base/time/time.h" |
16 #include "build/build_config.h" | 16 #include "build/build_config.h" |
17 #include "content/common/view_messages.h" | 17 #include "content/common/view_messages.h" |
18 #include "content/public/renderer/content_renderer_client.h" | 18 #include "content/public/renderer/content_renderer_client.h" |
19 #include "content/renderer/pepper/common.h" | |
20 #include "content/renderer/pepper/host_dispatcher_wrapper.h" | 19 #include "content/renderer/pepper/host_dispatcher_wrapper.h" |
21 #include "content/renderer/pepper/host_globals.h" | 20 #include "content/renderer/pepper/host_globals.h" |
22 #include "content/renderer/pepper/pepper_hung_plugin_filter.h" | 21 #include "content/renderer/pepper/pepper_hung_plugin_filter.h" |
23 #include "content/renderer/pepper/pepper_plugin_instance_impl.h" | 22 #include "content/renderer/pepper/pepper_plugin_instance_impl.h" |
24 #include "content/renderer/pepper/pepper_plugin_registry.h" | 23 #include "content/renderer/pepper/pepper_plugin_registry.h" |
25 #include "content/renderer/pepper/ppb_image_data_impl.h" | 24 #include "content/renderer/pepper/ppb_image_data_impl.h" |
26 #include "content/renderer/pepper/ppb_proxy_impl.h" | 25 #include "content/renderer/pepper/ppb_proxy_impl.h" |
27 #include "content/renderer/pepper/ppb_scrollbar_impl.h" | 26 #include "content/renderer/pepper/ppb_scrollbar_impl.h" |
28 #include "content/renderer/pepper/ppb_var_deprecated_impl.h" | 27 #include "content/renderer/pepper/ppb_var_deprecated_impl.h" |
29 #include "content/renderer/pepper/ppb_video_decoder_impl.h" | 28 #include "content/renderer/pepper/ppb_video_decoder_impl.h" |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 int32_t result) { | 199 int32_t result) { |
201 if (callback.func) { | 200 if (callback.func) { |
202 PpapiGlobals::Get()->GetMainThreadMessageLoop()->PostDelayedTask( | 201 PpapiGlobals::Get()->GetMainThreadMessageLoop()->PostDelayedTask( |
203 FROM_HERE, | 202 FROM_HERE, |
204 base::Bind(callback.func, callback.user_data, result), | 203 base::Bind(callback.func, callback.user_data, result), |
205 base::TimeDelta::FromMilliseconds(delay_in_msec)); | 204 base::TimeDelta::FromMilliseconds(delay_in_msec)); |
206 } | 205 } |
207 } | 206 } |
208 | 207 |
209 PP_Bool IsMainThread() { | 208 PP_Bool IsMainThread() { |
210 return BoolToPPBool(PpapiGlobals::Get() | 209 return PP_FromBool(PpapiGlobals::Get() |
211 ->GetMainThreadMessageLoop() | 210 ->GetMainThreadMessageLoop() |
212 ->BelongsToCurrentThread()); | 211 ->BelongsToCurrentThread()); |
213 } | 212 } |
214 | 213 |
215 const PPB_Core core_interface = {&AddRefResource, &ReleaseResource, | 214 const PPB_Core core_interface = {&AddRefResource, &ReleaseResource, |
216 &GetTime, &GetTickTime, | 215 &GetTime, &GetTickTime, |
217 &CallOnMainThread, &IsMainThread}; | 216 &CallOnMainThread, &IsMainThread}; |
218 | 217 |
219 // PPB_Testing ----------------------------------------------------------------- | 218 // PPB_Testing ----------------------------------------------------------------- |
220 | 219 |
221 PP_Bool ReadImageData(PP_Resource device_context_2d, | 220 PP_Bool ReadImageData(PP_Resource device_context_2d, |
222 PP_Resource image, | 221 PP_Resource image, |
223 const PP_Point* top_left) { | 222 const PP_Point* top_left) { |
224 EnterResource<PPB_Graphics2D_API> enter(device_context_2d, true); | 223 EnterResource<PPB_Graphics2D_API> enter(device_context_2d, true); |
225 if (enter.failed()) | 224 if (enter.failed()) |
226 return PP_FALSE; | 225 return PP_FALSE; |
227 return BoolToPPBool(enter.object()->ReadImageData(image, top_left)); | 226 return PP_FromBool(enter.object()->ReadImageData(image, top_left)); |
228 } | 227 } |
229 | 228 |
230 void RunMessageLoop(PP_Instance instance) { | 229 void RunMessageLoop(PP_Instance instance) { |
231 base::MessageLoop::ScopedNestableTaskAllower allow( | 230 base::MessageLoop::ScopedNestableTaskAllower allow( |
232 base::MessageLoop::current()); | 231 base::MessageLoop::current()); |
233 base::MessageLoop::current()->Run(); | 232 base::MessageLoop::current()->Run(); |
234 } | 233 } |
235 | 234 |
236 void QuitMessageLoop(PP_Instance instance) { | 235 void QuitMessageLoop(PP_Instance instance) { |
237 base::MessageLoop::current()->QuitNow(); | 236 base::MessageLoop::current()->QuitNow(); |
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
590 } | 589 } |
591 | 590 |
592 void PluginModule::SetReserveInstanceIDCallback( | 591 void PluginModule::SetReserveInstanceIDCallback( |
593 PP_Bool (*reserve)(PP_Module, PP_Instance)) { | 592 PP_Bool (*reserve)(PP_Module, PP_Instance)) { |
594 DCHECK(!reserve_instance_id_) << "Only expect one set."; | 593 DCHECK(!reserve_instance_id_) << "Only expect one set."; |
595 reserve_instance_id_ = reserve; | 594 reserve_instance_id_ = reserve; |
596 } | 595 } |
597 | 596 |
598 bool PluginModule::ReserveInstanceID(PP_Instance instance) { | 597 bool PluginModule::ReserveInstanceID(PP_Instance instance) { |
599 if (reserve_instance_id_) | 598 if (reserve_instance_id_) |
600 return PPBoolToBool(reserve_instance_id_(pp_module_, instance)); | 599 return PP_ToBool(reserve_instance_id_(pp_module_, instance)); |
601 return true; // Instance ID is usable. | 600 return true; // Instance ID is usable. |
602 } | 601 } |
603 | 602 |
604 void PluginModule::SetBroker(PepperBroker* broker) { | 603 void PluginModule::SetBroker(PepperBroker* broker) { |
605 DCHECK(!broker_ || !broker); | 604 DCHECK(!broker_ || !broker); |
606 broker_ = broker; | 605 broker_ = broker; |
607 } | 606 } |
608 | 607 |
609 PepperBroker* PluginModule::GetBroker() { return broker_; } | 608 PepperBroker* PluginModule::GetBroker() { return broker_; } |
610 | 609 |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
713 channel_handle, | 712 channel_handle, |
714 peer_pid, | 713 peer_pid, |
715 plugin_child_id, | 714 plugin_child_id, |
716 false)) // is_external = false | 715 false)) // is_external = false |
717 return scoped_refptr<PluginModule>(); | 716 return scoped_refptr<PluginModule>(); |
718 | 717 |
719 return module; | 718 return module; |
720 } | 719 } |
721 | 720 |
722 } // namespace content | 721 } // namespace content |
OLD | NEW |