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

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

Issue 1317593002: Have SSLErrorHandler decide which type of interstitial to display (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: typo Created 5 years, 3 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
« no previous file with comments | « chrome/browser/ssl/ssl_error_classification.h ('k') | chrome/browser/ssl/ssl_error_handler.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <vector> 5 #include <vector>
6 6
7 #include "chrome/browser/ssl/ssl_error_classification.h" 7 #include "chrome/browser/ssl/ssl_error_classification.h"
8 8
9 #include "base/build_time.h" 9 #include "base/build_time.h"
10 #include "base/metrics/field_trial.h" 10 #include "base/metrics/field_trial.h"
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 int cost = str1[i] == str2[j] ? 0 : 1; 110 int cost = str1[i] == str2[j] ? 0 : 1;
111 kSecondRow[j+1] = std::min(std::min( 111 kSecondRow[j+1] = std::min(std::min(
112 kSecondRow[j] + 1, kFirstRow[j + 1] + 1), kFirstRow[j] + cost); 112 kSecondRow[j] + 1, kFirstRow[j + 1] + 1), kFirstRow[j] + cost);
113 } 113 }
114 for (size_t j = 0; j < kFirstRow.size(); j++) 114 for (size_t j = 0; j < kFirstRow.size(); j++)
115 kFirstRow[j] = kSecondRow[j]; 115 kFirstRow[j] = kSecondRow[j];
116 } 116 }
117 return kSecondRow[str2.size()]; 117 return kSecondRow[str2.size()];
118 } 118 }
119 119
120 // The time to use when doing build time operations in browser tests.
121 base::Time g_testing_build_time;
122
120 } // namespace 123 } // namespace
121 124
122 SSLErrorClassification::SSLErrorClassification( 125 SSLErrorClassification::SSLErrorClassification(
123 content::WebContents* web_contents, 126 content::WebContents* web_contents,
124 const base::Time& current_time, 127 const base::Time& current_time,
125 const GURL& url, 128 const GURL& url,
126 int cert_error, 129 int cert_error,
127 const net::X509Certificate& cert) 130 const net::X509Certificate& cert)
128 : web_contents_(web_contents), 131 : web_contents_(web_contents),
129 current_time_(current_time), 132 current_time_(current_time),
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 net::NetworkChangeNotifier::GetConnectionType(), 238 net::NetworkChangeNotifier::GetConnectionType(),
236 net::NetworkChangeNotifier::CONNECTION_LAST); 239 net::NetworkChangeNotifier::CONNECTION_LAST);
237 } 240 }
238 241
239 base::TimeDelta SSLErrorClassification::TimePassedSinceExpiry() const { 242 base::TimeDelta SSLErrorClassification::TimePassedSinceExpiry() const {
240 base::TimeDelta delta = current_time_ - cert_.valid_expiry(); 243 base::TimeDelta delta = current_time_ - cert_.valid_expiry();
241 return delta; 244 return delta;
242 } 245 }
243 246
244 bool SSLErrorClassification::IsUserClockInThePast(const base::Time& time_now) { 247 bool SSLErrorClassification::IsUserClockInThePast(const base::Time& time_now) {
248 base::Time build_time;
249 if (!g_testing_build_time.is_null()) {
250 build_time = g_testing_build_time;
251 } else {
245 #if defined(DONT_EMBED_BUILD_METADATA) && !defined(OFFICIAL_BUILD) 252 #if defined(DONT_EMBED_BUILD_METADATA) && !defined(OFFICIAL_BUILD)
246 return false; 253 return false;
247 #else 254 #else
248 base::Time build_time = base::GetBuildTime(); 255 build_time = base::GetBuildTime();
256 #endif
257 }
258
249 if (time_now < build_time - base::TimeDelta::FromDays(2)) 259 if (time_now < build_time - base::TimeDelta::FromDays(2))
250 return true; 260 return true;
251 return false; 261 return false;
252 #endif
253 } 262 }
254 263
255 bool SSLErrorClassification::IsUserClockInTheFuture( 264 bool SSLErrorClassification::IsUserClockInTheFuture(
256 const base::Time& time_now) { 265 const base::Time& time_now) {
266 base::Time build_time;
267 if (!g_testing_build_time.is_null()) {
268 build_time = g_testing_build_time;
269 } else {
257 #if defined(DONT_EMBED_BUILD_METADATA) && !defined(OFFICIAL_BUILD) 270 #if defined(DONT_EMBED_BUILD_METADATA) && !defined(OFFICIAL_BUILD)
258 return false; 271 return false;
259 #else 272 #else
260 base::Time build_time = base::GetBuildTime(); 273 build_time = base::GetBuildTime();
274 #endif
275 }
276
261 if (time_now > build_time + base::TimeDelta::FromDays(365)) 277 if (time_now > build_time + base::TimeDelta::FromDays(365))
262 return true; 278 return true;
263 return false; 279 return false;
264 #endif 280 }
281
282 // static
283 void SSLErrorClassification::SetBuildTimeForTesting(
284 const base::Time& testing_time) {
285 g_testing_build_time = testing_time;
265 } 286 }
266 287
267 bool SSLErrorClassification::MaybeWindowsLacksSHA256Support() { 288 bool SSLErrorClassification::MaybeWindowsLacksSHA256Support() {
268 #if defined(OS_WIN) 289 #if defined(OS_WIN)
269 return !base::win::MaybeHasSHA256Support(); 290 return !base::win::MaybeHasSHA256Support();
270 #else 291 #else
271 return false; 292 return false;
272 #endif 293 #endif
273 } 294 }
274 295
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
529 // sure we don't clear the captive protal flag, since the interstitial was 550 // sure we don't clear the captive protal flag, since the interstitial was
530 // potentially caused by the captive portal. 551 // potentially caused by the captive portal.
531 captive_portal_detected_ = captive_portal_detected_ || 552 captive_portal_detected_ = captive_portal_detected_ ||
532 (results->result == captive_portal::RESULT_BEHIND_CAPTIVE_PORTAL); 553 (results->result == captive_portal::RESULT_BEHIND_CAPTIVE_PORTAL);
533 // Also keep track of non-HTTP portals and error cases. 554 // Also keep track of non-HTTP portals and error cases.
534 captive_portal_no_response_ = captive_portal_no_response_ || 555 captive_portal_no_response_ = captive_portal_no_response_ ||
535 (results->result == captive_portal::RESULT_NO_RESPONSE); 556 (results->result == captive_portal::RESULT_NO_RESPONSE);
536 } 557 }
537 #endif 558 #endif
538 } 559 }
OLDNEW
« no previous file with comments | « chrome/browser/ssl/ssl_error_classification.h ('k') | chrome/browser/ssl/ssl_error_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698