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

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

Issue 2842833003: Update SupportsUserData uses with unique_ptr. (Closed)
Patch Set: rebase Created 3 years, 7 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 <unordered_set> 8 #include <unordered_set>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 const int64_t kInterstitialDelayInMilliseconds = 3000; 70 const int64_t kInterstitialDelayInMilliseconds = 3000;
71 71
72 const char kHistogram[] = "interstitial.ssl_error_handler"; 72 const char kHistogram[] = "interstitial.ssl_error_handler";
73 73
74 // Adds a message to console after navigation commits and then, deletes itself. 74 // Adds a message to console after navigation commits and then, deletes itself.
75 // Also deletes itself if the navigation is stopped. 75 // Also deletes itself if the navigation is stopped.
76 class CommonNameMismatchRedirectObserver 76 class CommonNameMismatchRedirectObserver
77 : public content::WebContentsObserver, 77 : public content::WebContentsObserver,
78 public content::WebContentsUserData<CommonNameMismatchRedirectObserver> { 78 public content::WebContentsUserData<CommonNameMismatchRedirectObserver> {
79 public: 79 public:
80 ~CommonNameMismatchRedirectObserver() override {}
81
80 static void AddToConsoleAfterNavigation( 82 static void AddToConsoleAfterNavigation(
81 content::WebContents* web_contents, 83 content::WebContents* web_contents,
82 const std::string& request_url_hostname, 84 const std::string& request_url_hostname,
83 const std::string& suggested_url_hostname) { 85 const std::string& suggested_url_hostname) {
84 web_contents->SetUserData( 86 web_contents->SetUserData(
85 UserDataKey(), 87 UserDataKey(),
86 new CommonNameMismatchRedirectObserver( 88 base::WrapUnique(new CommonNameMismatchRedirectObserver(
87 web_contents, request_url_hostname, suggested_url_hostname)); 89 web_contents, request_url_hostname, suggested_url_hostname)));
88 } 90 }
89 91
90 private: 92 private:
91 CommonNameMismatchRedirectObserver(content::WebContents* web_contents, 93 CommonNameMismatchRedirectObserver(content::WebContents* web_contents,
92 const std::string& request_url_hostname, 94 const std::string& request_url_hostname,
93 const std::string& suggested_url_hostname) 95 const std::string& suggested_url_hostname)
94 : WebContentsObserver(web_contents), 96 : WebContentsObserver(web_contents),
95 web_contents_(web_contents), 97 web_contents_(web_contents),
96 request_url_hostname_(request_url_hostname), 98 request_url_hostname_(request_url_hostname),
97 suggested_url_hostname_(suggested_url_hostname) {} 99 suggested_url_hostname_(suggested_url_hostname) {}
98 ~CommonNameMismatchRedirectObserver() override {}
99 100
100 // WebContentsObserver: 101 // WebContentsObserver:
101 void NavigationStopped() override { 102 void NavigationStopped() override {
102 // Deletes |this|. 103 // Deletes |this|.
103 web_contents_->RemoveUserData(UserDataKey()); 104 web_contents_->RemoveUserData(UserDataKey());
104 } 105 }
105 106
106 void NavigationEntryCommitted( 107 void NavigationEntryCommitted(
107 const content::LoadCommittedDetails& /* load_details */) override { 108 const content::LoadCommittedDetails& /* load_details */) override {
108 web_contents_->GetMainFrame()->AddMessageToConsole( 109 web_contents_->GetMainFrame()->AddMessageToConsole(
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
462 463
463 Profile* profile = 464 Profile* profile =
464 Profile::FromBrowserContext(web_contents->GetBrowserContext()); 465 Profile::FromBrowserContext(web_contents->GetBrowserContext());
465 466
466 SSLErrorHandler* error_handler = new SSLErrorHandler( 467 SSLErrorHandler* error_handler = new SSLErrorHandler(
467 std::unique_ptr<SSLErrorHandler::Delegate>( 468 std::unique_ptr<SSLErrorHandler::Delegate>(
468 new SSLErrorHandlerDelegateImpl( 469 new SSLErrorHandlerDelegateImpl(
469 web_contents, ssl_info, profile, cert_error, options_mask, 470 web_contents, ssl_info, profile, cert_error, options_mask,
470 request_url, std::move(ssl_cert_reporter), callback)), 471 request_url, std::move(ssl_cert_reporter), callback)),
471 web_contents, profile, cert_error, ssl_info, request_url, callback); 472 web_contents, profile, cert_error, ssl_info, request_url, callback);
472 web_contents->SetUserData(UserDataKey(), error_handler); 473 web_contents->SetUserData(UserDataKey(), base::WrapUnique(error_handler));
473 error_handler->StartHandlingError(); 474 error_handler->StartHandlingError();
474 } 475 }
475 476
476 // static 477 // static
477 void SSLErrorHandler::ResetConfigForTesting() { 478 void SSLErrorHandler::ResetConfigForTesting() {
478 g_config.Pointer()->ResetForTesting(); 479 g_config.Pointer()->ResetForTesting();
479 } 480 }
480 481
481 // static 482 // static
482 void SSLErrorHandler::SetInterstitialDelayForTesting( 483 void SSLErrorHandler::SetInterstitialDelayForTesting(
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
771 network_time::NetworkTimeTracker* tracker = 772 network_time::NetworkTimeTracker* tracker =
772 g_config.Pointer()->network_time_tracker(); 773 g_config.Pointer()->network_time_tracker();
773 ssl_errors::ClockState clock_state = ssl_errors::GetClockState(now, tracker); 774 ssl_errors::ClockState clock_state = ssl_errors::GetClockState(now, tracker);
774 if (clock_state == ssl_errors::CLOCK_STATE_FUTURE || 775 if (clock_state == ssl_errors::CLOCK_STATE_FUTURE ||
775 clock_state == ssl_errors::CLOCK_STATE_PAST) { 776 clock_state == ssl_errors::CLOCK_STATE_PAST) {
776 ShowBadClockInterstitial(now, clock_state); 777 ShowBadClockInterstitial(now, clock_state);
777 return; // |this| is deleted after showing the interstitial. 778 return; // |this| is deleted after showing the interstitial.
778 } 779 }
779 ShowSSLInterstitial(); 780 ShowSSLInterstitial();
780 } 781 }
OLDNEW
« no previous file with comments | « chrome/browser/ssl/ssl_error_handler.h ('k') | chrome/browser/supervised_user/supervised_user_interstitial.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698