Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1279)

Unified Diff: chrome/browser/content_settings/pref_content_settings_provider.h

Issue 6410022: Add content_settings::PrefProvider to HostContentSettingsMap. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Worked on comments Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..31ccdb1be8e49dff9afe6945a6a3740cfb6e255b 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"
@@ -86,6 +90,119 @@ class PrefDefaultProvider : public DefaultProviderInterface,
DISALLOW_COPY_AND_ASSIGN(PrefDefaultProvider);
};
+class PrefProvider : public ProviderInterface,
+ 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);
+
+ 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);
+
+ bool RequiresResourceIdentifier(
+ ContentSettingsType content_type) const;
+
+ 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_

Powered by Google App Engine
This is Rietveld 408576698