Clear |displayed_content_with_cert_errors_| on navigation

I added this flag with the new plumbing for subresources with cert
errors in https://crbug.com/634171, but neglected to clear it on
navigation.

BUG=641180

Review-Url: https://codereview.chromium.org/2280753003
Cr-Commit-Position: refs/heads/master@{#415345}
diff --git a/chrome/browser/ssl/ssl_browser_tests.cc b/chrome/browser/ssl/ssl_browser_tests.cc
index 28422f92..171f831 100644
--- a/chrome/browser/ssl/ssl_browser_tests.cc
+++ b/chrome/browser/ssl/ssl_browser_tests.cc
@@ -763,6 +763,39 @@
                                  AuthState::RAN_INSECURE_CONTENT);
 }
 
+// Tests that the WebContents's flag for displaying content with cert
+// errors get cleared upon navigation.
+IN_PROC_BROWSER_TEST_F(SSLUITest,
+                       DisplayedContentWithCertErrorsClearedOnNavigation) {
+  ASSERT_TRUE(https_server_.Start());
+  ASSERT_TRUE(https_server_expired_.Start());
+
+  WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents();
+  ASSERT_TRUE(tab);
+
+  // Navigate to a page with a certificate error and click through the
+  // interstitial.
+  ui_test_utils::NavigateToURL(
+      browser(),
+      https_server_expired_.GetURL("/ssl/page_with_subresource.html"));
+  CheckAuthenticationBrokenState(tab, net::CERT_STATUS_DATE_INVALID,
+                                 AuthState::SHOWING_INTERSTITIAL);
+  ProceedThroughInterstitial(tab);
+
+  NavigationEntry* entry = tab->GetController().GetVisibleEntry();
+  ASSERT_TRUE(entry);
+  EXPECT_TRUE(entry->GetSSL().content_status &
+              content::SSLStatus::DISPLAYED_CONTENT_WITH_CERT_ERRORS);
+
+  // Navigate away to a different page, and check that the flag gets cleared.
+  ui_test_utils::NavigateToURL(browser(),
+                               https_server_.GetURL("/ssl/google.html"));
+  entry = tab->GetController().GetVisibleEntry();
+  ASSERT_TRUE(entry);
+  EXPECT_FALSE(entry->GetSSL().content_status &
+               content::SSLStatus::DISPLAYED_CONTENT_WITH_CERT_ERRORS);
+}
+
 IN_PROC_BROWSER_TEST_F(SSLUITest, TestBrokenHTTPSMetricsReporting_Proceed) {
   ASSERT_TRUE(https_server_expired_.Start());
   ASSERT_NO_FATAL_FAILURE(SetUpMockReporter());
diff --git a/chrome/test/data/ssl/page_with_subresource.html b/chrome/test/data/ssl/page_with_subresource.html
index 8df3161..efca7ac3 100644
--- a/chrome/test/data/ssl/page_with_subresource.html
+++ b/chrome/test/data/ssl/page_with_subresource.html
@@ -3,5 +3,5 @@
 <title>This page has a subresource</title>
 <script src="write_to_title.js" type="text/javascript"></script>
 </head>
-<body></body>
+<body><img src="google_files/logo.gif"/></body>
 </html>
diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc
index 51f3bba..05801d4f 100644
--- a/content/browser/web_contents/web_contents_impl.cc
+++ b/content/browser/web_contents/web_contents_impl.cc
@@ -3389,6 +3389,7 @@
     // Once the main frame is navigated, we're no longer considered to have
     // displayed insecure content.
     displayed_insecure_content_ = false;
+    displayed_content_with_cert_errors_ = false;
     SSLManager::NotifySSLInternalStateChanged(
         GetController().GetBrowserContext());
   }