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

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

Issue 7831075: Delegating the "are images allowed" decision to renderer. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Rebased. Created 9 years, 2 months 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
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 WebKit {
18 class WebSecurityOrigin; 18 class WebSecurityOrigin;
19 class WebURL; 19 class WebURL;
20 } 20 }
21 21
22 // Handles blocking content per content settings for each RenderView. 22 // Handles blocking content per content settings for each RenderView.
23 class ContentSettingsObserver 23 class ContentSettingsObserver
24 : public content::RenderViewObserver, 24 : public content::RenderViewObserver,
25 public content::RenderViewObserverTracker<ContentSettingsObserver> { 25 public content::RenderViewObserverTracker<ContentSettingsObserver> {
26 public: 26 public:
27 explicit ContentSettingsObserver(content::RenderView* render_view); 27 ContentSettingsObserver(content::RenderView* render_view,
28 const ContentSettingsForOneType* image_setting_rules);
28 virtual ~ContentSettingsObserver(); 29 virtual ~ContentSettingsObserver();
29 30
30 // Sets the content settings that back allowScripts(), allowImages(), and 31 // Sets the content settings that back allowScripts() and allowPlugins().
31 // allowPlugins().
32 void SetContentSettings(const ContentSettings& settings); 32 void SetContentSettings(const ContentSettings& settings);
33 33
34 // Sets the default content settings that back allowScripts(), 34 // Sets the default content settings that back allowScripts() and
35 // allowImages(), and allowPlugins(). 35 // allowPlugins().
36 static void SetDefaultContentSettings(const ContentSettings& settings); 36 static void SetDefaultContentSettings(const ContentSettings& settings);
37 37
38 // Returns the setting for the given type. 38 // Returns the setting for the given type.
39 ContentSetting GetContentSetting(ContentSettingsType type); 39 ContentSetting GetContentSetting(ContentSettingsType type);
40 40
41 // Sends an IPC notification that the specified content type was blocked. 41 // Sends an IPC notification that the specified content type was blocked.
42 // If the content type requires it, |resource_identifier| names the specific 42 // If the content type requires it, |resource_identifier| names the specific
43 // resource that was blocked (the plugin path in the case of plugins), 43 // resource that was blocked (the plugin path in the case of plugins),
44 // otherwise it's the empty string. 44 // otherwise it's the empty string.
45 void DidBlockContentType(ContentSettingsType settings_type, 45 void DidBlockContentType(ContentSettingsType settings_type,
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 // |content_type|. 79 // |content_type|.
80 bool AllowContentType(ContentSettingsType settings_type); 80 bool AllowContentType(ContentSettingsType settings_type);
81 81
82 // Resets the |content_blocked_| array. 82 // Resets the |content_blocked_| array.
83 void ClearBlockedContentSettings(); 83 void ClearBlockedContentSettings();
84 84
85 typedef std::map<GURL, ContentSettings> HostContentSettings; 85 typedef std::map<GURL, ContentSettings> HostContentSettings;
86 HostContentSettings host_content_settings_; 86 HostContentSettings host_content_settings_;
87 87
88 // Stores our most up-to-date view of the default content settings. 88 // Stores our most up-to-date view of the default content settings.
89 static ContentSettings default_settings_; 89 static ContentSettings default_settings_;
Bernhard Bauer 2011/10/17 13:13:19 If we're storing image settings globally, we could
marja 2011/10/18 12:23:02 Done.
90 90
91 // Stores if loading of images, scripts, and plugins is allowed. 91 // Stores if loading of scripts and plugins is allowed.
92 ContentSettings current_content_settings_; 92 ContentSettings current_content_settings_;
93 93
94 // Stores the rules for image content settings. Owned by
95 // ChromeContentRendererClient.
96 const ContentSettingsForOneType* image_setting_rules_;
97
94 // Stores if images, scripts, and plugins have actually been blocked. 98 // Stores if images, scripts, and plugins have actually been blocked.
95 bool content_blocked_[CONTENT_SETTINGS_NUM_TYPES]; 99 bool content_blocked_[CONTENT_SETTINGS_NUM_TYPES];
96 100
97 // Caches the result of AllowStorage. 101 // Caches the result of AllowStorage.
98 typedef std::pair<GURL, bool> StoragePermissionsKey; 102 typedef std::pair<GURL, bool> StoragePermissionsKey;
99 std::map<StoragePermissionsKey, bool> cached_storage_permissions_; 103 std::map<StoragePermissionsKey, bool> cached_storage_permissions_;
100 104
101 bool plugins_temporarily_allowed_; 105 bool plugins_temporarily_allowed_;
102 106
103 DISALLOW_COPY_AND_ASSIGN(ContentSettingsObserver); 107 DISALLOW_COPY_AND_ASSIGN(ContentSettingsObserver);
104 }; 108 };
105 109
106 #endif // CHROME_RENDERER_CONTENT_SETTINGS_OBSERVER_H_ 110 #endif // CHROME_RENDERER_CONTENT_SETTINGS_OBSERVER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698