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 |
(...skipping 16 matching lines...) Expand all Loading... | |
27 explicit ContentSettingsObserver(content::RenderView* render_view); | 27 explicit ContentSettingsObserver(content::RenderView* render_view); |
28 virtual ~ContentSettingsObserver(); | 28 virtual ~ContentSettingsObserver(); |
29 | 29 |
30 // Sets the content settings that back allowScripts() and allowPlugins(). | 30 // Sets the content settings that back allowScripts() and allowPlugins(). |
31 void SetContentSettings(const ContentSettings& settings); | 31 void SetContentSettings(const ContentSettings& settings); |
32 | 32 |
33 // Sets the default content settings that back allowScripts() and | 33 // Sets the default content settings that back allowScripts() and |
34 // allowPlugins(). | 34 // allowPlugins(). |
35 void SetDefaultContentSettings(const ContentSettings* settings); | 35 void SetDefaultContentSettings(const ContentSettings* settings); |
36 | 36 |
37 // Sets the image setting rules which back |allowImage()|. The | 37 // Sets the content setting rules which back |AllowImage()|, |AllowScript()|, |
38 // |ContentSettingsForOneType| object must outlive this | 38 // and |AllowScriptFromSource()|. |content_setting_rules| must outlive this |
39 // |ContentSettingsObserver|. | 39 // |ContentSettingsObserver|. |
40 void SetImageSettingRules( | 40 void SetContentSettingRules( |
41 const ContentSettingsForOneType* image_setting_rules); | 41 const RendererContentSettingRules* content_setting_rules); |
42 | 42 |
43 // Returns the setting for the given type. | 43 // Returns the setting for the given type. |
44 ContentSetting GetContentSetting(ContentSettingsType type); | 44 ContentSetting GetContentSetting(ContentSettingsType type); |
45 | 45 |
46 bool plugins_temporarily_allowed() { | 46 bool plugins_temporarily_allowed() { |
47 return plugins_temporarily_allowed_; | 47 return plugins_temporarily_allowed_; |
48 } | 48 } |
49 | 49 |
50 // Sends an IPC notification that the specified content type was blocked. | 50 // Sends an IPC notification that the specified content type was blocked. |
51 // If the content type requires it, |resource_identifier| names the specific | 51 // If the content type requires it, |resource_identifier| names the specific |
52 // resource that was blocked (the plugin path in the case of plugins), | 52 // resource that was blocked (the plugin path in the case of plugins), |
53 // otherwise it's the empty string. | 53 // otherwise it's the empty string. |
54 void DidBlockContentType(ContentSettingsType settings_type, | 54 void DidBlockContentType(ContentSettingsType settings_type, |
55 const std::string& resource_identifier); | 55 const std::string& resource_identifier); |
56 | 56 |
57 // These correspond to WebKit::WebPermissionClient methods. | 57 // These correspond to WebKit::WebPermissionClient methods. |
58 bool AllowDatabase(WebKit::WebFrame* frame, | 58 bool AllowDatabase(WebKit::WebFrame* frame, |
59 const WebKit::WebString& name, | 59 const WebKit::WebString& name, |
60 const WebKit::WebString& display_name, | 60 const WebKit::WebString& display_name, |
61 unsigned long estimated_size); | 61 unsigned long estimated_size); |
62 bool AllowFileSystem(WebKit::WebFrame* frame); | 62 bool AllowFileSystem(WebKit::WebFrame* frame); |
63 bool AllowImage(WebKit::WebFrame* frame, | 63 bool AllowImage(WebKit::WebFrame* frame, |
64 bool enabled_per_settings, | 64 bool enabled_per_settings, |
65 const WebKit::WebURL& image_url); | 65 const WebKit::WebURL& image_url); |
66 bool AllowIndexedDB(WebKit::WebFrame* frame, | 66 bool AllowIndexedDB(WebKit::WebFrame* frame, |
67 const WebKit::WebString& name, | 67 const WebKit::WebString& name, |
68 const WebKit::WebSecurityOrigin& origin); | 68 const WebKit::WebSecurityOrigin& origin); |
69 bool AllowPlugins(WebKit::WebFrame* frame, bool enabled_per_settings); | 69 bool AllowPlugins(WebKit::WebFrame* frame, bool enabled_per_settings); |
70 bool AllowScript(WebKit::WebFrame* frame, bool enabled_per_settings); | 70 bool AllowScript(WebKit::WebFrame* frame, bool enabled_per_settings); |
71 bool AllowScriptFromSource(WebKit::WebFrame* frame, bool enabled_per_settings, | |
72 const WebKit::WebURL& script_url); | |
71 bool AllowStorage(WebKit::WebFrame* frame, bool local); | 73 bool AllowStorage(WebKit::WebFrame* frame, bool local); |
72 void DidNotAllowPlugins(WebKit::WebFrame* frame); | 74 void DidNotAllowPlugins(WebKit::WebFrame* frame); |
73 void DidNotAllowScript(WebKit::WebFrame* frame); | 75 void DidNotAllowScript(WebKit::WebFrame* frame); |
74 | 76 |
75 private: | 77 private: |
76 // RenderViewObserver implementation. | 78 // RenderViewObserver implementation. |
77 virtual bool OnMessageReceived(const IPC::Message& message); | 79 virtual bool OnMessageReceived(const IPC::Message& message); |
78 virtual void DidCommitProvisionalLoad(WebKit::WebFrame* frame, | 80 virtual void DidCommitProvisionalLoad(WebKit::WebFrame* frame, |
79 bool is_new_navigation); | 81 bool is_new_navigation); |
80 | 82 |
(...skipping 11 matching lines...) Expand all Loading... | |
92 void ClearBlockedContentSettings(); | 94 void ClearBlockedContentSettings(); |
93 | 95 |
94 typedef std::map<GURL, ContentSettings> HostContentSettings; | 96 typedef std::map<GURL, ContentSettings> HostContentSettings; |
95 HostContentSettings host_content_settings_; | 97 HostContentSettings host_content_settings_; |
96 | 98 |
97 // A pointer to the most up-to-date view of the default content | 99 // A pointer to the most up-to-date view of the default content |
98 // settings. Normally, they are owned by |ChromeRenderProcessObserver|. In the | 100 // settings. Normally, they are owned by |ChromeRenderProcessObserver|. In the |
99 // tests they are owned by the caller of |SetDefaultContentSettings|. | 101 // tests they are owned by the caller of |SetDefaultContentSettings|. |
100 const ContentSettings* default_content_settings_; | 102 const ContentSettings* default_content_settings_; |
101 | 103 |
102 // Stores if loading of scripts and plugins is allowed. | 104 // Stores if loading of scripts and plugins is allowed. |
Bernhard Bauer
2011/11/08 09:32:52
This comment is not accurate anymore. In fact, I t
marja
2011/11/08 09:39:35
Ahh, true, I'll create another CL for removing thi
| |
103 ContentSettings current_content_settings_; | 105 ContentSettings current_content_settings_; |
104 | 106 |
105 // Stores the rules for image content settings. Normally, they are owned by | 107 // A pointer to content setting rules stored by the renderer. Normally, the |
106 // |ChromeRenderProcessObserver|. In the tests they are owned by the caller of | 108 // |RendererContentSettingRules| object is owned by |
107 // |SetImageSettingRules|. | 109 // |ChromeRenderProcessObserver|. In the tests it is owned by the caller of |
108 const ContentSettingsForOneType* image_setting_rules_; | 110 // |SetContentSettingRules|. |
111 const RendererContentSettingRules* content_setting_rules_; | |
109 | 112 |
110 // Stores if images, scripts, and plugins have actually been blocked. | 113 // Stores if images, scripts, and plugins have actually been blocked. |
111 bool content_blocked_[CONTENT_SETTINGS_NUM_TYPES]; | 114 bool content_blocked_[CONTENT_SETTINGS_NUM_TYPES]; |
112 | 115 |
113 // Caches the result of AllowStorage. | 116 // Caches the result of AllowStorage. |
114 typedef std::pair<GURL, bool> StoragePermissionsKey; | 117 typedef std::pair<GURL, bool> StoragePermissionsKey; |
115 std::map<StoragePermissionsKey, bool> cached_storage_permissions_; | 118 std::map<StoragePermissionsKey, bool> cached_storage_permissions_; |
116 | 119 |
117 bool plugins_temporarily_allowed_; | 120 bool plugins_temporarily_allowed_; |
118 | 121 |
119 DISALLOW_COPY_AND_ASSIGN(ContentSettingsObserver); | 122 DISALLOW_COPY_AND_ASSIGN(ContentSettingsObserver); |
120 }; | 123 }; |
121 | 124 |
122 #endif // CHROME_RENDERER_CONTENT_SETTINGS_OBSERVER_H_ | 125 #endif // CHROME_RENDERER_CONTENT_SETTINGS_OBSERVER_H_ |
OLD | NEW |