| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "chrome/browser/ssl/common_name_mismatch_handler.h" | 5 #include "chrome/browser/ssl/common_name_mismatch_handler.h" |
| 6 | 6 |
| 7 #include "base/callback_helpers.h" | 7 #include "base/callback_helpers.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
| 10 #include "chrome/browser/ssl/ssl_error_classification.h" | 10 #include "components/ssl_errors/error_classification.h" |
| 11 #include "net/base/load_flags.h" | 11 #include "net/base/load_flags.h" |
| 12 #include "net/http/http_response_headers.h" | 12 #include "net/http/http_response_headers.h" |
| 13 #include "net/http/http_util.h" | 13 #include "net/http/http_util.h" |
| 14 #include "net/url_request/url_request_status.h" | 14 #include "net/url_request/url_request_status.h" |
| 15 | 15 |
| 16 CommonNameMismatchHandler::CommonNameMismatchHandler( | 16 CommonNameMismatchHandler::CommonNameMismatchHandler( |
| 17 const GURL& request_url, | 17 const GURL& request_url, |
| 18 const scoped_refptr<net::URLRequestContextGetter>& request_context) | 18 const scoped_refptr<net::URLRequestContextGetter>& request_context) |
| 19 : request_url_(request_url), request_context_(request_context) {} | 19 : request_url_(request_url), request_context_(request_context) {} |
| 20 | 20 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 49 url_fetcher_->Start(); | 49 url_fetcher_->Start(); |
| 50 } | 50 } |
| 51 | 51 |
| 52 // static | 52 // static |
| 53 bool CommonNameMismatchHandler::GetSuggestedUrl( | 53 bool CommonNameMismatchHandler::GetSuggestedUrl( |
| 54 const GURL& request_url, | 54 const GURL& request_url, |
| 55 const std::vector<std::string>& dns_names, | 55 const std::vector<std::string>& dns_names, |
| 56 GURL* suggested_url) { | 56 GURL* suggested_url) { |
| 57 std::string host_name = request_url.host(); | 57 std::string host_name = request_url.host(); |
| 58 std::string www_mismatch_hostname; | 58 std::string www_mismatch_hostname; |
| 59 if (!SSLErrorClassification::GetWWWSubDomainMatch(host_name, dns_names, | 59 if (!ssl_errors::ErrorClassification::GetWWWSubDomainMatch( |
| 60 &www_mismatch_hostname)) { | 60 host_name, dns_names, &www_mismatch_hostname)) { |
| 61 return false; | 61 return false; |
| 62 } | 62 } |
| 63 // The full URL should be pinged, not just the new hostname. So, get the | 63 // The full URL should be pinged, not just the new hostname. So, get the |
| 64 // |suggested_url| with the |request_url|'s hostname replaced with | 64 // |suggested_url| with the |request_url|'s hostname replaced with |
| 65 // new hostname. Keep resource path, query params the same. | 65 // new hostname. Keep resource path, query params the same. |
| 66 GURL::Replacements replacements; | 66 GURL::Replacements replacements; |
| 67 replacements.SetHostStr(www_mismatch_hostname); | 67 replacements.SetHostStr(www_mismatch_hostname); |
| 68 *suggested_url = request_url.ReplaceComponents(replacements); | 68 *suggested_url = request_url.ReplaceComponents(replacements); |
| 69 return true; | 69 return true; |
| 70 } | 70 } |
| (...skipping 24 matching lines...) Expand all Loading... |
| 95 landing_url.host() != request_url_.host()) { | 95 landing_url.host() != request_url_.host()) { |
| 96 result = SUGGESTED_URL_AVAILABLE; | 96 result = SUGGESTED_URL_AVAILABLE; |
| 97 } | 97 } |
| 98 url_fetcher_.reset(); | 98 url_fetcher_.reset(); |
| 99 base::ResetAndReturn(&check_url_callback_).Run(result, suggested_url); | 99 base::ResetAndReturn(&check_url_callback_).Run(result, suggested_url); |
| 100 } | 100 } |
| 101 | 101 |
| 102 bool CommonNameMismatchHandler::IsCheckingSuggestedUrl() const { | 102 bool CommonNameMismatchHandler::IsCheckingSuggestedUrl() const { |
| 103 return url_fetcher_; | 103 return url_fetcher_; |
| 104 } | 104 } |
| OLD | NEW |