OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2016 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.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(MixedContentSettings); | |
16 | |
17 MixedContentSettings::MixedContentSettings(WebContents* tab) | |
18 : content::WebContentsObserver(tab), | |
19 insecure_content_site_instance_(nullptr), | |
nasko
2017/01/12 18:32:37
nit: You could initialize these in the header file
carlosk
2017/01/21 02:54:58
Done.
| |
20 insecure_content_allowed_running_(false) { | |
21 if (tab->HasOpener()) { | |
22 // Note: using the opener WebContents to override these settings only works | |
23 // because Chrome controls them at the tab level instead of at the frame | |
24 // level as Blink does. | |
nasko
2017/01/12 18:32:37
Hmm, I think we now track openers at the frame lev
carlosk
2017/01/21 02:54:58
We want to keep frame granularity at tab-level as
nasko
2017/02/10 01:08:20
Acknowledged.
| |
25 MixedContentSettings* opener_settings = | |
26 MixedContentSettings::FromWebContents(tab->GetOpener()); | |
27 if (opener_settings) { | |
28 insecure_content_site_instance_ = | |
29 opener_settings->insecure_content_site_instance_; | |
30 insecure_content_allowed_running_ = | |
31 opener_settings->insecure_content_allowed_running_; | |
32 } | |
33 } | |
34 } | |
35 | |
36 MixedContentSettings::~MixedContentSettings() {} | |
37 | |
38 void MixedContentSettings::AllowRunningOfInsecureContent() { | |
39 DCHECK_CURRENTLY_ON(BrowserThread::UI); | |
40 DCHECK(!insecure_content_site_instance_ || | |
41 insecure_content_site_instance_ == web_contents()->GetSiteInstance()); | |
42 insecure_content_site_instance_ = web_contents()->GetSiteInstance(); | |
43 insecure_content_allowed_running_ = true; | |
44 } | |
45 | |
46 void MixedContentSettings::DidFinishNavigation( | |
47 content::NavigationHandle* navigation_handle) { | |
48 if (!navigation_handle->IsInMainFrame() || !navigation_handle->HasCommitted()) | |
nasko
2017/01/12 18:32:37
What happens if the commit was for an error page?
carlosk
2017/01/21 02:54:58
In PlzNavigate, the RenderFrame that would render
nasko
2017/01/23 22:32:37
Do we have a test that ensures that is the case an
carlosk
2017/02/08 02:59:02
To clarify: this specific check will control if mi
nasko
2017/02/10 01:08:20
Ok. Where would one find that list?
carlosk
2017/02/11 01:40:22
It's currently in a task in my Asana task tracker.
| |
49 return; | |
50 | |
51 // Resets mixed-content settings on a successful navigation of the main frame | |
52 // to a new site instance. | |
nasko
2017/01/12 18:32:37
nit: s/site instance/SiteInstance/
carlosk
2017/01/21 02:54:58
Done. This comment also grew considerably to expla
nasko
2017/01/23 22:32:37
Thanks! That makes it a lot more clear why.
| |
53 content::SiteInstance* new_site = | |
54 navigation_handle->GetRenderFrameHost()->GetSiteInstance(); | |
55 if (new_site != insecure_content_site_instance_) { | |
56 insecure_content_site_instance_ = nullptr; | |
57 insecure_content_allowed_running_ = false; | |
58 } | |
59 } | |
OLD | NEW |