OLD | NEW |
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/renderer_host/render_view_host_impl.h" | 8 #include "content/browser/renderer_host/render_view_host_impl.h" |
9 #include "content/browser/ssl/ssl_cert_error_handler.h" | 9 #include "content/browser/ssl/ssl_cert_error_handler.h" |
10 #include "content/browser/web_contents/navigation_controller_impl.h" | 10 #include "content/browser/web_contents/navigation_controller_impl.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 int render_view_id) | 26 int render_view_id) |
27 : manager_(NULL), | 27 : manager_(NULL), |
28 request_id_(id), | 28 request_id_(id), |
29 delegate_(delegate), | 29 delegate_(delegate), |
30 render_process_id_(render_process_id), | 30 render_process_id_(render_process_id), |
31 render_view_id_(render_view_id), | 31 render_view_id_(render_view_id), |
32 request_url_(url), | 32 request_url_(url), |
33 resource_type_(resource_type), | 33 resource_type_(resource_type), |
34 request_has_been_notified_(false) { | 34 request_has_been_notified_(false) { |
35 DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::UI)); | 35 DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::UI)); |
36 DCHECK(delegate); | 36 DCHECK(delegate.get()); |
37 | 37 |
38 // This makes sure we don't disappear on the IO thread until we've given an | 38 // This makes sure we don't disappear on the IO thread until we've given an |
39 // answer to the net::URLRequest. | 39 // answer to the net::URLRequest. |
40 // | 40 // |
41 // Release in CompleteCancelRequest, CompleteContinueRequest, or | 41 // Release in CompleteCancelRequest, CompleteContinueRequest, or |
42 // CompleteTakeNoAction. | 42 // CompleteTakeNoAction. |
43 AddRef(); | 43 AddRef(); |
44 } | 44 } |
45 | 45 |
46 SSLErrorHandler::~SSLErrorHandler() {} | 46 SSLErrorHandler::~SSLErrorHandler() {} |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 // to notify the request twice, it may no longer exist and |this| might have | 126 // to notify the request twice, it may no longer exist and |this| might have |
127 // already have been deleted. | 127 // already have been deleted. |
128 DCHECK(!request_has_been_notified_); | 128 DCHECK(!request_has_been_notified_); |
129 if (request_has_been_notified_) | 129 if (request_has_been_notified_) |
130 return; | 130 return; |
131 | 131 |
132 SSLCertErrorHandler* cert_error = AsSSLCertErrorHandler(); | 132 SSLCertErrorHandler* cert_error = AsSSLCertErrorHandler(); |
133 const SSLInfo* ssl_info = NULL; | 133 const SSLInfo* ssl_info = NULL; |
134 if (cert_error) | 134 if (cert_error) |
135 ssl_info = &cert_error->ssl_info(); | 135 ssl_info = &cert_error->ssl_info(); |
136 if (delegate_) | 136 if (delegate_.get()) |
137 delegate_->CancelSSLRequest(request_id_, error, ssl_info); | 137 delegate_->CancelSSLRequest(request_id_, error, ssl_info); |
138 request_has_been_notified_ = true; | 138 request_has_been_notified_ = true; |
139 | 139 |
140 // We're done with this object on the IO thread. | 140 // We're done with this object on the IO thread. |
141 Release(); | 141 Release(); |
142 } | 142 } |
143 | 143 |
144 void SSLErrorHandler::CompleteContinueRequest() { | 144 void SSLErrorHandler::CompleteContinueRequest() { |
145 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 145 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
146 | 146 |
147 // It is important that we notify the net::URLRequest only once. If we try to | 147 // It is important that we notify the net::URLRequest only once. If we try to |
148 // notify the request twice, it may no longer exist and |this| might have | 148 // notify the request twice, it may no longer exist and |this| might have |
149 // already have been deleted. | 149 // already have been deleted. |
150 DCHECK(!request_has_been_notified_); | 150 DCHECK(!request_has_been_notified_); |
151 if (request_has_been_notified_) | 151 if (request_has_been_notified_) |
152 return; | 152 return; |
153 | 153 |
154 if (delegate_) | 154 if (delegate_.get()) |
155 delegate_->ContinueSSLRequest(request_id_); | 155 delegate_->ContinueSSLRequest(request_id_); |
156 request_has_been_notified_ = true; | 156 request_has_been_notified_ = true; |
157 | 157 |
158 // We're done with this object on the IO thread. | 158 // We're done with this object on the IO thread. |
159 Release(); | 159 Release(); |
160 } | 160 } |
161 | 161 |
162 void SSLErrorHandler::CompleteTakeNoAction() { | 162 void SSLErrorHandler::CompleteTakeNoAction() { |
163 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 163 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
164 | 164 |
165 // It is important that we notify the net::URLRequest only once. If we try to | 165 // It is important that we notify the net::URLRequest only once. If we try to |
166 // notify the request twice, it may no longer exist and |this| might have | 166 // notify the request twice, it may no longer exist and |this| might have |
167 // already have been deleted. | 167 // already have been deleted. |
168 DCHECK(!request_has_been_notified_); | 168 DCHECK(!request_has_been_notified_); |
169 if (request_has_been_notified_) | 169 if (request_has_been_notified_) |
170 return; | 170 return; |
171 | 171 |
172 request_has_been_notified_ = true; | 172 request_has_been_notified_ = true; |
173 | 173 |
174 // We're done with this object on the IO thread. | 174 // We're done with this object on the IO thread. |
175 Release(); | 175 Release(); |
176 } | 176 } |
177 | 177 |
178 } // namespace content | 178 } // namespace content |
OLD | NEW |