Chromium Code Reviews| Index: chrome/browser/ssl/common_name_mismatch_handler.h |
| diff --git a/chrome/browser/ssl/common_name_mismatch_handler.h b/chrome/browser/ssl/common_name_mismatch_handler.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..c3999360ef47c0df5deefd9a22ad6d637c9136e6 |
| --- /dev/null |
| +++ b/chrome/browser/ssl/common_name_mismatch_handler.h |
| @@ -0,0 +1,87 @@ |
| +// Copyright (c) 2015 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CHROME_BROWSER_SSL_COMMON_NAME_MISMATCH_HANDLER_H_ |
| +#define CHROME_BROWSER_SSL_COMMON_NAME_MISMATCH_HANDLER_H_ |
| + |
| +#include "base/basictypes.h" |
| +#include "base/callback.h" |
| +#include "base/compiler_specific.h" |
| +#include "base/memory/ref_counted.h" |
| +#include "base/memory/scoped_ptr.h" |
| +#include "base/threading/non_thread_safe.h" |
| +#include "base/time/time.h" |
| +#include "net/url_request/url_fetcher.h" |
| +#include "net/url_request/url_fetcher_delegate.h" |
| +#include "net/url_request/url_request_context_getter.h" |
| + |
| +class GURL; |
| + |
| +// This class contains methods to get a suggested url when there |
|
palmer
2015/07/09 19:13:01
"url" -> "URL" through this file.
"there is a ssl
Bhanu Dev
2015/07/11 04:00:43
Done.
|
| +// is a ssl common name invalid error and has methods to perform |
| +// a network request to check validity of new url. |
| +class CommonNameMismatchHandler : public net::URLFetcherDelegate, |
| + public base::NonThreadSafe { |
| + public: |
| + // Possible results of the validity of suggested url |
|
palmer
2015/07/09 19:13:01
This comment is (IMO) superfluous.
Bhanu Dev
2015/07/11 04:00:43
Done.
|
| + enum SuggestedUrlCheckResult { |
| + // The request succeeds with good response code i.e. url exists and its |
| + // cert. is valid . |
|
meacer
2015/07/09 17:58:55
nit: cert -> certificate. Remove space before the
Bhanu Dev
2015/07/11 04:00:42
Done.
|
| + RESULT_SUGGESTED_URL_VALID, |
| + // Suggested url is invalid |
| + RESULT_SUGGESTED_URL_INVALID |
| + }; |
| + |
| + struct Results { |
| + Results() : result(RESULT_SUGGESTED_URL_INVALID) {} |
| + |
| + SuggestedUrlCheckResult result; |
| + GURL new_url; |
|
meacer
2015/07/09 17:58:55
You need to include gurl.h instead of fwd declare,
Bhanu Dev
2015/07/11 04:00:42
Done.
|
| + }; |
| + |
| + typedef base::Callback<void(const Results& results)> CheckUrlCallback; |
| + |
| + explicit CommonNameMismatchHandler( |
| + const scoped_refptr<net::URLRequestContextGetter>& request_context); |
| + ~CommonNameMismatchHandler() override; |
| + |
| + // Triggers an check to validate suggested url. After completion, runs the |
|
meacer
2015/07/09 17:58:55
an check -> a check
Bhanu Dev
2015/07/11 04:00:43
Done.
|
| + // |callback|. |
| + void CheckSuggestedUrl(const GURL& url, |
| + const CheckUrlCallback& CheckUrlcallback); |
| + |
| + // Cancels the suggested url validity check. |
| + void CancelUrlCheck(); |
|
meacer
2015/07/09 17:58:55
I don't think you'll need this, so I suggest remov
Bhanu Dev
2015/07/11 04:00:42
Done.
|
| + |
| + // This method returns a bool indicating whether the error can be handled. |
|
palmer
2015/07/09 19:13:01
Be more concise: "Returns true if the error can be
Bhanu Dev
2015/07/11 04:00:42
Done.
|
| + // It interacts with the SslErrorClassification class to find the cause |
| + // of ssl error and generates suggested url if this error can be handled. |
| + static bool GetSuggestedUrl(const GURL request_url, |
|
palmer
2015/07/09 19:13:01
Pass by reference to avoid an unnecessary copy: co
Bhanu Dev
2015/07/11 04:00:42
Done.
|
| + const std::vector<std::string>& dns_names, |
| + GURL& suggested_url); |
|
palmer
2015/07/09 19:13:01
In Chromium style, output parameters ("out-params"
Bhanu Dev
2015/07/11 04:00:43
Done.
|
| + |
| + private: |
| + // net::URLFetcherDelegate: |
| + void OnURLFetchComplete(const net::URLFetcher* source) override; |
| + |
| + // Takes a net::URLFetcher that has finished trying to retrieve the |
| + // suggested URL, and fills a Results struct based on its result. |
|
palmer
2015/07/09 19:13:01
Use |...| to delineate C++ identifiers.
Bhanu Dev
2015/07/11 04:00:43
Done.
|
| + void GetSuggestedUrlCheckResult(const net::URLFetcher* url_fetcher, |
|
palmer
2015/07/09 19:13:01
Maybe const net::URLFetcher& instead of * ?
|
| + Results* results) const; |
| + |
| + // Returns true if the check is currently running. |
| + bool CheckingSuggestedUrl() const; |
| + |
| + // URL request context. |
|
palmer
2015/07/09 19:13:01
This comment is superfluous.
Bhanu Dev
2015/07/11 04:00:43
Done.
|
| + scoped_refptr<net::URLRequestContextGetter> request_context_; |
| + |
| + // Contains the callback method for urlfetch. |
|
palmer
2015/07/09 19:13:01
This comment is superfluous.
Bhanu Dev
2015/07/11 04:00:43
Done.
|
| + CheckUrlCallback check_url_callback_; |
| + |
| + scoped_ptr<net::URLFetcher> url_fetcher_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(CommonNameMismatchHandler); |
| +}; |
| + |
| +#endif // CHROME_BROWSER_SSL_COMMON_NAME_MISMATCH_HANDLER_H_ |