Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(25)

Side by Side Diff: chromecast/browser/cast_content_browser_client.cc

Issue 999243002: Chromecast buildfix: ClientCertificateDelegate changes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chromecast/browser/cast_content_browser_client.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 return; 207 return;
208 } 208 }
209 209
210 // In our case there are no relevant certs in the cert_request_info. The cert 210 // 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 211 // 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 212 // 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 213 // be on the IO thread to determine whether the app is whitelisted to return
214 // it, because CastNetworkDelegate is bound to the IO thread. 214 // it, because CastNetworkDelegate is bound to the IO thread.
215 // Subsequently, the callback must then itself be performed back here 215 // Subsequently, the callback must then itself be performed back here
216 // on the UI thread. 216 // on the UI thread.
217 // 217 //
218 // TODO(davidben): Stop using child ID to identify an app. 218 // TODO(davidben): Stop using child ID to identify an app.
219 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 219 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
220 content::BrowserThread::PostTaskAndReplyWithResult( 220 content::BrowserThread::PostTask(
221 content::BrowserThread::IO, FROM_HERE, 221 content::BrowserThread::IO, FROM_HERE,
222 base::Bind(&CastContentBrowserClient::SelectClientCertificateOnIOThread, 222 base::Bind(&CastContentBrowserClient::SelectClientCertificateOnIOThread,
223 base::Unretained(this), requesting_url, 223 base::Unretained(this), requesting_url,
224 web_contents->GetRenderProcessHost()->GetID()), 224 web_contents->GetRenderProcessHost()->GetID(),
225 base::Bind(&content::ClientCertificateDelegate::ContinueWithCertificate, 225 base::Passed(&delegate)));
226 delegate.Pass()));
227 } 226 }
228 227
229 net::X509Certificate* 228 void CastContentBrowserClient::SelectClientCertificateOnIOThread(
230 CastContentBrowserClient::SelectClientCertificateOnIOThread(
231 GURL requesting_url, 229 GURL requesting_url,
232 int render_process_id) { 230 int render_process_id,
231 scoped_ptr<content::ClientCertificateDelegate> delegate) {
233 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); 232 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
234 CastNetworkDelegate* network_delegate = 233 CastNetworkDelegate* network_delegate =
235 url_request_context_factory_->app_network_delegate(); 234 url_request_context_factory_->app_network_delegate();
236 if (network_delegate->IsWhitelisted(requesting_url, 235 if (network_delegate->IsWhitelisted(requesting_url,
237 render_process_id, false)) { 236 render_process_id, false)) {
238 return CastNetworkDelegate::DeviceCert(); 237 delegate->ContinueWithCertificate(CastNetworkDelegate::DeviceCert());
davidben 2015/03/11 22:57:59 This won't work. It has to be called on the IO thr
davidben 2015/03/11 22:59:28 Sorry, I meant UI thread.
gunsch 2015/03/11 23:05:59 I can use base::Owned, but it's a little ugly (rel
davidben 2015/03/11 23:26:38 Yeah, the release() bugged me in the other place I
239 } else { 238 } else {
240 LOG(ERROR) << "Invalid host for client certificate request: " 239 LOG(ERROR) << "Invalid host for client certificate request: "
241 << requesting_url.host() 240 << requesting_url.host()
242 << " with render_process_id: " 241 << " with render_process_id: "
243 << render_process_id; 242 << render_process_id;
244 return NULL;
245 } 243 }
246 } 244 }
247 245
248 bool CastContentBrowserClient::CanCreateWindow( 246 bool CastContentBrowserClient::CanCreateWindow(
249 const GURL& opener_url, 247 const GURL& opener_url,
250 const GURL& opener_top_level_frame_url, 248 const GURL& opener_top_level_frame_url,
251 const GURL& source_origin, 249 const GURL& source_origin,
252 WindowContainerType container_type, 250 WindowContainerType container_type,
253 const GURL& target_url, 251 const GURL& target_url,
254 const content::Referrer& referrer, 252 const content::Referrer& referrer,
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 process_type, dumps_path, false /* upload */); 355 process_type, dumps_path, false /* upload */);
358 // StartUploaderThread() even though upload is diferred. 356 // StartUploaderThread() even though upload is diferred.
359 // Breakpad-related memory is freed in the uploader thread. 357 // Breakpad-related memory is freed in the uploader thread.
360 crash_handler->StartUploaderThread(); 358 crash_handler->StartUploaderThread();
361 return crash_handler; 359 return crash_handler;
362 } 360 }
363 #endif // !defined(OS_ANDROID) 361 #endif // !defined(OS_ANDROID)
364 362
365 } // namespace shell 363 } // namespace shell
366 } // namespace chromecast 364 } // namespace chromecast
OLDNEW
« no previous file with comments | « chromecast/browser/cast_content_browser_client.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698