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

Side by Side Diff: content/browser/ssl/ssl_manager.cc

Issue 2639203003: Add certificate error handling to devtools. (Closed)
Patch Set: plumb error through agent host Created 3 years, 10 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/browser/ssl/ssl_manager.h" 5 #include "content/browser/ssl/ssl_manager.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/metrics/histogram_macros.h" 11 #include "base/metrics/histogram_macros.h"
12 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
13 #include "base/supports_user_data.h" 13 #include "base/supports_user_data.h"
14 #include "content/browser/devtools/render_frame_devtools_agent_host.h"
14 #include "content/browser/frame_host/navigation_entry_impl.h" 15 #include "content/browser/frame_host/navigation_entry_impl.h"
15 #include "content/browser/loader/resource_dispatcher_host_impl.h" 16 #include "content/browser/loader/resource_dispatcher_host_impl.h"
16 #include "content/browser/loader/resource_request_info_impl.h" 17 #include "content/browser/loader/resource_request_info_impl.h"
17 #include "content/browser/ssl/ssl_error_handler.h" 18 #include "content/browser/ssl/ssl_error_handler.h"
18 #include "content/browser/web_contents/web_contents_impl.h" 19 #include "content/browser/web_contents/web_contents_impl.h"
19 #include "content/public/browser/browser_context.h" 20 #include "content/public/browser/browser_context.h"
20 #include "content/public/browser/browser_thread.h" 21 #include "content/public/browser/browser_thread.h"
21 #include "content/public/browser/certificate_request_result_type.h" 22 #include "content/public/browser/certificate_request_result_type.h"
22 #include "content/public/browser/content_browser_client.h" 23 #include "content/public/browser/content_browser_client.h"
24 #include "content/public/browser/devtools_agent_host.h"
23 #include "content/public/browser/navigation_details.h" 25 #include "content/public/browser/navigation_details.h"
24 #include "content/public/browser/ssl_host_state_delegate.h" 26 #include "content/public/browser/ssl_host_state_delegate.h"
25 #include "net/url_request/url_request.h" 27 #include "net/url_request/url_request.h"
26 28
27 namespace content { 29 namespace content {
28 30
29 namespace { 31 namespace {
30 32
31 const char kSSLManagerKeyName[] = "content_ssl_manager"; 33 const char kSSLManagerKeyName[] = "content_ssl_manager";
32 34
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 bool overridable = (options_mask & OVERRIDABLE) != 0; 351 bool overridable = (options_mask & OVERRIDABLE) != 0;
350 bool strict_enforcement = (options_mask & STRICT_ENFORCEMENT) != 0; 352 bool strict_enforcement = (options_mask & STRICT_ENFORCEMENT) != 0;
351 bool expired_previous_decision = 353 bool expired_previous_decision =
352 (options_mask & EXPIRED_PREVIOUS_DECISION) != 0; 354 (options_mask & EXPIRED_PREVIOUS_DECISION) != 0;
353 355
354 WebContents* web_contents = handler->web_contents(); 356 WebContents* web_contents = handler->web_contents();
355 int cert_error = handler->cert_error(); 357 int cert_error = handler->cert_error();
356 const net::SSLInfo& ssl_info = handler->ssl_info(); 358 const net::SSLInfo& ssl_info = handler->ssl_info();
357 const GURL& request_url = handler->request_url(); 359 const GURL& request_url = handler->request_url();
358 ResourceType resource_type = handler->resource_type(); 360 ResourceType resource_type = handler->resource_type();
359 GetContentClient()->browser()->AllowCertificateError( 361
360 web_contents, cert_error, ssl_info, request_url, resource_type, 362 base::Callback<void(content::CertificateRequestResultType)> callback =
361 overridable, strict_enforcement, expired_previous_decision,
362 base::Bind(&OnAllowCertificate, base::Owned(handler.release()), 363 base::Bind(&OnAllowCertificate, base::Owned(handler.release()),
363 ssl_host_state_delegate_)); 364 ssl_host_state_delegate_);
365
366 RenderFrameDevToolsAgentHost* agent_host =
367 static_cast<RenderFrameDevToolsAgentHost*>(
368 DevToolsAgentHost::GetOrCreateFor(web_contents).get());
369 if (!RenderFrameDevToolsAgentHost::NotifyCertificateError(
370 agent_host, cert_error, request_url, callback)) {
371 GetContentClient()->browser()->AllowCertificateError(
372 web_contents, cert_error, ssl_info, request_url, resource_type,
373 overridable, strict_enforcement, expired_previous_decision, callback);
374 }
364 } 375 }
365 376
366 void SSLManager::UpdateEntry(NavigationEntryImpl* entry, 377 void SSLManager::UpdateEntry(NavigationEntryImpl* entry,
367 int add_content_status_flags, 378 int add_content_status_flags,
368 int remove_content_status_flags) { 379 int remove_content_status_flags) {
369 // We don't always have a navigation entry to update, for example in the 380 // We don't always have a navigation entry to update, for example in the
370 // case of the Web Inspector. 381 // case of the Web Inspector.
371 if (!entry) 382 if (!entry)
372 return; 383 return;
373 384
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 SSLManagerSet* managers = 432 SSLManagerSet* managers =
422 static_cast<SSLManagerSet*>(context->GetUserData(kSSLManagerKeyName)); 433 static_cast<SSLManagerSet*>(context->GetUserData(kSSLManagerKeyName));
423 434
424 for (std::set<SSLManager*>::iterator i = managers->get().begin(); 435 for (std::set<SSLManager*>::iterator i = managers->get().begin();
425 i != managers->get().end(); ++i) { 436 i != managers->get().end(); ++i) {
426 (*i)->UpdateEntry((*i)->controller()->GetLastCommittedEntry(), 0, 0); 437 (*i)->UpdateEntry((*i)->controller()->GetLastCommittedEntry(), 0, 0);
427 } 438 }
428 } 439 }
429 440
430 } // namespace content 441 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698