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

Side by Side Diff: components/content_settings/core/browser/content_settings_pref_provider.h

Issue 1005303003: Split the aggregate dictionary of content settings exceptions into per-type dictionaries (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Android fix 4. Created 5 years, 8 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 unified diff | Download patch
OLDNEW
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 #ifndef COMPONENTS_CONTENT_SETTINGS_CORE_BROWSER_CONTENT_SETTINGS_PREF_PROVIDER_ H_ 5 #ifndef COMPONENTS_CONTENT_SETTINGS_CORE_BROWSER_CONTENT_SETTINGS_PREF_PROVIDER_ H_
6 #define COMPONENTS_CONTENT_SETTINGS_CORE_BROWSER_CONTENT_SETTINGS_PREF_PROVIDER_ H_ 6 #define COMPONENTS_CONTENT_SETTINGS_CORE_BROWSER_CONTENT_SETTINGS_PREF_PROVIDER_ H_
7 7
8 // A content settings provider that takes its settings out of the pref service. 8 // A content settings provider that takes its settings out of the pref service.
9 9
10 #include <vector> 10 #include <vector>
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 ContentSettingsType content_type); 63 ContentSettingsType content_type);
64 64
65 void Notify(const ContentSettingsPattern& primary_pattern, 65 void Notify(const ContentSettingsPattern& primary_pattern,
66 const ContentSettingsPattern& secondary_pattern, 66 const ContentSettingsPattern& secondary_pattern,
67 ContentSettingsType content_type, 67 ContentSettingsType content_type,
68 const std::string& resource_identifier); 68 const std::string& resource_identifier);
69 69
70 // Gains ownership of |clock|. 70 // Gains ownership of |clock|.
71 void SetClockForTesting(scoped_ptr<base::Clock> clock); 71 void SetClockForTesting(scoped_ptr<base::Clock> clock);
72 72
73 ContentSettingsPref* content_settings_pref() { 73 private:
74 return content_settings_pref_.get(); 74 friend class DeadlockCheckerThread; // For testing.
75 }
76 75
77 private:
78 // Migrate the old media setting into new mic/camera content settings. 76 // Migrate the old media setting into new mic/camera content settings.
79 void MigrateObsoleteMediaContentSetting(); 77 void MigrateObsoleteMediaContentSetting();
80 78
79 // Migrate the settings from the old aggregate dictionary into the new format.
80 void MigrateAllExceptions();
81
82 // Writes the contents of the old aggregate dictionary preferences into
83 // separate dictionaries for content types. If |syncable_only| is true,
84 // only syncable content types will be written.
85 void WriteSettingsToNewPreferences(bool syncable_only);
86
81 // Weak; owned by the Profile and reset in ShutdownOnUIThread. 87 // Weak; owned by the Profile and reset in ShutdownOnUIThread.
82 PrefService* prefs_; 88 PrefService* prefs_;
83 89
84 // Can be set for testing. 90 // Can be set for testing.
85 scoped_ptr<base::Clock> clock_; 91 scoped_ptr<base::Clock> clock_;
86 92
87 bool is_incognito_; 93 bool is_incognito_;
88 94
89 PrefChangeRegistrar pref_change_registrar_; 95 PrefChangeRegistrar pref_change_registrar_;
90 96
91 scoped_ptr<ContentSettingsPref> content_settings_pref_; 97 std::vector<scoped_ptr<ContentSettingsPref> > content_settings_prefs_;
92 98
93 DISALLOW_COPY_AND_ASSIGN(PrefProvider); 99 DISALLOW_COPY_AND_ASSIGN(PrefProvider);
100
101 bool TestAllLocks() const;
102
103 // All functionality regarding reading and writing of preferences has been
104 // moved to |ContentSettingsPref|, which manages one content type per
105 // instance. However, for backward compatibility, we need to be able to write
106 // to the old and deprecated aggregate dictionary preference which maintains
107 // all content types. Therefore, |ContentSettingsPrefProvider| must still
108 // retain some of the functionality of |ContentSettingsPref|. The following
109 // attributes and methods serve this purpose.
110 // TODO(msramek): Remove this migration code after two stable releases.
111 struct ContentSettingsPrefEntry {
112 ContentSettingsPrefEntry(const ContentSettingsPattern primary_pattern,
113 const ContentSettingsPattern secondary_pattern,
114 const ResourceIdentifier resource_identifier,
115 base::Value* value);
116 ContentSettingsPrefEntry(const ContentSettingsPrefEntry& entry);
117 ContentSettingsPrefEntry& operator=(const ContentSettingsPrefEntry& entry);
118 ~ContentSettingsPrefEntry();
119
120 ContentSettingsPattern primary_pattern;
121 ContentSettingsPattern secondary_pattern;
122 ResourceIdentifier resource_identifier;
123 scoped_ptr<base::Value> value;
124 };
125
126 typedef std::map<ContentSettingsType, std::vector<ContentSettingsPrefEntry> >
127 ContentSettingsPrefEntryMap;
128
129 mutable base::Lock old_lock_;
130
131 bool updating_old_preferences_;
132
133 void OnOldContentSettingsPatternPairsChanged();
134
135 void ReadContentSettingsFromOldPref(ContentSettingsPrefEntryMap* entry_map);
136
137 base::ThreadChecker thread_checker_;
94 }; 138 };
95 139
96 } // namespace content_settings 140 } // namespace content_settings
97 141
98 #endif // COMPONENTS_CONTENT_SETTINGS_CORE_BROWSER_CONTENT_SETTINGS_PREF_PROVID ER_H_ 142 #endif // COMPONENTS_CONTENT_SETTINGS_CORE_BROWSER_CONTENT_SETTINGS_PREF_PROVID ER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698