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

Side by Side Diff: chromecast/browser/cast_content_browser_client.cc

Issue 859213006: Cancel client auth requests when not promptable. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@client-auth-cancel-1
Patch Set: adjust comment Created 5 years, 10 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 "chromecast/browser/cast_content_browser_client.h" 5 #include "chromecast/browser/cast_content_browser_client.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/base_switches.h" 9 #include "base/base_switches.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 10 matching lines...) Expand all
21 #include "chromecast/browser/media/cma_message_filter_host.h" 21 #include "chromecast/browser/media/cma_message_filter_host.h"
22 #include "chromecast/browser/url_request_context_factory.h" 22 #include "chromecast/browser/url_request_context_factory.h"
23 #include "chromecast/common/cast_paths.h" 23 #include "chromecast/common/cast_paths.h"
24 #include "chromecast/common/chromecast_switches.h" 24 #include "chromecast/common/chromecast_switches.h"
25 #include "chromecast/common/global_descriptors.h" 25 #include "chromecast/common/global_descriptors.h"
26 #include "components/crash/app/breakpad_linux.h" 26 #include "components/crash/app/breakpad_linux.h"
27 #include "components/crash/browser/crash_handler_host_linux.h" 27 #include "components/crash/browser/crash_handler_host_linux.h"
28 #include "components/network_hints/browser/network_hints_message_filter.h" 28 #include "components/network_hints/browser/network_hints_message_filter.h"
29 #include "content/public/browser/browser_thread.h" 29 #include "content/public/browser/browser_thread.h"
30 #include "content/public/browser/certificate_request_result_type.h" 30 #include "content/public/browser/certificate_request_result_type.h"
31 #include "content/public/browser/client_certificate_delegate.h"
31 #include "content/public/browser/render_process_host.h" 32 #include "content/public/browser/render_process_host.h"
32 #include "content/public/browser/resource_dispatcher_host.h" 33 #include "content/public/browser/resource_dispatcher_host.h"
33 #include "content/public/common/content_descriptors.h" 34 #include "content/public/common/content_descriptors.h"
34 #include "content/public/common/content_switches.h" 35 #include "content/public/common/content_switches.h"
35 #include "content/public/common/url_constants.h" 36 #include "content/public/common/url_constants.h"
36 #include "content/public/common/web_preferences.h" 37 #include "content/public/common/web_preferences.h"
37 #include "net/ssl/ssl_cert_request_info.h" 38 #include "net/ssl/ssl_cert_request_info.h"
38 39
39 #if defined(OS_ANDROID) 40 #if defined(OS_ANDROID)
40 #include "chromecast/browser/android/external_video_surface_container_impl.h" 41 #include "chromecast/browser/android/external_video_surface_container_impl.h"
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 bool expired_previous_decision, 187 bool expired_previous_decision,
187 const base::Callback<void(bool)>& callback, 188 const base::Callback<void(bool)>& callback,
188 content::CertificateRequestResultType* result) { 189 content::CertificateRequestResultType* result) {
189 // Allow developers to override certificate errors. 190 // Allow developers to override certificate errors.
190 // Otherwise, any fatal certificate errors will cause an abort. 191 // Otherwise, any fatal certificate errors will cause an abort.
191 *result = content::CERTIFICATE_REQUEST_RESULT_TYPE_CANCEL; 192 *result = content::CERTIFICATE_REQUEST_RESULT_TYPE_CANCEL;
192 return; 193 return;
193 } 194 }
194 195
195 void CastContentBrowserClient::SelectClientCertificate( 196 void CastContentBrowserClient::SelectClientCertificate(
196 int render_process_id, 197 WebContents* web_contents,
197 int render_view_id,
198 net::SSLCertRequestInfo* cert_request_info, 198 net::SSLCertRequestInfo* cert_request_info,
199 const base::Callback<void(net::X509Certificate*)>& callback) { 199 scoped_ptr<content::ClientCertificateDelegate> delegate) {
200 GURL requesting_url("https://" + cert_request_info->host_and_port.ToString()); 200 GURL requesting_url("https://" + cert_request_info->host_and_port.ToString());
201 201
202 if (!requesting_url.is_valid()) { 202 if (!requesting_url.is_valid()) {
203 LOG(ERROR) << "Invalid URL string: " 203 LOG(ERROR) << "Invalid URL string: "
204 << requesting_url.possibly_invalid_spec(); 204 << requesting_url.possibly_invalid_spec();
205 callback.Run(NULL); 205 delegate->SelectClientCertificate(nullptr);
206 return; 206 return;
207 } 207 }
208 208
209 // In our case there are no relevant certs in the cert_request_info. The cert 209 // In our case there are no relevant certs in the cert_request_info. The cert
210 // we need to return (if permitted) is the Cast device cert, which we can 210 // we need to return (if permitted) is the Cast device cert, which we can
211 // access directly through the ClientAuthSigner instance. However, we need to 211 // access directly through the ClientAuthSigner instance. However, we need to
212 // be on the IO thread to determine whether the app is whitelisted to return 212 // be on the IO thread to determine whether the app is whitelisted to return
213 // it, because CastNetworkDelegate is bound to the IO thread. 213 // it, because CastNetworkDelegate is bound to the IO thread.
214 // Subsequently, the callback must then itself be performed back here 214 // Subsequently, the callback must then itself be performed back here
215 // on the UI thread. 215 // on the UI thread.
216 //
217 // TODO(davidben): Stop using child ID to identify an app.
216 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 218 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
217 content::BrowserThread::PostTaskAndReplyWithResult( 219 content::BrowserThread::PostTaskAndReplyWithResult(
218 content::BrowserThread::IO, 220 content::BrowserThread::IO, FROM_HERE,
219 FROM_HERE, 221 base::Bind(&CastContentBrowserClient::SelectClientCertificateOnIOThread,
220 base::Bind( 222 base::Unretained(this), requesting_url,
221 &CastContentBrowserClient::SelectClientCertificateOnIOThread, 223 web_contents->GetRenderProcessHost()->GetID()),
222 base::Unretained(this), 224 base::Bind(&content::ClientCertificateDelegate::ContinueWithCertificate,
223 requesting_url, 225 delegate.Pass()));
224 render_process_id),
225 callback);
226 } 226 }
227 227
228 net::X509Certificate* 228 net::X509Certificate*
229 CastContentBrowserClient::SelectClientCertificateOnIOThread( 229 CastContentBrowserClient::SelectClientCertificateOnIOThread(
230 GURL requesting_url, 230 GURL requesting_url,
231 int render_process_id) { 231 int render_process_id) {
232 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); 232 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
233 CastNetworkDelegate* network_delegate = 233 CastNetworkDelegate* network_delegate =
234 url_request_context_factory_->app_network_delegate(); 234 url_request_context_factory_->app_network_delegate();
235 if (network_delegate->IsWhitelisted(requesting_url, 235 if (network_delegate->IsWhitelisted(requesting_url,
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 process_type, dumps_path, false /* upload */); 347 process_type, dumps_path, false /* upload */);
348 // StartUploaderThread() even though upload is diferred. 348 // StartUploaderThread() even though upload is diferred.
349 // Breakpad-related memory is freed in the uploader thread. 349 // Breakpad-related memory is freed in the uploader thread.
350 crash_handler->StartUploaderThread(); 350 crash_handler->StartUploaderThread();
351 return crash_handler; 351 return crash_handler;
352 } 352 }
353 #endif // !defined(OS_ANDROID) 353 #endif // !defined(OS_ANDROID)
354 354
355 } // namespace shell 355 } // namespace shell
356 } // namespace chromecast 356 } // namespace chromecast
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698