Chromium Code Reviews| Index: components/content_settings/core/browser/content_settings_pref_provider.h |
| diff --git a/components/content_settings/core/browser/content_settings_pref_provider.h b/components/content_settings/core/browser/content_settings_pref_provider.h |
| index 8c26c4d3e774f4865b82af7b53243f566ef8fd01..ff4dfa77ed4753c9bb16ccd9cc54470e5a1ccbaa 100644 |
| --- a/components/content_settings/core/browser/content_settings_pref_provider.h |
| +++ b/components/content_settings/core/browser/content_settings_pref_provider.h |
| @@ -10,6 +10,7 @@ |
| #include <vector> |
| #include "base/basictypes.h" |
| +#include "base/memory/scoped_vector.h" |
| #include "base/prefs/pref_change_registrar.h" |
| #include "components/content_settings/core/browser/content_settings_observable_provider.h" |
| #include "components/content_settings/core/browser/content_settings_utils.h" |
| @@ -70,14 +71,20 @@ class PrefProvider : public ObservableProvider { |
| // Gains ownership of |clock|. |
| void SetClockForTesting(scoped_ptr<base::Clock> clock); |
| - ContentSettingsPref* content_settings_pref() { |
| - return content_settings_pref_.get(); |
| - } |
| - |
| private: |
| + friend class DeadlockCheckerThread; // For testing. |
| + |
| // Migrate the old media setting into new mic/camera content settings. |
| void MigrateObsoleteMediaContentSetting(); |
| + // Migrate the settings from the old aggregate dictionary into the new format. |
| + void MigrateAllExceptions(); |
| + |
| + // Writes the contents of the old aggregate dictionary preferences into |
| + // separate dictionaries for content types. If |syncable_only| is true, |
| + // only syncable content types will be written. |
| + void WriteSettingsToNewPreferences(bool syncable_only); |
| + |
| // Weak; owned by the Profile and reset in ShutdownOnUIThread. |
| PrefService* prefs_; |
| @@ -88,9 +95,49 @@ class PrefProvider : public ObservableProvider { |
| PrefChangeRegistrar pref_change_registrar_; |
| - scoped_ptr<ContentSettingsPref> content_settings_pref_; |
| + ScopedVector<ContentSettingsPref> content_settings_prefs_; |
| DISALLOW_COPY_AND_ASSIGN(PrefProvider); |
| + |
| + bool TestAllLocks() const; |
| + |
| + // All functionality regarding reading and writing of preferences has been |
| + // moved to |ContentSettingsPref|, which manages one content type per |
| + // instance. However, for backward compatibility, we need to be able to write |
| + // to the old and deprecated aggregate dictionary preference which maintains |
| + // all content types. Therefore, |ContentSettingsPrefProvider| must still |
| + // retain some of the functionality of |ContentSettingsPref|. The following |
| + // attributes and methods serve this purpose. |
| + // TODO(msramek): Remove this migration code after two stable releases. |
| + struct ContentSettingsPrefEntry { |
| + ContentSettingsPrefEntry(const ContentSettingsPattern primary_pattern, |
| + const ContentSettingsPattern secondary_pattern, |
| + const ResourceIdentifier resource_identifier, |
| + base::Value* value); |
| + ContentSettingsPrefEntry(const ContentSettingsPrefEntry& entry); |
| + ContentSettingsPrefEntry& operator=(const ContentSettingsPrefEntry& entry); |
| + ~ContentSettingsPrefEntry(); |
| + |
| + ContentSettingsPattern primary_pattern; |
| + ContentSettingsPattern secondary_pattern; |
| + ResourceIdentifier resource_identifier; |
| + scoped_ptr<base::Value> value; |
| + }; |
| + |
| + ScopedVector<ContentSettingsPrefEntry> |
|
markusheintz_
2015/04/02 11:04:49
Please add comments to the fields here and below.
msramek
2015/04/02 16:22:55
Done.
|
| + pref_entry_map_[CONTENT_SETTINGS_NUM_TYPES]; |
| + |
| + void ClearPrefEntryMap(); |
| + |
| + mutable base::Lock old_lock_; |
| + |
| + bool updating_old_preferences_; |
| + |
| + void OnOldContentSettingsPatternPairsChanged(); |
| + |
| + void ReadContentSettingsFromOldPref(); |
| + |
| + base::ThreadChecker thread_checker_; |
| }; |
| } // namespace content_settings |