| 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 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 class ExtensionService; | 26 class ExtensionService; |
| 27 class GURL; | 27 class GURL; |
| 28 class PrefService; | 28 class PrefService; |
| 29 | 29 |
| 30 namespace base { | 30 namespace base { |
| 31 class Clock; | 31 class Clock; |
| 32 class Value; | 32 class Value; |
| 33 } | 33 } |
| 34 | 34 |
| 35 namespace content_settings { | 35 namespace content_settings { |
| 36 class ObservableProvider; |
| 36 class ProviderInterface; | 37 class ProviderInterface; |
| 37 class PrefProvider; | 38 class PrefProvider; |
| 38 } | 39 } |
| 39 | 40 |
| 40 namespace user_prefs { | 41 namespace user_prefs { |
| 41 class PrefRegistrySyncable; | 42 class PrefRegistrySyncable; |
| 42 } | 43 } |
| 43 | 44 |
| 44 class HostContentSettingsMap | 45 class HostContentSettingsMap |
| 45 : public content_settings::Observer, | 46 : public content_settings::Observer, |
| 46 public base::RefCountedThreadSafe<HostContentSettingsMap> { | 47 public base::RefCountedThreadSafe<HostContentSettingsMap> { |
| 47 public: | 48 public: |
| 48 enum ProviderType { | 49 enum ProviderType { |
| 49 INTERNAL_EXTENSION_PROVIDER = 0, | 50 INTERNAL_EXTENSION_PROVIDER = 0, |
| 50 POLICY_PROVIDER, | 51 POLICY_PROVIDER, |
| 51 CUSTOM_EXTENSION_PROVIDER, | 52 CUSTOM_EXTENSION_PROVIDER, |
| 52 PREF_PROVIDER, | 53 PREF_PROVIDER, |
| 53 DEFAULT_PROVIDER, | 54 DEFAULT_PROVIDER, |
| 54 NUM_PROVIDER_TYPES, | 55 NUM_PROVIDER_TYPES, |
| 55 }; | 56 }; |
| 56 | 57 |
| 57 HostContentSettingsMap(PrefService* prefs, bool incognito); | 58 HostContentSettingsMap(PrefService* prefs, bool incognito); |
| 58 | 59 |
| 59 #if defined(ENABLE_EXTENSIONS) | 60 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); |
| 60 // In some cases, the ExtensionService is not available at the time the | |
| 61 // HostContentSettingsMap is constructed. In these cases, we register the | |
| 62 // service once it's available. | |
| 63 void RegisterExtensionService(ExtensionService* extension_service); | |
| 64 #endif | |
| 65 | 61 |
| 66 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); | 62 // Adds a new provider for |type|. |
| 63 void RegisterProvider( |
| 64 ProviderType type, |
| 65 scoped_ptr<content_settings::ObservableProvider> provider); |
| 67 | 66 |
| 68 // Returns the default setting for a particular content type. If |provider_id| | 67 // Returns the default setting for a particular content type. If |provider_id| |
| 69 // is not NULL, the id of the provider which provided the default setting is | 68 // is not NULL, the id of the provider which provided the default setting is |
| 70 // assigned to it. | 69 // assigned to it. |
| 71 // | 70 // |
| 72 // This may be called on any thread. | 71 // This may be called on any thread. |
| 73 ContentSetting GetDefaultContentSetting(ContentSettingsType content_type, | 72 ContentSetting GetDefaultContentSetting(ContentSettingsType content_type, |
| 74 std::string* provider_id) const; | 73 std::string* provider_id) const; |
| 75 | 74 |
| 76 // Returns a single |ContentSetting| which applies to the given URLs. Note | 75 // Returns a single |ContentSetting| which applies to the given URLs. Note |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 314 // time and by RegisterExtensionService, both of which should happen | 313 // time and by RegisterExtensionService, both of which should happen |
| 315 // before any other uses of it. | 314 // before any other uses of it. |
| 316 ProviderMap content_settings_providers_; | 315 ProviderMap content_settings_providers_; |
| 317 | 316 |
| 318 ObserverList<content_settings::Observer> observers_; | 317 ObserverList<content_settings::Observer> observers_; |
| 319 | 318 |
| 320 DISALLOW_COPY_AND_ASSIGN(HostContentSettingsMap); | 319 DISALLOW_COPY_AND_ASSIGN(HostContentSettingsMap); |
| 321 }; | 320 }; |
| 322 | 321 |
| 323 #endif // CHROME_BROWSER_CONTENT_SETTINGS_HOST_CONTENT_SETTINGS_MAP_H_ | 322 #endif // CHROME_BROWSER_CONTENT_SETTINGS_HOST_CONTENT_SETTINGS_MAP_H_ |
| OLD | NEW |