Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // An implementation of WebURLLoader in terms of ResourceLoaderBridge. | 5 // An implementation of WebURLLoader in terms of ResourceLoaderBridge. |
| 6 | 6 |
| 7 #include "webkit/glue/weburlloader_impl.h" | 7 #include "webkit/glue/weburlloader_impl.h" |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/message_loop.h" | 12 #include "base/message_loop.h" |
| 13 #include "base/process_util.h" | 13 #include "base/process_util.h" |
| 14 #include "base/string_util.h" | 14 #include "base/string_util.h" |
| 15 #include "base/time.h" | 15 #include "base/time.h" |
| 16 #include "net/base/data_url.h" | 16 #include "net/base/data_url.h" |
| 17 #include "net/base/load_flags.h" | 17 #include "net/base/load_flags.h" |
| 18 #include "net/base/mime_util.h" | 18 #include "net/base/mime_util.h" |
| 19 #include "net/base/net_errors.h" | 19 #include "net/base/net_errors.h" |
| 20 #include "net/base/net_util.h" | 20 #include "net/base/net_util.h" |
| 21 #include "net/http/http_response_headers.h" | 21 #include "net/http/http_response_headers.h" |
| 22 #include "net/http/http_util.h" | |
| 22 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebHTTPHeade rVisitor.h" | 23 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebHTTPHeade rVisitor.h" |
| 23 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebHTTPLoadI nfo.h" | 24 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebHTTPLoadI nfo.h" |
| 24 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityPolicy.h" | 25 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityPolicy.h" |
| 25 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURL.h" | 26 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURL.h" |
| 26 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLError. h" | 27 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLError. h" |
| 27 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLLoadTi ming.h" | 28 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLLoadTi ming.h" |
| 28 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLLoader Client.h" | 29 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLLoader Client.h" |
| 29 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLReques t.h" | 30 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLReques t.h" |
| 30 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLRespon se.h" | 31 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLRespon se.h" |
| 31 #include "webkit/glue/ftp_directory_listing_response_delegate.h" | 32 #include "webkit/glue/ftp_directory_listing_response_delegate.h" |
| (...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 554 // without a client and therefore without much need to do further handling. | 555 // without a client and therefore without much need to do further handling. |
| 555 if (!client_) | 556 if (!client_) |
| 556 return; | 557 return; |
| 557 | 558 |
| 558 DCHECK(!ftp_listing_delegate_.get()); | 559 DCHECK(!ftp_listing_delegate_.get()); |
| 559 DCHECK(!multipart_delegate_.get()); | 560 DCHECK(!multipart_delegate_.get()); |
| 560 if (info.headers && info.mime_type == "multipart/x-mixed-replace") { | 561 if (info.headers && info.mime_type == "multipart/x-mixed-replace") { |
| 561 std::string content_type; | 562 std::string content_type; |
| 562 info.headers->EnumerateHeader(NULL, "content-type", &content_type); | 563 info.headers->EnumerateHeader(NULL, "content-type", &content_type); |
| 563 | 564 |
| 564 std::string boundary = net::GetHeaderParamValue( | 565 std::string mime_type; |
| 565 content_type, "boundary", net::QuoteRule::REMOVE_OUTER_QUOTES); | 566 std::string charset; |
| 567 bool had_charset; | |
| 568 std::string boundary; | |
| 569 net::HttpUtil::ParseContentType(content_type, &mime_type, &charset, | |
|
darin (slow to review)
2012/01/30 22:53:38
did you consider making ParseContentType support N
| |
| 570 &had_charset, &boundary); | |
| 566 TrimString(boundary, " \"", &boundary); | 571 TrimString(boundary, " \"", &boundary); |
| 567 | 572 |
| 568 // If there's no boundary, just handle the request normally. In the gecko | 573 // If there's no boundary, just handle the request normally. In the gecko |
| 569 // code, nsMultiMixedConv::OnStartRequest throws an exception. | 574 // code, nsMultiMixedConv::OnStartRequest throws an exception. |
| 570 if (!boundary.empty()) { | 575 if (!boundary.empty()) { |
| 571 multipart_delegate_.reset( | 576 multipart_delegate_.reset( |
| 572 new MultipartResponseDelegate(client_, loader_, response, boundary)); | 577 new MultipartResponseDelegate(client_, loader_, response, boundary)); |
| 573 } | 578 } |
| 574 } else if (info.mime_type == "text/vnd.chromium.ftp-dir" && | 579 } else if (info.mime_type == "text/vnd.chromium.ftp-dir" && |
| 575 !show_raw_listing) { | 580 !show_raw_listing) { |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 744 | 749 |
| 745 void WebURLLoaderImpl::setDefersLoading(bool value) { | 750 void WebURLLoaderImpl::setDefersLoading(bool value) { |
| 746 context_->SetDefersLoading(value); | 751 context_->SetDefersLoading(value); |
| 747 } | 752 } |
| 748 | 753 |
| 749 void WebURLLoaderImpl::UpdateRoutingId(int new_routing_id) { | 754 void WebURLLoaderImpl::UpdateRoutingId(int new_routing_id) { |
| 750 context_->UpdateRoutingId(new_routing_id); | 755 context_->UpdateRoutingId(new_routing_id); |
| 751 } | 756 } |
| 752 | 757 |
| 753 } // namespace webkit_glue | 758 } // namespace webkit_glue |
| OLD | NEW |