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

Unified Diff: chrome/browser/content_settings/mixed_content_settings_tab_helper.cc

Issue 1905033002: PlzNavigate: Move navigation-level mixed content checks to the browser. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@console-security-message
Patch Set: Minor changes from nasko@'s comments Created 3 years, 10 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/browser/content_settings/mixed_content_settings_tab_helper.h ('k') | chrome/browser/ui/browser.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/content_settings/mixed_content_settings_tab_helper.cc
diff --git a/chrome/browser/content_settings/mixed_content_settings_tab_helper.cc b/chrome/browser/content_settings/mixed_content_settings_tab_helper.cc
new file mode 100644
index 0000000000000000000000000000000000000000..0a6e6ff3da0beb642d060997750176e02e456a6e
--- /dev/null
+++ b/chrome/browser/content_settings/mixed_content_settings_tab_helper.cc
@@ -0,0 +1,64 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/content_settings/mixed_content_settings_tab_helper.h"
+
+#include "content/public/browser/browser_thread.h"
+#include "content/public/browser/navigation_handle.h"
+#include "content/public/browser/render_frame_host.h"
+#include "content/public/browser/site_instance.h"
+
+using content::BrowserThread;
+using content::WebContents;
+
+DEFINE_WEB_CONTENTS_USER_DATA_KEY(MixedContentSettingsTabHelper);
+
+MixedContentSettingsTabHelper::MixedContentSettingsTabHelper(WebContents* tab)
+ : content::WebContentsObserver(tab) {
+ if (!tab->HasOpener())
+ return;
+
+ // Note: using the opener WebContents to override these values only works
+ // because in Chrome these settings are maintained at the tab level instead of
+ // at the frame level as Blink does.
+ MixedContentSettingsTabHelper* opener_settings =
+ MixedContentSettingsTabHelper::FromWebContents(tab->GetOpener());
+ if (opener_settings) {
+ insecure_content_site_instance_ =
+ opener_settings->insecure_content_site_instance_;
+ is_running_insecure_content_allowed_ =
+ opener_settings->is_running_insecure_content_allowed_;
+ }
+}
+
+MixedContentSettingsTabHelper::~MixedContentSettingsTabHelper() {}
+
+void MixedContentSettingsTabHelper::AllowRunningOfInsecureContent() {
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
+ DCHECK(!insecure_content_site_instance_ ||
+ insecure_content_site_instance_ == web_contents()->GetSiteInstance());
+ insecure_content_site_instance_ = web_contents()->GetSiteInstance();
+ is_running_insecure_content_allowed_ = true;
+}
+
+void MixedContentSettingsTabHelper::DidFinishNavigation(
+ content::NavigationHandle* navigation_handle) {
+ if (!navigation_handle->IsInMainFrame() || !navigation_handle->HasCommitted())
+ return;
+
+ // Resets mixed content settings on a successful navigation of the main frame
+ // to a different SiteInstance. This follows the renderer side behavior which
+ // is reset whenever a cross-site navigation takes place: a new main
+ // RenderFrame is created along with a new ContentSettingsObserver, causing
+ // the effective reset of the mixed content running permission.
+ // Note: even though on the renderer this setting exists on a per frame basis,
+ // it has always been controlled at the WebContents level. Its value is always
+ // inherited from the parent frame and when changed the whole tree is updated.
+ content::SiteInstance* new_site =
+ navigation_handle->GetRenderFrameHost()->GetSiteInstance();
+ if (new_site != insecure_content_site_instance_) {
+ insecure_content_site_instance_ = nullptr;
+ is_running_insecure_content_allowed_ = false;
+ }
+}
« no previous file with comments | « chrome/browser/content_settings/mixed_content_settings_tab_helper.h ('k') | chrome/browser/ui/browser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698