OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_RENDERER_CONTENT_SETTINGS_OBSERVER_H_ | 5 #ifndef CHROME_RENDERER_CONTENT_SETTINGS_OBSERVER_H_ |
6 #define CHROME_RENDERER_CONTENT_SETTINGS_OBSERVER_H_ | 6 #define CHROME_RENDERER_CONTENT_SETTINGS_OBSERVER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
11 #include <unordered_map> | 11 #include <unordered_map> |
12 #include <utility> | 12 #include <utility> |
13 | 13 |
14 #include "base/gtest_prod_util.h" | 14 #include "base/gtest_prod_util.h" |
| 15 #include "chrome/common/insecure_content_renderer.mojom.h" |
15 #include "components/content_settings/core/common/content_settings.h" | 16 #include "components/content_settings/core/common/content_settings.h" |
16 #include "components/content_settings/core/common/content_settings_types.h" | 17 #include "components/content_settings/core/common/content_settings_types.h" |
17 #include "content/public/renderer/render_frame_observer.h" | 18 #include "content/public/renderer/render_frame_observer.h" |
18 #include "content/public/renderer/render_frame_observer_tracker.h" | 19 #include "content/public/renderer/render_frame_observer_tracker.h" |
19 #include "extensions/features/features.h" | 20 #include "extensions/features/features.h" |
| 21 #include "mojo/public/cpp/bindings/binding_set.h" |
20 #include "third_party/WebKit/public/web/WebContentSettingsClient.h" | 22 #include "third_party/WebKit/public/web/WebContentSettingsClient.h" |
21 #include "url/gurl.h" | 23 #include "url/gurl.h" |
22 | 24 |
23 namespace blink { | 25 namespace blink { |
24 class WebFrame; | 26 class WebFrame; |
25 class WebSecurityOrigin; | 27 class WebSecurityOrigin; |
26 class WebURL; | 28 class WebURL; |
27 } | 29 } |
28 | 30 |
29 namespace extensions { | 31 namespace extensions { |
30 class Dispatcher; | 32 class Dispatcher; |
31 class Extension; | 33 class Extension; |
32 } | 34 } |
33 | 35 |
34 // Handles blocking content per content settings for each RenderFrame. | 36 // Handles blocking content per content settings for each RenderFrame. |
35 class ContentSettingsObserver | 37 class ContentSettingsObserver |
36 : public content::RenderFrameObserver, | 38 : public content::RenderFrameObserver, |
37 public content::RenderFrameObserverTracker<ContentSettingsObserver>, | 39 public content::RenderFrameObserverTracker<ContentSettingsObserver>, |
38 public blink::WebContentSettingsClient { | 40 public blink::WebContentSettingsClient, |
| 41 public chrome::mojom::InsecureContentRenderer { |
39 public: | 42 public: |
40 // Set |should_whitelist| to true if |render_frame()| contains content that | 43 // Set |should_whitelist| to true if |render_frame()| contains content that |
41 // should be whitelisted for content settings. | 44 // should be whitelisted for content settings. |
42 ContentSettingsObserver(content::RenderFrame* render_frame, | 45 ContentSettingsObserver(content::RenderFrame* render_frame, |
43 extensions::Dispatcher* extension_dispatcher, | 46 extensions::Dispatcher* extension_dispatcher, |
44 bool should_whitelist); | 47 bool should_whitelist); |
45 ~ContentSettingsObserver() override; | 48 ~ContentSettingsObserver() override; |
46 | 49 |
47 // Sets the content setting rules which back |allowImage()|, |allowScript()|, | 50 // Sets the content setting rules which back |allowImage()|, |allowScript()|, |
48 // |allowScriptFromSource()| and |allowAutoplay()|. |content_setting_rules| | 51 // |allowScriptFromSource()| and |allowAutoplay()|. |content_setting_rules| |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 FRIEND_TEST_ALL_PREFIXES(ChromeRenderViewTest, | 94 FRIEND_TEST_ALL_PREFIXES(ChromeRenderViewTest, |
92 ContentSettingsInterstitialPages); | 95 ContentSettingsInterstitialPages); |
93 FRIEND_TEST_ALL_PREFIXES(ChromeRenderViewTest, PluginsTemporarilyAllowed); | 96 FRIEND_TEST_ALL_PREFIXES(ChromeRenderViewTest, PluginsTemporarilyAllowed); |
94 | 97 |
95 // RenderFrameObserver implementation. | 98 // RenderFrameObserver implementation. |
96 bool OnMessageReceived(const IPC::Message& message) override; | 99 bool OnMessageReceived(const IPC::Message& message) override; |
97 void DidCommitProvisionalLoad(bool is_new_navigation, | 100 void DidCommitProvisionalLoad(bool is_new_navigation, |
98 bool is_same_page_navigation) override; | 101 bool is_same_page_navigation) override; |
99 void OnDestruct() override; | 102 void OnDestruct() override; |
100 | 103 |
| 104 // chrome::mojom::InsecureContentRenderer: |
| 105 void SetAllowRunningInsecureContent() override; |
| 106 |
| 107 void OnInsecureContentRendererRequest( |
| 108 chrome::mojom::InsecureContentRendererRequest request); |
| 109 |
101 // Message handlers. | 110 // Message handlers. |
102 void OnLoadBlockedPlugins(const std::string& identifier); | 111 void OnLoadBlockedPlugins(const std::string& identifier); |
103 void OnSetAsInterstitial(); | 112 void OnSetAsInterstitial(); |
104 void OnSetAllowRunningInsecureContent(bool allow); | |
105 void OnReloadFrame(); | |
106 void OnRequestFileSystemAccessAsyncResponse(int request_id, bool allowed); | 113 void OnRequestFileSystemAccessAsyncResponse(int request_id, bool allowed); |
107 | 114 |
108 // Resets the |content_blocked_| array. | 115 // Resets the |content_blocked_| array. |
109 void ClearBlockedContentSettings(); | 116 void ClearBlockedContentSettings(); |
110 | 117 |
111 // Whether the observed RenderFrame is for a platform app. | 118 // Whether the observed RenderFrame is for a platform app. |
112 bool IsPlatformApp(); | 119 bool IsPlatformApp(); |
113 | 120 |
114 #if BUILDFLAG(ENABLE_EXTENSIONS) | 121 #if BUILDFLAG(ENABLE_EXTENSIONS) |
115 // If |origin| corresponds to an installed extension, returns that extension. | 122 // If |origin| corresponds to an installed extension, returns that extension. |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 bool is_interstitial_page_; | 161 bool is_interstitial_page_; |
155 | 162 |
156 int current_request_id_; | 163 int current_request_id_; |
157 using PermissionRequestMap = | 164 using PermissionRequestMap = |
158 std::unordered_map<int, blink::WebContentSettingCallbacks>; | 165 std::unordered_map<int, blink::WebContentSettingCallbacks>; |
159 PermissionRequestMap permission_requests_; | 166 PermissionRequestMap permission_requests_; |
160 | 167 |
161 // If true, IsWhitelistedForContentSettings will always return true. | 168 // If true, IsWhitelistedForContentSettings will always return true. |
162 const bool should_whitelist_; | 169 const bool should_whitelist_; |
163 | 170 |
| 171 mojo::BindingSet<chrome::mojom::InsecureContentRenderer> |
| 172 insecure_content_renderer_bindings_; |
| 173 |
164 DISALLOW_COPY_AND_ASSIGN(ContentSettingsObserver); | 174 DISALLOW_COPY_AND_ASSIGN(ContentSettingsObserver); |
165 }; | 175 }; |
166 | 176 |
167 #endif // CHROME_RENDERER_CONTENT_SETTINGS_OBSERVER_H_ | 177 #endif // CHROME_RENDERER_CONTENT_SETTINGS_OBSERVER_H_ |
OLD | NEW |