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

Side by Side Diff: net/url_request/url_request_http_job.cc

Issue 11931024: Removed static factories for data, ftp, file, and about jobs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add test for IsSafeRedirectTarget Created 7 years, 10 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "net/url_request/url_request_http_job.h" 5 #include "net/url_request/url_request_http_job.h"
6 6
7 #include "base/base_switches.h" 7 #include "base/base_switches.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/bind_helpers.h" 9 #include "base/bind_helpers.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 25 matching lines...) Expand all
36 #include "net/http/http_status_code.h" 36 #include "net/http/http_status_code.h"
37 #include "net/http/http_transaction.h" 37 #include "net/http/http_transaction.h"
38 #include "net/http/http_transaction_delegate.h" 38 #include "net/http/http_transaction_delegate.h"
39 #include "net/http/http_transaction_factory.h" 39 #include "net/http/http_transaction_factory.h"
40 #include "net/http/http_util.h" 40 #include "net/http/http_util.h"
41 #include "net/url_request/fraudulent_certificate_reporter.h" 41 #include "net/url_request/fraudulent_certificate_reporter.h"
42 #include "net/url_request/http_user_agent_settings.h" 42 #include "net/url_request/http_user_agent_settings.h"
43 #include "net/url_request/url_request.h" 43 #include "net/url_request/url_request.h"
44 #include "net/url_request/url_request_context.h" 44 #include "net/url_request/url_request_context.h"
45 #include "net/url_request/url_request_error_job.h" 45 #include "net/url_request/url_request_error_job.h"
46 #include "net/url_request/url_request_job_factory.h"
46 #include "net/url_request/url_request_redirect_job.h" 47 #include "net/url_request/url_request_redirect_job.h"
47 #include "net/url_request/url_request_throttler_header_adapter.h" 48 #include "net/url_request/url_request_throttler_header_adapter.h"
48 #include "net/url_request/url_request_throttler_manager.h" 49 #include "net/url_request/url_request_throttler_manager.h"
49 50
50 static const char kAvailDictionaryHeader[] = "Avail-Dictionary"; 51 static const char kAvailDictionaryHeader[] = "Avail-Dictionary";
51 52
52 namespace net { 53 namespace net {
53 54
54 class URLRequestHttpJob::HttpFilterContext : public FilterContext { 55 class URLRequestHttpJob::HttpFilterContext : public FilterContext {
55 public: 56 public:
(...skipping 956 matching lines...) Expand 10 before | Expand all | Expand 10 after
1012 // some decoding, as some proxies strip encoding completely. In such cases, 1013 // some decoding, as some proxies strip encoding completely. In such cases,
1013 // we may need to add (for example) SDCH filtering (when the context suggests 1014 // we may need to add (for example) SDCH filtering (when the context suggests
1014 // it is appropriate). 1015 // it is appropriate).
1015 Filter::FixupEncodingTypes(*filter_context_, &encoding_types); 1016 Filter::FixupEncodingTypes(*filter_context_, &encoding_types);
1016 1017
1017 return !encoding_types.empty() 1018 return !encoding_types.empty()
1018 ? Filter::Factory(encoding_types, *filter_context_) : NULL; 1019 ? Filter::Factory(encoding_types, *filter_context_) : NULL;
1019 } 1020 }
1020 1021
1021 bool URLRequestHttpJob::IsSafeRedirect(const GURL& location) { 1022 bool URLRequestHttpJob::IsSafeRedirect(const GURL& location) {
1022 // We only allow redirects to certain "safe" protocols. This does not 1023 // HTTP is always safe.
1023 // restrict redirects to externally handled protocols. Our consumer would 1024 // TODO(pauljensen): Remove once crbug.com/146591 is fixed.
1024 // need to take care of those. 1025 if (location.is_valid() &&
1025 1026 (location.scheme() == "http" || location.scheme() == "https"))
1026 if (!URLRequest::IsHandledURL(location))
1027 return true; 1027 return true;
mmenke 2013/02/19 17:26:15 nit: Use braces when the conditional is more than
pauljensen 2013/02/20 15:13:27 Done.
1028 1028 // Query URLRequestJobFactory as to whether |location| would be safe to
1029 static const char* kSafeSchemes[] = { 1029 // redirect to.
1030 "http", 1030 return request_->context()->job_factory() &&
1031 "https", 1031 request_->context()->job_factory()->IsSafeRedirectTarget(location);
1032 "ftp"
1033 };
1034
1035 for (size_t i = 0; i < arraysize(kSafeSchemes); ++i) {
1036 if (location.SchemeIs(kSafeSchemes[i]))
1037 return true;
1038 }
1039
1040 return false;
1041 } 1032 }
1042 1033
1043 bool URLRequestHttpJob::NeedsAuth() { 1034 bool URLRequestHttpJob::NeedsAuth() {
1044 int code = GetResponseCode(); 1035 int code = GetResponseCode();
1045 if (code == -1) 1036 if (code == -1)
1046 return false; 1037 return false;
1047 1038
1048 // Check if we need either Proxy or WWW Authentication. This could happen 1039 // Check if we need either Proxy or WWW Authentication. This could happen
1049 // because we either provided no auth info, or provided incorrect info. 1040 // because we either provided no auth info, or provided incorrect info.
1050 switch (code) { 1041 switch (code) {
(...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after
1576 1567
1577 void URLRequestHttpJob::NotifyURLRequestDestroyed() { 1568 void URLRequestHttpJob::NotifyURLRequestDestroyed() {
1578 awaiting_callback_ = false; 1569 awaiting_callback_ = false;
1579 } 1570 }
1580 1571
1581 void URLRequestHttpJob::OnDetachRequest() { 1572 void URLRequestHttpJob::OnDetachRequest() {
1582 http_transaction_delegate_->OnDetachRequest(); 1573 http_transaction_delegate_->OnDetachRequest();
1583 } 1574 }
1584 1575
1585 } // namespace net 1576 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698