Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(291)

Side by Side Diff: chrome/browser/ssl/ssl_error_handler.cc

Issue 819443003: Add finch gate for captive portal interstitial. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix unit tests Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/ssl_error_handler.h" 5 #include "chrome/browser/ssl/ssl_error_handler.h"
6 6
7 #include "base/metrics/field_trial.h" 7 #include "base/metrics/field_trial.h"
8 #include "base/metrics/histogram.h" 8 #include "base/metrics/histogram.h"
9 #include "base/time/time.h" 9 #include "base/time/time.h"
10 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 64
65 case SSLErrorHandler::NORMAL: 65 case SSLErrorHandler::NORMAL:
66 return base::TimeDelta::FromSeconds( 66 return base::TimeDelta::FromSeconds(
67 kDefaultInterstitialDisplayDelayInSeconds); 67 kDefaultInterstitialDisplayDelayInSeconds);
68 68
69 default: 69 default:
70 NOTREACHED(); 70 NOTREACHED();
71 } 71 }
72 return base::TimeDelta(); 72 return base::TimeDelta();
73 } 73 }
74
75 bool IsCaptivePortalInterstitialEnabled() {
76 return base::FieldTrialList::FindFullName("CaptivePortalInterstitial") ==
77 "Enabled";
78 }
74 #endif 79 #endif
75 80
76 } // namespace 81 } // namespace
77 82
78 DEFINE_WEB_CONTENTS_USER_DATA_KEY(SSLErrorHandler); 83 DEFINE_WEB_CONTENTS_USER_DATA_KEY(SSLErrorHandler);
79 84
80 void SSLErrorHandler::HandleSSLError( 85 void SSLErrorHandler::HandleSSLError(
81 content::WebContents* web_contents, 86 content::WebContents* web_contents,
82 int cert_error, 87 int cert_error,
83 const net::SSLInfo& ssl_info, 88 const net::SSLInfo& ssl_info,
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 #endif 141 #endif
137 } 142 }
138 143
139 SSLErrorHandler::~SSLErrorHandler() { 144 SSLErrorHandler::~SSLErrorHandler() {
140 } 145 }
141 146
142 void SSLErrorHandler::StartHandlingError() { 147 void SSLErrorHandler::StartHandlingError() {
143 RecordUMA(HANDLE_ALL); 148 RecordUMA(HANDLE_ALL);
144 149
145 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION) 150 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION)
146 CheckForCaptivePortal(); 151 if (IsCaptivePortalInterstitialEnabled()) {
147 timer_.Start(FROM_HERE, 152 CheckForCaptivePortal();
148 GetInterstitialDisplayDelay(g_interstitial_delay_type), 153 timer_.Start(FROM_HERE,
149 this, &SSLErrorHandler::OnTimerExpired); 154 GetInterstitialDisplayDelay(g_interstitial_delay_type),
150 if (g_timer_started_callback) 155 this, &SSLErrorHandler::OnTimerExpired);
151 g_timer_started_callback->Run(web_contents_); 156 if (g_timer_started_callback)
152 #else 157 g_timer_started_callback->Run(web_contents_);
158 return;
159 }
160 #endif
153 // Display an SSL interstitial. 161 // Display an SSL interstitial.
154 ShowSSLInterstitial(); 162 ShowSSLInterstitial();
155 #endif
156 } 163 }
157 164
158 void SSLErrorHandler::OnTimerExpired() { 165 void SSLErrorHandler::OnTimerExpired() {
159 ShowSSLInterstitial(); 166 ShowSSLInterstitial();
160 } 167 }
161 168
162 void SSLErrorHandler::CheckForCaptivePortal() { 169 void SSLErrorHandler::CheckForCaptivePortal() {
163 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION) 170 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION)
164 Profile* profile = Profile::FromBrowserContext( 171 Profile* profile = Profile::FromBrowserContext(
165 web_contents_->GetBrowserContext()); 172 web_contents_->GetBrowserContext());
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 timer_.Stop(); 215 timer_.Stop();
209 CaptivePortalService::Results* results = 216 CaptivePortalService::Results* results =
210 content::Details<CaptivePortalService::Results>(details).ptr(); 217 content::Details<CaptivePortalService::Results>(details).ptr();
211 if (results->result == captive_portal::RESULT_BEHIND_CAPTIVE_PORTAL) 218 if (results->result == captive_portal::RESULT_BEHIND_CAPTIVE_PORTAL)
212 ShowCaptivePortalInterstitial(); 219 ShowCaptivePortalInterstitial();
213 else 220 else
214 ShowSSLInterstitial(); 221 ShowSSLInterstitial();
215 } 222 }
216 #endif 223 #endif
217 } 224 }
OLDNEW
« no previous file with comments | « chrome/browser/captive_portal/captive_portal_browsertest.cc ('k') | chrome/browser/ssl/ssl_error_handler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698