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

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: Code review comments. Created 9 years, 3 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/renderer/render_view_observer.h" 12 #include "content/renderer/render_view_observer.h"
13 #include "content/renderer/render_view_observer_tracker.h" 13 #include "content/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 } 19 }
20 20
21 // Handles blocking content per content settings for each RenderView. 21 // Handles blocking content per content settings for each RenderView.
22 class ContentSettingsObserver 22 class ContentSettingsObserver
23 : public RenderViewObserver, 23 : public RenderViewObserver,
24 public RenderViewObserverTracker<ContentSettingsObserver> { 24 public RenderViewObserverTracker<ContentSettingsObserver> {
25 public: 25 public:
26 explicit ContentSettingsObserver(RenderView* render_view); 26 explicit ContentSettingsObserver(RenderView* render_view,
27 ContentSettingRules* image_setting_rules);
27 virtual ~ContentSettingsObserver(); 28 virtual ~ContentSettingsObserver();
28 29
29 // Sets the content settings that back allowScripts(), allowImages(), and 30 // Sets the content settings that back allowScripts(), and allowPlugins().
30 // allowPlugins().
31 void SetContentSettings(const ContentSettings& settings); 31 void SetContentSettings(const ContentSettings& settings);
32 32
33 // Sets the default content settings that back allowScripts(), 33 // Sets the default content settings that back allowScripts(), and
34 // allowImages(), and allowPlugins(). 34 // allowPlugins().
35 static void SetDefaultContentSettings(const ContentSettings& settings); 35 static void SetDefaultContentSettings(const ContentSettings& settings);
36 36
37 // Returns the setting for the given type. 37 // Returns the setting for the given type.
38 ContentSetting GetContentSetting(ContentSettingsType type); 38 ContentSetting GetContentSetting(ContentSettingsType type);
39 39
40 // Sends an IPC notification that the specified content type was blocked. 40 // Sends an IPC notification that the specified content type was blocked.
41 // If the content type requires it, |resource_identifier| names the specific 41 // If the content type requires it, |resource_identifier| names the specific
42 // resource that was blocked (the plugin path in the case of plugins), 42 // resource that was blocked (the plugin path in the case of plugins),
43 // otherwise it's the empty string. 43 // otherwise it's the empty string.
44 void DidBlockContentType(ContentSettingsType settings_type, 44 void DidBlockContentType(ContentSettingsType settings_type,
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 78
79 // Resets the |content_blocked_| array. 79 // Resets the |content_blocked_| array.
80 void ClearBlockedContentSettings(); 80 void ClearBlockedContentSettings();
81 81
82 typedef std::map<GURL, ContentSettings> HostContentSettings; 82 typedef std::map<GURL, ContentSettings> HostContentSettings;
83 HostContentSettings host_content_settings_; 83 HostContentSettings host_content_settings_;
84 84
85 // Stores our most up-to-date view of the default content settings. 85 // Stores our most up-to-date view of the default content settings.
86 static ContentSettings default_settings_; 86 static ContentSettings default_settings_;
87 87
88 // Stores if loading of images, scripts, and plugins is allowed. 88 // Stores the rules for image content settings. Not owned.
Bernhard Bauer 2011/09/15 12:52:19 Can you explain who owns them? And maybe make the
marja 2011/09/15 16:00:03 Done.
89 ContentSettingRules* image_setting_rules_;
90
91 // Stores if loading of scripts, and plugins is allowed.
89 ContentSettings current_content_settings_; 92 ContentSettings current_content_settings_;
90 93
91 // Stores if images, scripts, and plugins have actually been blocked. 94 // Stores if images, scripts, and plugins have actually been blocked.
92 bool content_blocked_[CONTENT_SETTINGS_NUM_TYPES]; 95 bool content_blocked_[CONTENT_SETTINGS_NUM_TYPES];
93 96
94 // Caches the result of AllowStorage. 97 // Caches the result of AllowStorage.
95 typedef std::pair<GURL, bool> StoragePermissionsKey; 98 typedef std::pair<GURL, bool> StoragePermissionsKey;
96 std::map<StoragePermissionsKey, bool> cached_storage_permissions_; 99 std::map<StoragePermissionsKey, bool> cached_storage_permissions_;
97 100
98 bool plugins_temporarily_allowed_; 101 bool plugins_temporarily_allowed_;
99 102
100 DISALLOW_COPY_AND_ASSIGN(ContentSettingsObserver); 103 DISALLOW_COPY_AND_ASSIGN(ContentSettingsObserver);
101 }; 104 };
102 105
103 #endif // CHROME_RENDERER_CONTENT_SETTINGS_OBSERVER_H_ 106 #endif // CHROME_RENDERER_CONTENT_SETTINGS_OBSERVER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698