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

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

Issue 2222003002: Combine SSLCertErrorHandler and SSLErrorHandler (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
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_error_handler.h" 5 #include "content/browser/ssl/ssl_error_handler.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "content/browser/frame_host/navigation_controller_impl.h" 8 #include "content/browser/frame_host/navigation_controller_impl.h"
9 #include "content/browser/frame_host/render_frame_host_impl.h" 9 #include "content/browser/frame_host/render_frame_host_impl.h"
10 #include "content/browser/ssl/ssl_cert_error_handler.h" 10 #include "content/browser/ssl/ssl_manager.h"
11 #include "content/browser/ssl/ssl_policy.h"
11 #include "content/browser/web_contents/web_contents_impl.h" 12 #include "content/browser/web_contents/web_contents_impl.h"
12 #include "content/public/browser/browser_thread.h" 13 #include "content/public/browser/browser_thread.h"
13 #include "content/public/browser/resource_request_info.h" 14 #include "content/public/browser/resource_request_info.h"
14 #include "net/base/net_errors.h" 15 #include "net/base/net_errors.h"
16 #include "net/cert/cert_status_flags.h"
15 #include "net/url_request/url_request.h" 17 #include "net/url_request/url_request.h"
16 18
17 using net::SSLInfo; 19 using net::SSLInfo;
18 20
19 namespace content { 21 namespace content {
20 22
21 SSLErrorHandler::SSLErrorHandler(const base::WeakPtr<Delegate>& delegate, 23 SSLErrorHandler::SSLErrorHandler(const base::WeakPtr<Delegate>& delegate,
22 ResourceType resource_type, 24 ResourceType resource_type,
23 const GURL& url) 25 const GURL& url,
26 const net::SSLInfo& ssl_info,
27 bool fatal)
24 : manager_(NULL), 28 : manager_(NULL),
25 delegate_(delegate), 29 delegate_(delegate),
30 request_has_been_notified_(false),
26 request_url_(url), 31 request_url_(url),
27 resource_type_(resource_type), 32 resource_type_(resource_type),
28 request_has_been_notified_(false) { 33 ssl_info_(ssl_info),
34 cert_error_(net::MapCertStatusToNetError(ssl_info.cert_status)),
35 fatal_(fatal) {
29 DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::UI)); 36 DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::UI));
30 DCHECK(delegate.get()); 37 DCHECK(delegate.get());
31 38
32 // This makes sure we don't disappear on the IO thread until we've given an 39 // This makes sure we don't disappear on the IO thread until we've given an
33 // answer to the net::URLRequest. 40 // answer to the net::URLRequest.
34 // 41 //
35 // Release in CompleteCancelRequest, CompleteContinueRequest, or 42 // Release in CompleteCancelRequest, CompleteContinueRequest, or
36 // CompleteTakeNoAction. 43 // CompleteTakeNoAction.
37 AddRef(); 44 AddRef();
38 } 45 }
39 46
40 SSLErrorHandler::~SSLErrorHandler() {} 47 SSLErrorHandler::~SSLErrorHandler() {}
41 48
42 void SSLErrorHandler::OnDispatchFailed() { 49 void SSLErrorHandler::OnDispatchFailed() {
43 TakeNoAction(); 50 // Requests can fail to dispatch because they don't have a WebContents. See
51 // <http://crbug.com/86537>. In this case we have to make a decision in this
52 // function, so we ignore revocation check failures.
53 if (net::IsCertStatusMinorError(ssl_info().cert_status)) {
54 ContinueRequest();
55 } else {
56 CancelRequest();
57 }
44 } 58 }
45 59
46 void SSLErrorHandler::OnDispatched() { 60 void SSLErrorHandler::OnDispatched() {
47 TakeNoAction(); 61 manager_->policy()->OnCertError(this);
48 }
49
50 SSLCertErrorHandler* SSLErrorHandler::AsSSLCertErrorHandler() {
51 return NULL;
52 } 62 }
53 63
54 void SSLErrorHandler::Dispatch( 64 void SSLErrorHandler::Dispatch(
55 const base::Callback<WebContents*(void)>& web_contents_getter) { 65 const base::Callback<WebContents*(void)>& web_contents_getter) {
56 DCHECK_CURRENTLY_ON(BrowserThread::UI); 66 DCHECK_CURRENTLY_ON(BrowserThread::UI);
57 67
58 WebContents* web_contents = web_contents_getter.Run(); 68 WebContents* web_contents = web_contents_getter.Run();
59 69
60 if (!web_contents) { 70 if (!web_contents) {
61 // We arrived on the UI thread, but the tab we're looking for is no longer 71 // We arrived on the UI thread, but the tab we're looking for is no longer
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 void SSLErrorHandler::CompleteCancelRequest(int error) { 128 void SSLErrorHandler::CompleteCancelRequest(int error) {
119 DCHECK_CURRENTLY_ON(BrowserThread::IO); 129 DCHECK_CURRENTLY_ON(BrowserThread::IO);
120 130
121 // It is important that we notify the net::URLRequest only once. If we try 131 // It is important that we notify the net::URLRequest only once. If we try
122 // to notify the request twice, it may no longer exist and |this| might have 132 // to notify the request twice, it may no longer exist and |this| might have
123 // already have been deleted. 133 // already have been deleted.
124 DCHECK(!request_has_been_notified_); 134 DCHECK(!request_has_been_notified_);
125 if (request_has_been_notified_) 135 if (request_has_been_notified_)
126 return; 136 return;
127 137
128 SSLCertErrorHandler* cert_error = AsSSLCertErrorHandler();
129 const SSLInfo* ssl_info = NULL;
130 if (cert_error)
131 ssl_info = &cert_error->ssl_info();
132 if (delegate_.get()) 138 if (delegate_.get())
133 delegate_->CancelSSLRequest(error, ssl_info); 139 delegate_->CancelSSLRequest(error, &ssl_info());
nasko 2016/08/08 18:47:12 ssl_info_?
estark 2016/08/08 20:13:00 Done.
134 request_has_been_notified_ = true; 140 request_has_been_notified_ = true;
135 141
136 // We're done with this object on the IO thread. 142 // We're done with this object on the IO thread.
137 Release(); 143 Release();
138 } 144 }
139 145
140 void SSLErrorHandler::CompleteContinueRequest() { 146 void SSLErrorHandler::CompleteContinueRequest() {
141 DCHECK_CURRENTLY_ON(BrowserThread::IO); 147 DCHECK_CURRENTLY_ON(BrowserThread::IO);
142 148
143 // It is important that we notify the net::URLRequest only once. If we try to 149 // It is important that we notify the net::URLRequest only once. If we try to
(...skipping 21 matching lines...) Expand all
165 if (request_has_been_notified_) 171 if (request_has_been_notified_)
166 return; 172 return;
167 173
168 request_has_been_notified_ = true; 174 request_has_been_notified_ = true;
169 175
170 // We're done with this object on the IO thread. 176 // We're done with this object on the IO thread.
171 Release(); 177 Release();
172 } 178 }
173 179
174 } // namespace content 180 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698