Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / content / child / npapi / plugin_url_fetcher.cc
index acd508b..d339033 100644 (file)
@@ -6,6 +6,7 @@
 
 #include "base/memory/scoped_ptr.h"
 #include "content/child/child_thread.h"
+#include "content/child/multipart_response_delegate.h"
 #include "content/child/npapi/plugin_host.h"
 #include "content/child/npapi/plugin_instance.h"
 #include "content/child/npapi/plugin_stream_url.h"
 #include "net/base/load_flags.h"
 #include "net/base/net_errors.h"
 #include "net/http/http_response_headers.h"
-#include "net/url_request/url_request.h"
+#include "net/url_request/redirect_info.h"
 #include "third_party/WebKit/public/platform/WebURLLoaderClient.h"
 #include "third_party/WebKit/public/platform/WebURLResponse.h"
-#include "webkit/child/multipart_response_delegate.h"
 #include "webkit/child/resource_loader_bridge.h"
 
 namespace content {
@@ -48,9 +48,10 @@ class MultiPartResponseClient : public blink::WebURLLoaderClient {
       blink::WebURLLoader* loader,
       const blink::WebURLResponse& response) OVERRIDE {
     int64 byte_range_upper_bound, instance_size;
-    if (!webkit_glue::MultipartResponseDelegate::ReadContentRanges(
-            response, &byte_range_lower_bound_, &byte_range_upper_bound,
-            &instance_size)) {
+    if (!MultipartResponseDelegate::ReadContentRanges(response,
+                                                      &byte_range_lower_bound_,
+                                                      &byte_range_upper_bound,
+                                                      &instance_size)) {
       NOTREACHED();
     }
   }
@@ -94,7 +95,6 @@ PluginURLFetcher::PluginURLFetcher(PluginStreamUrl* plugin_stream,
     : plugin_stream_(plugin_stream),
       url_(url),
       first_party_for_cookies_(first_party_for_cookies),
-      method_(method),
       referrer_(referrer),
       notify_redirects_(notify_redirects),
       is_plugin_src_load_(is_plugin_src_load),
@@ -112,7 +112,7 @@ PluginURLFetcher::PluginURLFetcher(PluginStreamUrl* plugin_stream,
   request_info.referrer = referrer;
   request_info.load_flags = net::LOAD_NORMAL;
   request_info.requestor_pid = origin_pid;
-  request_info.request_type = ResourceType::OBJECT;
+  request_info.request_type = RESOURCE_TYPE_OBJECT;
   request_info.routing_id = render_view_id;
 
   RequestExtraData extra_data;
@@ -190,8 +190,7 @@ void PluginURLFetcher::OnUploadProgress(uint64 position, uint64 size) {
 }
 
 bool PluginURLFetcher::OnReceivedRedirect(
-    const GURL& new_url,
-    const GURL& new_first_party_for_cookies,
+    const net::RedirectInfo& redirect_info,
     const ResourceResponseInfo& info) {
   if (!plugin_stream_)
     return false;
@@ -205,32 +204,28 @@ bool PluginURLFetcher::OnReceivedRedirect(
   // initiated by plug-ins.
   if (is_plugin_src_load_ &&
       !plugin_stream_->instance()->webplugin()->CheckIfRunInsecureContent(
-          new_url)) {
+          redirect_info.new_url)) {
     plugin_stream_->DidFail(resource_id_);  // That will delete |this|.
     return false;
   }
 
-  // It's unfortunate that this logic of when a redirect's method changes is
-  // in url_request.cc, but weburlloader_impl.cc and this file have to duplicate
-  // it instead of passing that information.
-  int response_code = info.headers->response_code();
-  method_ = net::URLRequest::ComputeMethodForRedirect(method_, response_code);
   GURL old_url = url_;
-  url_ = new_url;
-  first_party_for_cookies_ = new_first_party_for_cookies;
+  url_ = redirect_info.new_url;
+  first_party_for_cookies_ = redirect_info.new_first_party_for_cookies;
 
   // If the plugin does not participate in url redirect notifications then just
   // block cross origin 307 POST redirects.
   if (!notify_redirects_) {
-    if (response_code == 307 && method_ == "POST" &&
-        old_url.GetOrigin() != new_url.GetOrigin()) {
+    if (redirect_info.status_code == 307 &&
+        redirect_info.new_method == "POST" &&
+        old_url.GetOrigin() != url_.GetOrigin()) {
       plugin_stream_->DidFail(resource_id_);  // That will delete |this|.
       return false;
     }
   } else {
     // Pause the request while we ask the plugin what to do about the redirect.
     bridge_->SetDefersLoading(true);
-    plugin_stream_->WillSendRequest(url_, response_code);
+    plugin_stream_->WillSendRequest(url_, redirect_info.status_code);
   }
 
   return true;
@@ -254,14 +249,14 @@ void PluginURLFetcher::OnReceivedResponse(const ResourceResponseInfo& info) {
       WebURLLoaderImpl::PopulateURLResponse(url_, info, &response);
 
       std::string multipart_boundary;
-      if (webkit_glue::MultipartResponseDelegate::ReadMultipartBoundary(
+      if (MultipartResponseDelegate::ReadMultipartBoundary(
               response, &multipart_boundary)) {
         plugin_stream_->instance()->webplugin()->DidStartLoading();
 
         MultiPartResponseClient* multi_part_response_client =
             new MultiPartResponseClient(plugin_stream_);
 
-        multipart_delegate_.reset(new webkit_glue::MultipartResponseDelegate(
+        multipart_delegate_.reset(new MultipartResponseDelegate(
             multi_part_response_client, NULL, response, multipart_boundary));
 
         // Multiple ranges requested, data will be delivered by
@@ -273,7 +268,7 @@ void PluginURLFetcher::OnReceivedResponse(const ResourceResponseInfo& info) {
       int64 upper_bound = 0, instance_size = 0;
       // Single range requested - go through original processing for
       // non-multipart requests, but update data offset.
-      webkit_glue::MultipartResponseDelegate::ReadContentRanges(
+      MultipartResponseDelegate::ReadContentRanges(
           response, &data_offset_, &upper_bound, &instance_size);
     } else if (response_code == 200) {
       // TODO: should we handle this case? We used to but it's not clear that we