OLD | NEW |
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 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 static void RegisterUserPrefs(PrefService* prefs); | 53 static void RegisterUserPrefs(PrefService* prefs); |
54 | 54 |
55 // Returns the default setting for a particular content type. If |provider_id| | 55 // Returns the default setting for a particular content type. If |provider_id| |
56 // is not NULL, the id of the provider which provided the default setting is | 56 // is not NULL, the id of the provider which provided the default setting is |
57 // assigned to it. | 57 // assigned to it. |
58 // | 58 // |
59 // This may be called on any thread. | 59 // This may be called on any thread. |
60 ContentSetting GetDefaultContentSetting(ContentSettingsType content_type, | 60 ContentSetting GetDefaultContentSetting(ContentSettingsType content_type, |
61 std::string* provider_id) const; | 61 std::string* provider_id) const; |
62 | 62 |
63 // Returns the default settings for all content types. | |
64 // | |
65 // This may be called on any thread. | |
66 ContentSettings GetDefaultContentSettings() const; | |
67 | |
68 // Returns a single |ContentSetting| which applies to the given URLs. Note | 63 // Returns a single |ContentSetting| which applies to the given URLs. Note |
69 // that certain internal schemes are whitelisted. For |CONTENT_TYPE_COOKIES|, | 64 // that certain internal schemes are whitelisted. For |CONTENT_TYPE_COOKIES|, |
70 // |CookieSettings| should be used instead. For content types that can't be | 65 // |CookieSettings| should be used instead. For content types that can't be |
71 // converted to a |ContentSetting|, |GetContentSettingValue| should be called. | 66 // converted to a |ContentSetting|, |GetContentSettingValue| should be called. |
72 // If there is no content setting, returns CONTENT_SETTING_DEFAULT. | 67 // If there is no content setting, returns CONTENT_SETTING_DEFAULT. |
73 // | 68 // |
74 // May be called on any thread. | 69 // May be called on any thread. |
75 ContentSetting GetContentSetting( | 70 ContentSetting GetContentSetting( |
76 const GURL& primary_url, | 71 const GURL& primary_url, |
77 const GURL& secondary_url, | 72 const GURL& secondary_url, |
78 ContentSettingsType content_type, | 73 ContentSettingsType content_type, |
79 const std::string& resource_identifier) const; | 74 const std::string& resource_identifier) const; |
80 | 75 |
81 // Returns a single content setting |Value| which applies to the given URLs. | 76 // Returns a single content setting |Value| which applies to the given URLs. |
82 // If |primary_pattern| and |secondary_pattern| are not NULL, they are set to | 77 // If |primary_pattern| and |secondary_pattern| are not NULL, they are set to |
83 // the patterns of the applying rule. | 78 // the patterns of the applying rule. |
84 // Note that certain internal schemes are whitelisted. | 79 // Note that certain internal schemes are whitelisted. |
85 // If there is no content setting, returns NULL and leaves |primary_pattern| | 80 // If there is no content setting, returns NULL and leaves |primary_pattern| |
86 // and |secondary_pattern| unchanged. | 81 // and |secondary_pattern| unchanged. |
87 // Otherwise transfers ownership of the resulting |Value| to the caller. | 82 // Otherwise transfers ownership of the resulting |Value| to the caller. |
88 // May be called on any thread. | 83 // May be called on any thread. |
89 base::Value* GetContentSettingValue( | 84 base::Value* GetContentSettingValue( |
90 const GURL& primary_url, | 85 const GURL& primary_url, |
91 const GURL& secondary_url, | 86 const GURL& secondary_url, |
92 ContentSettingsType content_type, | 87 ContentSettingsType content_type, |
93 const std::string& resource_identifier, | 88 const std::string& resource_identifier, |
94 ContentSettingsPattern* primary_pattern, | 89 ContentSettingsPattern* primary_pattern, |
95 ContentSettingsPattern* secondary_pattern) const; | 90 ContentSettingsPattern* secondary_pattern) const; |
96 | 91 |
97 // Returns all ContentSettings which apply to the given |primary_url|. For | |
98 // content setting types that require an additional resource identifier, the | |
99 // default content setting is returned. | |
100 // | |
101 // This may be called on any thread. | |
102 ContentSettings GetContentSettings( | |
103 const GURL& primary_url) const; | |
104 | |
105 // For a given content type, returns all patterns with a non-default setting, | 92 // For a given content type, returns all patterns with a non-default setting, |
106 // mapped to their actual settings, in the precedence order of the rules. | 93 // mapped to their actual settings, in the precedence order of the rules. |
107 // |settings| must be a non-NULL outparam. | 94 // |settings| must be a non-NULL outparam. |
108 // | 95 // |
109 // This may be called on any thread. | 96 // This may be called on any thread. |
110 void GetSettingsForOneType(ContentSettingsType content_type, | 97 void GetSettingsForOneType(ContentSettingsType content_type, |
111 const std::string& resource_identifier, | 98 const std::string& resource_identifier, |
112 ContentSettingsForOneType* settings) const; | 99 ContentSettingsForOneType* settings) const; |
113 | 100 |
114 // Sets the default setting for a particular content type. This method must | 101 // Sets the default setting for a particular content type. This method must |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 // Content setting providers. | 203 // Content setting providers. |
217 ProviderMap content_settings_providers_; | 204 ProviderMap content_settings_providers_; |
218 | 205 |
219 // Used around accesses to the following objects to guarantee thread safety. | 206 // Used around accesses to the following objects to guarantee thread safety. |
220 mutable base::Lock lock_; | 207 mutable base::Lock lock_; |
221 | 208 |
222 DISALLOW_COPY_AND_ASSIGN(HostContentSettingsMap); | 209 DISALLOW_COPY_AND_ASSIGN(HostContentSettingsMap); |
223 }; | 210 }; |
224 | 211 |
225 #endif // CHROME_BROWSER_CONTENT_SETTINGS_HOST_CONTENT_SETTINGS_MAP_H_ | 212 #endif // CHROME_BROWSER_CONTENT_SETTINGS_HOST_CONTENT_SETTINGS_MAP_H_ |
OLD | NEW |