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" |
11 #include "base/files/scoped_file.h" | 11 #include "base/files/scoped_file.h" |
12 #include "base/i18n/rtl.h" | 12 #include "base/i18n/rtl.h" |
13 #include "base/path_service.h" | 13 #include "base/path_service.h" |
14 #include "chromecast/browser/cast_browser_context.h" | 14 #include "chromecast/browser/cast_browser_context.h" |
15 #include "chromecast/browser/cast_browser_main_parts.h" | 15 #include "chromecast/browser/cast_browser_main_parts.h" |
16 #include "chromecast/browser/cast_browser_process.h" | 16 #include "chromecast/browser/cast_browser_process.h" |
17 #include "chromecast/browser/cast_network_delegate.h" | 17 #include "chromecast/browser/cast_network_delegate.h" |
18 #include "chromecast/browser/devtools/cast_dev_tools_delegate.h" | 18 #include "chromecast/browser/devtools/cast_dev_tools_delegate.h" |
19 #include "chromecast/browser/geolocation/cast_access_token_store.h" | 19 #include "chromecast/browser/geolocation/cast_access_token_store.h" |
20 #include "chromecast/browser/media/cma_message_filter_host.h" | 20 #include "chromecast/browser/media/cma_message_filter_host.h" |
21 #include "chromecast/browser/url_request_context_factory.h" | 21 #include "chromecast/browser/url_request_context_factory.h" |
22 #include "chromecast/common/cast_paths.h" | 22 #include "chromecast/common/cast_paths.h" |
23 #include "chromecast/common/chromecast_switches.h" | 23 #include "chromecast/common/chromecast_switches.h" |
24 #include "chromecast/common/global_descriptors.h" | 24 #include "chromecast/common/global_descriptors.h" |
25 #include "components/crash/app/breakpad_linux.h" | 25 #include "components/crash/app/breakpad_linux.h" |
26 #include "components/crash/browser/crash_handler_host_linux.h" | 26 #include "components/crash/browser/crash_handler_host_linux.h" |
27 #include "components/network_hints/browser/network_hints_message_filter.h" | 27 #include "components/network_hints/browser/network_hints_message_filter.h" |
28 #include "content/public/browser/browser_thread.h" | 28 #include "content/public/browser/browser_thread.h" |
29 #include "content/public/browser/certificate_request_result_type.h" | 29 #include "content/public/browser/certificate_request_result_type.h" |
| 30 #include "content/public/browser/client_certificate_delegate.h" |
30 #include "content/public/browser/render_process_host.h" | 31 #include "content/public/browser/render_process_host.h" |
31 #include "content/public/common/content_descriptors.h" | 32 #include "content/public/common/content_descriptors.h" |
32 #include "content/public/common/content_switches.h" | 33 #include "content/public/common/content_switches.h" |
33 #include "content/public/common/url_constants.h" | 34 #include "content/public/common/url_constants.h" |
34 #include "content/public/common/web_preferences.h" | 35 #include "content/public/common/web_preferences.h" |
35 #include "net/ssl/ssl_cert_request_info.h" | 36 #include "net/ssl/ssl_cert_request_info.h" |
36 | 37 |
37 #if defined(OS_ANDROID) | 38 #if defined(OS_ANDROID) |
38 #include "chromecast/browser/android/external_video_surface_container_impl.h" | 39 #include "chromecast/browser/android/external_video_surface_container_impl.h" |
39 #endif // defined(OS_ANDROID) | 40 #endif // defined(OS_ANDROID) |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 bool expired_previous_decision, | 178 bool expired_previous_decision, |
178 const base::Callback<void(bool)>& callback, | 179 const base::Callback<void(bool)>& callback, |
179 content::CertificateRequestResultType* result) { | 180 content::CertificateRequestResultType* result) { |
180 // Allow developers to override certificate errors. | 181 // Allow developers to override certificate errors. |
181 // Otherwise, any fatal certificate errors will cause an abort. | 182 // Otherwise, any fatal certificate errors will cause an abort. |
182 *result = content::CERTIFICATE_REQUEST_RESULT_TYPE_CANCEL; | 183 *result = content::CERTIFICATE_REQUEST_RESULT_TYPE_CANCEL; |
183 return; | 184 return; |
184 } | 185 } |
185 | 186 |
186 void CastContentBrowserClient::SelectClientCertificate( | 187 void CastContentBrowserClient::SelectClientCertificate( |
187 int render_process_id, | 188 WebContents* web_contents, |
188 int render_view_id, | |
189 net::SSLCertRequestInfo* cert_request_info, | 189 net::SSLCertRequestInfo* cert_request_info, |
190 const base::Callback<void(net::X509Certificate*)>& callback) { | 190 scoped_ptr<content::ClientCertificateDelegate> delegate) { |
191 GURL requesting_url("https://" + cert_request_info->host_and_port.ToString()); | 191 GURL requesting_url("https://" + cert_request_info->host_and_port.ToString()); |
192 | 192 |
193 if (!requesting_url.is_valid()) { | 193 if (!requesting_url.is_valid()) { |
194 LOG(ERROR) << "Invalid URL string: " | 194 LOG(ERROR) << "Invalid URL string: " |
195 << requesting_url.possibly_invalid_spec(); | 195 << requesting_url.possibly_invalid_spec(); |
196 callback.Run(NULL); | 196 delegate->SelectClientCertificate(nullptr); |
197 return; | 197 return; |
198 } | 198 } |
199 | 199 |
200 // In our case there are no relevant certs in the cert_request_info. The cert | 200 // In our case there are no relevant certs in the cert_request_info. The cert |
201 // we need to return (if permitted) is the Cast device cert, which we can | 201 // we need to return (if permitted) is the Cast device cert, which we can |
202 // access directly through the ClientAuthSigner instance. However, we need to | 202 // access directly through the ClientAuthSigner instance. However, we need to |
203 // be on the IO thread to determine whether the app is whitelisted to return | 203 // be on the IO thread to determine whether the app is whitelisted to return |
204 // it, because CastNetworkDelegate is bound to the IO thread. | 204 // it, because CastNetworkDelegate is bound to the IO thread. |
205 // Subsequently, the callback must then itself be performed back here | 205 // Subsequently, the callback must then itself be performed back here |
206 // on the UI thread. | 206 // on the UI thread. |
| 207 // |
| 208 // TODO(davidben): Stop using child ID to identify an app. |
207 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 209 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
208 content::BrowserThread::PostTaskAndReplyWithResult( | 210 content::BrowserThread::PostTaskAndReplyWithResult( |
209 content::BrowserThread::IO, | 211 content::BrowserThread::IO, FROM_HERE, |
210 FROM_HERE, | 212 base::Bind(&CastContentBrowserClient::SelectClientCertificateOnIOThread, |
211 base::Bind( | 213 base::Unretained(this), requesting_url, |
212 &CastContentBrowserClient::SelectClientCertificateOnIOThread, | 214 web_contents->GetRenderProcessHost()->GetID()), |
213 base::Unretained(this), | 215 base::Bind(&content::ClientCertificateDelegate::ContinueWithCertificate, |
214 requesting_url, | 216 delegate.Pass())); |
215 render_process_id), | |
216 callback); | |
217 } | 217 } |
218 | 218 |
219 net::X509Certificate* | 219 net::X509Certificate* |
220 CastContentBrowserClient::SelectClientCertificateOnIOThread( | 220 CastContentBrowserClient::SelectClientCertificateOnIOThread( |
221 GURL requesting_url, | 221 GURL requesting_url, |
222 int render_process_id) { | 222 int render_process_id) { |
223 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); | 223 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); |
224 CastNetworkDelegate* network_delegate = | 224 CastNetworkDelegate* network_delegate = |
225 url_request_context_factory_->app_network_delegate(); | 225 url_request_context_factory_->app_network_delegate(); |
226 if (network_delegate->IsWhitelisted(requesting_url, | 226 if (network_delegate->IsWhitelisted(requesting_url, |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
338 process_type, dumps_path, false /* upload */); | 338 process_type, dumps_path, false /* upload */); |
339 // StartUploaderThread() even though upload is diferred. | 339 // StartUploaderThread() even though upload is diferred. |
340 // Breakpad-related memory is freed in the uploader thread. | 340 // Breakpad-related memory is freed in the uploader thread. |
341 crash_handler->StartUploaderThread(); | 341 crash_handler->StartUploaderThread(); |
342 return crash_handler; | 342 return crash_handler; |
343 } | 343 } |
344 #endif // !defined(OS_ANDROID) | 344 #endif // !defined(OS_ANDROID) |
345 | 345 |
346 } // namespace shell | 346 } // namespace shell |
347 } // namespace chromecast | 347 } // namespace chromecast |
OLD | NEW |