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( |
| 27 RenderView* render_view, ContentSettingsForOneType* image_setting_rules); |
27 virtual ~ContentSettingsObserver(); | 28 virtual ~ContentSettingsObserver(); |
28 | 29 |
29 // Sets the content settings that back allowScripts(), allowImages(), and | 30 // Sets the content settings that back allowScripts(), and allowPlugins(). |
30 // allowPlugins(). | |
31 void SetContentSettings(const ContentSettings& settings); | 31 void SetContentSettings(const ContentSettings& settings); |
32 | 32 |
33 // Sets the default content settings that back allowScripts(), | 33 // Sets the default content settings that back allowScripts(), and |
34 // allowImages(), and allowPlugins(). | 34 // allowPlugins(). |
35 static void SetDefaultContentSettings(const ContentSettings& settings); | 35 static void SetDefaultContentSettings(const ContentSettings& settings); |
36 | 36 |
37 // Returns the setting for the given type. | 37 // Returns the setting for the given type. |
38 ContentSetting GetContentSetting(ContentSettingsType type); | 38 ContentSetting GetContentSetting(ContentSettingsType type); |
39 | 39 |
40 // Sends an IPC notification that the specified content type was blocked. | 40 // Sends an IPC notification that the specified content type was blocked. |
41 // If the content type requires it, |resource_identifier| names the specific | 41 // If the content type requires it, |resource_identifier| names the specific |
42 // resource that was blocked (the plugin path in the case of plugins), | 42 // resource that was blocked (the plugin path in the case of plugins), |
43 // otherwise it's the empty string. | 43 // otherwise it's the empty string. |
44 void DidBlockContentType(ContentSettingsType settings_type, | 44 void DidBlockContentType(ContentSettingsType settings_type, |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 | 78 |
79 // Resets the |content_blocked_| array. | 79 // Resets the |content_blocked_| array. |
80 void ClearBlockedContentSettings(); | 80 void ClearBlockedContentSettings(); |
81 | 81 |
82 typedef std::map<GURL, ContentSettings> HostContentSettings; | 82 typedef std::map<GURL, ContentSettings> HostContentSettings; |
83 HostContentSettings host_content_settings_; | 83 HostContentSettings host_content_settings_; |
84 | 84 |
85 // Stores our most up-to-date view of the default content settings. | 85 // Stores our most up-to-date view of the default content settings. |
86 static ContentSettings default_settings_; | 86 static ContentSettings default_settings_; |
87 | 87 |
88 // Stores if loading of images, scripts, and plugins is allowed. | 88 // Stores the rules for image content settings. Owned by |
| 89 // ChromeContentRendererClient. |
| 90 const ContentSettingsForOneType* image_setting_rules_; |
| 91 |
| 92 // Stores if loading of scripts, and plugins is allowed. |
89 ContentSettings current_content_settings_; | 93 ContentSettings current_content_settings_; |
90 | 94 |
91 // Stores if images, scripts, and plugins have actually been blocked. | 95 // Stores if images, scripts, and plugins have actually been blocked. |
92 bool content_blocked_[CONTENT_SETTINGS_NUM_TYPES]; | 96 bool content_blocked_[CONTENT_SETTINGS_NUM_TYPES]; |
93 | 97 |
94 // Caches the result of AllowStorage. | 98 // Caches the result of AllowStorage. |
95 typedef std::pair<GURL, bool> StoragePermissionsKey; | 99 typedef std::pair<GURL, bool> StoragePermissionsKey; |
96 std::map<StoragePermissionsKey, bool> cached_storage_permissions_; | 100 std::map<StoragePermissionsKey, bool> cached_storage_permissions_; |
97 | 101 |
98 bool plugins_temporarily_allowed_; | 102 bool plugins_temporarily_allowed_; |
99 | 103 |
100 DISALLOW_COPY_AND_ASSIGN(ContentSettingsObserver); | 104 DISALLOW_COPY_AND_ASSIGN(ContentSettingsObserver); |
101 }; | 105 }; |
102 | 106 |
103 #endif // CHROME_RENDERER_CONTENT_SETTINGS_OBSERVER_H_ | 107 #endif // CHROME_RENDERER_CONTENT_SETTINGS_OBSERVER_H_ |
OLD | NEW |