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

Side by Side Diff: chrome/browser/content_settings/host_content_settings_map.h

Issue 8539004: Replace SetContentSetting method of the content_settings::Provider interface with GetWebsiteSetting (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: " 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 // Maps hostnames to custom content settings. Written on the UI thread and read 5 // Maps hostnames to custom content settings. Written on the UI thread and read
6 // on any thread. One instance per profile. 6 // on any thread. One instance per profile.
7 7
8 #ifndef CHROME_BROWSER_CONTENT_SETTINGS_HOST_CONTENT_SETTINGS_MAP_H_ 8 #ifndef CHROME_BROWSER_CONTENT_SETTINGS_HOST_CONTENT_SETTINGS_MAP_H_
9 #define CHROME_BROWSER_CONTENT_SETTINGS_HOST_CONTENT_SETTINGS_MAP_H_ 9 #define CHROME_BROWSER_CONTENT_SETTINGS_HOST_CONTENT_SETTINGS_MAP_H_
10 #pragma once 10 #pragma once
11 11
12 #include <map> 12 #include <map>
13 #include <string> 13 #include <string>
14 #include <vector> 14 #include <vector>
15 15
16 #include "base/basictypes.h" 16 #include "base/basictypes.h"
17 #include "base/memory/ref_counted.h" 17 #include "base/memory/ref_counted.h"
18 #include "base/synchronization/lock.h" 18 #include "base/synchronization/lock.h"
19 #include "base/tuple.h" 19 #include "base/tuple.h"
20 #include "base/values.h"
Bernhard Bauer 2011/11/11 14:00:40 Why do you need this header? base::Value is alread
markusheintz_ 2011/11/14 11:15:10 Done.
20 #include "chrome/browser/content_settings/content_settings_observer.h" 21 #include "chrome/browser/content_settings/content_settings_observer.h"
21 #include "chrome/browser/prefs/pref_change_registrar.h" 22 #include "chrome/browser/prefs/pref_change_registrar.h"
22 #include "chrome/common/content_settings.h" 23 #include "chrome/common/content_settings.h"
23 #include "chrome/common/content_settings_pattern.h" 24 #include "chrome/common/content_settings_pattern.h"
24 25
25 namespace base { 26 namespace base {
26 class Value; 27 class Value;
27 } // namespace base 28 } // namespace base
28 29
29 namespace content_settings { 30 namespace content_settings {
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 // ContentSettingsTypes that require an resource identifier to be specified, 129 // ContentSettingsTypes that require an resource identifier to be specified,
129 // the |resource_identifier| must be non-empty. 130 // the |resource_identifier| must be non-empty.
130 // 131 //
131 // This should only be called on the UI thread. 132 // This should only be called on the UI thread.
132 void SetContentSetting(const ContentSettingsPattern& primary_pattern, 133 void SetContentSetting(const ContentSettingsPattern& primary_pattern,
133 const ContentSettingsPattern& secondary_pattern, 134 const ContentSettingsPattern& secondary_pattern,
134 ContentSettingsType content_type, 135 ContentSettingsType content_type,
135 const std::string& resource_identifier, 136 const std::string& resource_identifier,
136 ContentSetting setting); 137 ContentSetting setting);
137 138
139 // Sets the |value| for the given patterns and content type. Setting the
140 // value to NULL causes the default value for that type to be used when
141 // loading pages matching this pattern. For ContentSettingsTypes that require
Bernhard Bauer 2011/11/11 14:00:40 Urgh, that comment is outdated :( If you're suffer
markusheintz_ 2011/11/14 11:15:10 Done.
142 // an resource identifier to be specified, the |resource_identifier| must be
143 // non-empty.
144 //
145 // Takes ownership of the passed value.
146 void SetWebsiteSetting(const ContentSettingsPattern& primary_pattern,
147 const ContentSettingsPattern& secondary_pattern,
148 ContentSettingsType content_type,
149 const std::string& resource_identifier,
150 base::Value* value);
151
138 // Convenience method to add a content setting for the given URLs, making sure 152 // Convenience method to add a content setting for the given URLs, making sure
139 // that there is no setting overriding it. For ContentSettingsTypes that 153 // that there is no setting overriding it. For ContentSettingsTypes that
140 // require an resource identifier to be specified, the |resource_identifier| 154 // require an resource identifier to be specified, the |resource_identifier|
141 // must be non-empty. 155 // must be non-empty.
142 // 156 //
143 // This should only be called on the UI thread. 157 // This should only be called on the UI thread.
144 void AddExceptionForURL(const GURL& primary_url, 158 void AddExceptionForURL(const GURL& primary_url,
145 const GURL& secondary_url, 159 const GURL& secondary_url,
146 ContentSettingsType content_type, 160 ContentSettingsType content_type,
147 const std::string& resource_identifier, 161 const std::string& resource_identifier,
148 ContentSetting setting); 162 ContentSetting setting);
149 163
150 // Clears all host-specific settings for one content type. 164 // Clears all host-specific settings for one content type.
151 // 165 //
152 // This should only be called on the UI thread. 166 // This should only be called on the UI thread.
153 void ClearSettingsForOneType(ContentSettingsType content_type); 167 void ClearSettingsForOneType(ContentSettingsType content_type);
154 168
169 static bool IsValueAllowedForType(const base::Value* value,
170 ContentSettingsType content_type);
155 static bool IsSettingAllowedForType(ContentSetting setting, 171 static bool IsSettingAllowedForType(ContentSetting setting,
156 ContentSettingsType content_type); 172 ContentSettingsType content_type);
157 173
158 // Detaches the HostContentSettingsMap from all Profile-related objects like 174 // Detaches the HostContentSettingsMap from all Profile-related objects like
159 // PrefService. This methods needs to be called before destroying the Profile. 175 // PrefService. This methods needs to be called before destroying the Profile.
160 // Afterwards, none of the methods above that should only be called on the UI 176 // Afterwards, none of the methods above that should only be called on the UI
161 // thread should be called anymore. 177 // thread should be called anymore.
162 void ShutdownOnUIThread(); 178 void ShutdownOnUIThread();
163 179
164 // content_settings::Observer implementation. 180 // content_settings::Observer implementation.
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 // Content setting providers. 236 // Content setting providers.
221 ProviderMap content_settings_providers_; 237 ProviderMap content_settings_providers_;
222 238
223 // Used around accesses to the following objects to guarantee thread safety. 239 // Used around accesses to the following objects to guarantee thread safety.
224 mutable base::Lock lock_; 240 mutable base::Lock lock_;
225 241
226 DISALLOW_COPY_AND_ASSIGN(HostContentSettingsMap); 242 DISALLOW_COPY_AND_ASSIGN(HostContentSettingsMap);
227 }; 243 };
228 244
229 #endif // CHROME_BROWSER_CONTENT_SETTINGS_HOST_CONTENT_SETTINGS_MAP_H_ 245 #endif // CHROME_BROWSER_CONTENT_SETTINGS_HOST_CONTENT_SETTINGS_MAP_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698