| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 | 10 |
| 11 #include <map> | 11 #include <map> |
| 12 #include <string> | 12 #include <string> |
| 13 #include <vector> | 13 #include <vector> |
| 14 | 14 |
| 15 #include "base/basictypes.h" | 15 #include "base/basictypes.h" |
| 16 #include "base/memory/ref_counted.h" | 16 #include "base/memory/ref_counted.h" |
| 17 #include "base/prefs/pref_change_registrar.h" | 17 #include "base/prefs/pref_change_registrar.h" |
| 18 #include "base/threading/platform_thread.h" | 18 #include "base/threading/platform_thread.h" |
| 19 #include "base/tuple.h" | 19 #include "base/tuple.h" |
| 20 #include "chrome/browser/content_settings/content_settings_observer.h" | 20 #include "chrome/browser/content_settings/content_settings_observer.h" |
| 21 #include "chrome/common/content_settings.h" | 21 #include "chrome/common/content_settings.h" |
| 22 #include "chrome/common/content_settings_pattern.h" | 22 #include "chrome/common/content_settings_pattern.h" |
| 23 #include "chrome/common/content_settings_types.h" | 23 #include "chrome/common/content_settings_types.h" |
| 24 | 24 |
| 25 namespace base { | |
| 26 class Value; | |
| 27 } // namespace base | |
| 28 | |
| 29 namespace content_settings { | |
| 30 class ProviderInterface; | |
| 31 } // namespace content_settings | |
| 32 | |
| 33 class ExtensionService; | 25 class ExtensionService; |
| 34 class GURL; | 26 class GURL; |
| 35 class PrefService; | 27 class PrefService; |
| 28 |
| 29 namespace base { |
| 30 class Value; |
| 31 } |
| 32 |
| 33 namespace content_settings { |
| 34 class ProviderInterface; |
| 35 } |
| 36 |
| 37 namespace user_prefs { |
| 36 class PrefRegistrySyncable; | 38 class PrefRegistrySyncable; |
| 39 } |
| 37 | 40 |
| 38 class HostContentSettingsMap | 41 class HostContentSettingsMap |
| 39 : public content_settings::Observer, | 42 : public content_settings::Observer, |
| 40 public base::RefCountedThreadSafe<HostContentSettingsMap> { | 43 public base::RefCountedThreadSafe<HostContentSettingsMap> { |
| 41 public: | 44 public: |
| 42 enum ProviderType { | 45 enum ProviderType { |
| 43 INTERNAL_EXTENSION_PROVIDER = 0, | 46 INTERNAL_EXTENSION_PROVIDER = 0, |
| 44 POLICY_PROVIDER, | 47 POLICY_PROVIDER, |
| 45 CUSTOM_EXTENSION_PROVIDER, | 48 CUSTOM_EXTENSION_PROVIDER, |
| 46 PREF_PROVIDER, | 49 PREF_PROVIDER, |
| 47 DEFAULT_PROVIDER, | 50 DEFAULT_PROVIDER, |
| 48 NUM_PROVIDER_TYPES, | 51 NUM_PROVIDER_TYPES, |
| 49 }; | 52 }; |
| 50 | 53 |
| 51 HostContentSettingsMap(PrefService* prefs, bool incognito); | 54 HostContentSettingsMap(PrefService* prefs, bool incognito); |
| 52 | 55 |
| 53 #if defined(ENABLE_EXTENSIONS) | 56 #if defined(ENABLE_EXTENSIONS) |
| 54 // In some cases, the ExtensionService is not available at the time the | 57 // In some cases, the ExtensionService is not available at the time the |
| 55 // HostContentSettingsMap is constructed. In these cases, we register the | 58 // HostContentSettingsMap is constructed. In these cases, we register the |
| 56 // service once it's available. | 59 // service once it's available. |
| 57 void RegisterExtensionService(ExtensionService* extension_service); | 60 void RegisterExtensionService(ExtensionService* extension_service); |
| 58 #endif | 61 #endif |
| 59 | 62 |
| 60 static void RegisterUserPrefs(PrefRegistrySyncable* registry); | 63 static void RegisterUserPrefs(user_prefs::PrefRegistrySyncable* registry); |
| 61 | 64 |
| 62 // Returns the default setting for a particular content type. If |provider_id| | 65 // Returns the default setting for a particular content type. If |provider_id| |
| 63 // is not NULL, the id of the provider which provided the default setting is | 66 // is not NULL, the id of the provider which provided the default setting is |
| 64 // assigned to it. | 67 // assigned to it. |
| 65 // | 68 // |
| 66 // This may be called on any thread. | 69 // This may be called on any thread. |
| 67 ContentSetting GetDefaultContentSetting(ContentSettingsType content_type, | 70 ContentSetting GetDefaultContentSetting(ContentSettingsType content_type, |
| 68 std::string* provider_id) const; | 71 std::string* provider_id) const; |
| 69 | 72 |
| 70 // Returns a single |ContentSetting| which applies to the given URLs. Note | 73 // Returns a single |ContentSetting| which applies to the given URLs. Note |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 | 257 |
| 255 // Content setting providers. This is only modified at construction | 258 // Content setting providers. This is only modified at construction |
| 256 // time and by RegisterExtensionService, both of which should happen | 259 // time and by RegisterExtensionService, both of which should happen |
| 257 // before any other uses of it. | 260 // before any other uses of it. |
| 258 ProviderMap content_settings_providers_; | 261 ProviderMap content_settings_providers_; |
| 259 | 262 |
| 260 DISALLOW_COPY_AND_ASSIGN(HostContentSettingsMap); | 263 DISALLOW_COPY_AND_ASSIGN(HostContentSettingsMap); |
| 261 }; | 264 }; |
| 262 | 265 |
| 263 #endif // CHROME_BROWSER_CONTENT_SETTINGS_HOST_CONTENT_SETTINGS_MAP_H_ | 266 #endif // CHROME_BROWSER_CONTENT_SETTINGS_HOST_CONTENT_SETTINGS_MAP_H_ |
| OLD | NEW |