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

Side by Side Diff: chrome/renderer/pepper_plugin_delegate_impl.cc

Issue 5828003: Move the Pepper implementation from webkit/glue/plugins/pepper_* to... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 10 years 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 | Annotate | Revision Log
OLDNEW
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 21 matching lines...) Expand all
32 #include "gfx/size.h" 32 #include "gfx/size.h"
33 #include "grit/locale_settings.h" 33 #include "grit/locale_settings.h"
34 #include "ipc/ipc_channel_handle.h" 34 #include "ipc/ipc_channel_handle.h"
35 #include "ppapi/c/dev/pp_video_dev.h" 35 #include "ppapi/c/dev/pp_video_dev.h"
36 #include "ppapi/proxy/host_dispatcher.h" 36 #include "ppapi/proxy/host_dispatcher.h"
37 #include "third_party/WebKit/WebKit/chromium/public/WebFileChooserCompletion.h" 37 #include "third_party/WebKit/WebKit/chromium/public/WebFileChooserCompletion.h"
38 #include "third_party/WebKit/WebKit/chromium/public/WebFileChooserParams.h" 38 #include "third_party/WebKit/WebKit/chromium/public/WebFileChooserParams.h"
39 #include "third_party/WebKit/WebKit/chromium/public/WebPluginContainer.h" 39 #include "third_party/WebKit/WebKit/chromium/public/WebPluginContainer.h"
40 #include "third_party/WebKit/WebKit/chromium/public/WebView.h" 40 #include "third_party/WebKit/WebKit/chromium/public/WebView.h"
41 #include "webkit/fileapi/file_system_callback_dispatcher.h" 41 #include "webkit/fileapi/file_system_callback_dispatcher.h"
42 #include "webkit/glue/plugins/pepper_file_io.h"
43 #include "webkit/glue/plugins/pepper_plugin_instance.h"
44 #include "webkit/glue/plugins/pepper_plugin_module.h"
45 #include "webkit/glue/plugins/webplugin.h" 42 #include "webkit/glue/plugins/webplugin.h"
43 #include "webkit/plugins/ppapi/ppb_file_io_impl.h"
44 #include "webkit/plugins/ppapi/plugin_instance.h"
45 #include "webkit/plugins/ppapi/plugin_module.h"
46 46
47 #if defined(OS_MACOSX) 47 #if defined(OS_MACOSX)
48 #include "chrome/common/render_messages.h" 48 #include "chrome/common/render_messages.h"
49 #include "chrome/renderer/render_thread.h" 49 #include "chrome/renderer/render_thread.h"
50 #endif 50 #endif
51 51
52 #if defined(OS_POSIX) 52 #if defined(OS_POSIX)
53 #include "ipc/ipc_channel_posix.h" 53 #include "ipc/ipc_channel_posix.h"
54 #endif 54 #endif
55 55
56 using WebKit::WebView; 56 using WebKit::WebView;
57 57
58 namespace { 58 namespace {
59 59
60 const int32 kDefaultCommandBufferSize = 1024 * 1024; 60 const int32 kDefaultCommandBufferSize = 1024 * 1024;
61 61
62 // Implements the Image2D using a TransportDIB. 62 // Implements the Image2D using a TransportDIB.
63 class PlatformImage2DImpl : public pepper::PluginDelegate::PlatformImage2D { 63 class PlatformImage2DImpl
64 : public webkit::plugins::ppapi::PluginDelegate::PlatformImage2D {
64 public: 65 public:
65 // This constructor will take ownership of the dib pointer. 66 // This constructor will take ownership of the dib pointer.
66 PlatformImage2DImpl(int width, int height, TransportDIB* dib) 67 PlatformImage2DImpl(int width, int height, TransportDIB* dib)
67 : width_(width), 68 : width_(width),
68 height_(height), 69 height_(height),
69 dib_(dib) { 70 dib_(dib) {
70 } 71 }
71 72
72 virtual skia::PlatformCanvas* Map() { 73 virtual skia::PlatformCanvas* Map() {
73 return dib_->GetPlatformCanvas(width_, height_); 74 return dib_->GetPlatformCanvas(width_, height_);
(...skipping 17 matching lines...) Expand all
91 private: 92 private:
92 int width_; 93 int width_;
93 int height_; 94 int height_;
94 scoped_ptr<TransportDIB> dib_; 95 scoped_ptr<TransportDIB> dib_;
95 96
96 DISALLOW_COPY_AND_ASSIGN(PlatformImage2DImpl); 97 DISALLOW_COPY_AND_ASSIGN(PlatformImage2DImpl);
97 }; 98 };
98 99
99 #ifdef ENABLE_GPU 100 #ifdef ENABLE_GPU
100 101
101 class PlatformContext3DImpl : public pepper::PluginDelegate::PlatformContext3D { 102 class PlatformContext3DImpl
103 : public webkit::plugins::ppapi::PluginDelegate::PlatformContext3D {
102 public: 104 public:
103 explicit PlatformContext3DImpl(WebKit::WebView* web_view) 105 explicit PlatformContext3DImpl(WebKit::WebView* web_view)
104 : web_view_(web_view), 106 : web_view_(web_view),
105 context_(NULL) { 107 context_(NULL) {
106 } 108 }
107 109
108 virtual ~PlatformContext3DImpl() { 110 virtual ~PlatformContext3DImpl() {
109 if (context_) { 111 if (context_) {
110 ggl::DestroyContext(context_); 112 ggl::DestroyContext(context_);
111 context_ = NULL; 113 context_ = NULL;
112 } 114 }
113 } 115 }
114 116
115 virtual bool Init(); 117 virtual bool Init();
116 virtual bool SwapBuffers(); 118 virtual bool SwapBuffers();
117 virtual unsigned GetError(); 119 virtual unsigned GetError();
118 virtual void SetSwapBuffersCallback(Callback0::Type* callback); 120 virtual void SetSwapBuffersCallback(Callback0::Type* callback);
119 void ResizeBackingTexture(const gfx::Size& size); 121 void ResizeBackingTexture(const gfx::Size& size);
120 virtual unsigned GetBackingTextureId(); 122 virtual unsigned GetBackingTextureId();
121 virtual gpu::gles2::GLES2Implementation* GetGLES2Implementation(); 123 virtual gpu::gles2::GLES2Implementation* GetGLES2Implementation();
122 124
123 private: 125 private:
124 WebKit::WebView* web_view_; 126 WebKit::WebView* web_view_;
125 ggl::Context* context_; 127 ggl::Context* context_;
126 }; 128 };
127 129
128 #endif // ENABLE_GPU 130 #endif // ENABLE_GPU
129 131
130 class PlatformAudioImpl 132 class PlatformAudioImpl
131 : public pepper::PluginDelegate::PlatformAudio, 133 : public webkit::plugins::ppapi::PluginDelegate::PlatformAudio,
132 public AudioMessageFilter::Delegate, 134 public AudioMessageFilter::Delegate,
133 public base::RefCountedThreadSafe<PlatformAudioImpl> { 135 public base::RefCountedThreadSafe<PlatformAudioImpl> {
134 public: 136 public:
135 explicit PlatformAudioImpl(scoped_refptr<AudioMessageFilter> filter) 137 explicit PlatformAudioImpl(scoped_refptr<AudioMessageFilter> filter)
136 : client_(NULL), filter_(filter), stream_id_(0), 138 : client_(NULL), filter_(filter), stream_id_(0),
137 main_message_loop_(MessageLoop::current()) { 139 main_message_loop_(MessageLoop::current()) {
138 DCHECK(filter_); 140 DCHECK(filter_);
139 } 141 }
140 142
141 virtual ~PlatformAudioImpl() { 143 virtual ~PlatformAudioImpl() {
142 // Make sure we have been shut down. 144 // Make sure we have been shut down.
143 DCHECK_EQ(0, stream_id_); 145 DCHECK_EQ(0, stream_id_);
144 DCHECK(!client_); 146 DCHECK(!client_);
145 } 147 }
146 148
147 // Initialize this audio context. StreamCreated() will be called when the 149 // Initialize this audio context. StreamCreated() will be called when the
148 // stream is created. 150 // stream is created.
149 bool Initialize(uint32_t sample_rate, uint32_t sample_count, 151 bool Initialize(uint32_t sample_rate, uint32_t sample_count,
150 pepper::PluginDelegate::PlatformAudio::Client* client); 152 webkit::plugins::ppapi::PluginDelegate::PlatformAudio::Client* client);
151 153
152 virtual bool StartPlayback() { 154 virtual bool StartPlayback() {
153 return filter_ && filter_->Send( 155 return filter_ && filter_->Send(
154 new ViewHostMsg_PlayAudioStream(0, stream_id_)); 156 new ViewHostMsg_PlayAudioStream(0, stream_id_));
155 } 157 }
156 158
157 virtual bool StopPlayback() { 159 virtual bool StopPlayback() {
158 return filter_ && filter_->Send( 160 return filter_ && filter_->Send(
159 new ViewHostMsg_PauseAudioStream(0, stream_id_)); 161 new ViewHostMsg_PauseAudioStream(0, stream_id_));
160 } 162 }
(...skipping 11 matching lines...) Expand all
172 LOG(FATAL) << "Should never get OnCreated in PlatformAudioImpl"; 174 LOG(FATAL) << "Should never get OnCreated in PlatformAudioImpl";
173 } 175 }
174 176
175 virtual void OnLowLatencyCreated(base::SharedMemoryHandle handle, 177 virtual void OnLowLatencyCreated(base::SharedMemoryHandle handle,
176 base::SyncSocket::Handle socket_handle, 178 base::SyncSocket::Handle socket_handle,
177 uint32 length); 179 uint32 length);
178 180
179 virtual void OnVolume(double volume) { } 181 virtual void OnVolume(double volume) { }
180 182
181 // The client to notify when the stream is created. 183 // The client to notify when the stream is created.
182 pepper::PluginDelegate::PlatformAudio::Client* client_; 184 webkit::plugins::ppapi::PluginDelegate::PlatformAudio::Client* client_;
183 // MessageFilter used to send/receive IPC. 185 // MessageFilter used to send/receive IPC.
184 scoped_refptr<AudioMessageFilter> filter_; 186 scoped_refptr<AudioMessageFilter> filter_;
185 // Our ID on the MessageFilter. 187 // Our ID on the MessageFilter.
186 int32 stream_id_; 188 int32 stream_id_;
187 189
188 MessageLoop* main_message_loop_; 190 MessageLoop* main_message_loop_;
189 191
190 DISALLOW_COPY_AND_ASSIGN(PlatformAudioImpl); 192 DISALLOW_COPY_AND_ASSIGN(PlatformAudioImpl);
191 }; 193 };
192 194
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 gpu::gles2::GLES2Implementation* 270 gpu::gles2::GLES2Implementation*
269 PlatformContext3DImpl::GetGLES2Implementation() { 271 PlatformContext3DImpl::GetGLES2Implementation() {
270 DCHECK(context_); 272 DCHECK(context_);
271 return ggl::GetImplementation(context_); 273 return ggl::GetImplementation(context_);
272 } 274 }
273 275
274 #endif // ENABLE_GPU 276 #endif // ENABLE_GPU
275 277
276 bool PlatformAudioImpl::Initialize( 278 bool PlatformAudioImpl::Initialize(
277 uint32_t sample_rate, uint32_t sample_count, 279 uint32_t sample_rate, uint32_t sample_count,
278 pepper::PluginDelegate::PlatformAudio::Client* client) { 280 webkit::plugins::ppapi::PluginDelegate::PlatformAudio::Client* client) {
279 281
280 DCHECK(client); 282 DCHECK(client);
281 // Make sure we don't call init more than once. 283 // Make sure we don't call init more than once.
282 DCHECK_EQ(0, stream_id_); 284 DCHECK_EQ(0, stream_id_);
283 285
284 client_ = client; 286 client_ = client;
285 287
286 ViewHostMsg_Audio_CreateStream_Params params; 288 ViewHostMsg_Audio_CreateStream_Params params;
287 params.params.format = AudioParameters::AUDIO_PCM_LINEAR; 289 params.params.format = AudioParameters::AUDIO_PCM_LINEAR;
288 params.params.channels = 2; 290 params.params.channels = 2;
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 stream_id_ = 0; 330 stream_id_ = 0;
329 client_ = NULL; 331 client_ = NULL;
330 332
331 // Release on the IO thread so that we avoid race problems with 333 // Release on the IO thread so that we avoid race problems with
332 // OnLowLatencyCreated. 334 // OnLowLatencyCreated.
333 filter_->message_loop()->ReleaseSoon(FROM_HERE, this); 335 filter_->message_loop()->ReleaseSoon(FROM_HERE, this);
334 } 336 }
335 337
336 // Implements the VideoDecoder. 338 // Implements the VideoDecoder.
337 class PlatformVideoDecoderImpl 339 class PlatformVideoDecoderImpl
338 : public pepper::PluginDelegate::PlatformVideoDecoder { 340 : public webkit::plugins::ppapi::PluginDelegate::PlatformVideoDecoder {
339 public: 341 public:
340 PlatformVideoDecoderImpl() 342 PlatformVideoDecoderImpl()
341 : input_buffer_size_(0), 343 : input_buffer_size_(0),
342 next_dib_id_(0), 344 next_dib_id_(0),
343 dib_(NULL) { 345 dib_(NULL) {
344 memset(&decoder_config_, 0, sizeof(decoder_config_)); 346 memset(&decoder_config_, 0, sizeof(decoder_config_));
345 memset(&flush_callback_, 0, sizeof(flush_callback_)); 347 memset(&flush_callback_, 0, sizeof(flush_callback_));
346 } 348 }
347 349
348 virtual bool Init(const PP_VideoDecoderConfig_Dev& decoder_config) { 350 virtual bool Init(const PP_VideoDecoderConfig_Dev& decoder_config) {
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 size_t input_buffer_size_; 414 size_t input_buffer_size_;
413 int next_dib_id_; 415 int next_dib_id_;
414 scoped_ptr<TransportDIB> dib_; 416 scoped_ptr<TransportDIB> dib_;
415 PP_VideoDecoderConfig_Dev decoder_config_; 417 PP_VideoDecoderConfig_Dev decoder_config_;
416 std::queue<PP_VideoCompressedDataBuffer_Dev*> input_buffers_; 418 std::queue<PP_VideoCompressedDataBuffer_Dev*> input_buffers_;
417 PP_CompletionCallback flush_callback_; 419 PP_CompletionCallback flush_callback_;
418 420
419 DISALLOW_COPY_AND_ASSIGN(PlatformVideoDecoderImpl); 421 DISALLOW_COPY_AND_ASSIGN(PlatformVideoDecoderImpl);
420 }; 422 };
421 423
422 class DispatcherWrapper : public pepper::PluginDelegate::OutOfProcessProxy { 424 class DispatcherWrapper
425 : public webkit::plugins::ppapi::PluginDelegate::OutOfProcessProxy {
423 public: 426 public:
424 DispatcherWrapper() {} 427 DispatcherWrapper() {}
425 virtual ~DispatcherWrapper() {} 428 virtual ~DispatcherWrapper() {}
426 429
427 bool Init(base::ProcessHandle plugin_process_handle, 430 bool Init(base::ProcessHandle plugin_process_handle,
428 IPC::ChannelHandle channel_handle, 431 IPC::ChannelHandle channel_handle,
429 PP_Module pp_module, 432 PP_Module pp_module,
430 pp::proxy::Dispatcher::GetInterfaceFunc local_get_interface); 433 pp::proxy::Dispatcher::GetInterfaceFunc local_get_interface);
431 434
432 // OutOfProcessProxy implementation. 435 // OutOfProcessProxy implementation.
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
470 } // namespace 473 } // namespace
471 474
472 PepperPluginDelegateImpl::PepperPluginDelegateImpl(RenderView* render_view) 475 PepperPluginDelegateImpl::PepperPluginDelegateImpl(RenderView* render_view)
473 : render_view_(render_view), 476 : render_view_(render_view),
474 id_generator_(0) { 477 id_generator_(0) {
475 } 478 }
476 479
477 PepperPluginDelegateImpl::~PepperPluginDelegateImpl() { 480 PepperPluginDelegateImpl::~PepperPluginDelegateImpl() {
478 } 481 }
479 482
480 scoped_refptr<pepper::PluginModule> 483 scoped_refptr<webkit::plugins::ppapi::PluginModule>
481 PepperPluginDelegateImpl::CreatePepperPlugin(const FilePath& path) { 484 PepperPluginDelegateImpl::CreatePepperPlugin(const FilePath& path) {
482 // Easy case is in-process plugins. 485 // Easy case is in-process plugins.
483 if (!PepperPluginRegistry::GetInstance()->RunOutOfProcessForPlugin(path)) 486 if (!PepperPluginRegistry::GetInstance()->RunOutOfProcessForPlugin(path))
484 return PepperPluginRegistry::GetInstance()->GetModule(path); 487 return PepperPluginRegistry::GetInstance()->GetModule(path);
485 488
486 // Out of process: have the browser start the plugin process for us. 489 // Out of process: have the browser start the plugin process for us.
487 base::ProcessHandle plugin_process_handle = NULL; 490 base::ProcessHandle plugin_process_handle = NULL;
488 IPC::ChannelHandle channel_handle; 491 IPC::ChannelHandle channel_handle;
489 render_view_->Send(new ViewHostMsg_OpenChannelToPepperPlugin( 492 render_view_->Send(new ViewHostMsg_OpenChannelToPepperPlugin(
490 path, &plugin_process_handle, &channel_handle)); 493 path, &plugin_process_handle, &channel_handle));
491 if (channel_handle.name.empty()) 494 if (channel_handle.name.empty())
492 return scoped_refptr<pepper::PluginModule>(); // Couldn't be initialized. 495 return scoped_refptr<webkit::plugins::ppapi::PluginModule>(); // Couldn't b e initialized.
493 496
494 // Create a new HostDispatcher for the proxying, and hook it to a new 497 // Create a new HostDispatcher for the proxying, and hook it to a new
495 // PluginModule. 498 // PluginModule.
496 scoped_refptr<pepper::PluginModule> module(new pepper::PluginModule); 499 scoped_refptr<webkit::plugins::ppapi::PluginModule> module(
500 new webkit::plugins::ppapi::PluginModule);
497 scoped_ptr<DispatcherWrapper> dispatcher(new DispatcherWrapper); 501 scoped_ptr<DispatcherWrapper> dispatcher(new DispatcherWrapper);
498 if (!dispatcher->Init(plugin_process_handle, channel_handle, 502 if (!dispatcher->Init(
499 module->pp_module(), 503 plugin_process_handle, channel_handle,
500 pepper::PluginModule::GetLocalGetInterfaceFunc())) 504 module->pp_module(),
501 return scoped_refptr<pepper::PluginModule>(); 505 webkit::plugins::ppapi::PluginModule::GetLocalGetInterfaceFunc()))
506 return scoped_refptr<webkit::plugins::ppapi::PluginModule>();
502 module->InitAsProxied(dispatcher.release()); 507 module->InitAsProxied(dispatcher.release());
503 return module; 508 return module;
504 } 509 }
505 510
506 void PepperPluginDelegateImpl::ViewInitiatedPaint() { 511 void PepperPluginDelegateImpl::ViewInitiatedPaint() {
507 // Notify all of our instances that we started painting. This is used for 512 // Notify all of our instances that we started painting. This is used for
508 // internal bookkeeping only, so we know that the set can not change under 513 // internal bookkeeping only, so we know that the set can not change under
509 // us. 514 // us.
510 for (std::set<pepper::PluginInstance*>::iterator i = 515 for (std::set<webkit::plugins::ppapi::PluginInstance*>::iterator i =
511 active_instances_.begin(); 516 active_instances_.begin();
512 i != active_instances_.end(); ++i) 517 i != active_instances_.end(); ++i)
513 (*i)->ViewInitiatedPaint(); 518 (*i)->ViewInitiatedPaint();
514 } 519 }
515 520
516 void PepperPluginDelegateImpl::ViewFlushedPaint() { 521 void PepperPluginDelegateImpl::ViewFlushedPaint() {
517 // Notify all instances that we painted. This will call into the plugin, and 522 // Notify all instances that we painted. This will call into the plugin, and
518 // we it may ask to close itself as a result. This will, in turn, modify our 523 // we it may ask to close itself as a result. This will, in turn, modify our
519 // set, possibly invalidating the iterator. So we iterate on a copy that 524 // set, possibly invalidating the iterator. So we iterate on a copy that
520 // won't change out from under us. 525 // won't change out from under us.
521 std::set<pepper::PluginInstance*> plugins = active_instances_; 526 std::set<webkit::plugins::ppapi::PluginInstance*> plugins = active_instances_;
522 for (std::set<pepper::PluginInstance*>::iterator i = plugins.begin(); 527 for (std::set<webkit::plugins::ppapi::PluginInstance*>::iterator i = plugins.b egin();
523 i != plugins.end(); ++i) { 528 i != plugins.end(); ++i) {
524 // The copy above makes sure our iterator is never invalid if some plugins 529 // The copy above makes sure our iterator is never invalid if some plugins
525 // are destroyed. But some plugin may decide to close all of its views in 530 // are destroyed. But some plugin may decide to close all of its views in
526 // response to a paint in one of them, so we need to make sure each one is 531 // response to a paint in one of them, so we need to make sure each one is
527 // still "current" before using it. 532 // still "current" before using it.
528 // 533 //
529 // It's possible that a plugin was destroyed, but another one was created 534 // It's possible that a plugin was destroyed, but another one was created
530 // with the same address. In this case, we'll call ViewFlushedPaint on that 535 // with the same address. In this case, we'll call ViewFlushedPaint on that
531 // new plugin. But that's OK for this particular case since we're just 536 // new plugin. But that's OK for this particular case since we're just
532 // notifying all of our instances that the view flushed, and the new one is 537 // notifying all of our instances that the view flushed, and the new one is
533 // one of our instances. 538 // one of our instances.
534 // 539 //
535 // What about the case where a new one is created in a callback at a new 540 // What about the case where a new one is created in a callback at a new
536 // address and we don't issue the callback? We're still OK since this 541 // address and we don't issue the callback? We're still OK since this
537 // callback is used for flush callbacks and we could not have possibly 542 // callback is used for flush callbacks and we could not have possibly
538 // started a new paint (ViewInitiatedPaint) for the new plugin while 543 // started a new paint (ViewInitiatedPaint) for the new plugin while
539 // processing a previous paint for an existing one. 544 // processing a previous paint for an existing one.
540 if (active_instances_.find(*i) != active_instances_.end()) 545 if (active_instances_.find(*i) != active_instances_.end())
541 (*i)->ViewFlushedPaint(); 546 (*i)->ViewFlushedPaint();
542 } 547 }
543 } 548 }
544 549
545 bool PepperPluginDelegateImpl::GetBitmapForOptimizedPluginPaint( 550 bool PepperPluginDelegateImpl::GetBitmapForOptimizedPluginPaint(
546 const gfx::Rect& paint_bounds, 551 const gfx::Rect& paint_bounds,
547 TransportDIB** dib, 552 TransportDIB** dib,
548 gfx::Rect* location, 553 gfx::Rect* location,
549 gfx::Rect* clip) { 554 gfx::Rect* clip) {
550 for (std::set<pepper::PluginInstance*>::iterator i = 555 for (std::set<webkit::plugins::ppapi::PluginInstance*>::iterator i =
551 active_instances_.begin(); 556 active_instances_.begin();
552 i != active_instances_.end(); ++i) { 557 i != active_instances_.end(); ++i) {
553 pepper::PluginInstance* instance = *i; 558 webkit::plugins::ppapi::PluginInstance* instance = *i;
554 if (instance->GetBitmapForOptimizedPluginPaint( 559 if (instance->GetBitmapForOptimizedPluginPaint(
555 paint_bounds, dib, location, clip)) 560 paint_bounds, dib, location, clip))
556 return true; 561 return true;
557 } 562 }
558 return false; 563 return false;
559 } 564 }
560 565
561 void PepperPluginDelegateImpl::InstanceCreated( 566 void PepperPluginDelegateImpl::InstanceCreated(
562 pepper::PluginInstance* instance) { 567 webkit::plugins::ppapi::PluginInstance* instance) {
563 active_instances_.insert(instance); 568 active_instances_.insert(instance);
564 569
565 // Set the initial focus. 570 // Set the initial focus.
566 instance->SetContentAreaFocus(render_view_->has_focus()); 571 instance->SetContentAreaFocus(render_view_->has_focus());
567 } 572 }
568 573
569 void PepperPluginDelegateImpl::InstanceDeleted( 574 void PepperPluginDelegateImpl::InstanceDeleted(
570 pepper::PluginInstance* instance) { 575 webkit::plugins::ppapi::PluginInstance* instance) {
571 active_instances_.erase(instance); 576 active_instances_.erase(instance);
572 } 577 }
573 578
574 pepper::PluginDelegate::PlatformImage2D* 579 webkit::plugins::ppapi::PluginDelegate::PlatformImage2D*
575 PepperPluginDelegateImpl::CreateImage2D(int width, int height) { 580 PepperPluginDelegateImpl::CreateImage2D(int width, int height) {
576 uint32 buffer_size = width * height * 4; 581 uint32 buffer_size = width * height * 4;
577 582
578 // Allocate the transport DIB and the PlatformCanvas pointing to it. 583 // Allocate the transport DIB and the PlatformCanvas pointing to it.
579 #if defined(OS_MACOSX) 584 #if defined(OS_MACOSX)
580 // On the Mac, shared memory has to be created in the browser in order to 585 // On the Mac, shared memory has to be created in the browser in order to
581 // work in the sandbox. Do this by sending a message to the browser 586 // work in the sandbox. Do this by sending a message to the browser
582 // requesting a TransportDIB (see also 587 // requesting a TransportDIB (see also
583 // chrome/renderer/webplugin_delegate_proxy.cc, method 588 // chrome/renderer/webplugin_delegate_proxy.cc, method
584 // WebPluginDelegateProxy::CreateBitmap() for similar code). Note that the 589 // WebPluginDelegateProxy::CreateBitmap() for similar code). Note that the
(...skipping 15 matching lines...) Expand all
600 #else 605 #else
601 static int next_dib_id = 0; 606 static int next_dib_id = 0;
602 TransportDIB* dib = TransportDIB::Create(buffer_size, next_dib_id++); 607 TransportDIB* dib = TransportDIB::Create(buffer_size, next_dib_id++);
603 if (!dib) 608 if (!dib)
604 return NULL; 609 return NULL;
605 #endif 610 #endif
606 611
607 return new PlatformImage2DImpl(width, height, dib); 612 return new PlatformImage2DImpl(width, height, dib);
608 } 613 }
609 614
610 pepper::PluginDelegate::PlatformContext3D* 615 webkit::plugins::ppapi::PluginDelegate::PlatformContext3D*
611 PepperPluginDelegateImpl::CreateContext3D() { 616 PepperPluginDelegateImpl::CreateContext3D() {
612 #ifdef ENABLE_GPU 617 #ifdef ENABLE_GPU
613 return new PlatformContext3DImpl(render_view_->webview()); 618 return new PlatformContext3DImpl(render_view_->webview());
614 #else 619 #else
615 return NULL; 620 return NULL;
616 #endif 621 #endif
617 } 622 }
618 623
619 pepper::PluginDelegate::PlatformVideoDecoder* 624 webkit::plugins::ppapi::PluginDelegate::PlatformVideoDecoder*
620 PepperPluginDelegateImpl::CreateVideoDecoder( 625 PepperPluginDelegateImpl::CreateVideoDecoder(
621 const PP_VideoDecoderConfig_Dev& decoder_config) { 626 const PP_VideoDecoderConfig_Dev& decoder_config) {
622 scoped_ptr<PlatformVideoDecoderImpl> decoder(new PlatformVideoDecoderImpl()); 627 scoped_ptr<PlatformVideoDecoderImpl> decoder(new PlatformVideoDecoderImpl());
623 628
624 if (!decoder->Init(decoder_config)) 629 if (!decoder->Init(decoder_config))
625 return NULL; 630 return NULL;
626 631
627 return decoder.release(); 632 return decoder.release();
628 } 633 }
629 634
630 void PepperPluginDelegateImpl::NumberOfFindResultsChanged(int identifier, 635 void PepperPluginDelegateImpl::NumberOfFindResultsChanged(int identifier,
631 int total, 636 int total,
632 bool final_result) { 637 bool final_result) {
633 render_view_->reportFindInPageMatchCount(identifier, total, final_result); 638 render_view_->reportFindInPageMatchCount(identifier, total, final_result);
634 } 639 }
635 640
636 void PepperPluginDelegateImpl::SelectedFindResultChanged(int identifier, 641 void PepperPluginDelegateImpl::SelectedFindResultChanged(int identifier,
637 int index) { 642 int index) {
638 render_view_->reportFindInPageSelection( 643 render_view_->reportFindInPageSelection(
639 identifier, index + 1, WebKit::WebRect()); 644 identifier, index + 1, WebKit::WebRect());
640 } 645 }
641 646
642 pepper::PluginDelegate::PlatformAudio* PepperPluginDelegateImpl::CreateAudio( 647 webkit::plugins::ppapi::PluginDelegate::PlatformAudio*
648 PepperPluginDelegateImpl::CreateAudio(
643 uint32_t sample_rate, uint32_t sample_count, 649 uint32_t sample_rate, uint32_t sample_count,
644 pepper::PluginDelegate::PlatformAudio::Client* client) { 650 webkit::plugins::ppapi::PluginDelegate::PlatformAudio::Client* client) {
645 scoped_refptr<PlatformAudioImpl> audio( 651 scoped_refptr<PlatformAudioImpl> audio(
646 new PlatformAudioImpl(render_view_->audio_message_filter())); 652 new PlatformAudioImpl(render_view_->audio_message_filter()));
647 if (audio->Initialize(sample_rate, sample_count, client)) { 653 if (audio->Initialize(sample_rate, sample_count, client)) {
648 654
649 // Also note ReleaseSoon invoked in PlatformAudioImpl::ShutDown(). 655 // Also note ReleaseSoon invoked in PlatformAudioImpl::ShutDown().
650 return audio.release(); 656 return audio.release();
651 } else { 657 } else {
652 return NULL; 658 return NULL;
653 } 659 }
654 } 660 }
(...skipping 21 matching lines...) Expand all
676 int message_id) { 682 int message_id) {
677 AsyncOpenFileCallback* callback = 683 AsyncOpenFileCallback* callback =
678 messages_waiting_replies_.Lookup(message_id); 684 messages_waiting_replies_.Lookup(message_id);
679 DCHECK(callback); 685 DCHECK(callback);
680 messages_waiting_replies_.Remove(message_id); 686 messages_waiting_replies_.Remove(message_id);
681 callback->Run(error_code, file); 687 callback->Run(error_code, file);
682 delete callback; 688 delete callback;
683 } 689 }
684 690
685 void PepperPluginDelegateImpl::OnSetFocus(bool has_focus) { 691 void PepperPluginDelegateImpl::OnSetFocus(bool has_focus) {
686 for (std::set<pepper::PluginInstance*>::iterator i = 692 for (std::set<webkit::plugins::ppapi::PluginInstance*>::iterator i =
687 active_instances_.begin(); 693 active_instances_.begin();
688 i != active_instances_.end(); ++i) 694 i != active_instances_.end(); ++i)
689 (*i)->SetContentAreaFocus(has_focus); 695 (*i)->SetContentAreaFocus(has_focus);
690 } 696 }
691 697
692 bool PepperPluginDelegateImpl::OpenFileSystem( 698 bool PepperPluginDelegateImpl::OpenFileSystem(
693 const GURL& url, 699 const GURL& url,
694 fileapi::FileSystemType type, 700 fileapi::FileSystemType type,
695 long long size, 701 long long size,
696 fileapi::FileSystemCallbackDispatcher* dispatcher) { 702 fileapi::FileSystemCallbackDispatcher* dispatcher) {
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
849 base::PlatformFileError error; 855 base::PlatformFileError error;
850 IPC::Message* msg = new ViewHostMsg_PepperQueryFile(full_path, info, &error); 856 IPC::Message* msg = new ViewHostMsg_PepperQueryFile(full_path, info, &error);
851 if (!render_view_->Send(msg)) { 857 if (!render_view_->Send(msg)) {
852 return base::PLATFORM_FILE_ERROR_FAILED; 858 return base::PLATFORM_FILE_ERROR_FAILED;
853 } 859 }
854 return error; 860 return error;
855 } 861 }
856 base::PlatformFileError PepperPluginDelegateImpl::GetModuleLocalDirContents( 862 base::PlatformFileError PepperPluginDelegateImpl::GetModuleLocalDirContents(
857 const std::string& module_name, 863 const std::string& module_name,
858 const FilePath& path, 864 const FilePath& path,
859 PepperDirContents* contents) { 865 webkit::plugins::ppapi::DirContents* contents) {
860 FilePath full_path = GetModuleLocalFilePath(module_name, path); 866 FilePath full_path = GetModuleLocalFilePath(module_name, path);
861 if (full_path.empty()) { 867 if (full_path.empty()) {
862 return base::PLATFORM_FILE_ERROR_ACCESS_DENIED; 868 return base::PLATFORM_FILE_ERROR_ACCESS_DENIED;
863 } 869 }
864 base::PlatformFileError error; 870 base::PlatformFileError error;
865 IPC::Message* msg = 871 IPC::Message* msg =
866 new ViewHostMsg_PepperGetDirContents(full_path, contents, &error); 872 new ViewHostMsg_PepperGetDirContents(full_path, contents, &error);
867 if (!render_view_->Send(msg)) { 873 if (!render_view_->Send(msg)) {
868 return base::PLATFORM_FILE_ERROR_FAILED; 874 return base::PLATFORM_FILE_ERROR_FAILED;
869 } 875 }
870 return error; 876 return error;
871 } 877 }
872 878
873 scoped_refptr<base::MessageLoopProxy> 879 scoped_refptr<base::MessageLoopProxy>
874 PepperPluginDelegateImpl::GetFileThreadMessageLoopProxy() { 880 PepperPluginDelegateImpl::GetFileThreadMessageLoopProxy() {
875 return RenderThread::current()->GetFileThreadMessageLoopProxy(); 881 return RenderThread::current()->GetFileThreadMessageLoopProxy();
876 } 882 }
877 883
878 pepper::FullscreenContainer* 884 webkit::plugins::ppapi::FullscreenContainer*
879 PepperPluginDelegateImpl::CreateFullscreenContainer( 885 PepperPluginDelegateImpl::CreateFullscreenContainer(
880 pepper::PluginInstance* instance) { 886 webkit::plugins::ppapi::PluginInstance* instance) {
881 return render_view_->CreatePepperFullscreenContainer(instance); 887 return render_view_->CreatePepperFullscreenContainer(instance);
882 } 888 }
883 889
884 std::string PepperPluginDelegateImpl::GetDefaultEncoding() { 890 std::string PepperPluginDelegateImpl::GetDefaultEncoding() {
885 // TODO(brettw) bug 56615: Somehow get the preference for the default 891 // TODO(brettw) bug 56615: Somehow get the preference for the default
886 // encoding here rather than using the global default for the UI language. 892 // encoding here rather than using the global default for the UI language.
887 return l10n_util::GetStringUTF8(IDS_DEFAULT_ENCODING); 893 return l10n_util::GetStringUTF8(IDS_DEFAULT_ENCODING);
888 } 894 }
889 895
890 void PepperPluginDelegateImpl::ZoomLimitsChanged(double minimum_factor, 896 void PepperPluginDelegateImpl::ZoomLimitsChanged(double minimum_factor,
(...skipping 17 matching lines...) Expand all
908 } 914 }
909 915
910 void PepperPluginDelegateImpl::DidStopLoading() { 916 void PepperPluginDelegateImpl::DidStopLoading() {
911 render_view_->DidStopLoadingForPlugin(); 917 render_view_->DidStopLoadingForPlugin();
912 } 918 }
913 919
914 void PepperPluginDelegateImpl::SetContentRestriction(int restrictions) { 920 void PepperPluginDelegateImpl::SetContentRestriction(int restrictions) {
915 render_view_->Send(new ViewHostMsg_UpdateContentRestrictions( 921 render_view_->Send(new ViewHostMsg_UpdateContentRestrictions(
916 render_view_->routing_id(), restrictions)); 922 render_view_->routing_id(), restrictions));
917 } 923 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698