Index: chrome/browser/ssl/ssl_error_handler.cc |
diff --git a/chrome/browser/ssl/ssl_error_handler.cc b/chrome/browser/ssl/ssl_error_handler.cc |
index adeac656ee511246ced3116bbb536808a32fe1b1..357f5e87a96181aec0dc59732ab7de292b257996 100644 |
--- a/chrome/browser/ssl/ssl_error_handler.cc |
+++ b/chrome/browser/ssl/ssl_error_handler.cc |
@@ -11,6 +11,7 @@ |
#include "chrome/browser/profiles/profile.h" |
#include "chrome/browser/ssl/ssl_blocking_page.h" |
#include "chrome/browser/ssl/ssl_cert_reporter.h" |
+#include "chrome/browser/ssl/ssl_error_classification.h" |
#include "content/public/browser/notification_service.h" |
#include "content/public/browser/notification_source.h" |
#include "content/public/browser/web_contents.h" |
@@ -150,9 +151,40 @@ SSLErrorHandler::SSLErrorHandler(content::WebContents* web_contents, |
SSLErrorHandler::~SSLErrorHandler() { |
} |
+bool IsCommonNameMismatchHandlerEnabled() { |
+ // Add finch trail later. |
+ return 1; |
meacer
2015/07/09 17:58:56
|return true| instead of 1. Actually, just remove
Bhanu Dev
2015/07/11 04:00:43
Done.
|
+} |
+ |
void SSLErrorHandler::StartHandlingError() { |
RecordUMA(HANDLE_ALL); |
+ if (IsCommonNameMismatchHandlerEnabled()) { |
+ std::vector<std::string> dns_names; |
+ ssl_info_.cert->GetDNSNames(&dns_names); |
+ DCHECK(!dns_names.empty()); |
meacer
2015/07/09 17:58:56
I feel that dns_names can actually be empty, so no
Bhanu Dev
2015/07/11 04:00:43
|dns_names| contains the DNS names in SAN field or
|
+ GURL suggested_url; |
+ if (CommonNameMismatchHandler::GetSuggestedUrl(request_url_, dns_names, |
+ suggested_url)) { |
+ Profile* profile = |
+ Profile::FromBrowserContext(web_contents_->GetBrowserContext()); |
+ scoped_refptr<net::URLRequestContextGetter> request_context( |
+ profile->GetRequestContext()); |
+ common_name_mismatch_handler_.reset( |
+ new CommonNameMismatchHandler(request_context)); |
+ common_name_mismatch_handler_->CheckSuggestedUrl( |
+ suggested_url, |
+ base::Bind(&SSLErrorHandler::CommonNameMismatchHandlerCallback, |
+ base::Unretained(this))); |
+ timer_.Start(FROM_HERE, base::TimeDelta::FromSeconds( |
+ common_name_handler_delay_in_seconds), |
+ this, &SSLErrorHandler::OnTimerExpired); |
+ if (g_timer_started_callback) |
+ g_timer_started_callback->Run(web_contents_); |
+ return; |
+ } |
+ } |
+ |
#if defined(ENABLE_CAPTIVE_PORTAL_DETECTION) |
if (IsCaptivePortalInterstitialEnabled()) { |
CheckForCaptivePortal(); |
@@ -165,11 +197,11 @@ void SSLErrorHandler::StartHandlingError() { |
} |
#endif |
// Display an SSL interstitial. |
- ShowSSLInterstitial(); |
+ ShowSSLInterstitial(GURL()); |
} |
void SSLErrorHandler::OnTimerExpired() { |
- ShowSSLInterstitial(); |
+ ShowSSLInterstitial(GURL()); |
} |
void SSLErrorHandler::CheckForCaptivePortal() { |
@@ -203,7 +235,7 @@ void SSLErrorHandler::ShowCaptivePortalInterstitial(const GURL& landing_url) { |
#endif |
} |
-void SSLErrorHandler::ShowSSLInterstitial() { |
+void SSLErrorHandler::ShowSSLInterstitial(const GURL& suggested_url) { |
// Show SSL blocking page. The interstitial owns the blocking page. |
const Profile* const profile = |
Profile::FromBrowserContext(web_contents_->GetBrowserContext()); |
@@ -212,7 +244,8 @@ void SSLErrorHandler::ShowSSLInterstitial() { |
: SHOW_SSL_INTERSTITIAL_NONOVERRIDABLE); |
(new SSLBlockingPage(web_contents_, cert_error_, ssl_info_, request_url_, |
options_mask_, base::Time::NowFromSystemTime(), |
- ssl_cert_reporter_.Pass(), callback_))->Show(); |
+ ssl_cert_reporter_.Pass(), callback_, suggested_url)) |
+ ->Show(); |
// Once an interstitial is displayed, no need to keep the handler around. |
// This is the equivalent of "delete this". |
web_contents_->RemoveUserData(UserDataKey()); |
@@ -230,7 +263,7 @@ void SSLErrorHandler::Observe( |
if (results->result == captive_portal::RESULT_BEHIND_CAPTIVE_PORTAL) |
ShowCaptivePortalInterstitial(results->landing_url); |
else |
- ShowSSLInterstitial(); |
+ ShowSSLInterstitial(GURL()); |
} |
#endif |
} |
@@ -248,3 +281,14 @@ void SSLErrorHandler::DidStartNavigationToPendingEntry( |
} |
web_contents_->RemoveUserData(UserDataKey()); |
} |
+ |
+void SSLErrorHandler::CommonNameMismatchHandlerCallback( |
+ const CommonNameMismatchHandler::Results& results) { |
+ timer_.Stop(); |
+ if (results.result == CommonNameMismatchHandler::SuggestedUrlCheckResult:: |
+ RESULT_SUGGESTED_URL_VALID) { |
+ ShowSSLInterstitial(results.new_url); |
meacer
2015/07/09 17:58:56
For this CL, let's just record the result in a his
Bhanu Dev
2015/07/11 04:00:43
Acknowledged.
|
+ } else { |
+ ShowSSLInterstitial(GURL()); |
+ } |
+} |