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

Unified Diff: content/browser/ssl/ssl_manager.cc

Issue 2410023003: Add unit test for notifying WebContents when SSLStatus changes due to HTTP-bad (Closed)
Patch Set: add test comments Created 4 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/ssl/ssl_manager.cc
diff --git a/content/browser/ssl/ssl_manager.cc b/content/browser/ssl/ssl_manager.cc
index f2145870a2f0d1bfc5cefa6d2c8bf76257b96417..56353542668e297ee98c032d67771148d9269730 100644
--- a/content/browser/ssl/ssl_manager.cc
+++ b/content/browser/ssl/ssl_manager.cc
@@ -112,6 +112,45 @@ void HandleSSLErrorOnUI(
manager->OnCertError(std::move(handler));
}
+// Updates |entry|'s flags to account for the presence of insecure
+// content (mixed content or subresources with certificate errors).
+void UpdateEntryForInsecureContent(
+ NavigationEntryImpl* entry,
+ WebContentsImpl* web_contents_impl,
+ SSLHostStateDelegate* ssl_host_state_delegate) {
+ // Update the entry's flags for insecure content.
+ if (!web_contents_impl->DisplayedInsecureContent())
+ entry->GetSSL().content_status &= ~SSLStatus::DISPLAYED_INSECURE_CONTENT;
+ if (web_contents_impl->DisplayedInsecureContent())
elawrence 2016/10/12 15:22:47 Can the value of this change from line 123? If not
estark 2016/10/12 16:20:16 Done.
+ entry->GetSSL().content_status |= SSLStatus::DISPLAYED_INSECURE_CONTENT;
+ if (!web_contents_impl->DisplayedContentWithCertErrors()) {
+ entry->GetSSL().content_status &=
+ ~SSLStatus::DISPLAYED_CONTENT_WITH_CERT_ERRORS;
+ }
+ if (web_contents_impl->DisplayedContentWithCertErrors()) {
elawrence 2016/10/12 15:22:46 ditto
estark 2016/10/12 16:20:16 Done.
+ entry->GetSSL().content_status |=
+ SSLStatus::DISPLAYED_CONTENT_WITH_CERT_ERRORS;
+ }
+
+ SiteInstance* site_instance = entry->site_instance();
+ // Note that |site_instance| can be NULL here because NavigationEntries don't
+ // necessarily have site instances. Without a process, the entry can't
+ // possibly have insecure content. See bug http://crbug.com/12423.
elawrence 2016/10/12 15:22:46 HTTPS for all URLs please. :) Utterly trivial, bu
estark 2016/10/12 16:20:16 Neither of those are my fault, I was just moving o
+ if (site_instance && ssl_host_state_delegate &&
elawrence 2016/10/12 15:22:46 Similar to earlier, is there a reason we shouldn't
estark 2016/10/12 16:20:16 Done.
+ ssl_host_state_delegate->DidHostRunInsecureContent(
+ entry->GetURL().host(), site_instance->GetProcess()->GetID(),
+ SSLHostStateDelegate::MIXED_CONTENT)) {
+ entry->GetSSL().content_status |= SSLStatus::RAN_INSECURE_CONTENT;
+ }
+
+ if (site_instance && ssl_host_state_delegate &&
+ ssl_host_state_delegate->DidHostRunInsecureContent(
+ entry->GetURL().host(), site_instance->GetProcess()->GetID(),
+ SSLHostStateDelegate::CERT_ERRORS_CONTENT)) {
+ entry->GetSSL().content_status |= SSLStatus::RAN_CONTENT_WITH_CERT_ERRORS;
+ }
+}
+
} // namespace
// static
@@ -364,45 +403,16 @@ void SSLManager::UpdateEntry(NavigationEntryImpl* entry) {
SSLStatus::DISPLAYED_CREDIT_CARD_FIELD_ON_HTTP;
}
- // Do not record information about insecure subresources if the main
- // page is HTTP or HTTPS without a certificate.
- if (!entry->GetURL().SchemeIsCryptographic() || !entry->GetSSL().certificate)
- return;
-
- // Update the entry's flags for insecure content.
- if (!web_contents_impl->DisplayedInsecureContent())
- entry->GetSSL().content_status &= ~SSLStatus::DISPLAYED_INSECURE_CONTENT;
- if (web_contents_impl->DisplayedInsecureContent())
- entry->GetSSL().content_status |= SSLStatus::DISPLAYED_INSECURE_CONTENT;
- if (!web_contents_impl->DisplayedContentWithCertErrors()) {
- entry->GetSSL().content_status &=
- ~SSLStatus::DISPLAYED_CONTENT_WITH_CERT_ERRORS;
- }
- if (web_contents_impl->DisplayedContentWithCertErrors()) {
- entry->GetSSL().content_status |=
- SSLStatus::DISPLAYED_CONTENT_WITH_CERT_ERRORS;
+ // Only record information about insecure subresources if the main
+ // page is HTTPS with a certificate.
+ if (entry->GetURL().SchemeIsCryptographic() && entry->GetSSL().certificate) {
+ UpdateEntryForInsecureContent(entry, web_contents_impl,
+ ssl_host_state_delegate_);
}
- SiteInstance* site_instance = entry->site_instance();
- // Note that |site_instance| can be NULL here because NavigationEntries don't
- // necessarily have site instances. Without a process, the entry can't
- // possibly have insecure content. See bug http://crbug.com/12423.
- if (site_instance && ssl_host_state_delegate_ &&
- ssl_host_state_delegate_->DidHostRunInsecureContent(
- entry->GetURL().host(), site_instance->GetProcess()->GetID(),
- SSLHostStateDelegate::MIXED_CONTENT)) {
- entry->GetSSL().content_status |= SSLStatus::RAN_INSECURE_CONTENT;
- }
-
- if (site_instance && ssl_host_state_delegate_ &&
- ssl_host_state_delegate_->DidHostRunInsecureContent(
- entry->GetURL().host(), site_instance->GetProcess()->GetID(),
- SSLHostStateDelegate::CERT_ERRORS_CONTENT)) {
- entry->GetSSL().content_status |= SSLStatus::RAN_CONTENT_WITH_CERT_ERRORS;
- }
-
- if (!entry->GetSSL().Equals(original_ssl_status))
+ if (!entry->GetSSL().Equals(original_ssl_status)) {
elawrence 2016/10/12 15:22:46 Will this be reached much more often than it was p
estark 2016/10/12 16:20:16 Ohh, nice catch. I thought that in the common case
elawrence 2016/10/12 16:28:58 Acknowledged.
NotifyDidChangeVisibleSSLState();
+ }
}
void SSLManager::NotifyDidChangeVisibleSSLState() {
« no previous file with comments | « no previous file | content/browser/ssl/ssl_manager_unittest.cc » ('j') | content/browser/ssl/ssl_manager_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698