Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(154)

Side by Side Diff: content/child/npapi/plugin_url_fetcher.cc

Issue 398903002: Plumb redirect info out of net, through content, and into child processes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: darin comments Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « content/child/npapi/plugin_url_fetcher.h ('k') | content/child/resource_dispatcher.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/child/npapi/plugin_url_fetcher.h" 5 #include "content/child/npapi/plugin_url_fetcher.h"
6 6
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "content/child/child_thread.h" 8 #include "content/child/child_thread.h"
9 #include "content/child/multipart_response_delegate.h" 9 #include "content/child/multipart_response_delegate.h"
10 #include "content/child/npapi/plugin_host.h" 10 #include "content/child/npapi/plugin_host.h"
11 #include "content/child/npapi/plugin_instance.h" 11 #include "content/child/npapi/plugin_instance.h"
12 #include "content/child/npapi/plugin_stream_url.h" 12 #include "content/child/npapi/plugin_stream_url.h"
13 #include "content/child/npapi/webplugin.h" 13 #include "content/child/npapi/webplugin.h"
14 #include "content/child/npapi/webplugin_resource_client.h" 14 #include "content/child/npapi/webplugin_resource_client.h"
15 #include "content/child/plugin_messages.h" 15 #include "content/child/plugin_messages.h"
16 #include "content/child/request_extra_data.h" 16 #include "content/child/request_extra_data.h"
17 #include "content/child/request_info.h" 17 #include "content/child/request_info.h"
18 #include "content/child/resource_dispatcher.h" 18 #include "content/child/resource_dispatcher.h"
19 #include "content/child/web_url_loader_impl.h" 19 #include "content/child/web_url_loader_impl.h"
20 #include "content/common/resource_request_body.h" 20 #include "content/common/resource_request_body.h"
21 #include "content/common/service_worker/service_worker_types.h" 21 #include "content/common/service_worker/service_worker_types.h"
22 #include "content/public/common/resource_response_info.h" 22 #include "content/public/common/resource_response_info.h"
23 #include "net/base/load_flags.h" 23 #include "net/base/load_flags.h"
24 #include "net/base/net_errors.h" 24 #include "net/base/net_errors.h"
25 #include "net/http/http_response_headers.h" 25 #include "net/http/http_response_headers.h"
26 #include "net/url_request/url_request.h" 26 #include "net/url_request/redirect_info.h"
27 #include "third_party/WebKit/public/platform/WebURLLoaderClient.h" 27 #include "third_party/WebKit/public/platform/WebURLLoaderClient.h"
28 #include "third_party/WebKit/public/platform/WebURLResponse.h" 28 #include "third_party/WebKit/public/platform/WebURLResponse.h"
29 #include "webkit/child/resource_loader_bridge.h" 29 #include "webkit/child/resource_loader_bridge.h"
30 30
31 namespace content { 31 namespace content {
32 namespace { 32 namespace {
33 33
34 // This class handles individual multipart responses. It is instantiated when 34 // This class handles individual multipart responses. It is instantiated when
35 // we receive HTTP status code 206 in the HTTP response. This indicates 35 // we receive HTTP status code 206 in the HTTP response. This indicates
36 // that the response could have multiple parts each separated by a boundary 36 // that the response could have multiple parts each separated by a boundary
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 bool notify_redirects, 88 bool notify_redirects,
89 bool is_plugin_src_load, 89 bool is_plugin_src_load,
90 int origin_pid, 90 int origin_pid,
91 int render_frame_id, 91 int render_frame_id,
92 int render_view_id, 92 int render_view_id,
93 unsigned long resource_id, 93 unsigned long resource_id,
94 bool copy_stream_data) 94 bool copy_stream_data)
95 : plugin_stream_(plugin_stream), 95 : plugin_stream_(plugin_stream),
96 url_(url), 96 url_(url),
97 first_party_for_cookies_(first_party_for_cookies), 97 first_party_for_cookies_(first_party_for_cookies),
98 method_(method),
99 referrer_(referrer), 98 referrer_(referrer),
100 notify_redirects_(notify_redirects), 99 notify_redirects_(notify_redirects),
101 is_plugin_src_load_(is_plugin_src_load), 100 is_plugin_src_load_(is_plugin_src_load),
102 origin_pid_(origin_pid), 101 origin_pid_(origin_pid),
103 render_frame_id_(render_frame_id), 102 render_frame_id_(render_frame_id),
104 render_view_id_(render_view_id), 103 render_view_id_(render_view_id),
105 resource_id_(resource_id), 104 resource_id_(resource_id),
106 copy_stream_data_(copy_stream_data), 105 copy_stream_data_(copy_stream_data),
107 data_offset_(0), 106 data_offset_(0),
108 pending_failure_notification_(false) { 107 pending_failure_notification_(false) {
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 } else { 183 } else {
185 bridge_->Cancel(); 184 bridge_->Cancel();
186 plugin_stream_->DidFail(resource_id_); // That will delete |this|. 185 plugin_stream_->DidFail(resource_id_); // That will delete |this|.
187 } 186 }
188 } 187 }
189 188
190 void PluginURLFetcher::OnUploadProgress(uint64 position, uint64 size) { 189 void PluginURLFetcher::OnUploadProgress(uint64 position, uint64 size) {
191 } 190 }
192 191
193 bool PluginURLFetcher::OnReceivedRedirect( 192 bool PluginURLFetcher::OnReceivedRedirect(
194 const GURL& new_url, 193 const net::RedirectInfo& redirect_info,
195 const GURL& new_first_party_for_cookies,
196 const ResourceResponseInfo& info) { 194 const ResourceResponseInfo& info) {
197 if (!plugin_stream_) 195 if (!plugin_stream_)
198 return false; 196 return false;
199 197
200 // TODO(jam): THIS LOGIC IS COPIED FROM WebPluginImpl::willSendRequest until 198 // TODO(jam): THIS LOGIC IS COPIED FROM WebPluginImpl::willSendRequest until
201 // kDirectNPAPIRequests is the default and we can remove the old path there. 199 // kDirectNPAPIRequests is the default and we can remove the old path there.
202 200
203 // Currently this check is just to catch an https -> http redirect when 201 // Currently this check is just to catch an https -> http redirect when
204 // loading the main plugin src URL. Longer term, we could investigate 202 // loading the main plugin src URL. Longer term, we could investigate
205 // firing mixed diplay or scripting issues for subresource loads 203 // firing mixed diplay or scripting issues for subresource loads
206 // initiated by plug-ins. 204 // initiated by plug-ins.
207 if (is_plugin_src_load_ && 205 if (is_plugin_src_load_ &&
208 !plugin_stream_->instance()->webplugin()->CheckIfRunInsecureContent( 206 !plugin_stream_->instance()->webplugin()->CheckIfRunInsecureContent(
209 new_url)) { 207 redirect_info.new_url)) {
210 plugin_stream_->DidFail(resource_id_); // That will delete |this|. 208 plugin_stream_->DidFail(resource_id_); // That will delete |this|.
211 return false; 209 return false;
212 } 210 }
213 211
214 // It's unfortunate that this logic of when a redirect's method changes is
215 // in url_request.cc, but weburlloader_impl.cc and this file have to duplicate
216 // it instead of passing that information.
217 int response_code;
218 if (info.headers) {
219 response_code = info.headers->response_code();
220 } else {
221 // A redirect may have NULL headers if it came from URLRequestRedirectJob.
222 //
223 // TODO(davidben): Get the actual response code from the browser. Either
224 // fake enough of headers to have a response code or pass it down as part of
225 // https://crbug.com/384609.
226 response_code = 307;
227 }
228 method_ = net::URLRequest::ComputeMethodForRedirect(method_, response_code);
229 GURL old_url = url_; 212 GURL old_url = url_;
230 url_ = new_url; 213 url_ = redirect_info.new_url;
231 first_party_for_cookies_ = new_first_party_for_cookies; 214 first_party_for_cookies_ = redirect_info.new_first_party_for_cookies;
232 215
233 // If the plugin does not participate in url redirect notifications then just 216 // If the plugin does not participate in url redirect notifications then just
234 // block cross origin 307 POST redirects. 217 // block cross origin 307 POST redirects.
235 if (!notify_redirects_) { 218 if (!notify_redirects_) {
236 if (response_code == 307 && method_ == "POST" && 219 if (redirect_info.status_code == 307 &&
237 old_url.GetOrigin() != new_url.GetOrigin()) { 220 redirect_info.new_method == "POST" &&
221 old_url.GetOrigin() != url_.GetOrigin()) {
238 plugin_stream_->DidFail(resource_id_); // That will delete |this|. 222 plugin_stream_->DidFail(resource_id_); // That will delete |this|.
239 return false; 223 return false;
240 } 224 }
241 } else { 225 } else {
242 // Pause the request while we ask the plugin what to do about the redirect. 226 // Pause the request while we ask the plugin what to do about the redirect.
243 bridge_->SetDefersLoading(true); 227 bridge_->SetDefersLoading(true);
244 plugin_stream_->WillSendRequest(url_, response_code); 228 plugin_stream_->WillSendRequest(url_, redirect_info.status_code);
245 } 229 }
246 230
247 return true; 231 return true;
248 } 232 }
249 233
250 void PluginURLFetcher::OnReceivedResponse(const ResourceResponseInfo& info) { 234 void PluginURLFetcher::OnReceivedResponse(const ResourceResponseInfo& info) {
251 if (!plugin_stream_) 235 if (!plugin_stream_)
252 return; 236 return;
253 237
254 // TODO(jam): THIS LOGIC IS COPIED FROM WebPluginImpl::didReceiveResponse 238 // TODO(jam): THIS LOGIC IS COPIED FROM WebPluginImpl::didReceiveResponse
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 } 366 }
383 367
384 if (error_code == net::OK) { 368 if (error_code == net::OK) {
385 plugin_stream_->DidFinishLoading(resource_id_); 369 plugin_stream_->DidFinishLoading(resource_id_);
386 } else { 370 } else {
387 plugin_stream_->DidFail(resource_id_); 371 plugin_stream_->DidFail(resource_id_);
388 } 372 }
389 } 373 }
390 374
391 } // namespace content 375 } // namespace content
OLDNEW
« no previous file with comments | « content/child/npapi/plugin_url_fetcher.h ('k') | content/child/resource_dispatcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698