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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/content_settings/mixed_content_settings_tab_helper.h"
6
7 #include "content/public/browser/browser_thread.h"
8 #include "content/public/browser/navigation_handle.h"
9 #include "content/public/browser/render_frame_host.h"
10 #include "content/public/browser/site_instance.h"
11
12 using content::BrowserThread;
13 using content::WebContents;
14
15 DEFINE_WEB_CONTENTS_USER_DATA_KEY(MixedContentSettingsTabHelper);
16
17 MixedContentSettingsTabHelper::MixedContentSettingsTabHelper(WebContents* tab)
18 : content::WebContentsObserver(tab) {
19 if (!tab->HasOpener())
20 return;
21
22 // Note: using the opener WebContents to override these values only works
23 // because in Chrome these settings are maintained at the tab level instead of
24 // at the frame level as Blink does.
25 MixedContentSettingsTabHelper* opener_settings =
26 MixedContentSettingsTabHelper::FromWebContents(tab->GetOpener());
27 if (opener_settings) {
28 insecure_content_site_instance_ =
29 opener_settings->insecure_content_site_instance_;
30 is_running_insecure_content_allowed_ =
31 opener_settings->is_running_insecure_content_allowed_;
32 }
33 }
34
35 MixedContentSettingsTabHelper::~MixedContentSettingsTabHelper() {}
36
37 void MixedContentSettingsTabHelper::AllowRunningOfInsecureContent() {
38 DCHECK_CURRENTLY_ON(BrowserThread::UI);
39 DCHECK(!insecure_content_site_instance_ ||
40 insecure_content_site_instance_ == web_contents()->GetSiteInstance());
41 insecure_content_site_instance_ = web_contents()->GetSiteInstance();
42 is_running_insecure_content_allowed_ = true;
43 }
44
45 void MixedContentSettingsTabHelper::DidFinishNavigation(
46 content::NavigationHandle* navigation_handle) {
47 if (!navigation_handle->IsInMainFrame() || !navigation_handle->HasCommitted())
48 return;
49
50 // Resets mixed content settings on a successful navigation of the main frame
51 // to a different SiteInstance. This follows the renderer side behavior which
52 // is reset whenever a cross-site navigation takes place: a new main
53 // RenderFrame is created along with a new ContentSettingsObserver, causing
54 // the effective reset of the mixed content running permission.
55 // Note: even though on the renderer this setting exists on a per frame basis,
56 // it has always been controlled at the WebContents level. Its value is always
57 // inherited from the parent frame and when changed the whole tree is updated.
58 content::SiteInstance* new_site =
59 navigation_handle->GetRenderFrameHost()->GetSiteInstance();
60 if (new_site != insecure_content_site_instance_) {
61 insecure_content_site_instance_ = nullptr;
62 is_running_insecure_content_allowed_ = false;
63 }
64 }
OLDNEW
« 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