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

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

Issue 48091: SSLPolicy Fix: Step 8.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ssl/ssl_manager.h ('k') | chrome/browser/ssl/ssl_policy.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 "chrome/browser/ssl/ssl_manager.h" 5 #include "chrome/browser/ssl/ssl_manager.h"
6 6
7 #include "base/message_loop.h" 7 #include "base/message_loop.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "chrome/browser/browser_process.h" 9 #include "chrome/browser/browser_process.h"
10 #include "chrome/browser/load_from_memory_cache_details.h" 10 #include "chrome/browser/load_from_memory_cache_details.h"
11 #include "chrome/browser/renderer_host/render_view_host.h" 11 #include "chrome/browser/renderer_host/render_view_host.h"
12 #include "chrome/browser/renderer_host/resource_request_details.h" 12 #include "chrome/browser/renderer_host/resource_request_details.h"
13 #include "chrome/browser/ssl/ssl_error_info.h" 13 #include "chrome/browser/ssl/ssl_error_info.h"
14 #include "chrome/browser/ssl/ssl_host_state.h" 14 #include "chrome/browser/ssl/ssl_host_state.h"
15 #include "chrome/browser/ssl/ssl_policy.h"
15 #include "chrome/browser/tab_contents/navigation_controller.h" 16 #include "chrome/browser/tab_contents/navigation_controller.h"
16 #include "chrome/browser/tab_contents/navigation_entry.h" 17 #include "chrome/browser/tab_contents/navigation_entry.h"
17 #include "chrome/browser/tab_contents/provisional_load_details.h" 18 #include "chrome/browser/tab_contents/provisional_load_details.h"
18 #include "chrome/browser/tab_contents/tab_util.h" 19 #include "chrome/browser/tab_contents/tab_util.h"
19 #include "chrome/browser/tab_contents/web_contents.h" 20 #include "chrome/browser/tab_contents/web_contents.h"
20 #include "chrome/browser/ssl/ssl_policy.h"
21 #include "chrome/common/l10n_util.h" 21 #include "chrome/common/l10n_util.h"
22 #include "chrome/common/notification_service.h" 22 #include "chrome/common/notification_service.h"
23 #include "chrome/common/pref_names.h" 23 #include "chrome/common/pref_names.h"
24 #include "chrome/common/pref_service.h" 24 #include "chrome/common/pref_service.h"
25 #include "chrome/common/resource_bundle.h" 25 #include "chrome/common/resource_bundle.h"
26 #include "grit/generated_resources.h" 26 #include "grit/generated_resources.h"
27 #include "grit/theme_resources.h" 27 #include "grit/theme_resources.h"
28 #include "net/base/cert_status_flags.h" 28 #include "net/base/cert_status_flags.h"
29 #include "net/base/net_errors.h" 29 #include "net/base/net_errors.h"
30 #include "net/url_request/url_request.h" 30 #include "net/url_request/url_request.h"
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 registrar_.Add(this, NotificationType::NAV_ENTRY_COMMITTED, 113 registrar_.Add(this, NotificationType::NAV_ENTRY_COMMITTED,
114 Source<NavigationController>(controller_)); 114 Source<NavigationController>(controller_));
115 registrar_.Add(this, NotificationType::FAIL_PROVISIONAL_LOAD_WITH_ERROR, 115 registrar_.Add(this, NotificationType::FAIL_PROVISIONAL_LOAD_WITH_ERROR,
116 Source<NavigationController>(controller_)); 116 Source<NavigationController>(controller_));
117 registrar_.Add(this, NotificationType::RESOURCE_RESPONSE_STARTED, 117 registrar_.Add(this, NotificationType::RESOURCE_RESPONSE_STARTED,
118 Source<NavigationController>(controller_)); 118 Source<NavigationController>(controller_));
119 registrar_.Add(this, NotificationType::RESOURCE_RECEIVED_REDIRECT, 119 registrar_.Add(this, NotificationType::RESOURCE_RECEIVED_REDIRECT,
120 Source<NavigationController>(controller_)); 120 Source<NavigationController>(controller_));
121 registrar_.Add(this, NotificationType::LOAD_FROM_MEMORY_CACHE, 121 registrar_.Add(this, NotificationType::LOAD_FROM_MEMORY_CACHE,
122 Source<NavigationController>(controller_)); 122 Source<NavigationController>(controller_));
123 registrar_.Add(this, NotificationType::SSL_INTERNAL_STATE_CHANGED,
124 NotificationService::AllSources());
123 } 125 }
124 126
125 SSLManager::~SSLManager() { 127 SSLManager::~SSLManager() {
126 } 128 }
127 129
128 // Delegate API method. 130 // Delegate API method.
129 void SSLManager::ShowMessage(const std::wstring& msg) { 131 void SSLManager::ShowMessage(const std::wstring& msg) {
130 ShowMessageWithLink(msg, std::wstring(), NULL); 132 ShowMessageWithLink(msg, std::wstring(), NULL);
131 } 133 }
132 134
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 return; 184 return;
183 WebContents* web_contents = tab_contents->AsWebContents(); 185 WebContents* web_contents = tab_contents->AsWebContents();
184 if (!web_contents) 186 if (!web_contents)
185 return; 187 return;
186 188
187 web_contents->render_view_host()->AddMessageToConsole( 189 web_contents->render_view_host()->AddMessageToConsole(
188 std::wstring(), msg, level); 190 std::wstring(), msg, level);
189 } 191 }
190 192
191 // Delegate API method. 193 // Delegate API method.
194 void SSLManager::MarkHostAsBroken(const std::string& host) {
195 ssl_host_state_->MarkHostAsBroken(host);
196 DispatchSSLInternalStateChanged();
197 }
198
199 // Delegate API method.
200 bool SSLManager::DidMarkHostAsBroken(const std::string& host) const {
201 return ssl_host_state_->DidMarkHostAsBroken(host);
202 }
203
204 // Delegate API method.
192 void SSLManager::DenyCertForHost(net::X509Certificate* cert, 205 void SSLManager::DenyCertForHost(net::X509Certificate* cert,
193 const std::string& host) { 206 const std::string& host) {
194 // Remember that we don't like this cert for this host. 207 // Remember that we don't like this cert for this host.
195 ssl_host_state_->DenyCertForHost(cert, host); 208 ssl_host_state_->DenyCertForHost(cert, host);
209 DispatchSSLInternalStateChanged();
196 } 210 }
197 211
198 // Delegate API method. 212 // Delegate API method.
199 void SSLManager::AllowCertForHost(net::X509Certificate* cert, 213 void SSLManager::AllowCertForHost(net::X509Certificate* cert,
200 const std::string& host) { 214 const std::string& host) {
201 ssl_host_state_->AllowCertForHost(cert, host); 215 ssl_host_state_->AllowCertForHost(cert, host);
216 DispatchSSLInternalStateChanged();
202 } 217 }
203 218
204 // Delegate API method. 219 // Delegate API method.
205 net::X509Certificate::Policy::Judgment SSLManager::QueryPolicy( 220 net::X509Certificate::Policy::Judgment SSLManager::QueryPolicy(
206 net::X509Certificate* cert, const std::string& host) { 221 net::X509Certificate* cert, const std::string& host) {
207 return ssl_host_state_->QueryPolicy(cert, host); 222 return ssl_host_state_->QueryPolicy(cert, host);
208 } 223 }
209 224
210 bool SSLManager::CanShowInsecureContent(const GURL& url) { 225 // Delegate API method.
211 return ssl_host_state_->DidAllowMixedContentForHost(url.host()); 226 void SSLManager::AllowMixedContentForHost(const std::string& host) {
227 ssl_host_state_->AllowMixedContentForHost(host);
228 DispatchSSLInternalStateChanged();
212 } 229 }
213 230
214 void SSLManager::AllowShowInsecureContentForURL(const GURL& url) { 231 // Delegate API method.
215 ssl_host_state_->AllowMixedContentForHost(url.host()); 232 bool SSLManager::DidAllowMixedContentForHost(const std::string& host) const {
233 return ssl_host_state_->DidAllowMixedContentForHost(host);
216 } 234 }
217 235
218 bool SSLManager::ProcessedSSLErrorFromRequest() const { 236 bool SSLManager::ProcessedSSLErrorFromRequest() const {
219 NavigationEntry* entry = controller_->GetActiveEntry(); 237 NavigationEntry* entry = controller_->GetActiveEntry();
220 if (!entry) { 238 if (!entry) {
221 NOTREACHED(); 239 NOTREACHED();
222 return false; 240 return false;
223 } 241 }
224 242
225 return net::IsCertStatusError(entry->ssl().cert_status()); 243 return net::IsCertStatusError(entry->ssl().cert_status());
226 } 244 }
227 245
228 //////////////////////////////////////////////////////////////////////////////// 246 ////////////////////////////////////////////////////////////////////////////////
229 // ErrorHandler 247 // ErrorHandler
230 248
231 SSLManager::ErrorHandler::ErrorHandler(ResourceDispatcherHost* rdh, 249 SSLManager::ErrorHandler::ErrorHandler(ResourceDispatcherHost* rdh,
232 URLRequest* request, 250 URLRequest* request,
251 ResourceType::Type resource_type,
252 const std::string& frame_origin,
253 const std::string& main_frame_origin,
233 MessageLoop* ui_loop) 254 MessageLoop* ui_loop)
234 : ui_loop_(ui_loop), 255 : ui_loop_(ui_loop),
235 io_loop_(MessageLoop::current()), 256 io_loop_(MessageLoop::current()),
236 manager_(NULL), 257 manager_(NULL),
237 request_id_(0, 0), 258 request_id_(0, 0),
238 resource_dispatcher_host_(rdh), 259 resource_dispatcher_host_(rdh),
239 request_url_(request->url()), 260 request_url_(request->url()),
261 resource_type_(resource_type),
262 frame_origin_(frame_origin),
263 main_frame_origin_(main_frame_origin),
240 request_has_been_notified_(false) { 264 request_has_been_notified_(false) {
241 DCHECK(MessageLoop::current() != ui_loop); 265 DCHECK(MessageLoop::current() != ui_loop);
242 266
243 ResourceDispatcherHost::ExtraRequestInfo* info = 267 ResourceDispatcherHost::ExtraRequestInfo* info =
244 ResourceDispatcherHost::ExtraInfoForRequest(request); 268 ResourceDispatcherHost::ExtraInfoForRequest(request);
245 request_id_.process_id = info->process_id; 269 request_id_.process_id = info->process_id;
246 request_id_.request_id = info->request_id; 270 request_id_.request_id = info->request_id;
247 271
248 if (!tab_util::GetTabContentsID(request, 272 if (!tab_util::GetTabContentsID(request,
249 &render_process_host_id_, 273 &render_process_host_id_,
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 } 444 }
421 445
422 446
423 //////////////////////////////////////////////////////////////////////////////// 447 ////////////////////////////////////////////////////////////////////////////////
424 // CertError 448 // CertError
425 449
426 SSLManager::CertError::CertError( 450 SSLManager::CertError::CertError(
427 ResourceDispatcherHost* rdh, 451 ResourceDispatcherHost* rdh,
428 URLRequest* request, 452 URLRequest* request,
429 ResourceType::Type resource_type, 453 ResourceType::Type resource_type,
454 const std::string& frame_origin,
455 const std::string& main_frame_origin,
430 int cert_error, 456 int cert_error,
431 net::X509Certificate* cert, 457 net::X509Certificate* cert,
432 MessageLoop* ui_loop) 458 MessageLoop* ui_loop)
433 : ErrorHandler(rdh, request, ui_loop), 459 : ErrorHandler(rdh, request, resource_type, frame_origin,
434 cert_error_(cert_error), 460 main_frame_origin, ui_loop),
435 resource_type_(resource_type) { 461 cert_error_(cert_error) {
436 DCHECK(request == resource_dispatcher_host_->GetURLRequest(request_id_)); 462 DCHECK(request == resource_dispatcher_host_->GetURLRequest(request_id_));
437 463
438 // We cannot use the request->ssl_info(), it's not been initialized yet, so 464 // We cannot use the request->ssl_info(), it's not been initialized yet, so
439 // we have to set the fields manually. 465 // we have to set the fields manually.
440 ssl_info_.cert = cert; 466 ssl_info_.cert = cert;
441 ssl_info_.SetCertError(cert_error); 467 ssl_info_.SetCertError(cert_error);
442 } 468 }
443 469
444 // static 470 // static
445 void SSLManager::OnSSLCertificateError(ResourceDispatcherHost* rdh, 471 void SSLManager::OnSSLCertificateError(ResourceDispatcherHost* rdh,
446 URLRequest* request, 472 URLRequest* request,
447 int cert_error, 473 int cert_error,
448 net::X509Certificate* cert, 474 net::X509Certificate* cert,
449 MessageLoop* ui_loop) { 475 MessageLoop* ui_loop) {
450 DLOG(INFO) << "OnSSLCertificateError() cert_error: " << cert_error << 476 DLOG(INFO) << "OnSSLCertificateError() cert_error: " << cert_error <<
451 " url: " << request->url().spec(); 477 " url: " << request->url().spec();
452 478
453 ResourceDispatcherHost::ExtraRequestInfo* info = 479 ResourceDispatcherHost::ExtraRequestInfo* info =
454 ResourceDispatcherHost::ExtraInfoForRequest(request); 480 ResourceDispatcherHost::ExtraInfoForRequest(request);
455 DCHECK(info); 481 DCHECK(info);
456 482
457 // A certificate error occurred. Construct a CertError object and hand it 483 // A certificate error occurred. Construct a CertError object and hand it
458 // over to the UI thread for processing. 484 // over to the UI thread for processing.
459 ui_loop->PostTask(FROM_HERE, 485 ui_loop->PostTask(FROM_HERE,
460 NewRunnableMethod(new CertError(rdh, request, info->resource_type, 486 NewRunnableMethod(new CertError(rdh,
461 cert_error, cert, ui_loop), 487 request,
488 info->resource_type,
489 info->frame_origin,
490 info->main_frame_origin,
491 cert_error,
492 cert,
493 ui_loop),
462 &CertError::Dispatch)); 494 &CertError::Dispatch));
463 } 495 }
464 496
465 // static 497 // static
466 bool SSLManager::ShouldStartRequest(ResourceDispatcherHost* rdh, 498 bool SSLManager::ShouldStartRequest(ResourceDispatcherHost* rdh,
467 URLRequest* request, 499 URLRequest* request,
468 MessageLoop* ui_loop) { 500 MessageLoop* ui_loop) {
469 ResourceDispatcherHost::ExtraRequestInfo* info = 501 ResourceDispatcherHost::ExtraRequestInfo* info =
470 ResourceDispatcherHost::ExtraInfoForRequest(request); 502 ResourceDispatcherHost::ExtraInfoForRequest(request);
471 DCHECK(info); 503 DCHECK(info);
472 504
473 // We cheat here and talk to the SSLPolicy on the IO thread because we need 505 // We cheat here and talk to the SSLPolicy on the IO thread because we need
474 // to respond synchronously to avoid delaying all network requests... 506 // to respond synchronously to avoid delaying all network requests...
475 if (!SSLPolicy::IsMixedContent(request->url(), 507 if (!SSLPolicy::IsMixedContent(request->url(),
476 info->resource_type, 508 info->resource_type,
477 info->main_frame_origin)) 509 info->main_frame_origin))
478 return true; 510 return true;
479 511
480 512
481 ui_loop->PostTask(FROM_HERE, 513 ui_loop->PostTask(FROM_HERE,
482 NewRunnableMethod(new MixedContentHandler(rdh, request, ui_loop), 514 NewRunnableMethod(new MixedContentHandler(rdh, request,
515 info->resource_type,
516 info->frame_origin,
517 info->main_frame_origin,
518 ui_loop),
483 &MixedContentHandler::Dispatch)); 519 &MixedContentHandler::Dispatch));
484 return false; 520 return false;
485 } 521 }
486 522
487 void SSLManager::OnCertError(CertError* error) { 523 void SSLManager::OnCertError(CertError* error) {
488 // Ask our delegate to deal with the error. 524 delegate()->OnCertError(error);
489 NavigationEntry* entry = controller_->GetActiveEntry();
490 // We might not have a navigation entry in some cases (e.g. when a
491 // HTTPS page opens a popup with no URL and then populate it with
492 // document.write()). See bug http://crbug.com/3845.
493 if (!entry)
494 return;
495
496 delegate()->OnCertError(entry->url(), error);
497 } 525 }
498 526
499 void SSLManager::OnMixedContent(MixedContentHandler* mixed_content) { 527 void SSLManager::OnMixedContent(MixedContentHandler* handler) {
500 // Ask our delegate to deal with the mixed content. 528 delegate()->OnMixedContent(handler);
501 NavigationEntry* entry = controller_->GetActiveEntry();
502 // We might not have a navigation entry in some cases (e.g. when a
503 // HTTPS page opens a popup with no URL and then populate it with
504 // document.write()). See bug http://crbug.com/3845.
505 if (!entry)
506 return;
507
508 delegate()->OnMixedContent(controller_, entry->url(), mixed_content);
509 } 529 }
510 530
511 void SSLManager::Observe(NotificationType type, 531 void SSLManager::Observe(NotificationType type,
512 const NotificationSource& source, 532 const NotificationSource& source,
513 const NotificationDetails& details) { 533 const NotificationDetails& details) {
514 // We should only be getting notifications from our controller. 534 // We should only be getting notifications from our controller.
515 DCHECK(source == Source<NavigationController>(controller_)); 535 DCHECK(source == Source<NavigationController>(controller_));
516 536
517 // Dispatch by type. 537 // Dispatch by type.
518 switch (type.value) { 538 switch (type.value) {
519 case NotificationType::NAV_ENTRY_COMMITTED: 539 case NotificationType::NAV_ENTRY_COMMITTED:
520 DidCommitProvisionalLoad(details); 540 DidCommitProvisionalLoad(details);
521 break; 541 break;
522 case NotificationType::FAIL_PROVISIONAL_LOAD_WITH_ERROR: 542 case NotificationType::FAIL_PROVISIONAL_LOAD_WITH_ERROR:
523 DidFailProvisionalLoadWithError( 543 DidFailProvisionalLoadWithError(
524 Details<ProvisionalLoadDetails>(details).ptr()); 544 Details<ProvisionalLoadDetails>(details).ptr());
525 break; 545 break;
526 case NotificationType::RESOURCE_RESPONSE_STARTED: 546 case NotificationType::RESOURCE_RESPONSE_STARTED:
527 DidStartResourceResponse(Details<ResourceRequestDetails>(details).ptr()); 547 DidStartResourceResponse(Details<ResourceRequestDetails>(details).ptr());
528 break; 548 break;
529 case NotificationType::RESOURCE_RECEIVED_REDIRECT: 549 case NotificationType::RESOURCE_RECEIVED_REDIRECT:
530 DidReceiveResourceRedirect( 550 DidReceiveResourceRedirect(
531 Details<ResourceRedirectDetails>(details).ptr()); 551 Details<ResourceRedirectDetails>(details).ptr());
532 break; 552 break;
533 case NotificationType::LOAD_FROM_MEMORY_CACHE: 553 case NotificationType::LOAD_FROM_MEMORY_CACHE:
534 DidLoadFromMemoryCache( 554 DidLoadFromMemoryCache(
535 Details<LoadFromMemoryCacheDetails>(details).ptr()); 555 Details<LoadFromMemoryCacheDetails>(details).ptr());
536 break; 556 break;
557 case NotificationType::SSL_INTERNAL_STATE_CHANGED:
558 DidChangeSSLInternalState();
559 break;
537 default: 560 default:
538 NOTREACHED() << "The SSLManager received an unexpected notification."; 561 NOTREACHED() << "The SSLManager received an unexpected notification.";
539 } 562 }
540 } 563 }
541 564
565 void SSLManager::DispatchSSLInternalStateChanged() {
566 NotificationService::current()->Notify(
567 NotificationType::SSL_INTERNAL_STATE_CHANGED,
568 Source<NavigationController>(controller_),
569 NotificationService::NoDetails());
570 }
571
572 void SSLManager::DispatchSSLVisibleStateChanged() {
573 NotificationService::current()->Notify(
574 NotificationType::SSL_VISIBLE_STATE_CHANGED,
575 Source<NavigationController>(controller_),
576 NotificationService::NoDetails());
577 }
578
542 void SSLManager::InitializeEntryIfNeeded(NavigationEntry* entry) { 579 void SSLManager::InitializeEntryIfNeeded(NavigationEntry* entry) {
543 DCHECK(entry); 580 DCHECK(entry);
544 581
545 // If the security style of the entry is SECURITY_STYLE_UNKNOWN, then it is a 582 // If the security style of the entry is SECURITY_STYLE_UNKNOWN, then it is a
546 // fresh entry and should get the default style. 583 // fresh entry and should get the default style.
547 if (entry->ssl().security_style() == SECURITY_STYLE_UNKNOWN) { 584 if (entry->ssl().security_style() == SECURITY_STYLE_UNKNOWN) {
548 entry->ssl().set_security_style( 585 entry->ssl().set_security_style(
549 delegate()->GetDefaultStyle(entry->url())); 586 delegate()->GetDefaultStyle(entry->url()));
550 } 587 }
551 } 588 }
552 589
553 void SSLManager::NavigationStateChanged() { 590 void SSLManager::NavigationStateChanged() {
554 NavigationEntry* active_entry = controller_->GetActiveEntry(); 591 NavigationEntry* active_entry = controller_->GetActiveEntry();
555 if (!active_entry) 592 if (!active_entry)
556 return; // Nothing showing yet. 593 return; // Nothing showing yet.
557 594
558 // This might be a new entry we've never seen before. 595 // This might be a new entry we've never seen before.
559 InitializeEntryIfNeeded(active_entry); 596 InitializeEntryIfNeeded(active_entry);
560 } 597 }
561 598
562 void SSLManager::DidLoadFromMemoryCache(LoadFromMemoryCacheDetails* details) { 599 void SSLManager::DidLoadFromMemoryCache(LoadFromMemoryCacheDetails* details) {
563 DCHECK(details); 600 DCHECK(details);
564 601
565 // Simulate loading this resource through the usual path. 602 // Simulate loading this resource through the usual path.
566 // Note that we specify SUB_RESOURCE as the resource type as WebCore only 603 // Note that we specify SUB_RESOURCE as the resource type as WebCore only
567 // caches sub-resources. 604 // caches sub-resources.
568 delegate()->OnRequestStarted(this, details->url(), 605 scoped_refptr<RequestInfo> info = new RequestInfo(
569 ResourceType::SUB_RESOURCE, 606 this,
570 details->ssl_cert_id(), 607 details->url(),
571 details->ssl_cert_status()); 608 ResourceType::SUB_RESOURCE,
609 details->frame_origin(),
610 details->main_frame_origin(),
611 details->ssl_cert_id(),
612 details->ssl_cert_status());
613
614 // Simulate loading this resource through the usual path.
615 delegate()->OnRequestStarted(info.get());
572 } 616 }
573 617
574 void SSLManager::DidCommitProvisionalLoad( 618 void SSLManager::DidCommitProvisionalLoad(
575 const NotificationDetails& in_details) { 619 const NotificationDetails& in_details) {
576 NavigationController::LoadCommittedDetails* details = 620 NavigationController::LoadCommittedDetails* details =
577 Details<NavigationController::LoadCommittedDetails>(in_details).ptr(); 621 Details<NavigationController::LoadCommittedDetails>(in_details).ptr();
578 622
579 // Ignore in-page navigations, they should not change the security style or 623 // Ignore in-page navigations, they should not change the security style or
580 // the info-bars. 624 // the info-bars.
581 if (details->is_in_page) 625 if (details->is_in_page)
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
647 if (details->in_page_navigation()) 691 if (details->in_page_navigation())
648 return; 692 return;
649 693
650 if (details->main_frame()) 694 if (details->main_frame())
651 ClearPendingMessages(); 695 ClearPendingMessages();
652 } 696 }
653 697
654 void SSLManager::DidStartResourceResponse(ResourceRequestDetails* details) { 698 void SSLManager::DidStartResourceResponse(ResourceRequestDetails* details) {
655 DCHECK(details); 699 DCHECK(details);
656 700
701 scoped_refptr<RequestInfo> info = new RequestInfo(
702 this,
703 details->url(),
704 details->resource_type(),
705 details->frame_origin(),
706 details->main_frame_origin(),
707 details->ssl_cert_id(),
708 details->ssl_cert_status());
709
657 // Notify our delegate that we started a resource request. Ideally, the 710 // Notify our delegate that we started a resource request. Ideally, the
658 // delegate should have the ability to cancel the request, but we can't do 711 // delegate should have the ability to cancel the request, but we can't do
659 // that yet. 712 // that yet.
660 delegate()->OnRequestStarted(this, details->url(), 713 delegate()->OnRequestStarted(info.get());
661 details->resource_type(),
662 details->ssl_cert_id() ,
663 details->ssl_cert_status());
664 } 714 }
665 715
666 void SSLManager::DidReceiveResourceRedirect(ResourceRedirectDetails* details) { 716 void SSLManager::DidReceiveResourceRedirect(ResourceRedirectDetails* details) {
667 // TODO(jcampan): when we receive a redirect for a sub-resource, we may want 717 // TODO(abarth): Make sure our redirect behavior is correct. If we ever see
668 // to clear any mixed/unsafe content error that it may have triggered. 718 // a non-HTTPS resource in the redirect chain, we want to
719 // trigger mixed content, even if the redirect chain goes back
720 // to HTTPS. This is because the network attacker can redirect
721 // the HTTP request to https://attacker.com/payload.js.
669 } 722 }
670 723
671 void SSLManager::ShowPendingMessages() { 724 void SSLManager::ShowPendingMessages() {
672 std::vector<SSLMessageInfo>::const_iterator iter; 725 std::vector<SSLMessageInfo>::const_iterator iter;
673 for (iter = pending_messages_.begin(); 726 for (iter = pending_messages_.begin();
674 iter != pending_messages_.end(); ++iter) { 727 iter != pending_messages_.end(); ++iter) {
675 ShowMessageWithLink(iter->message, iter->link_text, iter->action); 728 ShowMessageWithLink(iter->message, iter->link_text, iter->action);
676 } 729 }
677 ClearPendingMessages(); 730 ClearPendingMessages();
678 } 731 }
679 732
733 void SSLManager::DidChangeSSLInternalState() {
734 // TODO(abarth): We'll need to do something here in the next step.
735 }
736
680 void SSLManager::ClearPendingMessages() { 737 void SSLManager::ClearPendingMessages() {
681 pending_messages_.clear(); 738 pending_messages_.clear();
682 } 739 }
683 740
684 // static 741 // static
685 std::string SSLManager::SerializeSecurityInfo(int cert_id, 742 std::string SSLManager::SerializeSecurityInfo(int cert_id,
686 int cert_status, 743 int cert_status,
687 int security_bits) { 744 int security_bits) {
688 Pickle pickle; 745 Pickle pickle;
689 pickle.WriteInt(cert_id); 746 pickle.WriteInt(cert_id);
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
735 } 792 }
736 793
737 if (ca_name) { 794 if (ca_name) {
738 // TODO(wtc): should we show the root CA's name instead? 795 // TODO(wtc): should we show the root CA's name instead?
739 *ca_name = l10n_util::GetStringF( 796 *ca_name = l10n_util::GetStringF(
740 IDS_SECURE_CONNECTION_EV_CA, 797 IDS_SECURE_CONNECTION_EV_CA,
741 UTF8ToWide(cert.issuer().organization_names[0])); 798 UTF8ToWide(cert.issuer().organization_names[0]));
742 } 799 }
743 return true; 800 return true;
744 } 801 }
OLDNEW
« no previous file with comments | « chrome/browser/ssl/ssl_manager.h ('k') | chrome/browser/ssl/ssl_policy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698