OLD | NEW |
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 <stddef.h> | 7 #include <stddef.h> |
8 #include <string> | 8 #include <string> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 30 matching lines...) Expand all Loading... |
41 #include "content/public/browser/certificate_request_result_type.h" | 41 #include "content/public/browser/certificate_request_result_type.h" |
42 #include "content/public/browser/client_certificate_delegate.h" | 42 #include "content/public/browser/client_certificate_delegate.h" |
43 #include "content/public/browser/render_process_host.h" | 43 #include "content/public/browser/render_process_host.h" |
44 #include "content/public/browser/resource_dispatcher_host.h" | 44 #include "content/public/browser/resource_dispatcher_host.h" |
45 #include "content/public/browser/web_contents.h" | 45 #include "content/public/browser/web_contents.h" |
46 #include "content/public/common/content_descriptors.h" | 46 #include "content/public/common/content_descriptors.h" |
47 #include "content/public/common/content_switches.h" | 47 #include "content/public/common/content_switches.h" |
48 #include "content/public/common/url_constants.h" | 48 #include "content/public/common/url_constants.h" |
49 #include "content/public/common/web_preferences.h" | 49 #include "content/public/common/web_preferences.h" |
50 #include "net/ssl/ssl_cert_request_info.h" | 50 #include "net/ssl/ssl_cert_request_info.h" |
| 51 #include "net/ssl/ssl_platform_key.h" |
51 #include "net/url_request/url_request_context_getter.h" | 52 #include "net/url_request/url_request_context_getter.h" |
52 #include "ui/gl/gl_switches.h" | 53 #include "ui/gl/gl_switches.h" |
53 | 54 |
54 #if defined(OS_ANDROID) | 55 #if defined(OS_ANDROID) |
55 #include "components/crash/content/browser/crash_dump_manager_android.h" | 56 #include "components/crash/content/browser/crash_dump_manager_android.h" |
56 #include "components/external_video_surface/browser/android/external_video_surfa
ce_container_impl.h" | 57 #include "components/external_video_surface/browser/android/external_video_surfa
ce_container_impl.h" |
57 #else | 58 #else |
58 #include "chromecast/browser/media/cast_browser_cdm_factory.h" | 59 #include "chromecast/browser/media/cast_browser_cdm_factory.h" |
59 #endif // defined(OS_ANDROID) | 60 #endif // defined(OS_ANDROID) |
60 | 61 |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 | 278 |
278 void CastContentBrowserClient::SelectClientCertificate( | 279 void CastContentBrowserClient::SelectClientCertificate( |
279 content::WebContents* web_contents, | 280 content::WebContents* web_contents, |
280 net::SSLCertRequestInfo* cert_request_info, | 281 net::SSLCertRequestInfo* cert_request_info, |
281 scoped_ptr<content::ClientCertificateDelegate> delegate) { | 282 scoped_ptr<content::ClientCertificateDelegate> delegate) { |
282 GURL requesting_url("https://" + cert_request_info->host_and_port.ToString()); | 283 GURL requesting_url("https://" + cert_request_info->host_and_port.ToString()); |
283 | 284 |
284 if (!requesting_url.is_valid()) { | 285 if (!requesting_url.is_valid()) { |
285 LOG(ERROR) << "Invalid URL string: " | 286 LOG(ERROR) << "Invalid URL string: " |
286 << requesting_url.possibly_invalid_spec(); | 287 << requesting_url.possibly_invalid_spec(); |
287 delegate->ContinueWithCertificate(nullptr); | 288 delegate->ContinueWithCertificate(nullptr, nullptr); |
288 return; | 289 return; |
289 } | 290 } |
290 | 291 |
291 // In our case there are no relevant certs in the cert_request_info. The cert | 292 // In our case there are no relevant certs in the cert_request_info. The cert |
292 // we need to return (if permitted) is the Cast device cert, which we can | 293 // we need to return (if permitted) is the Cast device cert, which we can |
293 // access directly through the ClientAuthSigner instance. However, we need to | 294 // access directly through the ClientAuthSigner instance. However, we need to |
294 // be on the IO thread to determine whether the app is whitelisted to return | 295 // be on the IO thread to determine whether the app is whitelisted to return |
295 // it, because CastNetworkDelegate is bound to the IO thread. | 296 // it, because CastNetworkDelegate is bound to the IO thread. |
296 // Subsequently, the callback must then itself be performed back here | 297 // Subsequently, the callback must then itself be performed back here |
297 // on the UI thread. | 298 // on the UI thread. |
298 // | 299 // |
299 // TODO(davidben): Stop using child ID to identify an app. | 300 // TODO(davidben): Stop using child ID to identify an app. |
300 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 301 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
301 content::BrowserThread::PostTaskAndReplyWithResult( | 302 content::BrowserThread::PostTask( |
302 content::BrowserThread::IO, FROM_HERE, | 303 content::BrowserThread::IO, FROM_HERE, |
303 base::Bind(&CastContentBrowserClient::SelectClientCertificateOnIOThread, | 304 base::Bind(&CastContentBrowserClient::SelectClientCertificateOnIOThread, |
304 base::Unretained(this), requesting_url, | 305 base::Unretained(this), base::Passed(std::move(delegate)), |
305 web_contents->GetRenderProcessHost()->GetID()), | 306 requesting_url, |
306 base::Bind(&content::ClientCertificateDelegate::ContinueWithCertificate, | 307 web_contents->GetRenderProcessHost()->GetID())); |
307 base::Owned(delegate.release()))); | |
308 } | 308 } |
309 | 309 |
310 net::X509Certificate* | 310 void CastContentBrowserClient::SelectClientCertificateOnIOThread( |
311 CastContentBrowserClient::SelectClientCertificateOnIOThread( | 311 scoped_ptr<content::ClientCertificateDelegate> delegate, |
312 GURL requesting_url, | 312 GURL requesting_url, |
313 int render_process_id) { | 313 int render_process_id) { |
| 314 net::X509Certificate* cert = nullptr; |
| 315 net::SSLPrivateKey* private_key = nullptr; |
| 316 |
314 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); | 317 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); |
315 CastNetworkDelegate* network_delegate = | 318 CastNetworkDelegate* network_delegate = |
316 url_request_context_factory_->app_network_delegate(); | 319 url_request_context_factory_->app_network_delegate(); |
317 if (network_delegate->IsWhitelisted(requesting_url, | 320 if (network_delegate->IsWhitelisted(requesting_url, |
318 render_process_id, false)) { | 321 render_process_id, false)) { |
319 return CastNetworkDelegate::DeviceCert(); | 322 cert = CastNetworkDelegate::DeviceCert(); |
| 323 private_key = CastNetworkDelegate::DeviceKey(); |
320 } else { | 324 } else { |
321 LOG(ERROR) << "Invalid host for client certificate request: " | 325 LOG(ERROR) << "Invalid host for client certificate request: " |
322 << requesting_url.host() | 326 << requesting_url.host() |
323 << " with render_process_id: " | 327 << " with render_process_id: " |
324 << render_process_id; | 328 << render_process_id; |
325 return NULL; | |
326 } | 329 } |
| 330 |
| 331 content::BrowserThread::PostTask( |
| 332 content::BrowserThread::UI, FROM_HERE, |
| 333 base::Bind(&content::ClientCertificateDelegate::ContinueWithCertificate, |
| 334 base::Owned(delegate.release()), make_scoped_refptr(cert), |
| 335 make_scoped_refptr(private_key))); |
327 } | 336 } |
328 | 337 |
329 bool CastContentBrowserClient::CanCreateWindow( | 338 bool CastContentBrowserClient::CanCreateWindow( |
330 const GURL& opener_url, | 339 const GURL& opener_url, |
331 const GURL& opener_top_level_frame_url, | 340 const GURL& opener_top_level_frame_url, |
332 const GURL& source_origin, | 341 const GURL& source_origin, |
333 WindowContainerType container_type, | 342 WindowContainerType container_type, |
334 const GURL& target_url, | 343 const GURL& target_url, |
335 const content::Referrer& referrer, | 344 const content::Referrer& referrer, |
336 WindowOpenDisposition disposition, | 345 WindowOpenDisposition disposition, |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
453 process_type, dumps_path, false /* upload */); | 462 process_type, dumps_path, false /* upload */); |
454 // StartUploaderThread() even though upload is diferred. | 463 // StartUploaderThread() even though upload is diferred. |
455 // Breakpad-related memory is freed in the uploader thread. | 464 // Breakpad-related memory is freed in the uploader thread. |
456 crash_handler->StartUploaderThread(); | 465 crash_handler->StartUploaderThread(); |
457 return crash_handler; | 466 return crash_handler; |
458 } | 467 } |
459 #endif // !defined(OS_ANDROID) | 468 #endif // !defined(OS_ANDROID) |
460 | 469 |
461 } // namespace shell | 470 } // namespace shell |
462 } // namespace chromecast | 471 } // namespace chromecast |
OLD | NEW |