| 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 26 matching lines...) Expand all  Loading... | 
|   47                              net::LOAD_DO_NOT_SEND_COOKIES | |   47                              net::LOAD_DO_NOT_SEND_COOKIES | | 
|   48                              net::LOAD_DO_NOT_SEND_AUTH_DATA); |   48                              net::LOAD_DO_NOT_SEND_AUTH_DATA); | 
|   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(); |  | 
|   58   std::string www_mismatch_hostname; |   57   std::string www_mismatch_hostname; | 
|   59   if (!SSLErrorClassification::GetWWWSubDomainMatch(host_name, dns_names, |   58   if (!ssl_errors::GetWWWSubDomainMatch(request_url, dns_names, | 
|   60                                                     &www_mismatch_hostname)) { |   59                                         &www_mismatch_hostname)) { | 
|   61     return false; |   60     return false; | 
|   62   } |   61   } | 
|   63   // The full URL should be pinged, not just the new hostname. So, get the |   62   // 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 |   63   // |suggested_url| with the |request_url|'s hostname replaced with | 
|   65   // new hostname. Keep resource path, query params the same. |   64   // new hostname. Keep resource path, query params the same. | 
|   66   GURL::Replacements replacements; |   65   GURL::Replacements replacements; | 
|   67   replacements.SetHostStr(www_mismatch_hostname); |   66   replacements.SetHostStr(www_mismatch_hostname); | 
|   68   *suggested_url = request_url.ReplaceComponents(replacements); |   67   *suggested_url = request_url.ReplaceComponents(replacements); | 
|   69   return true; |   68   return true; | 
|   70 } |   69 } | 
| (...skipping 24 matching lines...) Expand all  Loading... | 
|   95       landing_url.host() != request_url_.host()) { |   94       landing_url.host() != request_url_.host()) { | 
|   96     result = SUGGESTED_URL_AVAILABLE; |   95     result = SUGGESTED_URL_AVAILABLE; | 
|   97   } |   96   } | 
|   98   url_fetcher_.reset(); |   97   url_fetcher_.reset(); | 
|   99   base::ResetAndReturn(&check_url_callback_).Run(result, suggested_url); |   98   base::ResetAndReturn(&check_url_callback_).Run(result, suggested_url); | 
|  100 } |   99 } | 
|  101  |  100  | 
|  102 bool CommonNameMismatchHandler::IsCheckingSuggestedUrl() const { |  101 bool CommonNameMismatchHandler::IsCheckingSuggestedUrl() const { | 
|  103   return url_fetcher_; |  102   return url_fetcher_; | 
|  104 } |  103 } | 
| OLD | NEW |