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

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

Issue 2408393003: Manage insecure content flags in SSLManager, not WebContentsImpl (Closed)
Patch Set: 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
« no previous file with comments | « content/browser/ssl/ssl_manager.h ('k') | content/browser/web_contents/web_contents_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..60fe39e6a9ff6212af9b7b07aaccd54b883c715d 100644
--- a/content/browser/ssl/ssl_manager.cc
+++ b/content/browser/ssl/ssl_manager.cc
@@ -22,7 +22,6 @@
#include "content/public/browser/content_browser_client.h"
#include "content/public/browser/navigation_details.h"
#include "content/public/browser/ssl_host_state_delegate.h"
-#include "content/public/browser/ssl_status.h"
#include "net/url_request/url_request.h"
namespace content {
@@ -151,17 +150,6 @@ void SSLManager::OnSSLCertificateSubresourceError(
ssl_info, fatal);
}
-// static
-void SSLManager::NotifySSLInternalStateChanged(BrowserContext* context) {
- SSLManagerSet* managers = static_cast<SSLManagerSet*>(
- context->GetUserData(kSSLManagerKeyName));
-
- for (std::set<SSLManager*>::iterator i = managers->get().begin();
- i != managers->get().end(); ++i) {
- (*i)->UpdateEntry((*i)->controller()->GetLastCommittedEntry());
- }
-}
-
SSLManager::SSLManager(NavigationControllerImpl* controller)
: controller_(controller),
ssl_host_state_delegate_(
@@ -185,13 +173,36 @@ SSLManager::~SSLManager() {
void SSLManager::DidCommitProvisionalLoad(const LoadCommittedDetails& details) {
NavigationEntryImpl* entry = controller_->GetLastCommittedEntry();
- UpdateEntry(entry);
+ UpdateEntry(entry, SSLStatus::NORMAL_CONTENT);
// Always notify the WebContents that the SSL state changed when a
// load is committed, in case the active navigation entry has changed.
NotifyDidChangeVisibleSSLState();
}
-void SSLManager::DidRunInsecureContent(const GURL& security_origin) {
+void SSLManager::DidDisplayMixedContent() {
+ UpdateLastCommittedEntry(SSLStatus::DISPLAYED_INSECURE_CONTENT);
+}
+
+void SSLManager::DidDisplayContentWithCertErrors() {
+ NavigationEntryImpl* entry = controller_->GetLastCommittedEntry();
+ if (!entry)
+ return;
+ // Only record information about subresources with cert errors if the
+ // main page is HTTPS with a certificate.
+ if (entry->GetURL().SchemeIsCryptographic() && entry->GetSSL().certificate) {
+ UpdateLastCommittedEntry(SSLStatus::DISPLAYED_CONTENT_WITH_CERT_ERRORS);
+ }
+}
+
+void SSLManager::DidShowPasswordInputOnHttp() {
+ UpdateLastCommittedEntry(SSLStatus::DISPLAYED_PASSWORD_FIELD_ON_HTTP);
+}
+
+void SSLManager::DidShowCreditCardInputOnHttp() {
+ UpdateLastCommittedEntry(SSLStatus::DISPLAYED_CREDIT_CARD_FIELD_ON_HTTP);
+}
+
+void SSLManager::DidRunMixedContent(const GURL& security_origin) {
NavigationEntryImpl* entry = controller_->GetLastCommittedEntry();
if (!entry)
return;
@@ -205,7 +216,7 @@ void SSLManager::DidRunInsecureContent(const GURL& security_origin) {
security_origin.host(), site_instance->GetProcess()->GetID(),
SSLHostStateDelegate::MIXED_CONTENT);
}
- UpdateEntry(entry);
+ UpdateEntry(entry, SSLStatus::NORMAL_CONTENT);
NotifySSLInternalStateChanged(controller_->GetBrowserContext());
}
@@ -223,7 +234,7 @@ void SSLManager::DidRunContentWithCertErrors(const GURL& security_origin) {
security_origin.host(), site_instance->GetProcess()->GetID(),
SSLHostStateDelegate::CERT_ERRORS_CONTENT);
}
- UpdateEntry(entry);
+ UpdateEntry(entry, SSLStatus::NORMAL_CONTENT);
NotifySSLInternalStateChanged(controller_->GetBrowserContext());
}
@@ -335,7 +346,9 @@ void SSLManager::OnCertErrorInternal(std::unique_ptr<SSLErrorHandler> handler,
ssl_host_state_delegate_));
}
-void SSLManager::UpdateEntry(NavigationEntryImpl* entry) {
+void SSLManager::UpdateEntry(
+ NavigationEntryImpl* entry,
+ SSLStatus::ContentStatusFlags additional_content_status_flags) {
// We don't always have a navigation entry to update, for example in the
// case of the Web Inspector.
if (!entry)
@@ -343,45 +356,7 @@ void SSLManager::UpdateEntry(NavigationEntryImpl* entry) {
SSLStatus original_ssl_status = entry->GetSSL(); // Copy!
entry->GetSSL().initialized = true;
-
- WebContentsImpl* web_contents_impl =
- static_cast<WebContentsImpl*>(controller_->delegate()->GetWebContents());
-
- // For sensitive inputs (password, credit card) on HTTP, do not clear
- // the |content_status| flag when the WebContents no longer has the
- // flag set. This is different from how DISPLAYED_INSECURE_CONTENT and
- // DISPLAYED_CONTENT_WITH_CERT_ERRORS are handled below. For sensitive
- // inputs on HTTP, once the NavigationEntry has been marked as having
- // displayed a sensitive input, it stays that way, even if the
- // sensitive input is subsequently removed from the page.
- if (web_contents_impl->DisplayedPasswordFieldOnHttp()) {
- entry->GetSSL().content_status |=
- SSLStatus::DISPLAYED_PASSWORD_FIELD_ON_HTTP;
- }
-
- if (web_contents_impl->DisplayedCreditCardFieldOnHttp()) {
- entry->GetSSL().content_status |=
- 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;
estark 2016/10/12 07:01:19 You might notice here that we used to clear flags
- 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;
- }
+ entry->GetSSL().content_status |= additional_content_status_flags;
SiteInstance* site_instance = entry->site_instance();
// Note that |site_instance| can be NULL here because NavigationEntries don't
@@ -394,7 +369,10 @@ void SSLManager::UpdateEntry(NavigationEntryImpl* entry) {
entry->GetSSL().content_status |= SSLStatus::RAN_INSECURE_CONTENT;
}
- if (site_instance && ssl_host_state_delegate_ &&
+ // Only record information about subresources with cert errors if the
+ // main page is HTTPS with a certificate.
+ if (entry->GetURL().SchemeIsCryptographic() && entry->GetSSL().certificate &&
+ site_instance && ssl_host_state_delegate_ &&
ssl_host_state_delegate_->DidHostRunInsecureContent(
entry->GetURL().host(), site_instance->GetProcess()->GetID(),
SSLHostStateDelegate::CERT_ERRORS_CONTENT)) {
@@ -405,10 +383,30 @@ void SSLManager::UpdateEntry(NavigationEntryImpl* entry) {
NotifyDidChangeVisibleSSLState();
}
+void SSLManager::UpdateLastCommittedEntry(
+ SSLStatus::ContentStatusFlags additional_content_status_flags) {
+ NavigationEntryImpl* entry = controller_->GetLastCommittedEntry();
+ if (!entry)
+ return;
+ UpdateEntry(entry, additional_content_status_flags);
+}
+
void SSLManager::NotifyDidChangeVisibleSSLState() {
WebContentsImpl* contents =
static_cast<WebContentsImpl*>(controller_->delegate()->GetWebContents());
contents->DidChangeVisibleSSLState();
}
+// static
+void SSLManager::NotifySSLInternalStateChanged(BrowserContext* context) {
+ SSLManagerSet* managers =
+ static_cast<SSLManagerSet*>(context->GetUserData(kSSLManagerKeyName));
+
+ for (std::set<SSLManager*>::iterator i = managers->get().begin();
+ i != managers->get().end(); ++i) {
+ (*i)->UpdateEntry((*i)->controller()->GetLastCommittedEntry(),
+ SSLStatus::NORMAL_CONTENT);
+ }
+}
+
} // namespace content
« no previous file with comments | « content/browser/ssl/ssl_manager.h ('k') | content/browser/web_contents/web_contents_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698