| OLD | NEW |
| 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/frame_host/navigation_entry_impl.h" | 14 #include "content/browser/frame_host/navigation_entry_impl.h" |
| 15 #include "content/browser/loader/resource_dispatcher_host_impl.h" | 15 #include "content/browser/loader/resource_dispatcher_host_impl.h" |
| 16 #include "content/browser/loader/resource_request_info_impl.h" | 16 #include "content/browser/loader/resource_request_info_impl.h" |
| 17 #include "content/browser/ssl/ssl_error_handler.h" | 17 #include "content/browser/ssl/ssl_error_handler.h" |
| 18 #include "content/browser/web_contents/web_contents_impl.h" | 18 #include "content/browser/web_contents/web_contents_impl.h" |
| 19 #include "content/common/security_style_util.h" | |
| 20 #include "content/public/browser/browser_context.h" | 19 #include "content/public/browser/browser_context.h" |
| 21 #include "content/public/browser/browser_thread.h" | 20 #include "content/public/browser/browser_thread.h" |
| 22 #include "content/public/browser/certificate_request_result_type.h" | 21 #include "content/public/browser/certificate_request_result_type.h" |
| 23 #include "content/public/browser/content_browser_client.h" | 22 #include "content/public/browser/content_browser_client.h" |
| 24 #include "content/public/browser/navigation_details.h" | 23 #include "content/public/browser/navigation_details.h" |
| 25 #include "content/public/browser/ssl_host_state_delegate.h" | 24 #include "content/public/browser/ssl_host_state_delegate.h" |
| 26 #include "content/public/browser/ssl_status.h" | 25 #include "content/public/browser/ssl_status.h" |
| 27 #include "net/url_request/url_request.h" | 26 #include "net/url_request/url_request.h" |
| 28 | 27 |
| 29 namespace content { | 28 namespace content { |
| (...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 336 ssl_host_state_delegate_)); | 335 ssl_host_state_delegate_)); |
| 337 } | 336 } |
| 338 | 337 |
| 339 void SSLManager::UpdateEntry(NavigationEntryImpl* entry) { | 338 void SSLManager::UpdateEntry(NavigationEntryImpl* entry) { |
| 340 // We don't always have a navigation entry to update, for example in the | 339 // We don't always have a navigation entry to update, for example in the |
| 341 // case of the Web Inspector. | 340 // case of the Web Inspector. |
| 342 if (!entry) | 341 if (!entry) |
| 343 return; | 342 return; |
| 344 | 343 |
| 345 SSLStatus original_ssl_status = entry->GetSSL(); // Copy! | 344 SSLStatus original_ssl_status = entry->GetSSL(); // Copy! |
| 346 | 345 entry->GetSSL().initialized = true; |
| 347 // Initialize the entry with an initial SecurityStyle if needed. | |
| 348 if (entry->GetSSL().security_style == SECURITY_STYLE_UNKNOWN) { | |
| 349 entry->GetSSL().security_style = GetSecurityStyleForResource( | |
| 350 entry->GetURL(), !!entry->GetSSL().certificate, | |
| 351 entry->GetSSL().cert_status); | |
| 352 } | |
| 353 | 346 |
| 354 WebContentsImpl* web_contents_impl = | 347 WebContentsImpl* web_contents_impl = |
| 355 static_cast<WebContentsImpl*>(controller_->delegate()->GetWebContents()); | 348 static_cast<WebContentsImpl*>(controller_->delegate()->GetWebContents()); |
| 356 if (entry->GetSSL().security_style == SECURITY_STYLE_UNAUTHENTICATED) | 349 // Do not record information about insecure subresources if the main |
| 350 // page is HTTP or HTTPS without a certificate. |
| 351 if (!entry->GetURL().SchemeIsCryptographic() || !entry->GetSSL().certificate) |
| 357 return; | 352 return; |
| 358 | 353 |
| 359 // Update the entry's flags for insecure content. | 354 // Update the entry's flags for insecure content. |
| 360 if (!web_contents_impl->DisplayedInsecureContent()) | 355 if (!web_contents_impl->DisplayedInsecureContent()) |
| 361 entry->GetSSL().content_status &= ~SSLStatus::DISPLAYED_INSECURE_CONTENT; | 356 entry->GetSSL().content_status &= ~SSLStatus::DISPLAYED_INSECURE_CONTENT; |
| 362 if (web_contents_impl->DisplayedInsecureContent()) | 357 if (web_contents_impl->DisplayedInsecureContent()) |
| 363 entry->GetSSL().content_status |= SSLStatus::DISPLAYED_INSECURE_CONTENT; | 358 entry->GetSSL().content_status |= SSLStatus::DISPLAYED_INSECURE_CONTENT; |
| 364 if (!web_contents_impl->DisplayedContentWithCertErrors()) | 359 if (!web_contents_impl->DisplayedContentWithCertErrors()) |
| 365 entry->GetSSL().content_status &= | 360 entry->GetSSL().content_status &= |
| 366 ~SSLStatus::DISPLAYED_CONTENT_WITH_CERT_ERRORS; | 361 ~SSLStatus::DISPLAYED_CONTENT_WITH_CERT_ERRORS; |
| 367 if (web_contents_impl->DisplayedContentWithCertErrors()) | 362 if (web_contents_impl->DisplayedContentWithCertErrors()) |
| 368 entry->GetSSL().content_status |= | 363 entry->GetSSL().content_status |= |
| 369 SSLStatus::DISPLAYED_CONTENT_WITH_CERT_ERRORS; | 364 SSLStatus::DISPLAYED_CONTENT_WITH_CERT_ERRORS; |
| 370 | 365 |
| 371 SiteInstance* site_instance = entry->site_instance(); | 366 SiteInstance* site_instance = entry->site_instance(); |
| 372 // Note that |site_instance| can be NULL here because NavigationEntries don't | 367 // Note that |site_instance| can be NULL here because NavigationEntries don't |
| 373 // necessarily have site instances. Without a process, the entry can't | 368 // necessarily have site instances. Without a process, the entry can't |
| 374 // possibly have insecure content. See bug http://crbug.com/12423. | 369 // possibly have insecure content. See bug http://crbug.com/12423. |
| 375 if (site_instance && ssl_host_state_delegate_ && | 370 if (site_instance && ssl_host_state_delegate_ && |
| 376 ssl_host_state_delegate_->DidHostRunInsecureContent( | 371 ssl_host_state_delegate_->DidHostRunInsecureContent( |
| 377 entry->GetURL().host(), site_instance->GetProcess()->GetID(), | 372 entry->GetURL().host(), site_instance->GetProcess()->GetID(), |
| 378 SSLHostStateDelegate::MIXED_CONTENT)) { | 373 SSLHostStateDelegate::MIXED_CONTENT)) { |
| 379 entry->GetSSL().security_style = SECURITY_STYLE_AUTHENTICATION_BROKEN; | |
| 380 entry->GetSSL().content_status |= SSLStatus::RAN_INSECURE_CONTENT; | 374 entry->GetSSL().content_status |= SSLStatus::RAN_INSECURE_CONTENT; |
| 381 } | 375 } |
| 382 | 376 |
| 383 if (site_instance && ssl_host_state_delegate_ && | 377 if (site_instance && ssl_host_state_delegate_ && |
| 384 ssl_host_state_delegate_->DidHostRunInsecureContent( | 378 ssl_host_state_delegate_->DidHostRunInsecureContent( |
| 385 entry->GetURL().host(), site_instance->GetProcess()->GetID(), | 379 entry->GetURL().host(), site_instance->GetProcess()->GetID(), |
| 386 SSLHostStateDelegate::CERT_ERRORS_CONTENT)) { | 380 SSLHostStateDelegate::CERT_ERRORS_CONTENT)) { |
| 387 entry->GetSSL().security_style = SECURITY_STYLE_AUTHENTICATION_BROKEN; | |
| 388 entry->GetSSL().content_status |= SSLStatus::RAN_CONTENT_WITH_CERT_ERRORS; | 381 entry->GetSSL().content_status |= SSLStatus::RAN_CONTENT_WITH_CERT_ERRORS; |
| 389 } | 382 } |
| 390 | 383 |
| 391 if (!entry->GetSSL().Equals(original_ssl_status)) | 384 if (!entry->GetSSL().Equals(original_ssl_status)) |
| 392 NotifyDidChangeVisibleSSLState(); | 385 NotifyDidChangeVisibleSSLState(); |
| 393 } | 386 } |
| 394 | 387 |
| 395 void SSLManager::NotifyDidChangeVisibleSSLState() { | 388 void SSLManager::NotifyDidChangeVisibleSSLState() { |
| 396 WebContentsImpl* contents = | 389 WebContentsImpl* contents = |
| 397 static_cast<WebContentsImpl*>(controller_->delegate()->GetWebContents()); | 390 static_cast<WebContentsImpl*>(controller_->delegate()->GetWebContents()); |
| 398 contents->DidChangeVisibleSSLState(); | 391 contents->DidChangeVisibleSSLState(); |
| 399 } | 392 } |
| 400 | 393 |
| 401 } // namespace content | 394 } // namespace content |
| OLD | NEW |