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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 bool expired_previous_decision, | 173 bool expired_previous_decision, |
173 const base::Callback<void(bool)>& callback, | 174 const base::Callback<void(bool)>& callback, |
174 content::CertificateRequestResultType* result) { | 175 content::CertificateRequestResultType* result) { |
175 // Allow developers to override certificate errors. | 176 // Allow developers to override certificate errors. |
176 // Otherwise, any fatal certificate errors will cause an abort. | 177 // Otherwise, any fatal certificate errors will cause an abort. |
177 *result = content::CERTIFICATE_REQUEST_RESULT_TYPE_CANCEL; | 178 *result = content::CERTIFICATE_REQUEST_RESULT_TYPE_CANCEL; |
178 return; | 179 return; |
179 } | 180 } |
180 | 181 |
181 void CastContentBrowserClient::SelectClientCertificate( | 182 void CastContentBrowserClient::SelectClientCertificate( |
182 int render_process_id, | 183 WebContents* web_contents, |
183 int render_view_id, | |
184 net::SSLCertRequestInfo* cert_request_info, | 184 net::SSLCertRequestInfo* cert_request_info, |
185 const base::Callback<void(net::X509Certificate*)>& callback) { | 185 scoped_ptr<content::ClientCertificateDelegate> delegate) { |
186 GURL requesting_url("https://" + cert_request_info->host_and_port.ToString()); | 186 GURL requesting_url("https://" + cert_request_info->host_and_port.ToString()); |
187 | 187 |
188 if (!requesting_url.is_valid()) { | 188 if (!requesting_url.is_valid()) { |
189 LOG(ERROR) << "Invalid URL string: " | 189 LOG(ERROR) << "Invalid URL string: " |
190 << requesting_url.possibly_invalid_spec(); | 190 << requesting_url.possibly_invalid_spec(); |
191 callback.Run(NULL); | 191 delegate->SelectClientCertificate(nullptr); |
192 return; | 192 return; |
193 } | 193 } |
194 | 194 |
195 // In our case there are no relevant certs in the cert_request_info. The cert | 195 // In our case there are no relevant certs in the cert_request_info. The cert |
196 // we need to return (if permitted) is the Cast device cert, which we can | 196 // we need to return (if permitted) is the Cast device cert, which we can |
197 // access directly through the ClientAuthSigner instance. However, we need to | 197 // access directly through the ClientAuthSigner instance. However, we need to |
198 // be on the IO thread to determine whether the app is whitelisted to return | 198 // be on the IO thread to determine whether the app is whitelisted to return |
199 // it, because CastNetworkDelegate is bound to the IO thread. | 199 // it, because CastNetworkDelegate is bound to the IO thread. |
200 // Subsequently, the callback must then itself be performed back here | 200 // Subsequently, the callback must then itself be performed back here |
201 // on the UI thread. | 201 // on the UI thread. |
| 202 // |
| 203 // TODO(davidben): Stop using child ID to identify an app. |
202 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 204 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
203 content::BrowserThread::PostTaskAndReplyWithResult( | 205 content::BrowserThread::PostTaskAndReplyWithResult( |
204 content::BrowserThread::IO, | 206 content::BrowserThread::IO, FROM_HERE, |
205 FROM_HERE, | 207 base::Bind(&CastContentBrowserClient::SelectClientCertificateOnIOThread, |
206 base::Bind( | 208 base::Unretained(this), requesting_url, |
207 &CastContentBrowserClient::SelectClientCertificateOnIOThread, | 209 web_contents->GetRenderProcessHost()->GetID()), |
208 base::Unretained(this), | 210 base::Bind(&content::ClientCertificateDelegate::ContinueWithCertificate, |
209 requesting_url, | 211 delegate.Pass())); |
210 render_process_id), | |
211 callback); | |
212 } | 212 } |
213 | 213 |
214 net::X509Certificate* | 214 net::X509Certificate* |
215 CastContentBrowserClient::SelectClientCertificateOnIOThread( | 215 CastContentBrowserClient::SelectClientCertificateOnIOThread( |
216 GURL requesting_url, | 216 GURL requesting_url, |
217 int render_process_id) { | 217 int render_process_id) { |
218 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); | 218 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); |
219 CastNetworkDelegate* network_delegate = | 219 CastNetworkDelegate* network_delegate = |
220 url_request_context_factory_->app_network_delegate(); | 220 url_request_context_factory_->app_network_delegate(); |
221 if (network_delegate->IsWhitelisted(requesting_url, | 221 if (network_delegate->IsWhitelisted(requesting_url, |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
333 process_type, dumps_path, false /* upload */); | 333 process_type, dumps_path, false /* upload */); |
334 // StartUploaderThread() even though upload is diferred. | 334 // StartUploaderThread() even though upload is diferred. |
335 // Breakpad-related memory is freed in the uploader thread. | 335 // Breakpad-related memory is freed in the uploader thread. |
336 crash_handler->StartUploaderThread(); | 336 crash_handler->StartUploaderThread(); |
337 return crash_handler; | 337 return crash_handler; |
338 } | 338 } |
339 #endif // !defined(OS_ANDROID) | 339 #endif // !defined(OS_ANDROID) |
340 | 340 |
341 } // namespace shell | 341 } // namespace shell |
342 } // namespace chromecast | 342 } // namespace chromecast |
OLD | NEW |