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

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

Issue 1551503002: Convert Pass()→std::move() in //chrome (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 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 <stdint.h> 7 #include <stdint.h>
8 #include <utility>
8 9
9 #include "base/callback_helpers.h" 10 #include "base/callback_helpers.h"
10 #include "base/macros.h" 11 #include "base/macros.h"
11 #include "base/metrics/field_trial.h" 12 #include "base/metrics/field_trial.h"
12 #include "base/metrics/histogram.h" 13 #include "base/metrics/histogram.h"
13 #include "base/strings/stringprintf.h" 14 #include "base/strings/stringprintf.h"
14 #include "base/time/clock.h" 15 #include "base/time/clock.h"
15 #include "base/time/time.h" 16 #include "base/time/time.h"
16 #include "chrome/browser/profiles/profile.h" 17 #include "chrome/browser/profiles/profile.h"
17 #include "chrome/browser/ssl/bad_clock_blocking_page.h" 18 #include "chrome/browser/ssl/bad_clock_blocking_page.h"
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 content::WebContents* web_contents, 154 content::WebContents* web_contents,
154 int cert_error, 155 int cert_error,
155 const net::SSLInfo& ssl_info, 156 const net::SSLInfo& ssl_info,
156 const GURL& request_url, 157 const GURL& request_url,
157 int options_mask, 158 int options_mask,
158 scoped_ptr<SSLCertReporter> ssl_cert_reporter, 159 scoped_ptr<SSLCertReporter> ssl_cert_reporter,
159 const base::Callback<void(bool)>& callback) { 160 const base::Callback<void(bool)>& callback) {
160 DCHECK(!FromWebContents(web_contents)); 161 DCHECK(!FromWebContents(web_contents));
161 SSLErrorHandler* error_handler = 162 SSLErrorHandler* error_handler =
162 new SSLErrorHandler(web_contents, cert_error, ssl_info, request_url, 163 new SSLErrorHandler(web_contents, cert_error, ssl_info, request_url,
163 options_mask, ssl_cert_reporter.Pass(), callback); 164 options_mask, std::move(ssl_cert_reporter), callback);
164 web_contents->SetUserData(UserDataKey(), error_handler); 165 web_contents->SetUserData(UserDataKey(), error_handler);
165 error_handler->StartHandlingError(); 166 error_handler->StartHandlingError();
166 } 167 }
167 168
168 // static 169 // static
169 void SSLErrorHandler::SetInterstitialDelayForTest(base::TimeDelta delay) { 170 void SSLErrorHandler::SetInterstitialDelayForTest(base::TimeDelta delay) {
170 g_interstitial_delay_in_milliseconds = delay.InMilliseconds(); 171 g_interstitial_delay_in_milliseconds = delay.InMilliseconds();
171 } 172 }
172 173
173 // static 174 // static
(...skipping 16 matching lines...) Expand all
190 scoped_ptr<SSLCertReporter> ssl_cert_reporter, 191 scoped_ptr<SSLCertReporter> ssl_cert_reporter,
191 const base::Callback<void(bool)>& callback) 192 const base::Callback<void(bool)>& callback)
192 : content::WebContentsObserver(web_contents), 193 : content::WebContentsObserver(web_contents),
193 web_contents_(web_contents), 194 web_contents_(web_contents),
194 cert_error_(cert_error), 195 cert_error_(cert_error),
195 ssl_info_(ssl_info), 196 ssl_info_(ssl_info),
196 request_url_(request_url), 197 request_url_(request_url),
197 options_mask_(options_mask), 198 options_mask_(options_mask),
198 callback_(callback), 199 callback_(callback),
199 profile_(Profile::FromBrowserContext(web_contents->GetBrowserContext())), 200 profile_(Profile::FromBrowserContext(web_contents->GetBrowserContext())),
200 ssl_cert_reporter_(ssl_cert_reporter.Pass()) {} 201 ssl_cert_reporter_(std::move(ssl_cert_reporter)) {}
201 202
202 SSLErrorHandler::~SSLErrorHandler() { 203 SSLErrorHandler::~SSLErrorHandler() {
203 } 204 }
204 205
205 void SSLErrorHandler::StartHandlingError() { 206 void SSLErrorHandler::StartHandlingError() {
206 RecordUMA(HANDLE_ALL); 207 RecordUMA(HANDLE_ALL);
207 208
208 const base::Time now = g_testing_clock == nullptr 209 const base::Time now = g_testing_clock == nullptr
209 ? base::Time::NowFromSystemTime() 210 ? base::Time::NowFromSystemTime()
210 : g_testing_clock->Now(); 211 : g_testing_clock->Now();
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 return SSLBlockingPage::IsOverridable(options_mask_, profile_); 308 return SSLBlockingPage::IsOverridable(options_mask_, profile_);
308 } 309 }
309 310
310 void SSLErrorHandler::ShowCaptivePortalInterstitial(const GURL& landing_url) { 311 void SSLErrorHandler::ShowCaptivePortalInterstitial(const GURL& landing_url) {
311 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION) 312 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION)
312 // Show captive portal blocking page. The interstitial owns the blocking page. 313 // Show captive portal blocking page. The interstitial owns the blocking page.
313 RecordUMA(IsErrorOverridable() 314 RecordUMA(IsErrorOverridable()
314 ? SHOW_CAPTIVE_PORTAL_INTERSTITIAL_OVERRIDABLE 315 ? SHOW_CAPTIVE_PORTAL_INTERSTITIAL_OVERRIDABLE
315 : SHOW_CAPTIVE_PORTAL_INTERSTITIAL_NONOVERRIDABLE); 316 : SHOW_CAPTIVE_PORTAL_INTERSTITIAL_NONOVERRIDABLE);
316 (new CaptivePortalBlockingPage(web_contents_, request_url_, landing_url, 317 (new CaptivePortalBlockingPage(web_contents_, request_url_, landing_url,
317 ssl_cert_reporter_.Pass(), ssl_info_, 318 std::move(ssl_cert_reporter_), ssl_info_,
318 callback_))->Show(); 319 callback_))
320 ->Show();
319 // Once an interstitial is displayed, no need to keep the handler around. 321 // Once an interstitial is displayed, no need to keep the handler around.
320 // This is the equivalent of "delete this". It also destroys the timer. 322 // This is the equivalent of "delete this". It also destroys the timer.
321 web_contents_->RemoveUserData(UserDataKey()); 323 web_contents_->RemoveUserData(UserDataKey());
322 #else 324 #else
323 NOTREACHED(); 325 NOTREACHED();
324 #endif 326 #endif
325 } 327 }
326 328
327 void SSLErrorHandler::ShowSSLInterstitial() { 329 void SSLErrorHandler::ShowSSLInterstitial() {
328 // Show SSL blocking page. The interstitial owns the blocking page. 330 // Show SSL blocking page. The interstitial owns the blocking page.
329 RecordUMA(IsErrorOverridable() ? SHOW_SSL_INTERSTITIAL_OVERRIDABLE 331 RecordUMA(IsErrorOverridable() ? SHOW_SSL_INTERSTITIAL_OVERRIDABLE
330 : SHOW_SSL_INTERSTITIAL_NONOVERRIDABLE); 332 : SHOW_SSL_INTERSTITIAL_NONOVERRIDABLE);
331 333
332 (new SSLBlockingPage(web_contents_, cert_error_, ssl_info_, request_url_, 334 (new SSLBlockingPage(web_contents_, cert_error_, ssl_info_, request_url_,
333 options_mask_, base::Time::NowFromSystemTime(), 335 options_mask_, base::Time::NowFromSystemTime(),
334 ssl_cert_reporter_.Pass(), callback_)) 336 std::move(ssl_cert_reporter_), callback_))
335 ->Show(); 337 ->Show();
336 // Once an interstitial is displayed, no need to keep the handler around. 338 // Once an interstitial is displayed, no need to keep the handler around.
337 // This is the equivalent of "delete this". 339 // This is the equivalent of "delete this".
338 web_contents_->RemoveUserData(UserDataKey()); 340 web_contents_->RemoveUserData(UserDataKey());
339 } 341 }
340 342
341 void SSLErrorHandler::ShowBadClockInterstitial(const base::Time& now) { 343 void SSLErrorHandler::ShowBadClockInterstitial(const base::Time& now) {
342 RecordUMA(SHOW_BAD_CLOCK); 344 RecordUMA(SHOW_BAD_CLOCK);
343 (new BadClockBlockingPage(web_contents_, cert_error_, ssl_info_, request_url_, 345 (new BadClockBlockingPage(web_contents_, cert_error_, ssl_info_, request_url_,
344 now, ssl_cert_reporter_.Pass(), callback_)) 346 now, std::move(ssl_cert_reporter_), callback_))
345 ->Show(); 347 ->Show();
346 // Once an interstitial is displayed, no need to keep the handler around. 348 // Once an interstitial is displayed, no need to keep the handler around.
347 // This is the equivalent of "delete this". 349 // This is the equivalent of "delete this".
348 web_contents_->RemoveUserData(UserDataKey()); 350 web_contents_->RemoveUserData(UserDataKey());
349 } 351 }
350 352
351 void SSLErrorHandler::CommonNameMismatchHandlerCallback( 353 void SSLErrorHandler::CommonNameMismatchHandlerCallback(
352 const CommonNameMismatchHandler::SuggestedUrlCheckResult& result, 354 const CommonNameMismatchHandler::SuggestedUrlCheckResult& result,
353 const GURL& suggested_url) { 355 const GURL& suggested_url) {
354 timer_.Stop(); 356 timer_.Stop();
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 if (!callback_.is_null()) { 403 if (!callback_.is_null()) {
402 base::ResetAndReturn(&callback_).Run(false); 404 base::ResetAndReturn(&callback_).Run(false);
403 } 405 }
404 if (common_name_mismatch_handler_) { 406 if (common_name_mismatch_handler_) {
405 common_name_mismatch_handler_->Cancel(); 407 common_name_mismatch_handler_->Cancel();
406 common_name_mismatch_handler_.reset(); 408 common_name_mismatch_handler_.reset();
407 } 409 }
408 // Deletes |this| and also destroys the timer. 410 // Deletes |this| and also destroys the timer.
409 web_contents_->RemoveUserData(UserDataKey()); 411 web_contents_->RemoveUserData(UserDataKey());
410 } 412 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698