OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/webplugin_delegate_proxy.h" | 5 #include "chrome/renderer/webplugin_delegate_proxy.h" |
6 | 6 |
7 #include "build/build_config.h" | 7 #include <algorithm> |
8 | |
9 #if defined(OS_WIN) | |
10 #include <atlbase.h> | |
11 #endif | |
12 | 8 |
13 #include "app/gfx/canvas.h" | 9 #include "app/gfx/canvas.h" |
14 #include "app/l10n_util.h" | 10 #include "app/l10n_util.h" |
15 #include "app/resource_bundle.h" | 11 #include "app/resource_bundle.h" |
| 12 #include "base/basictypes.h" |
16 #include "base/file_util.h" | 13 #include "base/file_util.h" |
17 #include "base/logging.h" | 14 #include "base/logging.h" |
18 #include "base/ref_counted.h" | 15 #include "base/ref_counted.h" |
19 #include "base/string_util.h" | 16 #include "base/string_util.h" |
20 #include "base/gfx/blit.h" | 17 #include "base/gfx/blit.h" |
21 #include "base/gfx/size.h" | 18 #include "base/gfx/size.h" |
22 #include "base/gfx/native_widget_types.h" | 19 #include "base/gfx/native_widget_types.h" |
23 #include "chrome/common/child_process_logging.h" | 20 #include "chrome/common/child_process_logging.h" |
24 #include "chrome/common/plugin_messages.h" | 21 #include "chrome/common/plugin_messages.h" |
25 #include "chrome/common/render_messages.h" | 22 #include "chrome/common/render_messages.h" |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 params.last_modified = last_modified; | 107 params.last_modified = last_modified; |
111 params.request_is_seekable = request_is_seekable; | 108 params.request_is_seekable = request_is_seekable; |
112 // Grab a reference on the underlying channel so it does not get | 109 // Grab a reference on the underlying channel so it does not get |
113 // deleted from under us. | 110 // deleted from under us. |
114 scoped_refptr<PluginChannelHost> channel_ref(channel_); | 111 scoped_refptr<PluginChannelHost> channel_ref(channel_); |
115 channel_->Send(new PluginMsg_DidReceiveResponse(instance_id_, params)); | 112 channel_->Send(new PluginMsg_DidReceiveResponse(instance_id_, params)); |
116 } | 113 } |
117 | 114 |
118 void DidReceiveData(const char* buffer, int length, int data_offset) { | 115 void DidReceiveData(const char* buffer, int length, int data_offset) { |
119 DCHECK(channel_ != NULL); | 116 DCHECK(channel_ != NULL); |
120 DCHECK(length > 0); | 117 DCHECK_GT(length, 0); |
121 std::vector<char> data; | 118 std::vector<char> data; |
122 data.resize(static_cast<size_t>(length)); | 119 data.resize(static_cast<size_t>(length)); |
123 memcpy(&data.front(), buffer, length); | 120 memcpy(&data.front(), buffer, length); |
124 // Grab a reference on the underlying channel so it does not get | 121 // Grab a reference on the underlying channel so it does not get |
125 // deleted from under us. | 122 // deleted from under us. |
126 scoped_refptr<PluginChannelHost> channel_ref(channel_); | 123 scoped_refptr<PluginChannelHost> channel_ref(channel_); |
127 channel_->Send(new PluginMsg_DidReceiveData(instance_id_, resource_id_, | 124 channel_->Send(new PluginMsg_DidReceiveData(instance_id_, resource_id_, |
128 data, data_offset)); | 125 data, data_offset)); |
129 } | 126 } |
130 | 127 |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 // association on POSIX, and if we ask for a new connection before it is | 206 // association on POSIX, and if we ask for a new connection before it is |
210 // released, the plugin will give us a new FD, and we'll assert when trying | 207 // released, the plugin will give us a new FD, and we'll assert when trying |
211 // to associate it with the channel name. | 208 // to associate it with the channel name. |
212 channel_host_ = NULL; | 209 channel_host_ = NULL; |
213 } | 210 } |
214 | 211 |
215 MessageLoop::current()->DeleteSoon(FROM_HERE, this); | 212 MessageLoop::current()->DeleteSoon(FROM_HERE, this); |
216 } | 213 } |
217 | 214 |
218 bool WebPluginDelegateProxy::Initialize(const GURL& url, | 215 bool WebPluginDelegateProxy::Initialize(const GURL& url, |
219 const std::vector<std::string>& arg_name
s, | 216 const std::vector<std::string>& arg_names, |
220 const std::vector<std::string>& arg_valu
es, | 217 const std::vector<std::string>& arg_values, |
221 webkit_glue::WebPlugin* plugin, | 218 webkit_glue::WebPlugin* plugin, |
222 bool load_manually) { | 219 bool load_manually) { |
223 IPC::ChannelHandle channel_handle; | 220 IPC::ChannelHandle channel_handle; |
224 WebPluginInfo info; | 221 WebPluginInfo info; |
225 if (!RenderThread::current()->Send(new ViewHostMsg_OpenChannelToPlugin( | 222 if (!RenderThread::current()->Send(new ViewHostMsg_OpenChannelToPlugin( |
226 url, mime_type_, webkit_glue::GetWebKitLocale(), | 223 url, mime_type_, webkit_glue::GetWebKitLocale(), |
227 &channel_handle, &info))) { | 224 &channel_handle, &info))) { |
228 return false; | 225 return false; |
229 } | 226 } |
230 | 227 |
231 #if defined(OS_POSIX) | 228 #if defined(OS_POSIX) |
232 if (channel_handle.name.empty()) { | 229 if (channel_handle.name.empty()) { |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 params.id = 0; | 313 params.id = 0; |
317 params.mime_type = mime_type; | 314 params.mime_type = mime_type; |
318 params.headers = headers; | 315 params.headers = headers; |
319 params.expected_length = expected_length; | 316 params.expected_length = expected_length; |
320 params.last_modified = last_modified; | 317 params.last_modified = last_modified; |
321 Send(new PluginMsg_DidReceiveManualResponse(instance_id_, url, params)); | 318 Send(new PluginMsg_DidReceiveManualResponse(instance_id_, url, params)); |
322 } | 319 } |
323 | 320 |
324 void WebPluginDelegateProxy::DidReceiveManualData(const char* buffer, | 321 void WebPluginDelegateProxy::DidReceiveManualData(const char* buffer, |
325 int length) { | 322 int length) { |
326 DCHECK(length > 0); | 323 DCHECK_GT(length, 0); |
327 std::vector<char> data; | 324 std::vector<char> data; |
328 data.resize(static_cast<size_t>(length)); | 325 data.resize(static_cast<size_t>(length)); |
329 memcpy(&data.front(), buffer, length); | 326 memcpy(&data.front(), buffer, length); |
330 Send(new PluginMsg_DidReceiveManualData(instance_id_, data)); | 327 Send(new PluginMsg_DidReceiveManualData(instance_id_, data)); |
331 } | 328 } |
332 | 329 |
333 void WebPluginDelegateProxy::DidFinishManualLoading() { | 330 void WebPluginDelegateProxy::DidFinishManualLoading() { |
334 Send(new PluginMsg_DidFinishManualLoading(instance_id_)); | 331 Send(new PluginMsg_DidFinishManualLoading(instance_id_)); |
335 } | 332 } |
336 | 333 |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
429 if (bitmaps_changed) | 426 if (bitmaps_changed) |
430 #endif | 427 #endif |
431 { | 428 { |
432 if (transport_store_.get()) { | 429 if (transport_store_.get()) { |
433 param.windowless_buffer = transport_store_->handle(); | 430 param.windowless_buffer = transport_store_->handle(); |
434 } else if (background_store_.get()) { | 431 } else if (background_store_.get()) { |
435 param.background_buffer = background_store_->handle(); | 432 param.background_buffer = background_store_->handle(); |
436 } | 433 } |
437 } | 434 } |
438 | 435 |
439 IPC::Message* msg; | 436 IPC::Message* msg; |
440 #if defined (OS_WIN) | 437 #if defined (OS_WIN) |
441 std::wstring filename = StringToLowerASCII(info_.path.BaseName().value()); | 438 std::wstring filename = StringToLowerASCII(info_.path.BaseName().value()); |
442 if (info_.name.find(L"Windows Media Player") != std::wstring::npos) { | 439 if (info_.name.find(L"Windows Media Player") != std::wstring::npos) { |
443 // Need to update geometry synchronously with WMP, otherwise if a site | 440 // Need to update geometry synchronously with WMP, otherwise if a site |
444 // scripts the plugin to start playing while it's in the middle of handling | 441 // scripts the plugin to start playing while it's in the middle of handling |
445 // an update geometry message, videos don't play. See urls in bug 20260. | 442 // an update geometry message, videos don't play. See urls in bug 20260. |
446 msg = new PluginMsg_UpdateGeometrySync(instance_id_, param); | 443 msg = new PluginMsg_UpdateGeometrySync(instance_id_, param); |
447 } else | 444 } else |
448 #endif | 445 #endif |
449 { | 446 { |
(...skipping 617 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1067 intptr_t existing_stream, bool notify_needed, intptr_t notify_data) { | 1064 intptr_t existing_stream, bool notify_needed, intptr_t notify_data) { |
1068 plugin_->InitiateHTTPRangeRequest(url.c_str(), range_info.c_str(), | 1065 plugin_->InitiateHTTPRangeRequest(url.c_str(), range_info.c_str(), |
1069 existing_stream, notify_needed, | 1066 existing_stream, notify_needed, |
1070 notify_data); | 1067 notify_data); |
1071 } | 1068 } |
1072 | 1069 |
1073 void WebPluginDelegateProxy::OnDeferResourceLoading(int resource_id, | 1070 void WebPluginDelegateProxy::OnDeferResourceLoading(int resource_id, |
1074 bool defer) { | 1071 bool defer) { |
1075 plugin_->SetDeferResourceLoading(resource_id, defer); | 1072 plugin_->SetDeferResourceLoading(resource_id, defer); |
1076 } | 1073 } |
OLD | NEW |