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

Side by Side Diff: content/browser/ssl/ssl_manager.cc

Issue 2213193005: Make SSLErrorHandler UI-thread-only and not-refcounted (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove UI-thread dereference for DCHECK Created 4 years, 4 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 | « content/browser/ssl/ssl_error_handler.cc ('k') | content/browser/ssl/ssl_policy.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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/browser/ssl/ssl_manager.h" 5 #include "content/browser/ssl/ssl_manager.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 26 matching lines...) Expand all
37 } 37 }
38 38
39 std::set<SSLManager*>& get() { return set_; } 39 std::set<SSLManager*>& get() { return set_; }
40 40
41 private: 41 private:
42 std::set<SSLManager*> set_; 42 std::set<SSLManager*> set_;
43 43
44 DISALLOW_COPY_AND_ASSIGN(SSLManagerSet); 44 DISALLOW_COPY_AND_ASSIGN(SSLManagerSet);
45 }; 45 };
46 46
47 void HandleSSLErrorOnUI(
48 const base::Callback<WebContents*(void)>& web_contents_getter,
49 const base::WeakPtr<SSLErrorHandler::Delegate>& delegate,
50 const ResourceType resource_type,
51 const GURL& url,
52 const net::SSLInfo& ssl_info,
53 bool fatal) {
54 content::WebContents* web_contents = web_contents_getter.Run();
55 std::unique_ptr<SSLErrorHandler> handler(new SSLErrorHandler(
56 web_contents, delegate, resource_type, url, ssl_info, fatal));
57
58 if (!web_contents) {
59 // Requests can fail to dispatch because they don't have a WebContents. See
60 // https://crbug.com/86537. In this case we have to make a decision in this
61 // function, so we ignore revocation check failures.
62 if (net::IsCertStatusMinorError(ssl_info.cert_status)) {
63 handler->ContinueRequest();
64 } else {
65 handler->CancelRequest();
66 }
67 return;
68 }
69
70 SSLManager* manager =
71 static_cast<NavigationControllerImpl*>(&web_contents->GetController())
72 ->ssl_manager();
73 manager->policy()->OnCertError(std::move(handler));
74 }
75
47 } // namespace 76 } // namespace
48 77
49 // static 78 // static
50 void SSLManager::OnSSLCertificateError( 79 void SSLManager::OnSSLCertificateError(
51 const base::WeakPtr<SSLErrorHandler::Delegate>& delegate, 80 const base::WeakPtr<SSLErrorHandler::Delegate>& delegate,
52 const ResourceType resource_type, 81 const ResourceType resource_type,
53 const GURL& url, 82 const GURL& url,
54 const base::Callback<WebContents*(void)>& web_contents_getter, 83 const base::Callback<WebContents*(void)>& web_contents_getter,
55 const net::SSLInfo& ssl_info, 84 const net::SSLInfo& ssl_info,
56 bool fatal) { 85 bool fatal) {
57 DCHECK(delegate.get()); 86 DCHECK(delegate.get());
58 DVLOG(1) << "OnSSLCertificateError() cert_error: " 87 DVLOG(1) << "OnSSLCertificateError() cert_error: "
59 << net::MapCertStatusToNetError(ssl_info.cert_status) 88 << net::MapCertStatusToNetError(ssl_info.cert_status)
60 << " resource_type: " << resource_type 89 << " resource_type: " << resource_type
61 << " url: " << url.spec() 90 << " url: " << url.spec()
62 << " cert_status: " << std::hex << ssl_info.cert_status; 91 << " cert_status: " << std::hex << ssl_info.cert_status;
63 92
64 // A certificate error occurred. Construct a SSLErrorHandler object and 93 // A certificate error occurred. Construct a SSLErrorHandler object
65 // hand it over to the UI thread for processing. 94 // on the UI thread for processing.
66 BrowserThread::PostTask( 95 BrowserThread::PostTask(
67 BrowserThread::UI, FROM_HERE, 96 BrowserThread::UI, FROM_HERE,
68 base::Bind( 97 base::Bind(&HandleSSLErrorOnUI, web_contents_getter, delegate,
69 &SSLErrorHandler::Dispatch, 98 resource_type, url, ssl_info, fatal));
70 new SSLErrorHandler(delegate, resource_type, url, ssl_info, fatal),
71 web_contents_getter));
72 } 99 }
73 100
74 // static 101 // static
75 void SSLManager::OnSSLCertificateSubresourceError( 102 void SSLManager::OnSSLCertificateSubresourceError(
76 const base::WeakPtr<SSLErrorHandler::Delegate>& delegate, 103 const base::WeakPtr<SSLErrorHandler::Delegate>& delegate,
77 const GURL& url, 104 const GURL& url,
78 int render_process_id, 105 int render_process_id,
79 int render_frame_id, 106 int render_frame_id,
80 const net::SSLInfo& ssl_info, 107 const net::SSLInfo& ssl_info,
81 bool fatal) { 108 bool fatal) {
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 NotifyDidChangeVisibleSSLState(); 205 NotifyDidChangeVisibleSSLState();
179 } 206 }
180 207
181 void SSLManager::NotifyDidChangeVisibleSSLState() { 208 void SSLManager::NotifyDidChangeVisibleSSLState() {
182 WebContentsImpl* contents = 209 WebContentsImpl* contents =
183 static_cast<WebContentsImpl*>(controller_->delegate()->GetWebContents()); 210 static_cast<WebContentsImpl*>(controller_->delegate()->GetWebContents());
184 contents->DidChangeVisibleSSLState(); 211 contents->DidChangeVisibleSSLState();
185 } 212 }
186 213
187 } // namespace content 214 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/ssl/ssl_error_handler.cc ('k') | content/browser/ssl/ssl_policy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698