| 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 14 matching lines...) Expand all Loading... |
| 25 #include "chromecast/common/chromecast_switches.h" | 25 #include "chromecast/common/chromecast_switches.h" |
| 26 #include "chromecast/common/global_descriptors.h" | 26 #include "chromecast/common/global_descriptors.h" |
| 27 #include "components/crash/app/breakpad_linux.h" | 27 #include "components/crash/app/breakpad_linux.h" |
| 28 #include "components/crash/browser/crash_handler_host_linux.h" | 28 #include "components/crash/browser/crash_handler_host_linux.h" |
| 29 #include "components/network_hints/browser/network_hints_message_filter.h" | 29 #include "components/network_hints/browser/network_hints_message_filter.h" |
| 30 #include "content/public/browser/browser_thread.h" | 30 #include "content/public/browser/browser_thread.h" |
| 31 #include "content/public/browser/certificate_request_result_type.h" | 31 #include "content/public/browser/certificate_request_result_type.h" |
| 32 #include "content/public/browser/client_certificate_delegate.h" | 32 #include "content/public/browser/client_certificate_delegate.h" |
| 33 #include "content/public/browser/render_process_host.h" | 33 #include "content/public/browser/render_process_host.h" |
| 34 #include "content/public/browser/resource_dispatcher_host.h" | 34 #include "content/public/browser/resource_dispatcher_host.h" |
| 35 #include "content/public/browser/web_contents.h" |
| 35 #include "content/public/common/content_descriptors.h" | 36 #include "content/public/common/content_descriptors.h" |
| 36 #include "content/public/common/content_switches.h" | 37 #include "content/public/common/content_switches.h" |
| 37 #include "content/public/common/url_constants.h" | 38 #include "content/public/common/url_constants.h" |
| 38 #include "content/public/common/web_preferences.h" | 39 #include "content/public/common/web_preferences.h" |
| 39 #include "net/ssl/ssl_cert_request_info.h" | 40 #include "net/ssl/ssl_cert_request_info.h" |
| 40 | 41 |
| 41 #if defined(OS_ANDROID) | 42 #if defined(OS_ANDROID) |
| 42 #include "chromecast/browser/android/external_video_surface_container_impl.h" | 43 #include "chromecast/browser/android/external_video_surface_container_impl.h" |
| 43 #endif // defined(OS_ANDROID) | 44 #endif // defined(OS_ANDROID) |
| 44 | 45 |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 bool expired_previous_decision, | 189 bool expired_previous_decision, |
| 189 const base::Callback<void(bool)>& callback, | 190 const base::Callback<void(bool)>& callback, |
| 190 content::CertificateRequestResultType* result) { | 191 content::CertificateRequestResultType* result) { |
| 191 // Allow developers to override certificate errors. | 192 // Allow developers to override certificate errors. |
| 192 // Otherwise, any fatal certificate errors will cause an abort. | 193 // Otherwise, any fatal certificate errors will cause an abort. |
| 193 *result = content::CERTIFICATE_REQUEST_RESULT_TYPE_CANCEL; | 194 *result = content::CERTIFICATE_REQUEST_RESULT_TYPE_CANCEL; |
| 194 return; | 195 return; |
| 195 } | 196 } |
| 196 | 197 |
| 197 void CastContentBrowserClient::SelectClientCertificate( | 198 void CastContentBrowserClient::SelectClientCertificate( |
| 198 WebContents* web_contents, | 199 content::WebContents* web_contents, |
| 199 net::SSLCertRequestInfo* cert_request_info, | 200 net::SSLCertRequestInfo* cert_request_info, |
| 200 scoped_ptr<content::ClientCertificateDelegate> delegate) { | 201 scoped_ptr<content::ClientCertificateDelegate> delegate) { |
| 201 GURL requesting_url("https://" + cert_request_info->host_and_port.ToString()); | 202 GURL requesting_url("https://" + cert_request_info->host_and_port.ToString()); |
| 202 | 203 |
| 203 if (!requesting_url.is_valid()) { | 204 if (!requesting_url.is_valid()) { |
| 204 LOG(ERROR) << "Invalid URL string: " | 205 LOG(ERROR) << "Invalid URL string: " |
| 205 << requesting_url.possibly_invalid_spec(); | 206 << requesting_url.possibly_invalid_spec(); |
| 206 delegate->SelectClientCertificate(nullptr); | 207 delegate->ContinueWithCertificate(nullptr); |
| 207 return; | 208 return; |
| 208 } | 209 } |
| 209 | 210 |
| 210 // In our case there are no relevant certs in the cert_request_info. The cert | 211 // In our case there are no relevant certs in the cert_request_info. The cert |
| 211 // we need to return (if permitted) is the Cast device cert, which we can | 212 // we need to return (if permitted) is the Cast device cert, which we can |
| 212 // access directly through the ClientAuthSigner instance. However, we need to | 213 // access directly through the ClientAuthSigner instance. However, we need to |
| 213 // be on the IO thread to determine whether the app is whitelisted to return | 214 // be on the IO thread to determine whether the app is whitelisted to return |
| 214 // it, because CastNetworkDelegate is bound to the IO thread. | 215 // it, because CastNetworkDelegate is bound to the IO thread. |
| 215 // Subsequently, the callback must then itself be performed back here | 216 // Subsequently, the callback must then itself be performed back here |
| 216 // on the UI thread. | 217 // on the UI thread. |
| 217 // | 218 // |
| 218 // TODO(davidben): Stop using child ID to identify an app. | 219 // TODO(davidben): Stop using child ID to identify an app. |
| 219 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 220 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 220 content::BrowserThread::PostTaskAndReplyWithResult( | 221 content::BrowserThread::PostTaskAndReplyWithResult( |
| 221 content::BrowserThread::IO, FROM_HERE, | 222 content::BrowserThread::IO, FROM_HERE, |
| 222 base::Bind(&CastContentBrowserClient::SelectClientCertificateOnIOThread, | 223 base::Bind(&CastContentBrowserClient::SelectClientCertificateOnIOThread, |
| 223 base::Unretained(this), requesting_url, | 224 base::Unretained(this), requesting_url, |
| 224 web_contents->GetRenderProcessHost()->GetID()), | 225 web_contents->GetRenderProcessHost()->GetID()), |
| 225 base::Bind(&content::ClientCertificateDelegate::ContinueWithCertificate, | 226 base::Bind(&content::ClientCertificateDelegate::ContinueWithCertificate, |
| 226 delegate.Pass())); | 227 base::Owned(delegate.release()))); |
| 227 } | 228 } |
| 228 | 229 |
| 229 net::X509Certificate* | 230 net::X509Certificate* |
| 230 CastContentBrowserClient::SelectClientCertificateOnIOThread( | 231 CastContentBrowserClient::SelectClientCertificateOnIOThread( |
| 231 GURL requesting_url, | 232 GURL requesting_url, |
| 232 int render_process_id) { | 233 int render_process_id) { |
| 233 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); | 234 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); |
| 234 CastNetworkDelegate* network_delegate = | 235 CastNetworkDelegate* network_delegate = |
| 235 url_request_context_factory_->app_network_delegate(); | 236 url_request_context_factory_->app_network_delegate(); |
| 236 if (network_delegate->IsWhitelisted(requesting_url, | 237 if (network_delegate->IsWhitelisted(requesting_url, |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 process_type, dumps_path, false /* upload */); | 358 process_type, dumps_path, false /* upload */); |
| 358 // StartUploaderThread() even though upload is diferred. | 359 // StartUploaderThread() even though upload is diferred. |
| 359 // Breakpad-related memory is freed in the uploader thread. | 360 // Breakpad-related memory is freed in the uploader thread. |
| 360 crash_handler->StartUploaderThread(); | 361 crash_handler->StartUploaderThread(); |
| 361 return crash_handler; | 362 return crash_handler; |
| 362 } | 363 } |
| 363 #endif // !defined(OS_ANDROID) | 364 #endif // !defined(OS_ANDROID) |
| 364 | 365 |
| 365 } // namespace shell | 366 } // namespace shell |
| 366 } // namespace chromecast | 367 } // namespace chromecast |
| OLD | NEW |