| OLD | NEW |
| 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 #ifndef CHROME_BROWSER_SSL_COMMON_NAME_MISMATCH_HANDLER_H_ | 5 #ifndef CHROME_BROWSER_SSL_COMMON_NAME_MISMATCH_HANDLER_H_ |
| 6 #define CHROME_BROWSER_SSL_COMMON_NAME_MISMATCH_HANDLER_H_ | 6 #define CHROME_BROWSER_SSL_COMMON_NAME_MISMATCH_HANDLER_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 13 #include "base/threading/non_thread_safe.h" | 13 #include "base/sequence_checker.h" |
| 14 #include "base/time/time.h" | 14 #include "base/time/time.h" |
| 15 #include "net/url_request/url_fetcher.h" | 15 #include "net/url_request/url_fetcher.h" |
| 16 #include "net/url_request/url_fetcher_delegate.h" | 16 #include "net/url_request/url_fetcher_delegate.h" |
| 17 #include "net/url_request/url_request_context_getter.h" | 17 #include "net/url_request/url_request_context_getter.h" |
| 18 #include "url/gurl.h" | 18 #include "url/gurl.h" |
| 19 | 19 |
| 20 namespace net { | 20 namespace net { |
| 21 class URLFetcher; | 21 class URLFetcher; |
| 22 } | 22 } |
| 23 | 23 |
| 24 // This class handles errors due to common name mismatches | 24 // This class handles errors due to common name mismatches |
| 25 // (|ERR_CERT_COMMON_NAME_INVALID|) and helps remediate them by suggesting | 25 // (|ERR_CERT_COMMON_NAME_INVALID|) and helps remediate them by suggesting |
| 26 // alternative URLs that may be what the user intended to load. | 26 // alternative URLs that may be what the user intended to load. |
| 27 class CommonNameMismatchHandler : public net::URLFetcherDelegate, | 27 class CommonNameMismatchHandler : public net::URLFetcherDelegate { |
| 28 public base::NonThreadSafe { | |
| 29 public: | 28 public: |
| 30 enum SuggestedUrlCheckResult { | 29 enum SuggestedUrlCheckResult { |
| 31 // The request succeeds with good response code i.e. URL exists and its | 30 // The request succeeds with good response code i.e. URL exists and its |
| 32 // certificate is valid. | 31 // certificate is valid. |
| 33 SUGGESTED_URL_AVAILABLE, | 32 SUGGESTED_URL_AVAILABLE, |
| 34 // Suggested URL is either not available or has a bad certificate. | 33 // Suggested URL is either not available or has a bad certificate. |
| 35 SUGGESTED_URL_NOT_AVAILABLE | 34 SUGGESTED_URL_NOT_AVAILABLE |
| 36 }; | 35 }; |
| 37 | 36 |
| 38 enum TestingState { | 37 enum TestingState { |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 | 78 |
| 80 // Returns true if the check is currently running. | 79 // Returns true if the check is currently running. |
| 81 bool IsCheckingSuggestedUrl() const; | 80 bool IsCheckingSuggestedUrl() const; |
| 82 | 81 |
| 83 static TestingState testing_state_; | 82 static TestingState testing_state_; |
| 84 const GURL request_url_; | 83 const GURL request_url_; |
| 85 scoped_refptr<net::URLRequestContextGetter> request_context_; | 84 scoped_refptr<net::URLRequestContextGetter> request_context_; |
| 86 CheckUrlCallback check_url_callback_; | 85 CheckUrlCallback check_url_callback_; |
| 87 std::unique_ptr<net::URLFetcher> url_fetcher_; | 86 std::unique_ptr<net::URLFetcher> url_fetcher_; |
| 88 | 87 |
| 88 SEQUENCE_CHECKER(sequence_checker_); |
| 89 |
| 89 DISALLOW_COPY_AND_ASSIGN(CommonNameMismatchHandler); | 90 DISALLOW_COPY_AND_ASSIGN(CommonNameMismatchHandler); |
| 90 }; | 91 }; |
| 91 | 92 |
| 92 #endif // CHROME_BROWSER_SSL_COMMON_NAME_MISMATCH_HANDLER_H_ | 93 #endif // CHROME_BROWSER_SSL_COMMON_NAME_MISMATCH_HANDLER_H_ |
| OLD | NEW |