OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/renderer/pepper_plugin_delegate_impl.h" | 5 #include "chrome/renderer/pepper_plugin_delegate_impl.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 | 8 |
9 #include "app/l10n_util.h" | 9 #include "app/l10n_util.h" |
10 #include "app/surface/transport_dib.h" | 10 #include "app/surface/transport_dib.h" |
(...skipping 23 matching lines...) Expand all Loading... |
34 #include "gfx/size.h" | 34 #include "gfx/size.h" |
35 #include "grit/locale_settings.h" | 35 #include "grit/locale_settings.h" |
36 #include "ipc/ipc_channel_handle.h" | 36 #include "ipc/ipc_channel_handle.h" |
37 #include "ppapi/c/dev/pp_video_dev.h" | 37 #include "ppapi/c/dev/pp_video_dev.h" |
38 #include "ppapi/proxy/host_dispatcher.h" | 38 #include "ppapi/proxy/host_dispatcher.h" |
39 #include "third_party/WebKit/WebKit/chromium/public/WebFileChooserCompletion.h" | 39 #include "third_party/WebKit/WebKit/chromium/public/WebFileChooserCompletion.h" |
40 #include "third_party/WebKit/WebKit/chromium/public/WebFileChooserParams.h" | 40 #include "third_party/WebKit/WebKit/chromium/public/WebFileChooserParams.h" |
41 #include "third_party/WebKit/WebKit/chromium/public/WebPluginContainer.h" | 41 #include "third_party/WebKit/WebKit/chromium/public/WebPluginContainer.h" |
42 #include "third_party/WebKit/WebKit/chromium/public/WebView.h" | 42 #include "third_party/WebKit/WebKit/chromium/public/WebView.h" |
43 #include "webkit/fileapi/file_system_callback_dispatcher.h" | 43 #include "webkit/fileapi/file_system_callback_dispatcher.h" |
44 #include "webkit/glue/plugins/pepper_file_io.h" | |
45 #include "webkit/glue/plugins/pepper_plugin_instance.h" | |
46 #include "webkit/glue/plugins/pepper_plugin_module.h" | |
47 #include "webkit/glue/plugins/webplugin.h" | 44 #include "webkit/glue/plugins/webplugin.h" |
| 45 #include "webkit/plugins/ppapi/ppb_file_io_impl.h" |
| 46 #include "webkit/plugins/ppapi/plugin_instance.h" |
| 47 #include "webkit/plugins/ppapi/plugin_module.h" |
48 | 48 |
49 #if defined(OS_MACOSX) | 49 #if defined(OS_MACOSX) |
50 #include "chrome/common/render_messages.h" | 50 #include "chrome/common/render_messages.h" |
51 #include "chrome/renderer/render_thread.h" | 51 #include "chrome/renderer/render_thread.h" |
52 #endif | 52 #endif |
53 | 53 |
54 #if defined(OS_POSIX) | 54 #if defined(OS_POSIX) |
55 #include "ipc/ipc_channel_posix.h" | 55 #include "ipc/ipc_channel_posix.h" |
56 #endif | 56 #endif |
57 | 57 |
58 using WebKit::WebView; | 58 using WebKit::WebView; |
59 | 59 |
60 namespace { | 60 namespace { |
61 | 61 |
62 const int32 kDefaultCommandBufferSize = 1024 * 1024; | 62 const int32 kDefaultCommandBufferSize = 1024 * 1024; |
63 | 63 |
64 // Implements the Image2D using a TransportDIB. | 64 // Implements the Image2D using a TransportDIB. |
65 class PlatformImage2DImpl : public pepper::PluginDelegate::PlatformImage2D { | 65 class PlatformImage2DImpl |
| 66 : public webkit::ppapi::PluginDelegate::PlatformImage2D { |
66 public: | 67 public: |
67 // This constructor will take ownership of the dib pointer. | 68 // This constructor will take ownership of the dib pointer. |
68 PlatformImage2DImpl(int width, int height, TransportDIB* dib) | 69 PlatformImage2DImpl(int width, int height, TransportDIB* dib) |
69 : width_(width), | 70 : width_(width), |
70 height_(height), | 71 height_(height), |
71 dib_(dib) { | 72 dib_(dib) { |
72 } | 73 } |
73 | 74 |
74 virtual skia::PlatformCanvas* Map() { | 75 virtual skia::PlatformCanvas* Map() { |
75 return dib_->GetPlatformCanvas(width_, height_); | 76 return dib_->GetPlatformCanvas(width_, height_); |
(...skipping 17 matching lines...) Expand all Loading... |
93 private: | 94 private: |
94 int width_; | 95 int width_; |
95 int height_; | 96 int height_; |
96 scoped_ptr<TransportDIB> dib_; | 97 scoped_ptr<TransportDIB> dib_; |
97 | 98 |
98 DISALLOW_COPY_AND_ASSIGN(PlatformImage2DImpl); | 99 DISALLOW_COPY_AND_ASSIGN(PlatformImage2DImpl); |
99 }; | 100 }; |
100 | 101 |
101 | 102 |
102 class PlatformAudioImpl | 103 class PlatformAudioImpl |
103 : public pepper::PluginDelegate::PlatformAudio, | 104 : public webkit::ppapi::PluginDelegate::PlatformAudio, |
104 public AudioMessageFilter::Delegate, | 105 public AudioMessageFilter::Delegate, |
105 public base::RefCountedThreadSafe<PlatformAudioImpl> { | 106 public base::RefCountedThreadSafe<PlatformAudioImpl> { |
106 public: | 107 public: |
107 explicit PlatformAudioImpl(scoped_refptr<AudioMessageFilter> filter) | 108 explicit PlatformAudioImpl(scoped_refptr<AudioMessageFilter> filter) |
108 : client_(NULL), filter_(filter), stream_id_(0), | 109 : client_(NULL), filter_(filter), stream_id_(0), |
109 main_message_loop_(MessageLoop::current()) { | 110 main_message_loop_(MessageLoop::current()) { |
110 DCHECK(filter_); | 111 DCHECK(filter_); |
111 } | 112 } |
112 | 113 |
113 virtual ~PlatformAudioImpl() { | 114 virtual ~PlatformAudioImpl() { |
114 // Make sure we have been shut down. | 115 // Make sure we have been shut down. |
115 DCHECK_EQ(0, stream_id_); | 116 DCHECK_EQ(0, stream_id_); |
116 DCHECK(!client_); | 117 DCHECK(!client_); |
117 } | 118 } |
118 | 119 |
119 // Initialize this audio context. StreamCreated() will be called when the | 120 // Initialize this audio context. StreamCreated() will be called when the |
120 // stream is created. | 121 // stream is created. |
121 bool Initialize(uint32_t sample_rate, uint32_t sample_count, | 122 bool Initialize(uint32_t sample_rate, uint32_t sample_count, |
122 pepper::PluginDelegate::PlatformAudio::Client* client); | 123 webkit::ppapi::PluginDelegate::PlatformAudio::Client* client); |
123 | 124 |
124 virtual bool StartPlayback() { | 125 virtual bool StartPlayback() { |
125 return filter_ && filter_->Send( | 126 return filter_ && filter_->Send( |
126 new ViewHostMsg_PlayAudioStream(0, stream_id_)); | 127 new ViewHostMsg_PlayAudioStream(0, stream_id_)); |
127 } | 128 } |
128 | 129 |
129 virtual bool StopPlayback() { | 130 virtual bool StopPlayback() { |
130 return filter_ && filter_->Send( | 131 return filter_ && filter_->Send( |
131 new ViewHostMsg_PauseAudioStream(0, stream_id_)); | 132 new ViewHostMsg_PauseAudioStream(0, stream_id_)); |
132 } | 133 } |
(...skipping 11 matching lines...) Expand all Loading... |
144 LOG(FATAL) << "Should never get OnCreated in PlatformAudioImpl"; | 145 LOG(FATAL) << "Should never get OnCreated in PlatformAudioImpl"; |
145 } | 146 } |
146 | 147 |
147 virtual void OnLowLatencyCreated(base::SharedMemoryHandle handle, | 148 virtual void OnLowLatencyCreated(base::SharedMemoryHandle handle, |
148 base::SyncSocket::Handle socket_handle, | 149 base::SyncSocket::Handle socket_handle, |
149 uint32 length); | 150 uint32 length); |
150 | 151 |
151 virtual void OnVolume(double volume) { } | 152 virtual void OnVolume(double volume) { } |
152 | 153 |
153 // The client to notify when the stream is created. | 154 // The client to notify when the stream is created. |
154 pepper::PluginDelegate::PlatformAudio::Client* client_; | 155 webkit::ppapi::PluginDelegate::PlatformAudio::Client* client_; |
155 // MessageFilter used to send/receive IPC. | 156 // MessageFilter used to send/receive IPC. |
156 scoped_refptr<AudioMessageFilter> filter_; | 157 scoped_refptr<AudioMessageFilter> filter_; |
157 // Our ID on the MessageFilter. | 158 // Our ID on the MessageFilter. |
158 int32 stream_id_; | 159 int32 stream_id_; |
159 | 160 |
160 MessageLoop* main_message_loop_; | 161 MessageLoop* main_message_loop_; |
161 | 162 |
162 DISALLOW_COPY_AND_ASSIGN(PlatformAudioImpl); | 163 DISALLOW_COPY_AND_ASSIGN(PlatformAudioImpl); |
163 }; | 164 }; |
164 | 165 |
165 bool PlatformAudioImpl::Initialize( | 166 bool PlatformAudioImpl::Initialize( |
166 uint32_t sample_rate, uint32_t sample_count, | 167 uint32_t sample_rate, uint32_t sample_count, |
167 pepper::PluginDelegate::PlatformAudio::Client* client) { | 168 webkit::ppapi::PluginDelegate::PlatformAudio::Client* client) { |
168 | 169 |
169 DCHECK(client); | 170 DCHECK(client); |
170 // Make sure we don't call init more than once. | 171 // Make sure we don't call init more than once. |
171 DCHECK_EQ(0, stream_id_); | 172 DCHECK_EQ(0, stream_id_); |
172 | 173 |
173 client_ = client; | 174 client_ = client; |
174 | 175 |
175 ViewHostMsg_Audio_CreateStream_Params params; | 176 ViewHostMsg_Audio_CreateStream_Params params; |
176 params.params.format = AudioParameters::AUDIO_PCM_LINEAR; | 177 params.params.format = AudioParameters::AUDIO_PCM_LINEAR; |
177 params.params.channels = 2; | 178 params.params.channels = 2; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 stream_id_ = 0; | 218 stream_id_ = 0; |
218 client_ = NULL; | 219 client_ = NULL; |
219 | 220 |
220 // Release on the IO thread so that we avoid race problems with | 221 // Release on the IO thread so that we avoid race problems with |
221 // OnLowLatencyCreated. | 222 // OnLowLatencyCreated. |
222 filter_->message_loop()->ReleaseSoon(FROM_HERE, this); | 223 filter_->message_loop()->ReleaseSoon(FROM_HERE, this); |
223 } | 224 } |
224 | 225 |
225 // Implements the VideoDecoder. | 226 // Implements the VideoDecoder. |
226 class PlatformVideoDecoderImpl | 227 class PlatformVideoDecoderImpl |
227 : public pepper::PluginDelegate::PlatformVideoDecoder { | 228 : public webkit::ppapi::PluginDelegate::PlatformVideoDecoder { |
228 public: | 229 public: |
229 PlatformVideoDecoderImpl() | 230 PlatformVideoDecoderImpl() |
230 : input_buffer_size_(0), | 231 : input_buffer_size_(0), |
231 next_dib_id_(0), | 232 next_dib_id_(0), |
232 dib_(NULL) { | 233 dib_(NULL) { |
233 memset(&decoder_config_, 0, sizeof(decoder_config_)); | 234 memset(&decoder_config_, 0, sizeof(decoder_config_)); |
234 memset(&flush_callback_, 0, sizeof(flush_callback_)); | 235 memset(&flush_callback_, 0, sizeof(flush_callback_)); |
235 } | 236 } |
236 | 237 |
237 virtual bool Init(const PP_VideoDecoderConfig_Dev& decoder_config) { | 238 virtual bool Init(const PP_VideoDecoderConfig_Dev& decoder_config) { |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 size_t input_buffer_size_; | 302 size_t input_buffer_size_; |
302 int next_dib_id_; | 303 int next_dib_id_; |
303 scoped_ptr<TransportDIB> dib_; | 304 scoped_ptr<TransportDIB> dib_; |
304 PP_VideoDecoderConfig_Dev decoder_config_; | 305 PP_VideoDecoderConfig_Dev decoder_config_; |
305 std::queue<PP_VideoCompressedDataBuffer_Dev*> input_buffers_; | 306 std::queue<PP_VideoCompressedDataBuffer_Dev*> input_buffers_; |
306 PP_CompletionCallback flush_callback_; | 307 PP_CompletionCallback flush_callback_; |
307 | 308 |
308 DISALLOW_COPY_AND_ASSIGN(PlatformVideoDecoderImpl); | 309 DISALLOW_COPY_AND_ASSIGN(PlatformVideoDecoderImpl); |
309 }; | 310 }; |
310 | 311 |
311 class DispatcherWrapper : public pepper::PluginDelegate::OutOfProcessProxy { | 312 class DispatcherWrapper |
| 313 : public webkit::ppapi::PluginDelegate::OutOfProcessProxy { |
312 public: | 314 public: |
313 DispatcherWrapper() {} | 315 DispatcherWrapper() {} |
314 virtual ~DispatcherWrapper() {} | 316 virtual ~DispatcherWrapper() {} |
315 | 317 |
316 bool Init(base::ProcessHandle plugin_process_handle, | 318 bool Init(base::ProcessHandle plugin_process_handle, |
317 IPC::ChannelHandle channel_handle, | 319 IPC::ChannelHandle channel_handle, |
318 PP_Module pp_module, | 320 PP_Module pp_module, |
319 pp::proxy::Dispatcher::GetInterfaceFunc local_get_interface); | 321 pp::proxy::Dispatcher::GetInterfaceFunc local_get_interface); |
320 | 322 |
321 // OutOfProcessProxy implementation. | 323 // OutOfProcessProxy implementation. |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
359 } // namespace | 361 } // namespace |
360 | 362 |
361 PepperPluginDelegateImpl::PepperPluginDelegateImpl(RenderView* render_view) | 363 PepperPluginDelegateImpl::PepperPluginDelegateImpl(RenderView* render_view) |
362 : render_view_(render_view), | 364 : render_view_(render_view), |
363 id_generator_(0) { | 365 id_generator_(0) { |
364 } | 366 } |
365 | 367 |
366 PepperPluginDelegateImpl::~PepperPluginDelegateImpl() { | 368 PepperPluginDelegateImpl::~PepperPluginDelegateImpl() { |
367 } | 369 } |
368 | 370 |
369 scoped_refptr<pepper::PluginModule> | 371 scoped_refptr<webkit::ppapi::PluginModule> |
370 PepperPluginDelegateImpl::CreatePepperPlugin(const FilePath& path) { | 372 PepperPluginDelegateImpl::CreatePepperPlugin(const FilePath& path) { |
371 // Easy case is in-process plugins. | 373 // Easy case is in-process plugins. |
372 if (!PepperPluginRegistry::GetInstance()->RunOutOfProcessForPlugin(path)) | 374 if (!PepperPluginRegistry::GetInstance()->RunOutOfProcessForPlugin(path)) |
373 return PepperPluginRegistry::GetInstance()->GetModule(path); | 375 return PepperPluginRegistry::GetInstance()->GetModule(path); |
374 | 376 |
375 // Out of process: have the browser start the plugin process for us. | 377 // Out of process: have the browser start the plugin process for us. |
376 base::ProcessHandle plugin_process_handle = NULL; | 378 base::ProcessHandle plugin_process_handle = NULL; |
377 IPC::ChannelHandle channel_handle; | 379 IPC::ChannelHandle channel_handle; |
378 render_view_->Send(new ViewHostMsg_OpenChannelToPepperPlugin( | 380 render_view_->Send(new ViewHostMsg_OpenChannelToPepperPlugin( |
379 path, &plugin_process_handle, &channel_handle)); | 381 path, &plugin_process_handle, &channel_handle)); |
380 if (channel_handle.name.empty()) | 382 if (channel_handle.name.empty()) |
381 return scoped_refptr<pepper::PluginModule>(); // Couldn't be initialized. | 383 return scoped_refptr<webkit::ppapi::PluginModule>(); // Couldn't be initial
ized. |
382 | 384 |
383 // Create a new HostDispatcher for the proxying, and hook it to a new | 385 // Create a new HostDispatcher for the proxying, and hook it to a new |
384 // PluginModule. | 386 // PluginModule. |
385 scoped_refptr<pepper::PluginModule> module(new pepper::PluginModule); | 387 scoped_refptr<webkit::ppapi::PluginModule> module( |
| 388 new webkit::ppapi::PluginModule); |
386 scoped_ptr<DispatcherWrapper> dispatcher(new DispatcherWrapper); | 389 scoped_ptr<DispatcherWrapper> dispatcher(new DispatcherWrapper); |
387 if (!dispatcher->Init(plugin_process_handle, channel_handle, | 390 if (!dispatcher->Init( |
388 module->pp_module(), | 391 plugin_process_handle, channel_handle, |
389 pepper::PluginModule::GetLocalGetInterfaceFunc())) | 392 module->pp_module(), |
390 return scoped_refptr<pepper::PluginModule>(); | 393 webkit::ppapi::PluginModule::GetLocalGetInterfaceFunc())) |
| 394 return scoped_refptr<webkit::ppapi::PluginModule>(); |
391 module->InitAsProxied(dispatcher.release()); | 395 module->InitAsProxied(dispatcher.release()); |
392 return module; | 396 return module; |
393 } | 397 } |
394 | 398 |
395 void PepperPluginDelegateImpl::ViewInitiatedPaint() { | 399 void PepperPluginDelegateImpl::ViewInitiatedPaint() { |
396 // Notify all of our instances that we started painting. This is used for | 400 // Notify all of our instances that we started painting. This is used for |
397 // internal bookkeeping only, so we know that the set can not change under | 401 // internal bookkeeping only, so we know that the set can not change under |
398 // us. | 402 // us. |
399 for (std::set<pepper::PluginInstance*>::iterator i = | 403 for (std::set<webkit::ppapi::PluginInstance*>::iterator i = |
400 active_instances_.begin(); | 404 active_instances_.begin(); |
401 i != active_instances_.end(); ++i) | 405 i != active_instances_.end(); ++i) |
402 (*i)->ViewInitiatedPaint(); | 406 (*i)->ViewInitiatedPaint(); |
403 } | 407 } |
404 | 408 |
405 void PepperPluginDelegateImpl::ViewFlushedPaint() { | 409 void PepperPluginDelegateImpl::ViewFlushedPaint() { |
406 // Notify all instances that we painted. This will call into the plugin, and | 410 // Notify all instances that we painted. This will call into the plugin, and |
407 // we it may ask to close itself as a result. This will, in turn, modify our | 411 // we it may ask to close itself as a result. This will, in turn, modify our |
408 // set, possibly invalidating the iterator. So we iterate on a copy that | 412 // set, possibly invalidating the iterator. So we iterate on a copy that |
409 // won't change out from under us. | 413 // won't change out from under us. |
410 std::set<pepper::PluginInstance*> plugins = active_instances_; | 414 std::set<webkit::ppapi::PluginInstance*> plugins = active_instances_; |
411 for (std::set<pepper::PluginInstance*>::iterator i = plugins.begin(); | 415 for (std::set<webkit::ppapi::PluginInstance*>::iterator i = plugins.begin(); |
412 i != plugins.end(); ++i) { | 416 i != plugins.end(); ++i) { |
413 // The copy above makes sure our iterator is never invalid if some plugins | 417 // The copy above makes sure our iterator is never invalid if some plugins |
414 // are destroyed. But some plugin may decide to close all of its views in | 418 // are destroyed. But some plugin may decide to close all of its views in |
415 // response to a paint in one of them, so we need to make sure each one is | 419 // response to a paint in one of them, so we need to make sure each one is |
416 // still "current" before using it. | 420 // still "current" before using it. |
417 // | 421 // |
418 // It's possible that a plugin was destroyed, but another one was created | 422 // It's possible that a plugin was destroyed, but another one was created |
419 // with the same address. In this case, we'll call ViewFlushedPaint on that | 423 // with the same address. In this case, we'll call ViewFlushedPaint on that |
420 // new plugin. But that's OK for this particular case since we're just | 424 // new plugin. But that's OK for this particular case since we're just |
421 // notifying all of our instances that the view flushed, and the new one is | 425 // notifying all of our instances that the view flushed, and the new one is |
422 // one of our instances. | 426 // one of our instances. |
423 // | 427 // |
424 // What about the case where a new one is created in a callback at a new | 428 // What about the case where a new one is created in a callback at a new |
425 // address and we don't issue the callback? We're still OK since this | 429 // address and we don't issue the callback? We're still OK since this |
426 // callback is used for flush callbacks and we could not have possibly | 430 // callback is used for flush callbacks and we could not have possibly |
427 // started a new paint (ViewInitiatedPaint) for the new plugin while | 431 // started a new paint (ViewInitiatedPaint) for the new plugin while |
428 // processing a previous paint for an existing one. | 432 // processing a previous paint for an existing one. |
429 if (active_instances_.find(*i) != active_instances_.end()) | 433 if (active_instances_.find(*i) != active_instances_.end()) |
430 (*i)->ViewFlushedPaint(); | 434 (*i)->ViewFlushedPaint(); |
431 } | 435 } |
432 } | 436 } |
433 | 437 |
434 bool PepperPluginDelegateImpl::GetBitmapForOptimizedPluginPaint( | 438 bool PepperPluginDelegateImpl::GetBitmapForOptimizedPluginPaint( |
435 const gfx::Rect& paint_bounds, | 439 const gfx::Rect& paint_bounds, |
436 TransportDIB** dib, | 440 TransportDIB** dib, |
437 gfx::Rect* location, | 441 gfx::Rect* location, |
438 gfx::Rect* clip) { | 442 gfx::Rect* clip) { |
439 for (std::set<pepper::PluginInstance*>::iterator i = | 443 for (std::set<webkit::ppapi::PluginInstance*>::iterator i = |
440 active_instances_.begin(); | 444 active_instances_.begin(); |
441 i != active_instances_.end(); ++i) { | 445 i != active_instances_.end(); ++i) { |
442 pepper::PluginInstance* instance = *i; | 446 webkit::ppapi::PluginInstance* instance = *i; |
443 if (instance->GetBitmapForOptimizedPluginPaint( | 447 if (instance->GetBitmapForOptimizedPluginPaint( |
444 paint_bounds, dib, location, clip)) | 448 paint_bounds, dib, location, clip)) |
445 return true; | 449 return true; |
446 } | 450 } |
447 return false; | 451 return false; |
448 } | 452 } |
449 | 453 |
450 void PepperPluginDelegateImpl::InstanceCreated( | 454 void PepperPluginDelegateImpl::InstanceCreated( |
451 pepper::PluginInstance* instance) { | 455 webkit::ppapi::PluginInstance* instance) { |
452 active_instances_.insert(instance); | 456 active_instances_.insert(instance); |
453 | 457 |
454 // Set the initial focus. | 458 // Set the initial focus. |
455 instance->SetContentAreaFocus(render_view_->has_focus()); | 459 instance->SetContentAreaFocus(render_view_->has_focus()); |
456 } | 460 } |
457 | 461 |
458 void PepperPluginDelegateImpl::InstanceDeleted( | 462 void PepperPluginDelegateImpl::InstanceDeleted( |
459 pepper::PluginInstance* instance) { | 463 webkit::ppapi::PluginInstance* instance) { |
460 active_instances_.erase(instance); | 464 active_instances_.erase(instance); |
461 } | 465 } |
462 | 466 |
463 pepper::PluginDelegate::PlatformImage2D* | 467 webkit::ppapi::PluginDelegate::PlatformImage2D* |
464 PepperPluginDelegateImpl::CreateImage2D(int width, int height) { | 468 PepperPluginDelegateImpl::CreateImage2D(int width, int height) { |
465 uint32 buffer_size = width * height * 4; | 469 uint32 buffer_size = width * height * 4; |
466 | 470 |
467 // Allocate the transport DIB and the PlatformCanvas pointing to it. | 471 // Allocate the transport DIB and the PlatformCanvas pointing to it. |
468 #if defined(OS_MACOSX) | 472 #if defined(OS_MACOSX) |
469 // On the Mac, shared memory has to be created in the browser in order to | 473 // On the Mac, shared memory has to be created in the browser in order to |
470 // work in the sandbox. Do this by sending a message to the browser | 474 // work in the sandbox. Do this by sending a message to the browser |
471 // requesting a TransportDIB (see also | 475 // requesting a TransportDIB (see also |
472 // chrome/renderer/webplugin_delegate_proxy.cc, method | 476 // chrome/renderer/webplugin_delegate_proxy.cc, method |
473 // WebPluginDelegateProxy::CreateBitmap() for similar code). Note that the | 477 // WebPluginDelegateProxy::CreateBitmap() for similar code). Note that the |
(...skipping 15 matching lines...) Expand all Loading... |
489 #else | 493 #else |
490 static int next_dib_id = 0; | 494 static int next_dib_id = 0; |
491 TransportDIB* dib = TransportDIB::Create(buffer_size, next_dib_id++); | 495 TransportDIB* dib = TransportDIB::Create(buffer_size, next_dib_id++); |
492 if (!dib) | 496 if (!dib) |
493 return NULL; | 497 return NULL; |
494 #endif | 498 #endif |
495 | 499 |
496 return new PlatformImage2DImpl(width, height, dib); | 500 return new PlatformImage2DImpl(width, height, dib); |
497 } | 501 } |
498 | 502 |
499 pepper::PluginDelegate::PlatformContext3D* | 503 webkit::ppapi::PluginDelegate::PlatformContext3D* |
500 PepperPluginDelegateImpl::CreateContext3D() { | 504 PepperPluginDelegateImpl::CreateContext3D() { |
501 #ifdef ENABLE_GPU | 505 #ifdef ENABLE_GPU |
502 WebGraphicsContext3DCommandBufferImpl* context = | 506 WebGraphicsContext3DCommandBufferImpl* context = |
503 static_cast<WebGraphicsContext3DCommandBufferImpl*>( | 507 static_cast<WebGraphicsContext3DCommandBufferImpl*>( |
504 render_view_->webview()->graphicsContext3D()); | 508 render_view_->webview()->graphicsContext3D()); |
505 if (!context) | 509 if (!context) |
506 return NULL; | 510 return NULL; |
507 | 511 |
508 ggl::Context* parent_context = context->context(); | 512 ggl::Context* parent_context = context->context(); |
509 if (!parent_context) | 513 if (!parent_context) |
510 return NULL; | 514 return NULL; |
511 | 515 |
512 return new PlatformContext3DImpl(parent_context); | 516 return new PlatformContext3DImpl(parent_context); |
513 #else | 517 #else |
514 return NULL; | 518 return NULL; |
515 #endif | 519 #endif |
516 } | 520 } |
517 | 521 |
518 pepper::PluginDelegate::PlatformVideoDecoder* | 522 webkit::ppapi::PluginDelegate::PlatformVideoDecoder* |
519 PepperPluginDelegateImpl::CreateVideoDecoder( | 523 PepperPluginDelegateImpl::CreateVideoDecoder( |
520 const PP_VideoDecoderConfig_Dev& decoder_config) { | 524 const PP_VideoDecoderConfig_Dev& decoder_config) { |
521 scoped_ptr<PlatformVideoDecoderImpl> decoder(new PlatformVideoDecoderImpl()); | 525 scoped_ptr<PlatformVideoDecoderImpl> decoder(new PlatformVideoDecoderImpl()); |
522 | 526 |
523 if (!decoder->Init(decoder_config)) | 527 if (!decoder->Init(decoder_config)) |
524 return NULL; | 528 return NULL; |
525 | 529 |
526 return decoder.release(); | 530 return decoder.release(); |
527 } | 531 } |
528 | 532 |
529 void PepperPluginDelegateImpl::NumberOfFindResultsChanged(int identifier, | 533 void PepperPluginDelegateImpl::NumberOfFindResultsChanged(int identifier, |
530 int total, | 534 int total, |
531 bool final_result) { | 535 bool final_result) { |
532 render_view_->reportFindInPageMatchCount(identifier, total, final_result); | 536 render_view_->reportFindInPageMatchCount(identifier, total, final_result); |
533 } | 537 } |
534 | 538 |
535 void PepperPluginDelegateImpl::SelectedFindResultChanged(int identifier, | 539 void PepperPluginDelegateImpl::SelectedFindResultChanged(int identifier, |
536 int index) { | 540 int index) { |
537 render_view_->reportFindInPageSelection( | 541 render_view_->reportFindInPageSelection( |
538 identifier, index + 1, WebKit::WebRect()); | 542 identifier, index + 1, WebKit::WebRect()); |
539 } | 543 } |
540 | 544 |
541 pepper::PluginDelegate::PlatformAudio* PepperPluginDelegateImpl::CreateAudio( | 545 webkit::ppapi::PluginDelegate::PlatformAudio* |
| 546 PepperPluginDelegateImpl::CreateAudio( |
542 uint32_t sample_rate, uint32_t sample_count, | 547 uint32_t sample_rate, uint32_t sample_count, |
543 pepper::PluginDelegate::PlatformAudio::Client* client) { | 548 webkit::ppapi::PluginDelegate::PlatformAudio::Client* client) { |
544 scoped_refptr<PlatformAudioImpl> audio( | 549 scoped_refptr<PlatformAudioImpl> audio( |
545 new PlatformAudioImpl(render_view_->audio_message_filter())); | 550 new PlatformAudioImpl(render_view_->audio_message_filter())); |
546 if (audio->Initialize(sample_rate, sample_count, client)) { | 551 if (audio->Initialize(sample_rate, sample_count, client)) { |
547 | 552 |
548 // Also note ReleaseSoon invoked in PlatformAudioImpl::ShutDown(). | 553 // Also note ReleaseSoon invoked in PlatformAudioImpl::ShutDown(). |
549 return audio.release(); | 554 return audio.release(); |
550 } else { | 555 } else { |
551 return NULL; | 556 return NULL; |
552 } | 557 } |
553 } | 558 } |
(...skipping 21 matching lines...) Expand all Loading... |
575 int message_id) { | 580 int message_id) { |
576 AsyncOpenFileCallback* callback = | 581 AsyncOpenFileCallback* callback = |
577 messages_waiting_replies_.Lookup(message_id); | 582 messages_waiting_replies_.Lookup(message_id); |
578 DCHECK(callback); | 583 DCHECK(callback); |
579 messages_waiting_replies_.Remove(message_id); | 584 messages_waiting_replies_.Remove(message_id); |
580 callback->Run(error_code, file); | 585 callback->Run(error_code, file); |
581 delete callback; | 586 delete callback; |
582 } | 587 } |
583 | 588 |
584 void PepperPluginDelegateImpl::OnSetFocus(bool has_focus) { | 589 void PepperPluginDelegateImpl::OnSetFocus(bool has_focus) { |
585 for (std::set<pepper::PluginInstance*>::iterator i = | 590 for (std::set<webkit::ppapi::PluginInstance*>::iterator i = |
586 active_instances_.begin(); | 591 active_instances_.begin(); |
587 i != active_instances_.end(); ++i) | 592 i != active_instances_.end(); ++i) |
588 (*i)->SetContentAreaFocus(has_focus); | 593 (*i)->SetContentAreaFocus(has_focus); |
589 } | 594 } |
590 | 595 |
591 bool PepperPluginDelegateImpl::OpenFileSystem( | 596 bool PepperPluginDelegateImpl::OpenFileSystem( |
592 const GURL& url, | 597 const GURL& url, |
593 fileapi::FileSystemType type, | 598 fileapi::FileSystemType type, |
594 long long size, | 599 long long size, |
595 fileapi::FileSystemCallbackDispatcher* dispatcher) { | 600 fileapi::FileSystemCallbackDispatcher* dispatcher) { |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
748 base::PlatformFileError error; | 753 base::PlatformFileError error; |
749 IPC::Message* msg = new PepperFileMsg_QueryFile(full_path, info, &error); | 754 IPC::Message* msg = new PepperFileMsg_QueryFile(full_path, info, &error); |
750 if (!render_view_->Send(msg)) { | 755 if (!render_view_->Send(msg)) { |
751 return base::PLATFORM_FILE_ERROR_FAILED; | 756 return base::PLATFORM_FILE_ERROR_FAILED; |
752 } | 757 } |
753 return error; | 758 return error; |
754 } | 759 } |
755 base::PlatformFileError PepperPluginDelegateImpl::GetModuleLocalDirContents( | 760 base::PlatformFileError PepperPluginDelegateImpl::GetModuleLocalDirContents( |
756 const std::string& module_name, | 761 const std::string& module_name, |
757 const FilePath& path, | 762 const FilePath& path, |
758 PepperDirContents* contents) { | 763 webkit::ppapi::DirContents* contents) { |
759 FilePath full_path = GetModuleLocalFilePath(module_name, path); | 764 FilePath full_path = GetModuleLocalFilePath(module_name, path); |
760 if (full_path.empty()) { | 765 if (full_path.empty()) { |
761 return base::PLATFORM_FILE_ERROR_ACCESS_DENIED; | 766 return base::PLATFORM_FILE_ERROR_ACCESS_DENIED; |
762 } | 767 } |
763 base::PlatformFileError error; | 768 base::PlatformFileError error; |
764 IPC::Message* msg = | 769 IPC::Message* msg = |
765 new PepperFileMsg_GetDirContents(full_path, contents, &error); | 770 new PepperFileMsg_GetDirContents(full_path, contents, &error); |
766 if (!render_view_->Send(msg)) { | 771 if (!render_view_->Send(msg)) { |
767 return base::PLATFORM_FILE_ERROR_FAILED; | 772 return base::PLATFORM_FILE_ERROR_FAILED; |
768 } | 773 } |
769 return error; | 774 return error; |
770 } | 775 } |
771 | 776 |
772 scoped_refptr<base::MessageLoopProxy> | 777 scoped_refptr<base::MessageLoopProxy> |
773 PepperPluginDelegateImpl::GetFileThreadMessageLoopProxy() { | 778 PepperPluginDelegateImpl::GetFileThreadMessageLoopProxy() { |
774 return RenderThread::current()->GetFileThreadMessageLoopProxy(); | 779 return RenderThread::current()->GetFileThreadMessageLoopProxy(); |
775 } | 780 } |
776 | 781 |
777 pepper::FullscreenContainer* | 782 webkit::ppapi::FullscreenContainer* |
778 PepperPluginDelegateImpl::CreateFullscreenContainer( | 783 PepperPluginDelegateImpl::CreateFullscreenContainer( |
779 pepper::PluginInstance* instance) { | 784 webkit::ppapi::PluginInstance* instance) { |
780 return render_view_->CreatePepperFullscreenContainer(instance); | 785 return render_view_->CreatePepperFullscreenContainer(instance); |
781 } | 786 } |
782 | 787 |
783 std::string PepperPluginDelegateImpl::GetDefaultEncoding() { | 788 std::string PepperPluginDelegateImpl::GetDefaultEncoding() { |
784 // TODO(brettw) bug 56615: Somehow get the preference for the default | 789 // TODO(brettw) bug 56615: Somehow get the preference for the default |
785 // encoding here rather than using the global default for the UI language. | 790 // encoding here rather than using the global default for the UI language. |
786 return l10n_util::GetStringUTF8(IDS_DEFAULT_ENCODING); | 791 return l10n_util::GetStringUTF8(IDS_DEFAULT_ENCODING); |
787 } | 792 } |
788 | 793 |
789 void PepperPluginDelegateImpl::ZoomLimitsChanged(double minimum_factor, | 794 void PepperPluginDelegateImpl::ZoomLimitsChanged(double minimum_factor, |
(...skipping 17 matching lines...) Expand all Loading... |
807 } | 812 } |
808 | 813 |
809 void PepperPluginDelegateImpl::DidStopLoading() { | 814 void PepperPluginDelegateImpl::DidStopLoading() { |
810 render_view_->DidStopLoadingForPlugin(); | 815 render_view_->DidStopLoadingForPlugin(); |
811 } | 816 } |
812 | 817 |
813 void PepperPluginDelegateImpl::SetContentRestriction(int restrictions) { | 818 void PepperPluginDelegateImpl::SetContentRestriction(int restrictions) { |
814 render_view_->Send(new ViewHostMsg_UpdateContentRestrictions( | 819 render_view_->Send(new ViewHostMsg_UpdateContentRestrictions( |
815 render_view_->routing_id(), restrictions)); | 820 render_view_->routing_id(), restrictions)); |
816 } | 821 } |
OLD | NEW |