Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: chrome/renderer/content_settings_observer.h

Issue 8409006: Take script URLs into account when applying script content settings. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Cleanup. Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 static void SetDefaultContentSettings(const ContentSettings& settings); 35 static 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()| and
38 // |ContentSettingsForOneType| object must outlive this 38 // |AllowScriptFromSource()|. |content_setting_rules| must be an array
39 // indexable with |ContentSettingsType| and it must outlive this
39 // |ContentSettingsObserver|. 40 // |ContentSettingsObserver|.
40 void SetImageSettingRules( 41 void SetContentSettingRules(
41 const ContentSettingsForOneType* image_setting_rules); 42 const ContentSettingsForOneType* content_setting_rules);
42 43
43 // Returns the setting for the given type. 44 // Returns the setting for the given type.
44 ContentSetting GetContentSetting(ContentSettingsType type); 45 ContentSetting GetContentSetting(ContentSettingsType type);
45 46
46 bool plugins_temporarily_allowed() { 47 bool plugins_temporarily_allowed() {
47 return plugins_temporarily_allowed_; 48 return plugins_temporarily_allowed_;
48 } 49 }
49 50
50 // Sends an IPC notification that the specified content type was blocked. 51 // Sends an IPC notification that the specified content type was blocked.
51 // If the content type requires it, |resource_identifier| names the specific 52 // If the content type requires it, |resource_identifier| names the specific
52 // resource that was blocked (the plugin path in the case of plugins), 53 // resource that was blocked (the plugin path in the case of plugins),
53 // otherwise it's the empty string. 54 // otherwise it's the empty string.
54 void DidBlockContentType(ContentSettingsType settings_type, 55 void DidBlockContentType(ContentSettingsType settings_type,
55 const std::string& resource_identifier); 56 const std::string& resource_identifier);
56 57
57 // These correspond to WebKit::WebPermissionClient methods. 58 // These correspond to WebKit::WebPermissionClient methods.
58 bool AllowDatabase(WebKit::WebFrame* frame, 59 bool AllowDatabase(WebKit::WebFrame* frame,
59 const WebKit::WebString& name, 60 const WebKit::WebString& name,
60 const WebKit::WebString& display_name, 61 const WebKit::WebString& display_name,
61 unsigned long estimated_size); 62 unsigned long estimated_size);
62 bool AllowFileSystem(WebKit::WebFrame* frame); 63 bool AllowFileSystem(WebKit::WebFrame* frame);
63 bool AllowImage(WebKit::WebFrame* frame, 64 bool AllowImage(WebKit::WebFrame* frame,
64 bool enabled_per_settings, 65 bool enabled_per_settings,
65 const WebKit::WebURL& image_url); 66 const WebKit::WebURL& image_url);
66 bool AllowIndexedDB(WebKit::WebFrame* frame, 67 bool AllowIndexedDB(WebKit::WebFrame* frame,
67 const WebKit::WebString& name, 68 const WebKit::WebString& name,
68 const WebKit::WebSecurityOrigin& origin); 69 const WebKit::WebSecurityOrigin& origin);
69 bool AllowPlugins(WebKit::WebFrame* frame, bool enabled_per_settings); 70 bool AllowPlugins(WebKit::WebFrame* frame, bool enabled_per_settings);
70 bool AllowScript(WebKit::WebFrame* frame, bool enabled_per_settings); 71 bool AllowScript(WebKit::WebFrame* frame, bool enabled_per_settings);
72 bool AllowScriptFromSource(WebKit::WebFrame* frame, bool enabled_per_settings,
73 const WebKit::WebURL& script_url);
71 bool AllowStorage(WebKit::WebFrame* frame, bool local); 74 bool AllowStorage(WebKit::WebFrame* frame, bool local);
72 void DidNotAllowPlugins(WebKit::WebFrame* frame); 75 void DidNotAllowPlugins(WebKit::WebFrame* frame);
73 void DidNotAllowScript(WebKit::WebFrame* frame); 76 void DidNotAllowScript(WebKit::WebFrame* frame);
74 77
75 private: 78 private:
76 // RenderViewObserver implementation. 79 // RenderViewObserver implementation.
77 virtual bool OnMessageReceived(const IPC::Message& message); 80 virtual bool OnMessageReceived(const IPC::Message& message);
78 virtual void DidCommitProvisionalLoad(WebKit::WebFrame* frame, 81 virtual void DidCommitProvisionalLoad(WebKit::WebFrame* frame,
79 bool is_new_navigation); 82 bool is_new_navigation);
80 83
(...skipping 13 matching lines...) Expand all
94 typedef std::map<GURL, ContentSettings> HostContentSettings; 97 typedef std::map<GURL, ContentSettings> HostContentSettings;
95 HostContentSettings host_content_settings_; 98 HostContentSettings host_content_settings_;
96 99
97 // Stores our most up-to-date view of the default content settings. 100 // Stores our most up-to-date view of the default content settings.
98 // TODO(marja): Store default settings in |ChromeRenderProcessObserver|. 101 // TODO(marja): Store default settings in |ChromeRenderProcessObserver|.
99 static ContentSettings default_settings_; 102 static ContentSettings default_settings_;
100 103
101 // Stores if loading of scripts and plugins is allowed. 104 // Stores if loading of scripts and plugins is allowed.
102 ContentSettings current_content_settings_; 105 ContentSettings current_content_settings_;
103 106
104 // Stores the rules for image content settings. Normally, they are owned by 107 // A pointer to content setting rules for image and script content
105 // |ChromeRenderProcessObserver|; in the tests they are owned by the caller of 108 // types. Normally, they are owned by |ChromeRenderProcessObserver|; in the
106 // |SetImageSettingRules|. 109 // tests they are owned by the caller of |SetImageSettingRules|.
107 const ContentSettingsForOneType* image_setting_rules_; 110 const ContentSettingsForOneType* content_setting_rules_;
108 111
109 // Stores if images, scripts, and plugins have actually been blocked. 112 // Stores if images, scripts, and plugins have actually been blocked.
110 bool content_blocked_[CONTENT_SETTINGS_NUM_TYPES]; 113 bool content_blocked_[CONTENT_SETTINGS_NUM_TYPES];
111 114
112 // Caches the result of AllowStorage. 115 // Caches the result of AllowStorage.
113 typedef std::pair<GURL, bool> StoragePermissionsKey; 116 typedef std::pair<GURL, bool> StoragePermissionsKey;
114 std::map<StoragePermissionsKey, bool> cached_storage_permissions_; 117 std::map<StoragePermissionsKey, bool> cached_storage_permissions_;
115 118
116 bool plugins_temporarily_allowed_; 119 bool plugins_temporarily_allowed_;
117 120
118 DISALLOW_COPY_AND_ASSIGN(ContentSettingsObserver); 121 DISALLOW_COPY_AND_ASSIGN(ContentSettingsObserver);
119 }; 122 };
120 123
121 #endif // CHROME_RENDERER_CONTENT_SETTINGS_OBSERVER_H_ 124 #endif // CHROME_RENDERER_CONTENT_SETTINGS_OBSERVER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698