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/file_path.h" | 9 #include "base/file_path.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 const WebURLRequest& request, | 285 const WebURLRequest& request, |
286 ResourceLoaderBridge::SyncLoadResponse* sync_load_response); | 286 ResourceLoaderBridge::SyncLoadResponse* sync_load_response); |
287 | 287 |
288 // ResourceLoaderBridge::Peer methods: | 288 // ResourceLoaderBridge::Peer methods: |
289 virtual void OnUploadProgress(uint64 position, uint64 size); | 289 virtual void OnUploadProgress(uint64 position, uint64 size); |
290 virtual bool OnReceivedRedirect( | 290 virtual bool OnReceivedRedirect( |
291 const GURL& new_url, | 291 const GURL& new_url, |
292 const ResourceResponseInfo& info, | 292 const ResourceResponseInfo& info, |
293 bool* has_new_first_party_for_cookies, | 293 bool* has_new_first_party_for_cookies, |
294 GURL* new_first_party_for_cookies); | 294 GURL* new_first_party_for_cookies); |
295 virtual void OnReceivedResponse( | 295 virtual void OnReceivedResponse(const ResourceResponseInfo& info); |
296 const ResourceResponseInfo& info, bool content_filtered); | |
297 virtual void OnDownloadedData(int len); | 296 virtual void OnDownloadedData(int len); |
298 virtual void OnReceivedData(const char* data, int len); | 297 virtual void OnReceivedData(const char* data, int len); |
299 virtual void OnReceivedCachedMetadata(const char* data, int len); | 298 virtual void OnReceivedCachedMetadata(const char* data, int len); |
300 virtual void OnCompletedRequest(const net::URLRequestStatus& status, | 299 virtual void OnCompletedRequest(const net::URLRequestStatus& status, |
301 const std::string& security_info, | 300 const std::string& security_info, |
302 const base::Time& completion_time); | 301 const base::Time& completion_time); |
303 | 302 |
304 private: | 303 private: |
305 friend class base::RefCounted<Context>; | 304 friend class base::RefCounted<Context>; |
306 ~Context() {} | 305 ~Context() {} |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
527 if (new_url == GURL(new_request.url())) | 526 if (new_url == GURL(new_request.url())) |
528 return true; | 527 return true; |
529 | 528 |
530 // We assume that WebKit only changes the URL to suppress a redirect, and we | 529 // We assume that WebKit only changes the URL to suppress a redirect, and we |
531 // assume that it does so by setting it to be invalid. | 530 // assume that it does so by setting it to be invalid. |
532 DCHECK(!new_request.url().isValid()); | 531 DCHECK(!new_request.url().isValid()); |
533 return false; | 532 return false; |
534 } | 533 } |
535 | 534 |
536 void WebURLLoaderImpl::Context::OnReceivedResponse( | 535 void WebURLLoaderImpl::Context::OnReceivedResponse( |
537 const ResourceResponseInfo& info, | 536 const ResourceResponseInfo& info) { |
538 bool content_filtered) { | |
539 if (!client_) | 537 if (!client_) |
540 return; | 538 return; |
541 | 539 |
542 WebURLResponse response; | 540 WebURLResponse response; |
543 response.initialize(); | 541 response.initialize(); |
544 PopulateURLResponse(request_.url(), info, &response); | 542 PopulateURLResponse(request_.url(), info, &response); |
545 response.setIsContentFiltered(content_filtered); | |
546 | 543 |
547 bool show_raw_listing = (GURL(request_.url()).query() == "raw"); | 544 bool show_raw_listing = (GURL(request_.url()).query() == "raw"); |
548 | 545 |
549 if (info.mime_type == "text/vnd.chromium.ftp-dir") { | 546 if (info.mime_type == "text/vnd.chromium.ftp-dir") { |
550 if (show_raw_listing) { | 547 if (show_raw_listing) { |
551 // Set the MIME type to plain text to prevent any active content. | 548 // Set the MIME type to plain text to prevent any active content. |
552 response.setMIMEType("text/plain"); | 549 response.setMIMEType("text/plain"); |
553 } else { | 550 } else { |
554 // We're going to produce a parsed listing in HTML. | 551 // We're going to produce a parsed listing in HTML. |
555 response.setMIMEType("text/html"); | 552 response.setMIMEType("text/html"); |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
687 | 684 |
688 return false; | 685 return false; |
689 } | 686 } |
690 | 687 |
691 void WebURLLoaderImpl::Context::HandleDataURL() { | 688 void WebURLLoaderImpl::Context::HandleDataURL() { |
692 ResourceResponseInfo info; | 689 ResourceResponseInfo info; |
693 net::URLRequestStatus status; | 690 net::URLRequestStatus status; |
694 std::string data; | 691 std::string data; |
695 | 692 |
696 if (GetInfoFromDataURL(request_.url(), &info, &data, &status)) { | 693 if (GetInfoFromDataURL(request_.url(), &info, &data, &status)) { |
697 OnReceivedResponse(info, false); | 694 OnReceivedResponse(info); |
698 if (!data.empty()) | 695 if (!data.empty()) |
699 OnReceivedData(data.data(), data.size()); | 696 OnReceivedData(data.data(), data.size()); |
700 } | 697 } |
701 | 698 |
702 OnCompletedRequest(status, info.security_info, base::Time::Now()); | 699 OnCompletedRequest(status, info.security_info, base::Time::Now()); |
703 } | 700 } |
704 | 701 |
705 // WebURLLoaderImpl ----------------------------------------------------------- | 702 // WebURLLoaderImpl ----------------------------------------------------------- |
706 | 703 |
707 WebURLLoaderImpl::WebURLLoaderImpl() | 704 WebURLLoaderImpl::WebURLLoaderImpl() |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
750 | 747 |
751 void WebURLLoaderImpl::cancel() { | 748 void WebURLLoaderImpl::cancel() { |
752 context_->Cancel(); | 749 context_->Cancel(); |
753 } | 750 } |
754 | 751 |
755 void WebURLLoaderImpl::setDefersLoading(bool value) { | 752 void WebURLLoaderImpl::setDefersLoading(bool value) { |
756 context_->SetDefersLoading(value); | 753 context_->SetDefersLoading(value); |
757 } | 754 } |
758 | 755 |
759 } // namespace webkit_glue | 756 } // namespace webkit_glue |
OLD | NEW |