| 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 <atlbase.h> | 7 #include <atlbase.h> |
| 8 | 8 |
| 9 #include "generated_resources.h" | 9 #include "generated_resources.h" |
| 10 | 10 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 public: | 37 public: |
| 38 ResourceClientProxy(PluginChannelHost* channel, int instance_id) | 38 ResourceClientProxy(PluginChannelHost* channel, int instance_id) |
| 39 : channel_(channel), instance_id_(instance_id), resource_id_(0), | 39 : channel_(channel), instance_id_(instance_id), resource_id_(0), |
| 40 notify_needed_(false), notify_data_(NULL) { | 40 notify_needed_(false), notify_data_(NULL) { |
| 41 } | 41 } |
| 42 | 42 |
| 43 ~ResourceClientProxy() { | 43 ~ResourceClientProxy() { |
| 44 } | 44 } |
| 45 | 45 |
| 46 void Initialize(int resource_id, const std::string &url, bool notify_needed, | 46 void Initialize(int resource_id, const std::string &url, bool notify_needed, |
| 47 void *notify_data) { | 47 void *notify_data, void* existing_stream) { |
| 48 resource_id_ = resource_id; | 48 resource_id_ = resource_id; |
| 49 url_ = url; | 49 url_ = url; |
| 50 notify_needed_ = notify_needed; | 50 notify_needed_ = notify_needed; |
| 51 notify_data_ = notify_data; | 51 notify_data_ = notify_data; |
| 52 | 52 |
| 53 PluginMsg_URLRequestReply_Params params; | 53 PluginMsg_URLRequestReply_Params params; |
| 54 params.resource_id = resource_id; | 54 params.resource_id = resource_id; |
| 55 params.url = url_; | 55 params.url = url_; |
| 56 params.notify_needed = notify_needed_; | 56 params.notify_needed = notify_needed_; |
| 57 params.notify_data = notify_data_; | 57 params.notify_data = notify_data_; |
| 58 params.stream = existing_stream; |
| 58 | 59 |
| 59 channel_->Send(new PluginMsg_HandleURLRequestReply(instance_id_, params)); | 60 channel_->Send(new PluginMsg_HandleURLRequestReply(instance_id_, params)); |
| 60 } | 61 } |
| 61 | 62 |
| 62 // PluginResourceClient implementation: | 63 // PluginResourceClient implementation: |
| 63 void WillSendRequest(const GURL& url) { | 64 void WillSendRequest(const GURL& url) { |
| 64 DCHECK(channel_ != NULL); | 65 DCHECK(channel_ != NULL); |
| 65 channel_->Send(new PluginMsg_WillSendRequest(instance_id_, resource_id_, | 66 channel_->Send(new PluginMsg_WillSendRequest(instance_id_, resource_id_, |
| 66 url)); | 67 url)); |
| 67 } | 68 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 78 params.headers = headers; | 79 params.headers = headers; |
| 79 params.expected_length = expected_length; | 80 params.expected_length = expected_length; |
| 80 params.last_modified = last_modified; | 81 params.last_modified = last_modified; |
| 81 // Grab a reference on the underlying channel so it does not get | 82 // Grab a reference on the underlying channel so it does not get |
| 82 // deleted from under us. | 83 // deleted from under us. |
| 83 scoped_refptr<PluginChannelHost> channel_ref(channel_); | 84 scoped_refptr<PluginChannelHost> channel_ref(channel_); |
| 84 channel_->Send(new PluginMsg_DidReceiveResponse(instance_id_, params, | 85 channel_->Send(new PluginMsg_DidReceiveResponse(instance_id_, params, |
| 85 cancel)); | 86 cancel)); |
| 86 } | 87 } |
| 87 | 88 |
| 88 void DidReceiveData(const char* buffer, int length) { | 89 void DidReceiveData(const char* buffer, int length, int data_offset) { |
| 89 DCHECK(channel_ != NULL); | 90 DCHECK(channel_ != NULL); |
| 90 DCHECK(length > 0); | 91 DCHECK(length > 0); |
| 91 std::vector<char> data; | 92 std::vector<char> data; |
| 92 data.resize(static_cast<size_t>(length)); | 93 data.resize(static_cast<size_t>(length)); |
| 93 memcpy(&data.front(), buffer, length); | 94 memcpy(&data.front(), buffer, length); |
| 94 // Grab a reference on the underlying channel so it does not get | 95 // Grab a reference on the underlying channel so it does not get |
| 95 // deleted from under us. | 96 // deleted from under us. |
| 96 scoped_refptr<PluginChannelHost> channel_ref(channel_); | 97 scoped_refptr<PluginChannelHost> channel_ref(channel_); |
| 97 channel_->Send(new PluginMsg_DidReceiveData(instance_id_, resource_id_, | 98 channel_->Send(new PluginMsg_DidReceiveData(instance_id_, resource_id_, |
| 98 data)); | 99 data, data_offset)); |
| 99 } | 100 } |
| 100 | 101 |
| 101 void DidFinishLoading() { | 102 void DidFinishLoading() { |
| 102 DCHECK(channel_ != NULL); | 103 DCHECK(channel_ != NULL); |
| 103 channel_->Send(new PluginMsg_DidFinishLoading(instance_id_, resource_id_)); | 104 channel_->Send(new PluginMsg_DidFinishLoading(instance_id_, resource_id_)); |
| 104 channel_ = NULL; | 105 channel_ = NULL; |
| 105 MessageLoop::current()->DeleteSoon(FROM_HERE, this); | 106 MessageLoop::current()->DeleteSoon(FROM_HERE, this); |
| 106 } | 107 } |
| 107 | 108 |
| 108 void DidFail() { | 109 void DidFail() { |
| 109 DCHECK(channel_ != NULL); | 110 DCHECK(channel_ != NULL); |
| 110 channel_->Send(new PluginMsg_DidFail(instance_id_, resource_id_)); | 111 channel_->Send(new PluginMsg_DidFail(instance_id_, resource_id_)); |
| 111 channel_ = NULL; | 112 channel_ = NULL; |
| 112 MessageLoop::current()->DeleteSoon(FROM_HERE, this); | 113 MessageLoop::current()->DeleteSoon(FROM_HERE, this); |
| 113 } | 114 } |
| 114 | 115 |
| 115 private: | 116 private: |
| 116 int resource_id_; | 117 int resource_id_; |
| 117 int instance_id_; | 118 int instance_id_; |
| 118 scoped_refptr<PluginChannelHost> channel_; | 119 scoped_refptr<PluginChannelHost> channel_; |
| 119 std::string url_; | 120 std::string url_; |
| 120 bool notify_needed_; | 121 bool notify_needed_; |
| 121 void* notify_data_; | 122 void* notify_data_; |
| 122 }; | 123 }; |
| 123 | 124 |
| 124 WebPluginDelegateProxy* WebPluginDelegateProxy::Create( | 125 WebPluginDelegateProxy* WebPluginDelegateProxy::Create( |
| 125 const GURL& url, | 126 const GURL& url, |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 OnGetPluginElement) | 310 OnGetPluginElement) |
| 310 IPC_MESSAGE_HANDLER(PluginHostMsg_SetCookie, OnSetCookie) | 311 IPC_MESSAGE_HANDLER(PluginHostMsg_SetCookie, OnSetCookie) |
| 311 IPC_MESSAGE_HANDLER(PluginHostMsg_GetCookies, OnGetCookies) | 312 IPC_MESSAGE_HANDLER(PluginHostMsg_GetCookies, OnGetCookies) |
| 312 IPC_MESSAGE_HANDLER(PluginHostMsg_ShowModalHTMLDialog, | 313 IPC_MESSAGE_HANDLER(PluginHostMsg_ShowModalHTMLDialog, |
| 313 OnShowModalHTMLDialog) | 314 OnShowModalHTMLDialog) |
| 314 IPC_MESSAGE_HANDLER(PluginHostMsg_MissingPluginStatus, | 315 IPC_MESSAGE_HANDLER(PluginHostMsg_MissingPluginStatus, |
| 315 OnMissingPluginStatus) | 316 OnMissingPluginStatus) |
| 316 IPC_MESSAGE_HANDLER(PluginHostMsg_URLRequest, OnHandleURLRequest) | 317 IPC_MESSAGE_HANDLER(PluginHostMsg_URLRequest, OnHandleURLRequest) |
| 317 IPC_MESSAGE_HANDLER(PluginHostMsg_GetCPBrowsingContext, | 318 IPC_MESSAGE_HANDLER(PluginHostMsg_GetCPBrowsingContext, |
| 318 OnGetCPBrowsingContext) | 319 OnGetCPBrowsingContext) |
| 320 IPC_MESSAGE_HANDLER(PluginHostMsg_CancelDocumentLoad, OnCancelDocumentLoad) |
| 321 IPC_MESSAGE_HANDLER(PluginHostMsg_InitiateHTTPRangeRequest, |
| 322 OnInitiateHTTPRangeRequest) |
| 319 IPC_MESSAGE_UNHANDLED_ERROR() | 323 IPC_MESSAGE_UNHANDLED_ERROR() |
| 320 IPC_END_MESSAGE_MAP() | 324 IPC_END_MESSAGE_MAP() |
| 321 } | 325 } |
| 322 | 326 |
| 323 void WebPluginDelegateProxy::OnChannelError() { | 327 void WebPluginDelegateProxy::OnChannelError() { |
| 324 OnInvalidate(); | 328 OnInvalidate(); |
| 325 render_view_->PluginCrashed(plugin_path_); | 329 render_view_->PluginCrashed(plugin_path_); |
| 326 } | 330 } |
| 327 | 331 |
| 328 void WebPluginDelegateProxy::UpdateGeometry(const gfx::Rect& window_rect, | 332 void WebPluginDelegateProxy::UpdateGeometry(const gfx::Rect& window_rect, |
| (...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 648 plugin_->HandleURLRequest(params.method.c_str(), | 652 plugin_->HandleURLRequest(params.method.c_str(), |
| 649 params.is_javascript_url, target, | 653 params.is_javascript_url, target, |
| 650 static_cast<unsigned int>(params.buffer.size()), | 654 static_cast<unsigned int>(params.buffer.size()), |
| 651 data, params.is_file_data, params.notify, | 655 data, params.is_file_data, params.notify, |
| 652 params.url.c_str(), params.notify_data, | 656 params.url.c_str(), params.notify_data, |
| 653 params.popups_allowed); | 657 params.popups_allowed); |
| 654 } | 658 } |
| 655 | 659 |
| 656 WebPluginResourceClient* WebPluginDelegateProxy::CreateResourceClient( | 660 WebPluginResourceClient* WebPluginDelegateProxy::CreateResourceClient( |
| 657 int resource_id, const std::string &url, bool notify_needed, | 661 int resource_id, const std::string &url, bool notify_needed, |
| 658 void *notify_data) { | 662 void* notify_data, void* npstream) { |
| 659 ResourceClientProxy* proxy = new ResourceClientProxy(channel_host_, | 663 ResourceClientProxy* proxy = new ResourceClientProxy(channel_host_, |
| 660 instance_id_); | 664 instance_id_); |
| 661 proxy->Initialize(resource_id, url, notify_needed, notify_data); | 665 proxy->Initialize(resource_id, url, notify_needed, notify_data, npstream); |
| 662 return proxy; | 666 return proxy; |
| 663 } | 667 } |
| 664 | 668 |
| 665 void WebPluginDelegateProxy::URLRequestRouted(const std::string& url, | 669 void WebPluginDelegateProxy::URLRequestRouted(const std::string& url, |
| 666 bool notify_needed, | 670 bool notify_needed, |
| 667 void* notify_data) { | 671 void* notify_data) { |
| 668 Send(new PluginMsg_URLRequestRouted(instance_id_, url, notify_needed, | 672 Send(new PluginMsg_URLRequestRouted(instance_id_, url, notify_needed, |
| 669 notify_data)); | 673 notify_data)); |
| 670 } | 674 } |
| 671 | 675 |
| 676 void WebPluginDelegateProxy::OnCancelDocumentLoad() { |
| 677 plugin_->CancelDocumentLoad(); |
| 678 } |
| 679 |
| 680 void WebPluginDelegateProxy::OnInitiateHTTPRangeRequest( |
| 681 const std::string& url, const std::string& range_info, |
| 682 HANDLE existing_stream, bool notify_needed, HANDLE notify_data) { |
| 683 plugin_->InitiateHTTPRangeRequest(url.c_str(), range_info.c_str(), |
| 684 existing_stream, notify_needed, |
| 685 notify_data); |
| 686 } |
| OLD | NEW |