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

Unified Diff: content/browser/web_contents/web_contents_impl.cc

Issue 181253003: Downgrade page security if an inline has invalid certificate. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Do not set insecure content flag for favicon loading. Created 6 years, 3 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 | « chrome/test/data/ssl/page_with_dynamic_insecure_content.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/web_contents/web_contents_impl.cc
diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc
index b34f55c9edb9e37a8349a26317f054f8e799a196..6b0a66229712d7022e458440e3161600f7459578 100644
--- a/content/browser/web_contents/web_contents_impl.cc
+++ b/content/browser/web_contents/web_contents_impl.cc
@@ -180,6 +180,10 @@ const char kWebContentsAndroidKey[] = "web_contents_android";
base::LazyInstance<std::vector<WebContentsImpl::CreatedCallback> >
g_created_callbacks = LAZY_INSTANCE_INITIALIZER;
+bool HasInsecureContent(const net::CertStatus status) {
+ return net::IsCertStatusError(status) && !net::IsCertStatusMinorError(status);
+}
+
static int StartDownload(RenderFrameHost* rfh,
const GURL& url,
bool is_favicon,
@@ -2240,6 +2244,21 @@ void WebContentsImpl::DragSourceEndedAt(int client_x, int client_y,
void WebContentsImpl::DidGetResourceResponseStart(
const ResourceRequestDetails& details) {
+
+ // If inline resource has invalid certificate, set the insecure content flag.
+ // For all the intended notifications to be sent, we need to call
+ // SSLManager::NotifySSLInternalStateChanged() after setting the flag.
+ // In "standard" insecure content scenario (i.e. http resource in https
+ // context) the flag is set and SSLManager gets notified in
+ // OnDidDisplayInsecureContent() (Webkit notification handler).
+ // When, however, the certificate for the inline is invalid, Webkit will not
+ // tell us about it and we need to set the flag & notify SSLManager manually.
+ // Note: the call to SSLManager::NotifySSLInternalStateChanged() will be done
+ // from SSLManager::DidStartResourceResponse().
+ if (details.resource_type != RESOURCE_TYPE_FAVICON &&
+ HasInsecureContent(details.ssl_cert_status))
+ displayed_insecure_content_ = true;
+
controller_.ssl_manager()->DidStartResourceResponse(details);
FOR_EACH_OBSERVER(WebContentsObserver, observers_,
@@ -2628,6 +2647,12 @@ void WebContentsImpl::OnDidLoadResourceFromMemoryCache(
url, GetRenderProcessHost()->GetID(), cert_id, cert_status, http_method,
mime_type, resource_type);
+ // See WebContentsImpl::DidGetResourceResponseStart for an explanation of why
+ // displayed_insecure_content_ is set here.
+ if (details.resource_type != RESOURCE_TYPE_FAVICON &&
+ HasInsecureContent(cert_status))
+ displayed_insecure_content_ = true;
+
controller_.ssl_manager()->DidLoadFromMemoryCache(details);
FOR_EACH_OBSERVER(WebContentsObserver, observers_,
« no previous file with comments | « chrome/test/data/ssl/page_with_dynamic_insecure_content.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698