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

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

Issue 63273002: Rename WebKit namespace to blink (part 4) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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) 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
11 #include "chrome/common/content_settings.h" 11 #include "chrome/common/content_settings.h"
12 #include "content/public/renderer/render_view_observer.h" 12 #include "content/public/renderer/render_view_observer.h"
13 #include "content/public/renderer/render_view_observer_tracker.h" 13 #include "content/public/renderer/render_view_observer_tracker.h"
14 14
15 class GURL; 15 class GURL;
16 16
17 namespace WebKit { 17 namespace blink {
18 class WebFrame; 18 class WebFrame;
19 class WebSecurityOrigin; 19 class WebSecurityOrigin;
20 class WebURL; 20 class WebURL;
21 } 21 }
22 22
23 // Handles blocking content per content settings for each RenderView. 23 // Handles blocking content per content settings for each RenderView.
24 class ContentSettingsObserver 24 class ContentSettingsObserver
25 : public content::RenderViewObserver, 25 : public content::RenderViewObserver,
26 public content::RenderViewObserverTracker<ContentSettingsObserver> { 26 public content::RenderViewObserverTracker<ContentSettingsObserver> {
27 public: 27 public:
28 explicit ContentSettingsObserver(content::RenderView* render_view); 28 explicit ContentSettingsObserver(content::RenderView* render_view);
29 virtual ~ContentSettingsObserver(); 29 virtual ~ContentSettingsObserver();
30 30
31 // Sets the content setting rules which back |AllowImage()|, |AllowScript()|, 31 // Sets the content setting rules which back |AllowImage()|, |AllowScript()|,
32 // and |AllowScriptFromSource()|. |content_setting_rules| must outlive this 32 // and |AllowScriptFromSource()|. |content_setting_rules| must outlive this
33 // |ContentSettingsObserver|. 33 // |ContentSettingsObserver|.
34 void SetContentSettingRules( 34 void SetContentSettingRules(
35 const RendererContentSettingRules* content_setting_rules); 35 const RendererContentSettingRules* content_setting_rules);
36 36
37 bool IsPluginTemporarilyAllowed(const std::string& identifier); 37 bool IsPluginTemporarilyAllowed(const std::string& identifier);
38 38
39 // Sends an IPC notification that the specified content type was blocked. 39 // Sends an IPC notification that the specified content type was blocked.
40 // If the content type requires it, |resource_identifier| names the specific 40 // If the content type requires it, |resource_identifier| names the specific
41 // resource that was blocked (the plugin path in the case of plugins), 41 // resource that was blocked (the plugin path in the case of plugins),
42 // otherwise it's the empty string. 42 // otherwise it's the empty string.
43 void DidBlockContentType(ContentSettingsType settings_type, 43 void DidBlockContentType(ContentSettingsType settings_type,
44 const std::string& resource_identifier); 44 const std::string& resource_identifier);
45 45
46 // These correspond to WebKit::WebPermissionClient methods. 46 // These correspond to blink::WebPermissionClient methods.
47 bool AllowDatabase(WebKit::WebFrame* frame, 47 bool AllowDatabase(blink::WebFrame* frame,
48 const WebKit::WebString& name, 48 const blink::WebString& name,
49 const WebKit::WebString& display_name, 49 const blink::WebString& display_name,
50 unsigned long estimated_size); 50 unsigned long estimated_size);
51 bool AllowFileSystem(WebKit::WebFrame* frame); 51 bool AllowFileSystem(blink::WebFrame* frame);
52 bool AllowImage(WebKit::WebFrame* frame, 52 bool AllowImage(blink::WebFrame* frame,
53 bool enabled_per_settings, 53 bool enabled_per_settings,
54 const WebKit::WebURL& image_url); 54 const blink::WebURL& image_url);
55 bool AllowIndexedDB(WebKit::WebFrame* frame, 55 bool AllowIndexedDB(blink::WebFrame* frame,
56 const WebKit::WebString& name, 56 const blink::WebString& name,
57 const WebKit::WebSecurityOrigin& origin); 57 const blink::WebSecurityOrigin& origin);
58 bool AllowPlugins(WebKit::WebFrame* frame, bool enabled_per_settings); 58 bool AllowPlugins(blink::WebFrame* frame, bool enabled_per_settings);
59 bool AllowScript(WebKit::WebFrame* frame, bool enabled_per_settings); 59 bool AllowScript(blink::WebFrame* frame, bool enabled_per_settings);
60 bool AllowScriptFromSource(WebKit::WebFrame* frame, bool enabled_per_settings, 60 bool AllowScriptFromSource(blink::WebFrame* frame, bool enabled_per_settings,
61 const WebKit::WebURL& script_url); 61 const blink::WebURL& script_url);
62 bool AllowStorage(WebKit::WebFrame* frame, bool local); 62 bool AllowStorage(blink::WebFrame* frame, bool local);
63 63
64 void DidNotAllowPlugins(); 64 void DidNotAllowPlugins();
65 void DidNotAllowScript(); 65 void DidNotAllowScript();
66 void DidNotAllowMixedScript(); 66 void DidNotAllowMixedScript();
67 67
68 // These two methods are not related to content settings, they are used 68 // These two methods are not related to content settings, they are used
69 // for cases when the NPAPI plugins malfunction if used. 69 // for cases when the NPAPI plugins malfunction if used.
70 void BlockNPAPIPlugins(); 70 void BlockNPAPIPlugins();
71 bool AreNPAPIPluginsBlocked() const; 71 bool AreNPAPIPluginsBlocked() const;
72 72
73 private: 73 private:
74 FRIEND_TEST_ALL_PREFIXES(ContentSettingsObserverTest, WhitelistedSchemes); 74 FRIEND_TEST_ALL_PREFIXES(ContentSettingsObserverTest, WhitelistedSchemes);
75 FRIEND_TEST_ALL_PREFIXES(ChromeRenderViewTest, 75 FRIEND_TEST_ALL_PREFIXES(ChromeRenderViewTest,
76 ContentSettingsInterstitialPages); 76 ContentSettingsInterstitialPages);
77 77
78 // RenderViewObserver implementation. 78 // RenderViewObserver implementation.
79 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; 79 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
80 virtual void DidCommitProvisionalLoad(WebKit::WebFrame* frame, 80 virtual void DidCommitProvisionalLoad(blink::WebFrame* frame,
81 bool is_new_navigation) OVERRIDE; 81 bool is_new_navigation) OVERRIDE;
82 82
83 // Message handlers. 83 // Message handlers.
84 void OnLoadBlockedPlugins(const std::string& identifier); 84 void OnLoadBlockedPlugins(const std::string& identifier);
85 void OnSetAsInterstitial(); 85 void OnSetAsInterstitial();
86 86
87 // Resets the |content_blocked_| array. 87 // Resets the |content_blocked_| array.
88 void ClearBlockedContentSettings(); 88 void ClearBlockedContentSettings();
89 89
90 // Helpers. 90 // Helpers.
91 // True if |frame| contains content that is white-listed for content settings. 91 // True if |frame| contains content that is white-listed for content settings.
92 static bool IsWhitelistedForContentSettings(WebKit::WebFrame* frame); 92 static bool IsWhitelistedForContentSettings(blink::WebFrame* frame);
93 static bool IsWhitelistedForContentSettings( 93 static bool IsWhitelistedForContentSettings(
94 const WebKit::WebSecurityOrigin& origin, 94 const blink::WebSecurityOrigin& origin,
95 const GURL& document_url); 95 const GURL& document_url);
96 96
97 // A pointer to content setting rules stored by the renderer. Normally, the 97 // A pointer to content setting rules stored by the renderer. Normally, the
98 // |RendererContentSettingRules| object is owned by 98 // |RendererContentSettingRules| object is owned by
99 // |ChromeRenderProcessObserver|. In the tests it is owned by the caller of 99 // |ChromeRenderProcessObserver|. In the tests it is owned by the caller of
100 // |SetContentSettingRules|. 100 // |SetContentSettingRules|.
101 const RendererContentSettingRules* content_setting_rules_; 101 const RendererContentSettingRules* content_setting_rules_;
102 102
103 // Stores if images, scripts, and plugins have actually been blocked. 103 // Stores if images, scripts, and plugins have actually been blocked.
104 bool content_blocked_[CONTENT_SETTINGS_NUM_TYPES]; 104 bool content_blocked_[CONTENT_SETTINGS_NUM_TYPES];
105 105
106 // Caches the result of AllowStorage. 106 // Caches the result of AllowStorage.
107 typedef std::pair<GURL, bool> StoragePermissionsKey; 107 typedef std::pair<GURL, bool> StoragePermissionsKey;
108 std::map<StoragePermissionsKey, bool> cached_storage_permissions_; 108 std::map<StoragePermissionsKey, bool> cached_storage_permissions_;
109 109
110 // Caches the result of |AllowScript|. 110 // Caches the result of |AllowScript|.
111 std::map<WebKit::WebFrame*, bool> cached_script_permissions_; 111 std::map<blink::WebFrame*, bool> cached_script_permissions_;
112 112
113 std::set<std::string> temporarily_allowed_plugins_; 113 std::set<std::string> temporarily_allowed_plugins_;
114 bool is_interstitial_page_; 114 bool is_interstitial_page_;
115 bool npapi_plugins_blocked_; 115 bool npapi_plugins_blocked_;
116 116
117 DISALLOW_COPY_AND_ASSIGN(ContentSettingsObserver); 117 DISALLOW_COPY_AND_ASSIGN(ContentSettingsObserver);
118 }; 118 };
119 119
120 #endif // CHROME_RENDERER_CONTENT_SETTINGS_OBSERVER_H_ 120 #endif // CHROME_RENDERER_CONTENT_SETTINGS_OBSERVER_H_
OLDNEW
« no previous file with comments | « chrome/renderer/chrome_render_view_observer.cc ('k') | chrome/renderer/content_settings_observer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698