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

Unified Diff: components/content_settings/core/browser/content_settings_default_provider.h

Issue 1004733003: Split the default content settings into syncable and nonsyncable. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Reset PMI, reacting to unsyncable pref changes as well. Created 5 years, 9 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: components/content_settings/core/browser/content_settings_default_provider.h
diff --git a/components/content_settings/core/browser/content_settings_default_provider.h b/components/content_settings/core/browser/content_settings_default_provider.h
index 6679bdc33197915c89ab91919b5453ce395a039e..2a58fa869b44f82948ecaa15038206b2ba67da73 100644
--- a/components/content_settings/core/browser/content_settings_default_provider.h
+++ b/components/content_settings/core/browser/content_settings_default_provider.h
@@ -50,22 +50,53 @@ class DefaultProvider : public ObservableProvider {
void ShutdownOnUIThread() override;
private:
- // Sets the fields of |settings| based on the values in |dictionary|.
- void GetSettingsFromDictionary(const base::DictionaryValue* dictionary);
+ typedef linked_ptr<base::Value> ValuePtr;
+ typedef std::map<ContentSettingsType, ValuePtr> ValueMap;
+
+ // Reads all individual settings from the pref service.
+ void ReadDefaultSettings();
+
+ // Change the remembered setting in the memory.
+ void ChangeSetting(ContentSettingsType content_type, base::Value* value);
+
+ // True if |value| is NULL or it is the default value for |content_type|.
+ bool IsValueEmptyOrDefault(ContentSettingsType content_type,
+ base::Value* value);
+
+ // Parses a |DictionaryValue| into a |ValueMap|.
+ scoped_ptr<ValueMap> GetSettingsFromDictionary(
+ const base::DictionaryValue* dictionary);
- // Forces the default settings to be explicitly set instead of themselves
- // being CONTENT_SETTING_DEFAULT.
- void ForceDefaultsToBeExplicit();
+ // Forces the default settings in |value_map| to be explicitly set instead
+ // of themselves being CONTENT_SETTING_DEFAULT.
+ void ForceDefaultsToBeExplicit(ValueMap* value_map);
- // Reads the default settings from the preferences service. If |overwrite| is
- // true and the preference is missing, the local copy will be cleared as well.
- void ReadDefaultSettings(bool overwrite);
+ // Reads the dictionary prefrence and returns the dictionary parsed as
+ // a |ValueMap|.
+ scoped_ptr<ValueMap> ReadDictionaryPref();
+
+ // Reads an individual preference.
+ scoped_ptr<base::Value> ReadIndividualPref(ContentSettingsType content_type);
+
+ // Writes the value |value| to the individual preference corresponding
+ // to |content_type|. It's the responsibility of caller to obtain a lock
+ // and notify observers.
+ void WriteIndividualPref(ContentSettingsType content_type,
+ base::Value* value);
+
+ // Writes the value |value| to the dictionary preference entry corresponding
+ // to |content_type|. It's the responsibility of caller to obtain a lock
+ // and notify observers.
+ void WriteDictionaryPref(ContentSettingsType content_type,
+ base::Value* value);
// Called on prefs change.
void OnPreferenceChanged(const std::string& pref_name);
- typedef linked_ptr<base::Value> ValuePtr;
- typedef std::map<ContentSettingsType, ValuePtr> ValueMap;
+ // Migrates the dictionary settings to the individual settings. Only called
+ // once during the first run.
+ void MigrateDefaultSettings();
+
// Copies of the pref data, so that we can read it on the IO thread.
ValueMap default_settings_;
@@ -74,7 +105,7 @@ class DefaultProvider : public ObservableProvider {
// Whether this settings map is for an Incognito session.
bool is_incognito_;
- // Used around accesses to the |default_content_settings_| object to guarantee
+ // Used around accesses to the |default_settings_| object to guarantee
// thread safety.
mutable base::Lock lock_;

Powered by Google App Engine
This is Rietveld 408576698