OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/plugin/webplugin_delegate_stub.h" | 5 #include "chrome/plugin/webplugin_delegate_stub.h" |
6 | 6 |
7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "chrome/common/child_process_logging.h" | 10 #include "chrome/common/child_process_logging.h" |
11 #include "chrome/common/chrome_switches.h" | 11 #include "chrome/common/chrome_switches.h" |
12 #include "chrome/common/plugin_messages.h" | 12 #include "chrome/common/plugin_messages.h" |
13 #include "chrome/plugin/npobject_stub.h" | 13 #include "chrome/plugin/npobject_stub.h" |
14 #include "chrome/plugin/plugin_channel.h" | 14 #include "chrome/plugin/plugin_channel.h" |
15 #include "chrome/plugin/plugin_thread.h" | 15 #include "chrome/plugin/plugin_thread.h" |
16 #include "chrome/plugin/webplugin_proxy.h" | 16 #include "chrome/plugin/webplugin_proxy.h" |
17 #include "printing/native_metafile.h" | 17 #include "printing/native_metafile.h" |
18 #include "third_party/npapi/bindings/npapi.h" | 18 #include "third_party/npapi/bindings/npapi.h" |
19 #include "third_party/npapi/bindings/npruntime.h" | 19 #include "third_party/npapi/bindings/npruntime.h" |
20 #include "skia/ext/platform_device.h" | 20 #include "skia/ext/platform_device.h" |
21 #include "third_party/WebKit/Source/WebKit/chromium/public/WebBindings.h" | 21 #include "third_party/WebKit/Source/WebKit/chromium/public/WebBindings.h" |
22 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCursorInfo.h" | 22 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCursorInfo.h" |
23 #include "webkit/plugins/npapi/webplugin_delegate_impl.h" | 23 #include "webkit/plugins/npapi/webplugin_delegate_impl.h" |
24 #include "webkit/glue/webcursor.h" | 24 #include "webkit/glue/webcursor.h" |
25 | 25 |
26 #if defined(ENABLE_GPU) | |
27 #include "app/gfx/gl/gl_context.h" | |
28 #endif | |
29 | |
30 using WebKit::WebBindings; | 26 using WebKit::WebBindings; |
31 using WebKit::WebCursorInfo; | 27 using WebKit::WebCursorInfo; |
32 using webkit::npapi::WebPlugin; | 28 using webkit::npapi::WebPlugin; |
33 using webkit::npapi::WebPluginResourceClient; | 29 using webkit::npapi::WebPluginResourceClient; |
34 | 30 |
35 class FinishDestructionTask : public Task { | 31 class FinishDestructionTask : public Task { |
36 public: | 32 public: |
37 FinishDestructionTask(webkit::npapi::WebPluginDelegateImpl* delegate, | 33 FinishDestructionTask(webkit::npapi::WebPluginDelegateImpl* delegate, |
38 WebPlugin* webplugin) | 34 WebPlugin* webplugin) |
39 : delegate_(delegate), webplugin_(webplugin) { | 35 : delegate_(delegate), webplugin_(webplugin) { |
(...skipping 20 matching lines...) Expand all Loading... |
60 delegate_(NULL), | 56 delegate_(NULL), |
61 webplugin_(NULL), | 57 webplugin_(NULL), |
62 in_destructor_(false) { | 58 in_destructor_(false) { |
63 DCHECK(channel); | 59 DCHECK(channel); |
64 } | 60 } |
65 | 61 |
66 WebPluginDelegateStub::~WebPluginDelegateStub() { | 62 WebPluginDelegateStub::~WebPluginDelegateStub() { |
67 in_destructor_ = true; | 63 in_destructor_ = true; |
68 child_process_logging::SetActiveURL(page_url_); | 64 child_process_logging::SetActiveURL(page_url_); |
69 | 65 |
70 #if defined(ENABLE_GPU) | |
71 // Make sure there is no command buffer before destroying the window handle. | |
72 // The GPU service code might otherwise asynchronously perform an operation | |
73 // using the window handle. | |
74 command_buffer_stub_.reset(); | |
75 #endif | |
76 | |
77 if (channel_->in_send()) { | 66 if (channel_->in_send()) { |
78 // The delegate or an npobject is in the callstack, so don't delete it | 67 // The delegate or an npobject is in the callstack, so don't delete it |
79 // right away. | 68 // right away. |
80 MessageLoop::current()->PostNonNestableTask(FROM_HERE, | 69 MessageLoop::current()->PostNonNestableTask(FROM_HERE, |
81 new FinishDestructionTask(delegate_, webplugin_)); | 70 new FinishDestructionTask(delegate_, webplugin_)); |
82 } else { | 71 } else { |
83 // Safe to delete right away. | 72 // Safe to delete right away. |
84 if (delegate_) | 73 if (delegate_) |
85 delegate_->PluginDestroyed(); | 74 delegate_->PluginDestroyed(); |
86 | 75 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 OnDidReceiveManualResponse) | 121 OnDidReceiveManualResponse) |
133 IPC_MESSAGE_HANDLER(PluginMsg_DidReceiveManualData, OnDidReceiveManualData) | 122 IPC_MESSAGE_HANDLER(PluginMsg_DidReceiveManualData, OnDidReceiveManualData) |
134 IPC_MESSAGE_HANDLER(PluginMsg_DidFinishManualLoading, | 123 IPC_MESSAGE_HANDLER(PluginMsg_DidFinishManualLoading, |
135 OnDidFinishManualLoading) | 124 OnDidFinishManualLoading) |
136 IPC_MESSAGE_HANDLER(PluginMsg_DidManualLoadFail, OnDidManualLoadFail) | 125 IPC_MESSAGE_HANDLER(PluginMsg_DidManualLoadFail, OnDidManualLoadFail) |
137 IPC_MESSAGE_HANDLER(PluginMsg_InstallMissingPlugin, OnInstallMissingPlugin) | 126 IPC_MESSAGE_HANDLER(PluginMsg_InstallMissingPlugin, OnInstallMissingPlugin) |
138 IPC_MESSAGE_HANDLER(PluginMsg_HandleURLRequestReply, | 127 IPC_MESSAGE_HANDLER(PluginMsg_HandleURLRequestReply, |
139 OnHandleURLRequestReply) | 128 OnHandleURLRequestReply) |
140 IPC_MESSAGE_HANDLER(PluginMsg_HTTPRangeRequestReply, | 129 IPC_MESSAGE_HANDLER(PluginMsg_HTTPRangeRequestReply, |
141 OnHTTPRangeRequestReply) | 130 OnHTTPRangeRequestReply) |
142 IPC_MESSAGE_HANDLER(PluginMsg_CreateCommandBuffer, | |
143 OnCreateCommandBuffer) | |
144 IPC_MESSAGE_HANDLER(PluginMsg_DestroyCommandBuffer, | |
145 OnDestroyCommandBuffer) | |
146 #if defined(OS_MACOSX) | |
147 IPC_MESSAGE_HANDLER(PluginMsg_SetFakeAcceleratedSurfaceWindowHandle, | |
148 OnSetFakeAcceleratedSurfaceWindowHandle) | |
149 #endif | |
150 IPC_MESSAGE_UNHANDLED(handled = false) | 131 IPC_MESSAGE_UNHANDLED(handled = false) |
151 IPC_END_MESSAGE_MAP() | 132 IPC_END_MESSAGE_MAP() |
152 | 133 |
153 if (!in_destructor_) | 134 if (!in_destructor_) |
154 Release(); | 135 Release(); |
155 | 136 |
156 DCHECK(handled); | 137 DCHECK(handled); |
157 return handled; | 138 return handled; |
158 } | 139 } |
159 | 140 |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
403 } | 384 } |
404 | 385 |
405 void WebPluginDelegateStub::OnDidManualLoadFail() { | 386 void WebPluginDelegateStub::OnDidManualLoadFail() { |
406 delegate_->DidManualLoadFail(); | 387 delegate_->DidManualLoadFail(); |
407 } | 388 } |
408 | 389 |
409 void WebPluginDelegateStub::OnInstallMissingPlugin() { | 390 void WebPluginDelegateStub::OnInstallMissingPlugin() { |
410 delegate_->InstallMissingPlugin(); | 391 delegate_->InstallMissingPlugin(); |
411 } | 392 } |
412 | 393 |
413 void WebPluginDelegateStub::OnCreateCommandBuffer(int* route_id) { | |
414 *route_id = 0; | |
415 #if defined(ENABLE_GPU) | |
416 // Fail to create the command buffer if some GL implementation cannot be | |
417 // initialized. | |
418 if (!gfx::GLContext::InitializeOneOff()) | |
419 return; | |
420 | |
421 command_buffer_stub_.reset(new CommandBufferStub( | |
422 channel_, | |
423 instance_id_, | |
424 delegate_->windowed_handle())); | |
425 | |
426 *route_id = command_buffer_stub_->route_id(); | |
427 #endif // ENABLE_GPU | |
428 } | |
429 | |
430 void WebPluginDelegateStub::OnDestroyCommandBuffer() { | |
431 #if defined(ENABLE_GPU) | |
432 command_buffer_stub_.reset(); | |
433 #endif | |
434 } | |
435 | |
436 void WebPluginDelegateStub::CreateSharedBuffer( | 394 void WebPluginDelegateStub::CreateSharedBuffer( |
437 uint32 size, | 395 uint32 size, |
438 base::SharedMemory* shared_buf, | 396 base::SharedMemory* shared_buf, |
439 base::SharedMemoryHandle* remote_handle) { | 397 base::SharedMemoryHandle* remote_handle) { |
440 if (!shared_buf->CreateAndMapAnonymous(size)) { | 398 if (!shared_buf->CreateAndMapAnonymous(size)) { |
441 NOTREACHED(); | 399 NOTREACHED(); |
442 shared_buf->Close(); | 400 shared_buf->Close(); |
443 return; | 401 return; |
444 } | 402 } |
445 | 403 |
(...skipping 21 matching lines...) Expand all Loading... |
467 webplugin_->OnResourceCreated(resource_id, resource_client); | 425 webplugin_->OnResourceCreated(resource_id, resource_client); |
468 } | 426 } |
469 | 427 |
470 void WebPluginDelegateStub::OnHTTPRangeRequestReply( | 428 void WebPluginDelegateStub::OnHTTPRangeRequestReply( |
471 unsigned long resource_id, int range_request_id) { | 429 unsigned long resource_id, int range_request_id) { |
472 WebPluginResourceClient* resource_client = | 430 WebPluginResourceClient* resource_client = |
473 delegate_->CreateSeekableResourceClient(resource_id, range_request_id); | 431 delegate_->CreateSeekableResourceClient(resource_id, range_request_id); |
474 webplugin_->OnResourceCreated(resource_id, resource_client); | 432 webplugin_->OnResourceCreated(resource_id, resource_client); |
475 } | 433 } |
476 | 434 |
477 #if defined(OS_MACOSX) | |
478 void WebPluginDelegateStub::OnSetFakeAcceleratedSurfaceWindowHandle( | |
479 gfx::PluginWindowHandle window) { | |
480 delegate_->set_windowed_handle(window); | |
481 } | |
482 #endif | |
483 | |
OLD | NEW |