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