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 #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/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
185 NOTREACHED() << "requires a valid context"; | 185 NOTREACHED() << "requires a valid context"; |
186 return new URLRequestErrorJob(request, ERR_INVALID_ARGUMENT); | 186 return new URLRequestErrorJob(request, ERR_INVALID_ARGUMENT); |
187 } | 187 } |
188 | 188 |
189 TransportSecurityState::DomainState domain_state; | 189 TransportSecurityState::DomainState domain_state; |
190 if (scheme == "http" && | 190 if (scheme == "http" && |
191 request->context()->transport_security_state() && | 191 request->context()->transport_security_state() && |
192 request->context()->transport_security_state()->IsEnabledForHost( | 192 request->context()->transport_security_state()->IsEnabledForHost( |
193 &domain_state, | 193 &domain_state, |
194 request->url().host(), | 194 request->url().host(), |
195 request->context()->IsSNIAvailable())) { | 195 SSLConfigService::IsSNIAvailable( |
willchan no longer on Chromium
2011/05/05 18:00:35
please include ssl_config_service.h for this
Chris Evans
2011/05/05 22:00:56
Done.
| |
196 request->context()->ssl_config_service()))) { | |
196 if (domain_state.mode == | 197 if (domain_state.mode == |
197 TransportSecurityState::DomainState::MODE_STRICT) { | 198 TransportSecurityState::DomainState::MODE_STRICT) { |
198 DCHECK_EQ(request->url().scheme(), "http"); | 199 DCHECK_EQ(request->url().scheme(), "http"); |
199 url_canon::Replacements<char> replacements; | 200 url_canon::Replacements<char> replacements; |
200 static const char kNewScheme[] = "https"; | 201 static const char kNewScheme[] = "https"; |
201 replacements.SetScheme(kNewScheme, | 202 replacements.SetScheme(kNewScheme, |
202 url_parse::Component(0, strlen(kNewScheme))); | 203 url_parse::Component(0, strlen(kNewScheme))); |
203 GURL new_location = request->url().ReplaceComponents(replacements); | 204 GURL new_location = request->url().ReplaceComponents(replacements); |
204 return new URLRequestRedirectJob(request, new_location); | 205 return new URLRequestRedirectJob(request, new_location); |
205 } else { | 206 } else { |
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
668 // certificate. | 669 // certificate. |
669 const SSLInfo& ssl_info = transaction_->GetResponseInfo()->ssl_info; | 670 const SSLInfo& ssl_info = transaction_->GetResponseInfo()->ssl_info; |
670 if (result == OK && | 671 if (result == OK && |
671 ssl_info.is_valid() && | 672 ssl_info.is_valid() && |
672 ssl_info.is_issued_by_known_root && | 673 ssl_info.is_issued_by_known_root && |
673 context_->transport_security_state()) { | 674 context_->transport_security_state()) { |
674 TransportSecurityState::DomainState domain_state; | 675 TransportSecurityState::DomainState domain_state; |
675 if (context_->transport_security_state()->HasPinsForHost( | 676 if (context_->transport_security_state()->HasPinsForHost( |
676 &domain_state, | 677 &domain_state, |
677 request_->url().host(), | 678 request_->url().host(), |
678 context_->IsSNIAvailable())) { | 679 SSLConfigService::IsSNIAvailable( |
680 context_->ssl_config_service()))) { | |
679 if (!domain_state.IsChainOfPublicKeysPermitted( | 681 if (!domain_state.IsChainOfPublicKeysPermitted( |
680 ssl_info.public_key_hashes)) { | 682 ssl_info.public_key_hashes)) { |
681 result = ERR_CERT_INVALID; | 683 result = ERR_CERT_INVALID; |
682 UMA_HISTOGRAM_BOOLEAN("Net.CertificatePinSuccess", false); | 684 UMA_HISTOGRAM_BOOLEAN("Net.CertificatePinSuccess", false); |
683 } else { | 685 } else { |
684 UMA_HISTOGRAM_BOOLEAN("Net.CertificatePinSuccess", true); | 686 UMA_HISTOGRAM_BOOLEAN("Net.CertificatePinSuccess", true); |
685 } | 687 } |
686 } | 688 } |
687 } | 689 } |
688 | 690 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
727 if (result == ERR_CERT_UNABLE_TO_CHECK_REVOCATION) | 729 if (result == ERR_CERT_UNABLE_TO_CHECK_REVOCATION) |
728 return true; | 730 return true; |
729 | 731 |
730 // Check whether our context is using Strict-Transport-Security. | 732 // Check whether our context is using Strict-Transport-Security. |
731 if (!context_->transport_security_state()) | 733 if (!context_->transport_security_state()) |
732 return true; | 734 return true; |
733 | 735 |
734 TransportSecurityState::DomainState domain_state; | 736 TransportSecurityState::DomainState domain_state; |
735 // TODO(agl): don't ignore opportunistic mode. | 737 // TODO(agl): don't ignore opportunistic mode. |
736 const bool r = context_->transport_security_state()->IsEnabledForHost( | 738 const bool r = context_->transport_security_state()->IsEnabledForHost( |
737 &domain_state, request_info_.url.host(), context_->IsSNIAvailable()); | 739 &domain_state, request_info_.url.host(), |
740 SSLConfigService::IsSNIAvailable(context_->ssl_config_service())); | |
738 | 741 |
739 return !r || domain_state.mode == | 742 return !r || domain_state.mode == |
740 TransportSecurityState::DomainState::MODE_OPPORTUNISTIC; | 743 TransportSecurityState::DomainState::MODE_OPPORTUNISTIC; |
741 } | 744 } |
742 | 745 |
743 void URLRequestHttpJob::RestartTransactionWithAuth( | 746 void URLRequestHttpJob::RestartTransactionWithAuth( |
744 const string16& username, | 747 const string16& username, |
745 const string16& password) { | 748 const string16& password) { |
746 username_ = username; | 749 username_ = username; |
747 password_ = password; | 750 password_ = password; |
(...skipping 646 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1394 } | 1397 } |
1395 | 1398 |
1396 bool URLRequestHttpJob::IsCompressibleContent() const { | 1399 bool URLRequestHttpJob::IsCompressibleContent() const { |
1397 std::string mime_type; | 1400 std::string mime_type; |
1398 return GetMimeType(&mime_type) && | 1401 return GetMimeType(&mime_type) && |
1399 (IsSupportedJavascriptMimeType(mime_type.c_str()) || | 1402 (IsSupportedJavascriptMimeType(mime_type.c_str()) || |
1400 IsSupportedNonImageMimeType(mime_type.c_str())); | 1403 IsSupportedNonImageMimeType(mime_type.c_str())); |
1401 } | 1404 } |
1402 | 1405 |
1403 } // namespace net | 1406 } // namespace net |
OLD | NEW |