OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/renderer/npapi/webplugin_delegate_proxy.h" | 5 #include "content/renderer/npapi/webplugin_delegate_proxy.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 // deleting itself after its callback has been called. | 95 // deleting itself after its callback has been called. |
96 class ResourceClientProxy : public WebPluginResourceClient { | 96 class ResourceClientProxy : public WebPluginResourceClient { |
97 public: | 97 public: |
98 ResourceClientProxy(PluginChannelHost* channel, int instance_id) | 98 ResourceClientProxy(PluginChannelHost* channel, int instance_id) |
99 : channel_(channel), instance_id_(instance_id), resource_id_(0), | 99 : channel_(channel), instance_id_(instance_id), resource_id_(0), |
100 multibyte_response_expected_(false) { | 100 multibyte_response_expected_(false) { |
101 } | 101 } |
102 | 102 |
103 ~ResourceClientProxy() override {} | 103 ~ResourceClientProxy() override {} |
104 | 104 |
105 void Initialize(unsigned long resource_id, const GURL& url, int notify_id) { | 105 void Initialize(unsigned long resource_id, const GURL& url) { |
106 resource_id_ = resource_id; | 106 resource_id_ = resource_id; |
107 channel_->Send(new PluginMsg_HandleURLRequestReply( | 107 channel_->Send(new PluginMsg_HandleURLRequestReply( |
108 instance_id_, resource_id, url, notify_id)); | 108 instance_id_, resource_id, url)); |
109 } | 109 } |
110 | 110 |
111 void InitializeForSeekableStream(unsigned long resource_id, | 111 void InitializeForSeekableStream(unsigned long resource_id, |
112 int range_request_id) { | 112 int range_request_id) { |
113 resource_id_ = resource_id; | 113 resource_id_ = resource_id; |
114 multibyte_response_expected_ = true; | 114 multibyte_response_expected_ = true; |
115 channel_->Send(new PluginMsg_HTTPRangeRequestReply( | 115 channel_->Send(new PluginMsg_HTTPRangeRequestReply( |
116 instance_id_, resource_id, range_request_id)); | 116 instance_id_, resource_id, range_request_id)); |
117 } | 117 } |
118 | 118 |
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
381 DLOG(WARNING) << "dropping message because channel host is null"; | 381 DLOG(WARNING) << "dropping message because channel host is null"; |
382 delete msg; | 382 delete msg; |
383 return false; | 383 return false; |
384 } | 384 } |
385 | 385 |
386 return channel_host_->Send(msg); | 386 return channel_host_->Send(msg); |
387 } | 387 } |
388 | 388 |
389 void WebPluginDelegateProxy::SendJavaScriptStream(const GURL& url, | 389 void WebPluginDelegateProxy::SendJavaScriptStream(const GURL& url, |
390 const std::string& result, | 390 const std::string& result, |
391 bool success, | 391 bool success) { |
392 int notify_id) { | 392 Send(new PluginMsg_SendJavaScriptStream(instance_id_, url, result, success)); |
393 Send(new PluginMsg_SendJavaScriptStream( | |
394 instance_id_, url, result, success, notify_id)); | |
395 } | 393 } |
396 | 394 |
397 void WebPluginDelegateProxy::DidReceiveManualResponse( | 395 void WebPluginDelegateProxy::DidReceiveManualResponse( |
398 const GURL& url, const std::string& mime_type, | 396 const GURL& url, const std::string& mime_type, |
399 const std::string& headers, uint32 expected_length, | 397 const std::string& headers, uint32 expected_length, |
400 uint32 last_modified) { | 398 uint32 last_modified) { |
401 PluginMsg_DidReceiveResponseParams params; | 399 PluginMsg_DidReceiveResponseParams params; |
402 params.id = 0; | 400 params.id = 0; |
403 params.mime_type = mime_type; | 401 params.mime_type = mime_type; |
404 params.headers = headers; | 402 params.headers = headers; |
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
734 // Return a dummy NPP for WebKit to use to identify this plugin. | 732 // Return a dummy NPP for WebKit to use to identify this plugin. |
735 return npp_.get(); | 733 return npp_.get(); |
736 } | 734 } |
737 | 735 |
738 bool WebPluginDelegateProxy::GetFormValue(base::string16* value) { | 736 bool WebPluginDelegateProxy::GetFormValue(base::string16* value) { |
739 bool success = false; | 737 bool success = false; |
740 Send(new PluginMsg_GetFormValue(instance_id_, value, &success)); | 738 Send(new PluginMsg_GetFormValue(instance_id_, value, &success)); |
741 return success; | 739 return success; |
742 } | 740 } |
743 | 741 |
744 void WebPluginDelegateProxy::DidFinishLoadWithReason( | |
745 const GURL& url, NPReason reason, int notify_id) { | |
746 Send(new PluginMsg_DidFinishLoadWithReason( | |
747 instance_id_, url, reason, notify_id)); | |
748 } | |
749 | |
750 void WebPluginDelegateProxy::SetFocus(bool focused) { | 742 void WebPluginDelegateProxy::SetFocus(bool focused) { |
751 Send(new PluginMsg_SetFocus(instance_id_, focused)); | 743 Send(new PluginMsg_SetFocus(instance_id_, focused)); |
752 #if defined(OS_WIN) | 744 #if defined(OS_WIN) |
753 if (render_view_) | 745 if (render_view_) |
754 render_view_->PluginFocusChanged(focused, instance_id_); | 746 render_view_->PluginFocusChanged(focused, instance_id_); |
755 #endif | 747 #endif |
756 } | 748 } |
757 | 749 |
758 bool WebPluginDelegateProxy::HandleInputEvent( | 750 bool WebPluginDelegateProxy::HandleInputEvent( |
759 const WebInputEvent& event, | 751 const WebInputEvent& event, |
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1070 const char* data = NULL; | 1062 const char* data = NULL; |
1071 if (params.buffer.size()) | 1063 if (params.buffer.size()) |
1072 data = ¶ms.buffer[0]; | 1064 data = ¶ms.buffer[0]; |
1073 | 1065 |
1074 const char* target = NULL; | 1066 const char* target = NULL; |
1075 if (params.target.length()) | 1067 if (params.target.length()) |
1076 target = params.target.c_str(); | 1068 target = params.target.c_str(); |
1077 | 1069 |
1078 plugin_->HandleURLRequest( | 1070 plugin_->HandleURLRequest( |
1079 params.url.c_str(), params.method.c_str(), target, data, | 1071 params.url.c_str(), params.method.c_str(), target, data, |
1080 static_cast<unsigned int>(params.buffer.size()), params.notify_id, | 1072 static_cast<unsigned int>(params.buffer.size()), |
1081 params.popups_allowed, params.notify_redirects); | 1073 params.popups_allowed, params.notify_redirects); |
1082 } | 1074 } |
1083 | 1075 |
1084 WebPluginResourceClient* WebPluginDelegateProxy::CreateResourceClient( | 1076 WebPluginResourceClient* WebPluginDelegateProxy::CreateResourceClient( |
1085 unsigned long resource_id, const GURL& url, int notify_id) { | 1077 unsigned long resource_id, const GURL& url) { |
1086 if (!channel_host_.get()) | 1078 if (!channel_host_.get()) |
1087 return NULL; | 1079 return NULL; |
1088 | 1080 |
1089 ResourceClientProxy* proxy = | 1081 ResourceClientProxy* proxy = |
1090 new ResourceClientProxy(channel_host_.get(), instance_id_); | 1082 new ResourceClientProxy(channel_host_.get(), instance_id_); |
1091 proxy->Initialize(resource_id, url, notify_id); | 1083 proxy->Initialize(resource_id, url); |
1092 return proxy; | 1084 return proxy; |
1093 } | 1085 } |
1094 | 1086 |
1095 WebPluginResourceClient* WebPluginDelegateProxy::CreateSeekableResourceClient( | 1087 WebPluginResourceClient* WebPluginDelegateProxy::CreateSeekableResourceClient( |
1096 unsigned long resource_id, int range_request_id) { | 1088 unsigned long resource_id, int range_request_id) { |
1097 if (!channel_host_.get()) | 1089 if (!channel_host_.get()) |
1098 return NULL; | 1090 return NULL; |
1099 | 1091 |
1100 ResourceClientProxy* proxy = | 1092 ResourceClientProxy* proxy = |
1101 new ResourceClientProxy(channel_host_.get(), instance_id_); | 1093 new ResourceClientProxy(channel_host_.get(), instance_id_); |
1102 proxy->InitializeForSeekableStream(resource_id, range_request_id); | 1094 proxy->InitializeForSeekableStream(resource_id, range_request_id); |
1103 return proxy; | 1095 return proxy; |
1104 } | 1096 } |
1105 | 1097 |
1106 void WebPluginDelegateProxy::FetchURL(unsigned long resource_id, | 1098 void WebPluginDelegateProxy::FetchURL(unsigned long resource_id, |
1107 int notify_id, | |
1108 const GURL& url, | 1099 const GURL& url, |
1109 const GURL& first_party_for_cookies, | 1100 const GURL& first_party_for_cookies, |
1110 const std::string& method, | 1101 const std::string& method, |
1111 const char* buf, | 1102 const char* buf, |
1112 unsigned int len, | 1103 unsigned int len, |
1113 const Referrer& referrer, | 1104 const Referrer& referrer, |
1114 bool notify_redirects, | 1105 bool notify_redirects, |
1115 bool is_plugin_src_load, | 1106 bool is_plugin_src_load, |
1116 int origin_pid, | 1107 int origin_pid, |
1117 int render_frame_id, | 1108 int render_frame_id, |
1118 int render_view_id) { | 1109 int render_view_id) { |
1119 PluginMsg_FetchURL_Params params; | 1110 PluginMsg_FetchURL_Params params; |
1120 params.resource_id = resource_id; | 1111 params.resource_id = resource_id; |
1121 params.notify_id = notify_id; | |
1122 params.url = url; | 1112 params.url = url; |
1123 params.first_party_for_cookies = first_party_for_cookies; | 1113 params.first_party_for_cookies = first_party_for_cookies; |
1124 params.method = method; | 1114 params.method = method; |
1125 if (len) { | 1115 if (len) { |
1126 params.post_data.resize(len); | 1116 params.post_data.resize(len); |
1127 memcpy(¶ms.post_data.front(), buf, len); | 1117 memcpy(¶ms.post_data.front(), buf, len); |
1128 } | 1118 } |
1129 params.referrer = referrer.url; | 1119 params.referrer = referrer.url; |
1130 params.referrer_policy = referrer.policy; | 1120 params.referrer_policy = referrer.policy; |
1131 params.notify_redirect = notify_redirects; | 1121 params.notify_redirect = notify_redirects; |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1227 | 1217 |
1228 plugin_->URLRedirectResponse(allow, resource_id); | 1218 plugin_->URLRedirectResponse(allow, resource_id); |
1229 } | 1219 } |
1230 | 1220 |
1231 void WebPluginDelegateProxy::OnCheckIfRunInsecureContent(const GURL& url, | 1221 void WebPluginDelegateProxy::OnCheckIfRunInsecureContent(const GURL& url, |
1232 bool* result) { | 1222 bool* result) { |
1233 *result = plugin_->CheckIfRunInsecureContent(url); | 1223 *result = plugin_->CheckIfRunInsecureContent(url); |
1234 } | 1224 } |
1235 | 1225 |
1236 } // namespace content | 1226 } // namespace content |
OLD | NEW |