| 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 | 10 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 class Dispatcher; | 26 class Dispatcher; |
| 27 class Extension; | 27 class Extension; |
| 28 } | 28 } |
| 29 | 29 |
| 30 // Handles blocking content per content settings for each RenderFrame. | 30 // Handles blocking content per content settings for each RenderFrame. |
| 31 class ContentSettingsObserver | 31 class ContentSettingsObserver |
| 32 : public content::RenderFrameObserver, | 32 : public content::RenderFrameObserver, |
| 33 public content::RenderFrameObserverTracker<ContentSettingsObserver>, | 33 public content::RenderFrameObserverTracker<ContentSettingsObserver>, |
| 34 public blink::WebPermissionClient { | 34 public blink::WebPermissionClient { |
| 35 public: | 35 public: |
| 36 // Set |should_whitelist| to true if |render_frame()| contains content that |
| 37 // should be whitelisted for content settings. |
| 36 ContentSettingsObserver(content::RenderFrame* render_frame, | 38 ContentSettingsObserver(content::RenderFrame* render_frame, |
| 37 extensions::Dispatcher* extension_dispatcher); | 39 extensions::Dispatcher* extension_dispatcher, |
| 40 bool should_whitelist); |
| 38 ~ContentSettingsObserver() override; | 41 ~ContentSettingsObserver() override; |
| 39 | 42 |
| 40 // Sets the content setting rules which back |AllowImage()|, |AllowScript()|, | 43 // Sets the content setting rules which back |AllowImage()|, |AllowScript()|, |
| 41 // and |AllowScriptFromSource()|. |content_setting_rules| must outlive this | 44 // and |AllowScriptFromSource()|. |content_setting_rules| must outlive this |
| 42 // |ContentSettingsObserver|. | 45 // |ContentSettingsObserver|. |
| 43 void SetContentSettingRules( | 46 void SetContentSettingRules( |
| 44 const RendererContentSettingRules* content_setting_rules); | 47 const RendererContentSettingRules* content_setting_rules); |
| 45 | 48 |
| 46 bool IsPluginTemporarilyAllowed(const std::string& identifier); | 49 bool IsPluginTemporarilyAllowed(const std::string& identifier); |
| 47 | 50 |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 bool IsPlatformApp(); | 115 bool IsPlatformApp(); |
| 113 | 116 |
| 114 #if defined(ENABLE_EXTENSIONS) | 117 #if defined(ENABLE_EXTENSIONS) |
| 115 // If |origin| corresponds to an installed extension, returns that extension. | 118 // If |origin| corresponds to an installed extension, returns that extension. |
| 116 // Otherwise returns NULL. | 119 // Otherwise returns NULL. |
| 117 const extensions::Extension* GetExtension( | 120 const extensions::Extension* GetExtension( |
| 118 const blink::WebSecurityOrigin& origin) const; | 121 const blink::WebSecurityOrigin& origin) const; |
| 119 #endif | 122 #endif |
| 120 | 123 |
| 121 // Helpers. | 124 // Helpers. |
| 122 // True if |frame| contains content that is white-listed for content settings. | 125 // True if |render_frame()| contains content that is white-listed for content |
| 123 static bool IsWhitelistedForContentSettings(content::RenderFrame* frame); | 126 // settings. |
| 127 bool IsWhitelistedForContentSettings() const; |
| 124 static bool IsWhitelistedForContentSettings( | 128 static bool IsWhitelistedForContentSettings( |
| 125 const blink::WebSecurityOrigin& origin, | 129 const blink::WebSecurityOrigin& origin, |
| 126 const GURL& document_url); | 130 const GURL& document_url); |
| 127 | 131 |
| 128 #if defined(ENABLE_EXTENSIONS) | 132 #if defined(ENABLE_EXTENSIONS) |
| 129 // Owned by ChromeContentRendererClient and outlive us. | 133 // Owned by ChromeContentRendererClient and outlive us. |
| 130 extensions::Dispatcher* extension_dispatcher_; | 134 extensions::Dispatcher* extension_dispatcher_; |
| 131 #endif | 135 #endif |
| 132 | 136 |
| 133 // Insecure content may be permitted for the duration of this render view. | 137 // Insecure content may be permitted for the duration of this render view. |
| (...skipping 17 matching lines...) Expand all Loading... |
| 151 std::map<blink::WebFrame*, bool> cached_script_permissions_; | 155 std::map<blink::WebFrame*, bool> cached_script_permissions_; |
| 152 | 156 |
| 153 std::set<std::string> temporarily_allowed_plugins_; | 157 std::set<std::string> temporarily_allowed_plugins_; |
| 154 bool is_interstitial_page_; | 158 bool is_interstitial_page_; |
| 155 bool npapi_plugins_blocked_; | 159 bool npapi_plugins_blocked_; |
| 156 | 160 |
| 157 int current_request_id_; | 161 int current_request_id_; |
| 158 typedef std::map<int, blink::WebPermissionCallbacks> PermissionRequestMap; | 162 typedef std::map<int, blink::WebPermissionCallbacks> PermissionRequestMap; |
| 159 PermissionRequestMap permission_requests_; | 163 PermissionRequestMap permission_requests_; |
| 160 | 164 |
| 165 // If true, IsWhitelistedForContentSettings will always return true. |
| 166 const bool should_whitelist_; |
| 167 |
| 161 DISALLOW_COPY_AND_ASSIGN(ContentSettingsObserver); | 168 DISALLOW_COPY_AND_ASSIGN(ContentSettingsObserver); |
| 162 }; | 169 }; |
| 163 | 170 |
| 164 #endif // CHROME_RENDERER_CONTENT_SETTINGS_OBSERVER_H_ | 171 #endif // CHROME_RENDERER_CONTENT_SETTINGS_OBSERVER_H_ |
| OLD | NEW |