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

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

Issue 104833006: Switch ContentSettingsObserver to be a RenderFrameObserver instead of a RenderViewObserver (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years 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_frame_observer.h"
13 #include "content/public/renderer/render_view_observer_tracker.h" 13 #include "content/public/renderer/render_frame_observer_tracker.h"
14 #include "extensions/common/permissions/api_permission.h" 14 #include "extensions/common/permissions/api_permission.h"
15 #include "third_party/WebKit/public/web/WebPermissionClient.h" 15 #include "third_party/WebKit/public/web/WebPermissionClient.h"
16 16
17 class GURL; 17 class GURL;
18 18
19 namespace blink { 19 namespace blink {
20 class WebFrame; 20 class WebFrame;
21 class WebSecurityOrigin; 21 class WebSecurityOrigin;
22 class WebURL; 22 class WebURL;
23 } 23 }
24 24
25 namespace extensions { 25 namespace extensions {
26 class Dispatcher; 26 class Dispatcher;
27 class Extension; 27 class Extension;
28 } 28 }
29 29
30 // Handles blocking content per content settings for each RenderView. 30 // Handles blocking content per content settings for each RenderFrame.
31 class ContentSettingsObserver 31 class ContentSettingsObserver
32 : public content::RenderViewObserver, 32 : public content::RenderFrameObserver,
33 public content::RenderViewObserverTracker<ContentSettingsObserver>, 33 public content::RenderFrameObserverTracker<ContentSettingsObserver>,
34 public blink::WebPermissionClient { 34 public blink::WebPermissionClient {
35 public: 35 public:
36 ContentSettingsObserver(content::RenderView* render_view, 36 ContentSettingsObserver(content::RenderFrame* render_frame,
37 extensions::Dispatcher* extension_dispatcher); 37 extensions::Dispatcher* extension_dispatcher);
38 virtual ~ContentSettingsObserver(); 38 virtual ~ContentSettingsObserver();
39 39
40 // Sets the content setting rules which back |AllowImage()|, |AllowScript()|, 40 // Sets the content setting rules which back |AllowImage()|, |AllowScript()|,
41 // and |AllowScriptFromSource()|. |content_setting_rules| must outlive this 41 // and |AllowScriptFromSource()|. |content_setting_rules| must outlive this
42 // |ContentSettingsObserver|. 42 // |ContentSettingsObserver|.
43 void SetContentSettingRules( 43 void SetContentSettingRules(
44 const RendererContentSettingRules* content_setting_rules); 44 const RendererContentSettingRules* content_setting_rules);
45 45
46 bool IsPluginTemporarilyAllowed(const std::string& identifier); 46 bool IsPluginTemporarilyAllowed(const std::string& identifier);
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 const blink::WebSecurityOrigin& context, 97 const blink::WebSecurityOrigin& context,
98 const blink::WebURL& url); 98 const blink::WebURL& url);
99 99
100 // This is used for cases when the NPAPI plugins malfunction if used. 100 // This is used for cases when the NPAPI plugins malfunction if used.
101 bool AreNPAPIPluginsBlocked() const; 101 bool AreNPAPIPluginsBlocked() const;
102 102
103 private: 103 private:
104 FRIEND_TEST_ALL_PREFIXES(ContentSettingsObserverTest, WhitelistedSchemes); 104 FRIEND_TEST_ALL_PREFIXES(ContentSettingsObserverTest, WhitelistedSchemes);
105 FRIEND_TEST_ALL_PREFIXES(ChromeRenderViewTest, 105 FRIEND_TEST_ALL_PREFIXES(ChromeRenderViewTest,
106 ContentSettingsInterstitialPages); 106 ContentSettingsInterstitialPages);
107 FRIEND_TEST_ALL_PREFIXES(ChromeRenderViewTest, PluginsTemporarilyAllowed);
107 108
108 // RenderViewObserver implementation. 109 // RenderFrameObserver implementation.
110 virtual void WebFrameCreated(blink::WebFrame* frame) OVERRIDE;
109 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; 111 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
110 virtual void DidCommitProvisionalLoad(blink::WebFrame* frame, 112 virtual void DidCommitProvisionalLoad(blink::WebFrame* frame,
111 bool is_new_navigation) OVERRIDE; 113 bool is_new_navigation) OVERRIDE;
112 114
113 // Message handlers. 115 // Message handlers.
114 void OnLoadBlockedPlugins(const std::string& identifier); 116 void OnLoadBlockedPlugins(const std::string& identifier);
115 void OnSetAsInterstitial(); 117 void OnSetAsInterstitial();
116 void OnNPAPINotSupported(); 118 void OnNPAPINotSupported();
117 void OnSetAllowDisplayingInsecureContent(bool allow); 119 void OnSetAllowDisplayingInsecureContent(bool allow);
118 void OnSetAllowRunningInsecureContent(bool allow); 120 void OnSetAllowRunningInsecureContent(bool allow);
121 void OnReloadFrame();
119 122
120 // Resets the |content_blocked_| array. 123 // Resets the |content_blocked_| array.
121 void ClearBlockedContentSettings(); 124 void ClearBlockedContentSettings();
122 125
123 // If |origin| corresponds to an installed extension, returns that extension. 126 // If |origin| corresponds to an installed extension, returns that extension.
124 // Otherwise returns NULL. 127 // Otherwise returns NULL.
125 const extensions::Extension* GetExtension( 128 const extensions::Extension* GetExtension(
126 const blink::WebSecurityOrigin& origin) const; 129 const blink::WebSecurityOrigin& origin) const;
127 130
128 // Helpers. 131 // Helpers.
(...skipping 27 matching lines...) Expand all
156 std::map<blink::WebFrame*, bool> cached_script_permissions_; 159 std::map<blink::WebFrame*, bool> cached_script_permissions_;
157 160
158 std::set<std::string> temporarily_allowed_plugins_; 161 std::set<std::string> temporarily_allowed_plugins_;
159 bool is_interstitial_page_; 162 bool is_interstitial_page_;
160 bool npapi_plugins_blocked_; 163 bool npapi_plugins_blocked_;
161 164
162 DISALLOW_COPY_AND_ASSIGN(ContentSettingsObserver); 165 DISALLOW_COPY_AND_ASSIGN(ContentSettingsObserver);
163 }; 166 };
164 167
165 #endif // CHROME_RENDERER_CONTENT_SETTINGS_OBSERVER_H_ 168 #endif // CHROME_RENDERER_CONTENT_SETTINGS_OBSERVER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698