| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_HOST_CONTENT_SETTINGS_MAP_H_ | 8 #ifndef CHROME_BROWSER_HOST_CONTENT_SETTINGS_MAP_H_ |
| 9 #define CHROME_BROWSER_HOST_CONTENT_SETTINGS_MAP_H_ | 9 #define CHROME_BROWSER_HOST_CONTENT_SETTINGS_MAP_H_ |
| 10 | 10 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 | 62 |
| 63 // Sets the blocking setting for a particular hostname and content type. | 63 // Sets the blocking setting for a particular hostname and content type. |
| 64 // Setting the value to CONTENT_SETTING_DEFAULT causes the default setting for | 64 // Setting the value to CONTENT_SETTING_DEFAULT causes the default setting for |
| 65 // that type to be used when loading pages from this host. | 65 // that type to be used when loading pages from this host. |
| 66 // | 66 // |
| 67 // This should only be called on the UI thread. | 67 // This should only be called on the UI thread. |
| 68 void SetContentSetting(const std::string& host, | 68 void SetContentSetting(const std::string& host, |
| 69 ContentSettingsType content_type, | 69 ContentSettingsType content_type, |
| 70 ContentSetting setting); | 70 ContentSetting setting); |
| 71 | 71 |
| 72 // This setting trumps any host-specific settings. |
| 73 bool BlockThirdPartyCookies() const { return block_third_party_cookies_; } |
| 74 |
| 72 // Resets all settings levels. | 75 // Resets all settings levels. |
| 73 // | 76 // |
| 74 // This should only be called on the UI thread. | 77 // This should only be called on the UI thread. |
| 75 void ResetToDefaults(); | 78 void ResetToDefaults(); |
| 76 | 79 |
| 77 private: | 80 private: |
| 78 friend class base::RefCountedThreadSafe<HostContentSettingsMap>; | 81 friend class base::RefCountedThreadSafe<HostContentSettingsMap>; |
| 79 | 82 |
| 80 typedef std::map<std::string, ContentSettings> HostContentSettings; | 83 typedef std::map<std::string, ContentSettings> HostContentSettings; |
| 81 | 84 |
| 82 // The names of the ContentSettingsType values, for use with dictionary prefs. | 85 // The names of the ContentSettingsType values, for use with dictionary prefs. |
| 83 static const wchar_t* kTypeNames[]; | 86 static const wchar_t* kTypeNames[]; |
| 84 | 87 |
| 85 ~HostContentSettingsMap(); | 88 ~HostContentSettingsMap(); |
| 86 | 89 |
| 87 // Sets the fields of |settings| based on the values in |dictionary|. | 90 // Sets the fields of |settings| based on the values in |dictionary|. |
| 88 void GetSettingsFromDictionary(const DictionaryValue* dictionary, | 91 void GetSettingsFromDictionary(const DictionaryValue* dictionary, |
| 89 ContentSettings* settings); | 92 ContentSettings* settings); |
| 90 | 93 |
| 91 // The profile we're associated with. | 94 // The profile we're associated with. |
| 92 Profile* profile_; | 95 Profile* profile_; |
| 93 | 96 |
| 94 // Copies of the pref data, so that we can read it on the IO thread. | 97 // Copies of the pref data, so that we can read it on the IO thread. |
| 95 ContentSettings default_content_settings_; | 98 ContentSettings default_content_settings_; |
| 96 HostContentSettings host_content_settings_; | 99 HostContentSettings host_content_settings_; |
| 97 | 100 |
| 101 // Misc global settings. |
| 102 bool block_third_party_cookies_; |
| 103 |
| 98 // Used around accesses to the settings objects to guarantee thread safety. | 104 // Used around accesses to the settings objects to guarantee thread safety. |
| 99 mutable Lock lock_; | 105 mutable Lock lock_; |
| 100 | 106 |
| 101 DISALLOW_COPY_AND_ASSIGN(HostContentSettingsMap); | 107 DISALLOW_COPY_AND_ASSIGN(HostContentSettingsMap); |
| 102 }; | 108 }; |
| 103 | 109 |
| 104 #endif // CHROME_BROWSER_HOST_CONTENT_SETTINGS_MAP_H_ | 110 #endif // CHROME_BROWSER_HOST_CONTENT_SETTINGS_MAP_H_ |
| OLD | NEW |