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 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
295 | 296 |
296 void CastContentBrowserClient::SelectClientCertificate( | 297 void CastContentBrowserClient::SelectClientCertificate( |
297 content::WebContents* web_contents, | 298 content::WebContents* web_contents, |
298 net::SSLCertRequestInfo* cert_request_info, | 299 net::SSLCertRequestInfo* cert_request_info, |
299 scoped_ptr<content::ClientCertificateDelegate> delegate) { | 300 scoped_ptr<content::ClientCertificateDelegate> delegate) { |
300 GURL requesting_url("https://" + cert_request_info->host_and_port.ToString()); | 301 GURL requesting_url("https://" + cert_request_info->host_and_port.ToString()); |
301 | 302 |
302 if (!requesting_url.is_valid()) { | 303 if (!requesting_url.is_valid()) { |
303 LOG(ERROR) << "Invalid URL string: " | 304 LOG(ERROR) << "Invalid URL string: " |
304 << requesting_url.possibly_invalid_spec(); | 305 << requesting_url.possibly_invalid_spec(); |
305 delegate->ContinueWithCertificate(nullptr); | 306 delegate->ContinueWithCertificate(nullptr, nullptr); |
306 return; | 307 return; |
307 } | 308 } |
308 | 309 |
309 // In our case there are no relevant certs in the cert_request_info. The cert | 310 // In our case there are no relevant certs in the cert_request_info. The cert |
310 // we need to return (if permitted) is the Cast device cert, which we can | 311 // we need to return (if permitted) is the Cast device cert, which we can |
311 // access directly through the ClientAuthSigner instance. However, we need to | 312 // access directly through the ClientAuthSigner instance. However, we need to |
312 // be on the IO thread to determine whether the app is whitelisted to return | 313 // be on the IO thread to determine whether the app is whitelisted to return |
313 // it, because CastNetworkDelegate is bound to the IO thread. | 314 // it, because CastNetworkDelegate is bound to the IO thread. |
314 // Subsequently, the callback must then itself be performed back here | 315 // Subsequently, the callback must then itself be performed back here |
315 // on the UI thread. | 316 // on the UI thread. |
316 // | 317 // |
317 // TODO(davidben): Stop using child ID to identify an app. | 318 // TODO(davidben): Stop using child ID to identify an app. |
318 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 319 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
319 content::BrowserThread::PostTaskAndReplyWithResult( | 320 content::BrowserThread::PostTask( |
320 content::BrowserThread::IO, FROM_HERE, | 321 content::BrowserThread::IO, FROM_HERE, |
321 base::Bind(&CastContentBrowserClient::SelectClientCertificateOnIOThread, | 322 base::Bind(&CastContentBrowserClient::SelectClientCertificateOnIOThread, |
322 base::Unretained(this), requesting_url, | 323 base::Unretained(this), base::Passed(delegate.Pass()), |
323 web_contents->GetRenderProcessHost()->GetID()), | 324 requesting_url, |
324 base::Bind(&content::ClientCertificateDelegate::ContinueWithCertificate, | 325 web_contents->GetRenderProcessHost()->GetID())); |
325 base::Owned(delegate.release()))); | |
326 } | 326 } |
327 | 327 |
328 net::X509Certificate* | 328 void CastContentBrowserClient::SelectClientCertificateOnIOThread( |
329 CastContentBrowserClient::SelectClientCertificateOnIOThread( | 329 scoped_ptr<content::ClientCertificateDelegate> delegate, |
330 GURL requesting_url, | 330 GURL requesting_url, |
331 int render_process_id) { | 331 int render_process_id) { |
| 332 net::X509Certificate* cert = nullptr; |
| 333 net::SSLPrivateKey* pkey = nullptr; |
| 334 |
332 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); | 335 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); |
333 CastNetworkDelegate* network_delegate = | 336 CastNetworkDelegate* network_delegate = |
334 url_request_context_factory_->app_network_delegate(); | 337 url_request_context_factory_->app_network_delegate(); |
335 if (network_delegate->IsWhitelisted(requesting_url, | 338 if (network_delegate->IsWhitelisted(requesting_url, |
336 render_process_id, false)) { | 339 render_process_id, false)) { |
337 return CastNetworkDelegate::DeviceCert(); | 340 cert = CastNetworkDelegate::DeviceCert(); |
| 341 pkey = CastNetworkDelegate::DeviceKey(); |
338 } else { | 342 } else { |
339 LOG(ERROR) << "Invalid host for client certificate request: " | 343 LOG(ERROR) << "Invalid host for client certificate request: " |
340 << requesting_url.host() | 344 << requesting_url.host() |
341 << " with render_process_id: " | 345 << " with render_process_id: " |
342 << render_process_id; | 346 << render_process_id; |
343 return NULL; | |
344 } | 347 } |
| 348 |
| 349 content::BrowserThread::PostTask( |
| 350 content::BrowserThread::UI, FROM_HERE, |
| 351 base::Bind(&content::ClientCertificateDelegate::ContinueWithCertificate, |
| 352 base::Owned(delegate.release()), make_scoped_refptr(cert), |
| 353 make_scoped_refptr(pkey))); |
345 } | 354 } |
346 | 355 |
347 bool CastContentBrowserClient::CanCreateWindow( | 356 bool CastContentBrowserClient::CanCreateWindow( |
348 const GURL& opener_url, | 357 const GURL& opener_url, |
349 const GURL& opener_top_level_frame_url, | 358 const GURL& opener_top_level_frame_url, |
350 const GURL& source_origin, | 359 const GURL& source_origin, |
351 WindowContainerType container_type, | 360 WindowContainerType container_type, |
352 const GURL& target_url, | 361 const GURL& target_url, |
353 const content::Referrer& referrer, | 362 const content::Referrer& referrer, |
354 WindowOpenDisposition disposition, | 363 WindowOpenDisposition disposition, |
(...skipping 98 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 |