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/webplugin_delegate_proxy.h" | 5 #include "content/renderer/webplugin_delegate_proxy.h" |
6 | 6 |
7 #if defined(TOOLKIT_GTK) | 7 #if defined(TOOLKIT_GTK) |
8 #include <gtk/gtk.h> | 8 #include <gtk/gtk.h> |
9 #elif defined(USE_X11) | 9 #elif defined(USE_X11) |
10 #include <cairo/cairo.h> | 10 #include <cairo/cairo.h> |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 | 99 |
100 // Proxy for WebPluginResourceClient. The object owns itself after creation, | 100 // Proxy for WebPluginResourceClient. The object owns itself after creation, |
101 // deleting itself after its callback has been called. | 101 // deleting itself after its callback has been called. |
102 class ResourceClientProxy : public webkit::npapi::WebPluginResourceClient { | 102 class ResourceClientProxy : public webkit::npapi::WebPluginResourceClient { |
103 public: | 103 public: |
104 ResourceClientProxy(PluginChannelHost* channel, int instance_id) | 104 ResourceClientProxy(PluginChannelHost* channel, int instance_id) |
105 : channel_(channel), instance_id_(instance_id), resource_id_(0), | 105 : channel_(channel), instance_id_(instance_id), resource_id_(0), |
106 multibyte_response_expected_(false) { | 106 multibyte_response_expected_(false) { |
107 } | 107 } |
108 | 108 |
109 ~ResourceClientProxy() { | 109 virtual ~ResourceClientProxy() { |
110 } | 110 } |
111 | 111 |
112 void Initialize(unsigned long resource_id, const GURL& url, int notify_id) { | 112 void Initialize(unsigned long resource_id, const GURL& url, int notify_id) { |
113 resource_id_ = resource_id; | 113 resource_id_ = resource_id; |
114 channel_->Send(new PluginMsg_HandleURLRequestReply( | 114 channel_->Send(new PluginMsg_HandleURLRequestReply( |
115 instance_id_, resource_id, url, notify_id)); | 115 instance_id_, resource_id, url, notify_id)); |
116 } | 116 } |
117 | 117 |
118 void InitializeForSeekableStream(unsigned long resource_id, | 118 void InitializeForSeekableStream(unsigned long resource_id, |
119 int range_request_id) { | 119 int range_request_id) { |
120 resource_id_ = resource_id; | 120 resource_id_ = resource_id; |
121 multibyte_response_expected_ = true; | 121 multibyte_response_expected_ = true; |
122 channel_->Send(new PluginMsg_HTTPRangeRequestReply( | 122 channel_->Send(new PluginMsg_HTTPRangeRequestReply( |
123 instance_id_, resource_id, range_request_id)); | 123 instance_id_, resource_id, range_request_id)); |
124 } | 124 } |
125 | 125 |
126 // PluginResourceClient implementation: | 126 // PluginResourceClient implementation: |
127 void WillSendRequest(const GURL& url, int http_status_code) { | 127 virtual void WillSendRequest(const GURL& url, int http_status_code) OVERRIDE { |
128 DCHECK(channel_ != NULL); | 128 DCHECK(channel_ != NULL); |
129 channel_->Send(new PluginMsg_WillSendRequest(instance_id_, resource_id_, | 129 channel_->Send(new PluginMsg_WillSendRequest(instance_id_, resource_id_, |
130 url, http_status_code)); | 130 url, http_status_code)); |
131 } | 131 } |
132 | 132 |
133 void DidReceiveResponse(const std::string& mime_type, | 133 virtual void DidReceiveResponse(const std::string& mime_type, |
134 const std::string& headers, | 134 const std::string& headers, |
135 uint32 expected_length, | 135 uint32 expected_length, |
136 uint32 last_modified, | 136 uint32 last_modified, |
137 bool request_is_seekable) { | 137 bool request_is_seekable) OVERRIDE { |
138 DCHECK(channel_ != NULL); | 138 DCHECK(channel_ != NULL); |
139 PluginMsg_DidReceiveResponseParams params; | 139 PluginMsg_DidReceiveResponseParams params; |
140 params.id = resource_id_; | 140 params.id = resource_id_; |
141 params.mime_type = mime_type; | 141 params.mime_type = mime_type; |
142 params.headers = headers; | 142 params.headers = headers; |
143 params.expected_length = expected_length; | 143 params.expected_length = expected_length; |
144 params.last_modified = last_modified; | 144 params.last_modified = last_modified; |
145 params.request_is_seekable = request_is_seekable; | 145 params.request_is_seekable = request_is_seekable; |
146 // Grab a reference on the underlying channel so it does not get | 146 // Grab a reference on the underlying channel so it does not get |
147 // deleted from under us. | 147 // deleted from under us. |
148 scoped_refptr<PluginChannelHost> channel_ref(channel_); | 148 scoped_refptr<PluginChannelHost> channel_ref(channel_); |
149 channel_->Send(new PluginMsg_DidReceiveResponse(instance_id_, params)); | 149 channel_->Send(new PluginMsg_DidReceiveResponse(instance_id_, params)); |
150 } | 150 } |
151 | 151 |
152 void DidReceiveData(const char* buffer, int length, int data_offset) { | 152 virtual void DidReceiveData(const char* buffer, |
| 153 int length, |
| 154 int data_offset) OVERRIDE { |
153 DCHECK(channel_ != NULL); | 155 DCHECK(channel_ != NULL); |
154 DCHECK_GT(length, 0); | 156 DCHECK_GT(length, 0); |
155 std::vector<char> data; | 157 std::vector<char> data; |
156 data.resize(static_cast<size_t>(length)); | 158 data.resize(static_cast<size_t>(length)); |
157 memcpy(&data.front(), buffer, length); | 159 memcpy(&data.front(), buffer, length); |
158 // Grab a reference on the underlying channel so it does not get | 160 // Grab a reference on the underlying channel so it does not get |
159 // deleted from under us. | 161 // deleted from under us. |
160 scoped_refptr<PluginChannelHost> channel_ref(channel_); | 162 scoped_refptr<PluginChannelHost> channel_ref(channel_); |
161 channel_->Send(new PluginMsg_DidReceiveData(instance_id_, resource_id_, | 163 channel_->Send(new PluginMsg_DidReceiveData(instance_id_, resource_id_, |
162 data, data_offset)); | 164 data, data_offset)); |
163 } | 165 } |
164 | 166 |
165 void DidFinishLoading() { | 167 virtual void DidFinishLoading() OVERRIDE { |
166 DCHECK(channel_ != NULL); | 168 DCHECK(channel_ != NULL); |
167 channel_->Send(new PluginMsg_DidFinishLoading(instance_id_, resource_id_)); | 169 channel_->Send(new PluginMsg_DidFinishLoading(instance_id_, resource_id_)); |
168 channel_ = NULL; | 170 channel_ = NULL; |
169 MessageLoop::current()->DeleteSoon(FROM_HERE, this); | 171 MessageLoop::current()->DeleteSoon(FROM_HERE, this); |
170 } | 172 } |
171 | 173 |
172 void DidFail() { | 174 virtual void DidFail() OVERRIDE { |
173 DCHECK(channel_ != NULL); | 175 DCHECK(channel_ != NULL); |
174 channel_->Send(new PluginMsg_DidFail(instance_id_, resource_id_)); | 176 channel_->Send(new PluginMsg_DidFail(instance_id_, resource_id_)); |
175 channel_ = NULL; | 177 channel_ = NULL; |
176 MessageLoop::current()->DeleteSoon(FROM_HERE, this); | 178 MessageLoop::current()->DeleteSoon(FROM_HERE, this); |
177 } | 179 } |
178 | 180 |
179 bool IsMultiByteResponseExpected() { | 181 virtual bool IsMultiByteResponseExpected() OVERRIDE { |
180 return multibyte_response_expected_; | 182 return multibyte_response_expected_; |
181 } | 183 } |
182 | 184 |
183 int ResourceId() { | 185 virtual int ResourceId() OVERRIDE { |
184 return resource_id_; | 186 return resource_id_; |
185 } | 187 } |
186 | 188 |
187 private: | 189 private: |
188 scoped_refptr<PluginChannelHost> channel_; | 190 scoped_refptr<PluginChannelHost> channel_; |
189 int instance_id_; | 191 int instance_id_; |
190 unsigned long resource_id_; | 192 unsigned long resource_id_; |
191 // Set to true if the response expected is a multibyte response. | 193 // Set to true if the response expected is a multibyte response. |
192 // For e.g. response for a HTTP byte range request. | 194 // For e.g. response for a HTTP byte range request. |
193 bool multibyte_response_expected_; | 195 bool multibyte_response_expected_; |
(...skipping 1108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1302 | 1304 |
1303 void WebPluginDelegateProxy::OnURLRedirectResponse(bool allow, | 1305 void WebPluginDelegateProxy::OnURLRedirectResponse(bool allow, |
1304 int resource_id) { | 1306 int resource_id) { |
1305 if (!plugin_) | 1307 if (!plugin_) |
1306 return; | 1308 return; |
1307 | 1309 |
1308 plugin_->URLRedirectResponse(allow, resource_id); | 1310 plugin_->URLRedirectResponse(allow, resource_id); |
1309 } | 1311 } |
1310 | 1312 |
1311 } // namespace content | 1313 } // namespace content |
OLD | NEW |