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

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

Issue 859213006: Cancel client auth requests when not promptable. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@client-auth-cancel-1
Patch Set: worker_common.js was missing a license header (also a rebase) 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
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 11 matching lines...) Expand all
22 #include "chromecast/browser/media/cma_message_filter_host.h" 22 #include "chromecast/browser/media/cma_message_filter_host.h"
23 #include "chromecast/browser/url_request_context_factory.h" 23 #include "chromecast/browser/url_request_context_factory.h"
24 #include "chromecast/common/cast_paths.h" 24 #include "chromecast/common/cast_paths.h"
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/render_process_host.h" 33 #include "content/public/browser/render_process_host.h"
33 #include "content/public/browser/resource_dispatcher_host.h" 34 #include "content/public/browser/resource_dispatcher_host.h"
34 #include "content/public/common/content_descriptors.h" 35 #include "content/public/common/content_descriptors.h"
35 #include "content/public/common/content_switches.h" 36 #include "content/public/common/content_switches.h"
36 #include "content/public/common/url_constants.h" 37 #include "content/public/common/url_constants.h"
37 #include "content/public/common/web_preferences.h" 38 #include "content/public/common/web_preferences.h"
38 #include "net/ssl/ssl_cert_request_info.h" 39 #include "net/ssl/ssl_cert_request_info.h"
39 40
40 #if defined(OS_ANDROID) 41 #if defined(OS_ANDROID)
41 #include "chromecast/browser/android/external_video_surface_container_impl.h" 42 #include "chromecast/browser/android/external_video_surface_container_impl.h"
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 bool expired_previous_decision, 188 bool expired_previous_decision,
188 const base::Callback<void(bool)>& callback, 189 const base::Callback<void(bool)>& callback,
189 content::CertificateRequestResultType* result) { 190 content::CertificateRequestResultType* result) {
190 // Allow developers to override certificate errors. 191 // Allow developers to override certificate errors.
191 // Otherwise, any fatal certificate errors will cause an abort. 192 // Otherwise, any fatal certificate errors will cause an abort.
192 *result = content::CERTIFICATE_REQUEST_RESULT_TYPE_CANCEL; 193 *result = content::CERTIFICATE_REQUEST_RESULT_TYPE_CANCEL;
193 return; 194 return;
194 } 195 }
195 196
196 void CastContentBrowserClient::SelectClientCertificate( 197 void CastContentBrowserClient::SelectClientCertificate(
197 int render_process_id, 198 WebContents* web_contents,
198 int render_view_id,
199 net::SSLCertRequestInfo* cert_request_info, 199 net::SSLCertRequestInfo* cert_request_info,
200 const base::Callback<void(net::X509Certificate*)>& callback) { 200 scoped_ptr<content::ClientCertificateDelegate> delegate) {
201 GURL requesting_url("https://" + cert_request_info->host_and_port.ToString()); 201 GURL requesting_url("https://" + cert_request_info->host_and_port.ToString());
202 202
203 if (!requesting_url.is_valid()) { 203 if (!requesting_url.is_valid()) {
204 LOG(ERROR) << "Invalid URL string: " 204 LOG(ERROR) << "Invalid URL string: "
205 << requesting_url.possibly_invalid_spec(); 205 << requesting_url.possibly_invalid_spec();
206 callback.Run(NULL); 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 //
218 // TODO(davidben): Stop using child ID to identify an app.
217 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 219 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
218 content::BrowserThread::PostTaskAndReplyWithResult( 220 content::BrowserThread::PostTaskAndReplyWithResult(
219 content::BrowserThread::IO, 221 content::BrowserThread::IO, FROM_HERE,
220 FROM_HERE, 222 base::Bind(&CastContentBrowserClient::SelectClientCertificateOnIOThread,
221 base::Bind( 223 base::Unretained(this), requesting_url,
222 &CastContentBrowserClient::SelectClientCertificateOnIOThread, 224 web_contents->GetRenderProcessHost()->GetID()),
223 base::Unretained(this), 225 base::Bind(&content::ClientCertificateDelegate::ContinueWithCertificate,
224 requesting_url, 226 delegate.Pass()));
225 render_process_id),
226 callback);
227 } 227 }
228 228
229 net::X509Certificate* 229 net::X509Certificate*
230 CastContentBrowserClient::SelectClientCertificateOnIOThread( 230 CastContentBrowserClient::SelectClientCertificateOnIOThread(
231 GURL requesting_url, 231 GURL requesting_url,
232 int render_process_id) { 232 int render_process_id) {
233 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); 233 DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
234 CastNetworkDelegate* network_delegate = 234 CastNetworkDelegate* network_delegate =
235 url_request_context_factory_->app_network_delegate(); 235 url_request_context_factory_->app_network_delegate();
236 if (network_delegate->IsWhitelisted(requesting_url, 236 if (network_delegate->IsWhitelisted(requesting_url,
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 process_type, dumps_path, false /* upload */); 357 process_type, dumps_path, false /* upload */);
358 // StartUploaderThread() even though upload is diferred. 358 // StartUploaderThread() even though upload is diferred.
359 // Breakpad-related memory is freed in the uploader thread. 359 // Breakpad-related memory is freed in the uploader thread.
360 crash_handler->StartUploaderThread(); 360 crash_handler->StartUploaderThread();
361 return crash_handler; 361 return crash_handler;
362 } 362 }
363 #endif // !defined(OS_ANDROID) 363 #endif // !defined(OS_ANDROID)
364 364
365 } // namespace shell 365 } // namespace shell
366 } // namespace chromecast 366 } // namespace chromecast
OLDNEW
« no previous file with comments | « chromecast/browser/cast_content_browser_client.h ('k') | content/browser/loader/resource_loader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698