Index: chrome/browser/content_settings/pref_content_settings_provider.h |
diff --git a/chrome/browser/content_settings/pref_content_settings_provider.h b/chrome/browser/content_settings/pref_content_settings_provider.h |
index 8ed966424c9bef008d51e51043e372687bf837c5..7f009aae53b5b3afb287740c1b7d15e89be29435 100644 |
--- a/chrome/browser/content_settings/pref_content_settings_provider.h |
+++ b/chrome/browser/content_settings/pref_content_settings_provider.h |
@@ -8,6 +8,10 @@ |
// A content settings provider that takes its settings out of the pref service. |
+#include <map> |
+#include <string> |
+#include <utility> |
+ |
#include "base/basictypes.h" |
#include "base/synchronization/lock.h" |
#include "chrome/browser/content_settings/content_settings_provider.h" |
@@ -76,6 +80,7 @@ class PrefDefaultProvider : public DefaultProviderInterface, |
// thread safety. |
mutable base::Lock lock_; |
jochen (gone - plz use gerrit)
2011/02/04 08:38:43
no additional empty line
markusheintz_
2011/02/04 10:08:03
Done.
|
+ |
PrefChangeRegistrar pref_change_registrar_; |
NotificationRegistrar notification_registrar_; |
@@ -86,6 +91,121 @@ class PrefDefaultProvider : public DefaultProviderInterface, |
DISALLOW_COPY_AND_ASSIGN(PrefDefaultProvider); |
}; |
+class PrefProvider |
+ : public ProviderInterface, |
jochen (gone - plz use gerrit)
2011/02/04 08:38:43
this should be on the previous line
markusheintz_
2011/02/04 10:08:03
Done.
|
+ public NotificationObserver { |
+ public: |
+ static void RegisterUserPrefs(PrefService* prefs); |
+ |
+ explicit PrefProvider(Profile* profile); |
+ virtual ~PrefProvider(); |
+ |
+ // ContentSettingsProvider implementation. |
+ virtual bool ContentSettingsTypeIsManaged( |
+ ContentSettingsType content_type); |
+ |
+ virtual ContentSetting GetContentSetting( |
+ const GURL& requesting_url, |
+ const GURL& embedding_url, |
+ ContentSettingsType content_type, |
+ const ResourceIdentifier& resource_identifier) const; |
+ |
+ virtual void SetContentSetting( |
+ const ContentSettingsPattern& requesting_pattern, |
+ const ContentSettingsPattern& embedding_pattern, |
+ ContentSettingsType content_type, |
+ const ResourceIdentifier& resource_identifier, |
+ ContentSetting content_setting); |
+ |
+ virtual void GetAllContentSettingsRules( |
+ ContentSettingsType content_type, |
+ const ResourceIdentifier& resource_identifier, |
+ Rules* content_setting_rules) const; |
+ |
+ virtual void ClearAllContentSettingsRules( |
+ ContentSettingsType content_type); |
+ |
+ virtual void ResetToDefaults(); |
+ |
+ // NotificationObserver implementation. |
+ virtual void Observe(NotificationType type, |
+ const NotificationSource& source, |
+ const NotificationDetails& details); |
+ |
+ // PrefProvider specific methods |
+ static bool RequiresResourceIdentifier( |
+ ContentSettingsType content_type); |
+ |
+ private: |
+ typedef std::pair<ContentSettingsType, std::string> |
+ ContentSettingsTypeResourceIdentifierPair; |
+ typedef std::map<ContentSettingsTypeResourceIdentifierPair, ContentSetting> |
+ ResourceContentSettings; |
+ |
+ struct ExtendedContentSettings { |
+ ContentSettings content_settings; |
+ ResourceContentSettings content_settings_for_resources; |
+ }; |
+ |
+ typedef std::map<std::string, ExtendedContentSettings> HostContentSettings; |
+ |
+ // Various migration methods (old cookie, popup and per-host data gets |
+ // migrated to the new format). |
+ void MigrateObsoletePerhostPref(PrefService* prefs); |
+ void MigrateObsoletePopupsPref(PrefService* prefs); |
+ |
+ bool AllDefault(const ExtendedContentSettings& settings) const; |
+ |
+ void ReadExceptions(bool overwrite); |
+ |
+ void CanonicalizeContentSettingsExceptions( |
+ DictionaryValue* all_settings_dictionary); |
+ |
+ void GetSettingsFromDictionary( |
+ const DictionaryValue* dictionary, |
+ ContentSettings* settings); |
+ |
+ void GetResourceSettingsFromDictionary( |
+ const DictionaryValue* dictionary, |
+ ResourceContentSettings* settings); |
+ |
+ void NotifyObservers(const ContentSettingsDetails& details); |
+ |
+ void UnregisterObservers(); |
+ |
+ Profile* profile_; |
+ |
+ // Whether this settings map is for an OTR session. |
+ bool is_off_the_record_; |
+ |
+ // Used around accesses to the content_settings_ object to guarantee |
+ // thread safety. |
+ mutable base::Lock lock_; |
+ |
+ PrefChangeRegistrar pref_change_registrar_; |
+ NotificationRegistrar notification_registrar_; |
+ |
+ // Copies of the pref data, so that we can read it on threads other than the |
+ // UI thread. |
+ HostContentSettings host_content_settings_; |
+ |
+ // Differences to the preference-stored host content settings for |
+ // off-the-record settings. |
+ HostContentSettings off_the_record_settings_; |
+ |
+ // Whether we are currently updating preferences, this is used to ignore |
+ // notifications from the preferences service that we triggered ourself. |
+ bool updating_preferences_; |
+ |
+ // Do not fire any Notifications as long as we are in the constructor. |
+ bool initializing_; |
+ |
+ // LEGACY: TBR |
+ ContentSettings GetNonDefaultContentSettings(const GURL& url) const; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(PrefProvider); |
+}; |
+ |
} // namespace content_settings |
#endif // CHROME_BROWSER_CONTENT_SETTINGS_PREF_CONTENT_SETTINGS_PROVIDER_H_ |