| OLD | NEW |
| 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/npapi/plugin_host.h" | 9 #include "content/child/npapi/plugin_host.h" |
| 10 #include "content/child/npapi/plugin_instance.h" | 10 #include "content/child/npapi/plugin_instance.h" |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 bridge_->Cancel(); | 183 bridge_->Cancel(); |
| 184 plugin_stream_->DidFail(resource_id_); // That will delete |this|. | 184 plugin_stream_->DidFail(resource_id_); // That will delete |this|. |
| 185 } | 185 } |
| 186 } | 186 } |
| 187 | 187 |
| 188 void PluginURLFetcher::OnUploadProgress(uint64 position, uint64 size) { | 188 void PluginURLFetcher::OnUploadProgress(uint64 position, uint64 size) { |
| 189 } | 189 } |
| 190 | 190 |
| 191 bool PluginURLFetcher::OnReceivedRedirect( | 191 bool PluginURLFetcher::OnReceivedRedirect( |
| 192 const GURL& new_url, | 192 const GURL& new_url, |
| 193 const webkit_glue::ResourceResponseInfo& info, | 193 const GURL& new_first_party_for_cookies, |
| 194 bool* has_new_first_party_for_cookies, | 194 const webkit_glue::ResourceResponseInfo& info) { |
| 195 GURL* new_first_party_for_cookies) { | |
| 196 if (!plugin_stream_) | 195 if (!plugin_stream_) |
| 197 return false; | 196 return false; |
| 198 | 197 |
| 199 // TODO(jam): THIS LOGIC IS COPIED FROM WebPluginImpl::willSendRequest until | 198 // TODO(jam): THIS LOGIC IS COPIED FROM WebPluginImpl::willSendRequest until |
| 200 // 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. |
| 201 | 200 |
| 202 // 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 |
| 203 // loading the main plugin src URL. Longer term, we could investigate | 202 // loading the main plugin src URL. Longer term, we could investigate |
| 204 // firing mixed diplay or scripting issues for subresource loads | 203 // firing mixed diplay or scripting issues for subresource loads |
| 205 // initiated by plug-ins. | 204 // initiated by plug-ins. |
| 206 if (is_plugin_src_load_ && | 205 if (is_plugin_src_load_ && |
| 207 !plugin_stream_->instance()->webplugin()->CheckIfRunInsecureContent( | 206 !plugin_stream_->instance()->webplugin()->CheckIfRunInsecureContent( |
| 208 new_url)) { | 207 new_url)) { |
| 209 plugin_stream_->DidFail(resource_id_); // That will delete |this|. | 208 plugin_stream_->DidFail(resource_id_); // That will delete |this|. |
| 210 return false; | 209 return false; |
| 211 } | 210 } |
| 212 | 211 |
| 213 // It's unfortunate that this logic of when a redirect's method changes is | 212 // It's unfortunate that this logic of when a redirect's method changes is |
| 214 // in url_request.cc, but weburlloader_impl.cc and this file have to duplicate | 213 // in url_request.cc, but weburlloader_impl.cc and this file have to duplicate |
| 215 // it instead of passing that information. | 214 // it instead of passing that information. |
| 216 int response_code = info.headers->response_code(); | 215 int response_code = info.headers->response_code(); |
| 217 if (response_code != 307) | 216 if (response_code != 307) |
| 218 method_ = "GET"; | 217 method_ = "GET"; |
| 219 GURL old_url = url_; | 218 GURL old_url = url_; |
| 220 url_ = new_url; | 219 url_ = new_url; |
| 221 *has_new_first_party_for_cookies = true; | 220 first_party_for_cookies_ = new_first_party_for_cookies; |
| 222 *new_first_party_for_cookies = first_party_for_cookies_; | |
| 223 | 221 |
| 224 // If the plugin does not participate in url redirect notifications then just | 222 // If the plugin does not participate in url redirect notifications then just |
| 225 // block cross origin 307 POST redirects. | 223 // block cross origin 307 POST redirects. |
| 226 if (!notify_redirects_) { | 224 if (!notify_redirects_) { |
| 227 if (response_code == 307 && method_ == "POST" && | 225 if (response_code == 307 && method_ == "POST" && |
| 228 old_url.GetOrigin() != new_url.GetOrigin()) { | 226 old_url.GetOrigin() != new_url.GetOrigin()) { |
| 229 plugin_stream_->DidFail(resource_id_); // That will delete |this|. | 227 plugin_stream_->DidFail(resource_id_); // That will delete |this|. |
| 230 return false; | 228 return false; |
| 231 } | 229 } |
| 232 } else { | 230 } else { |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 374 } | 372 } |
| 375 | 373 |
| 376 if (error_code == net::OK) { | 374 if (error_code == net::OK) { |
| 377 plugin_stream_->DidFinishLoading(resource_id_); | 375 plugin_stream_->DidFinishLoading(resource_id_); |
| 378 } else { | 376 } else { |
| 379 plugin_stream_->DidFail(resource_id_); | 377 plugin_stream_->DidFail(resource_id_); |
| 380 } | 378 } |
| 381 } | 379 } |
| 382 | 380 |
| 383 } // namespace content | 381 } // namespace content |
| OLD | NEW |