OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 | 10 |
11 #include "chrome/common/content_settings.h" | 11 #include "chrome/common/content_settings.h" |
12 #include "content/renderer/render_view_observer.h" | 12 #include "content/renderer/render_view_observer.h" |
13 #include "content/renderer/render_view_observer_tracker.h" | 13 #include "content/renderer/render_view_observer_tracker.h" |
14 | 14 |
15 class GURL; | 15 class GURL; |
16 | 16 |
17 namespace WebKit { | 17 namespace WebKit { |
18 class WebSecurityOrigin; | 18 class WebSecurityOrigin; |
19 } | 19 } |
20 | 20 |
21 // Handles blocking content per content settings for each RenderView. | 21 // Handles blocking content per content settings for each RenderView. |
22 class ContentSettingsObserver | 22 class ContentSettingsObserver |
23 : public RenderViewObserver, | 23 : public RenderViewObserver, |
24 public RenderViewObserverTracker<ContentSettingsObserver> { | 24 public RenderViewObserverTracker<ContentSettingsObserver> { |
25 public: | 25 public: |
26 explicit ContentSettingsObserver(RenderView* render_view); | 26 explicit ContentSettingsObserver(RenderView* render_view); |
27 virtual ~ContentSettingsObserver(); | 27 virtual ~ContentSettingsObserver(); |
28 | 28 |
29 // Sets the content settings that back allowScripts(), allowImages(), and | 29 // Sets the content settings that back allowScripts(), and allowPlugins(). |
30 // allowPlugins(). | |
31 void SetContentSettings(const ContentSettings& settings); | 30 void SetContentSettings(const ContentSettings& settings); |
32 | 31 |
33 // Sets the default content settings that back allowScripts(), | 32 // Sets the default content settings that back allowScripts(), and |
34 // allowImages(), and allowPlugins(). | 33 // allowPlugins(). |
35 static void SetDefaultContentSettings(const ContentSettings& settings); | 34 static void SetDefaultContentSettings(const ContentSettings& settings); |
36 | 35 |
36 // Sets the content setting rules that back allowImages(). | |
37 static void SetImageSettingRules(const ContentSettingRules& rules); | |
38 | |
37 // Returns the setting for the given type. | 39 // Returns the setting for the given type. |
38 ContentSetting GetContentSetting(ContentSettingsType type); | 40 ContentSetting GetContentSetting(ContentSettingsType type); |
39 | 41 |
40 // Sends an IPC notification that the specified content type was blocked. | 42 // Sends an IPC notification that the specified content type was blocked. |
41 // If the content type requires it, |resource_identifier| names the specific | 43 // If the content type requires it, |resource_identifier| names the specific |
42 // resource that was blocked (the plugin path in the case of plugins), | 44 // resource that was blocked (the plugin path in the case of plugins), |
43 // otherwise it's the empty string. | 45 // otherwise it's the empty string. |
44 void DidBlockContentType(ContentSettingsType settings_type, | 46 void DidBlockContentType(ContentSettingsType settings_type, |
45 const std::string& resource_identifier); | 47 const std::string& resource_identifier); |
46 | 48 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
78 | 80 |
79 // Resets the |content_blocked_| array. | 81 // Resets the |content_blocked_| array. |
80 void ClearBlockedContentSettings(); | 82 void ClearBlockedContentSettings(); |
81 | 83 |
82 typedef std::map<GURL, ContentSettings> HostContentSettings; | 84 typedef std::map<GURL, ContentSettings> HostContentSettings; |
83 HostContentSettings host_content_settings_; | 85 HostContentSettings host_content_settings_; |
84 | 86 |
85 // Stores our most up-to-date view of the default content settings. | 87 // Stores our most up-to-date view of the default content settings. |
86 static ContentSettings default_settings_; | 88 static ContentSettings default_settings_; |
87 | 89 |
88 // Stores if loading of images, scripts, and plugins is allowed. | 90 // Stores the rules for image content settings. |
91 static ContentSettingRules image_setting_rules_; | |
Bernhard Bauer
2011/09/13 17:38:11
I'd really like to avoid adding even more static i
marja
2011/09/15 12:02:00
I made ChromeContentRendererClient own the image_s
| |
92 | |
93 // Stores if loading of scripts, and plugins is allowed. | |
89 ContentSettings current_content_settings_; | 94 ContentSettings current_content_settings_; |
90 | 95 |
91 // Stores if images, scripts, and plugins have actually been blocked. | 96 // Stores if images, scripts, and plugins have actually been blocked. |
92 bool content_blocked_[CONTENT_SETTINGS_NUM_TYPES]; | 97 bool content_blocked_[CONTENT_SETTINGS_NUM_TYPES]; |
93 | 98 |
94 // Caches the result of AllowStorage. | 99 // Caches the result of AllowStorage. |
95 typedef std::pair<GURL, bool> StoragePermissionsKey; | 100 typedef std::pair<GURL, bool> StoragePermissionsKey; |
96 std::map<StoragePermissionsKey, bool> cached_storage_permissions_; | 101 std::map<StoragePermissionsKey, bool> cached_storage_permissions_; |
97 | 102 |
98 bool plugins_temporarily_allowed_; | 103 bool plugins_temporarily_allowed_; |
99 | 104 |
100 DISALLOW_COPY_AND_ASSIGN(ContentSettingsObserver); | 105 DISALLOW_COPY_AND_ASSIGN(ContentSettingsObserver); |
101 }; | 106 }; |
102 | 107 |
103 #endif // CHROME_RENDERER_CONTENT_SETTINGS_OBSERVER_H_ | 108 #endif // CHROME_RENDERER_CONTENT_SETTINGS_OBSERVER_H_ |
OLD | NEW |