OLD | NEW |
---|---|
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> |
11 | 11 |
12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
13 #include "base/memory/scoped_vector.h" | |
13 #include "base/prefs/pref_change_registrar.h" | 14 #include "base/prefs/pref_change_registrar.h" |
14 #include "components/content_settings/core/browser/content_settings_observable_p rovider.h" | 15 #include "components/content_settings/core/browser/content_settings_observable_p rovider.h" |
15 #include "components/content_settings/core/browser/content_settings_utils.h" | 16 #include "components/content_settings/core/browser/content_settings_utils.h" |
16 | 17 |
17 class PrefService; | 18 class PrefService; |
18 | 19 |
19 namespace base { | 20 namespace base { |
20 class Clock; | 21 class Clock; |
21 class DictionaryValue; | 22 class DictionaryValue; |
22 } | 23 } |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
63 ContentSettingsType content_type); | 64 ContentSettingsType content_type); |
64 | 65 |
65 void Notify(const ContentSettingsPattern& primary_pattern, | 66 void Notify(const ContentSettingsPattern& primary_pattern, |
66 const ContentSettingsPattern& secondary_pattern, | 67 const ContentSettingsPattern& secondary_pattern, |
67 ContentSettingsType content_type, | 68 ContentSettingsType content_type, |
68 const std::string& resource_identifier); | 69 const std::string& resource_identifier); |
69 | 70 |
70 // Gains ownership of |clock|. | 71 // Gains ownership of |clock|. |
71 void SetClockForTesting(scoped_ptr<base::Clock> clock); | 72 void SetClockForTesting(scoped_ptr<base::Clock> clock); |
72 | 73 |
73 ContentSettingsPref* content_settings_pref() { | 74 private: |
74 return content_settings_pref_.get(); | 75 friend class DeadlockCheckerThread; // For testing. |
75 } | |
76 | 76 |
77 private: | |
78 // Migrate the old media setting into new mic/camera content settings. | 77 // Migrate the old media setting into new mic/camera content settings. |
79 void MigrateObsoleteMediaContentSetting(); | 78 void MigrateObsoleteMediaContentSetting(); |
80 | 79 |
80 // Migrate the settings from the old aggregate dictionary into the new format. | |
81 void MigrateAllExceptions(); | |
82 | |
83 // Writes the contents of the old aggregate dictionary preferences into | |
84 // separate dictionaries for content types. If |syncable_only| is true, | |
85 // only syncable content types will be written. | |
86 void WriteSettingsToNewPreferences(bool syncable_only); | |
87 | |
81 // Weak; owned by the Profile and reset in ShutdownOnUIThread. | 88 // Weak; owned by the Profile and reset in ShutdownOnUIThread. |
82 PrefService* prefs_; | 89 PrefService* prefs_; |
83 | 90 |
84 // Can be set for testing. | 91 // Can be set for testing. |
85 scoped_ptr<base::Clock> clock_; | 92 scoped_ptr<base::Clock> clock_; |
86 | 93 |
87 bool is_incognito_; | 94 bool is_incognito_; |
88 | 95 |
89 PrefChangeRegistrar pref_change_registrar_; | 96 PrefChangeRegistrar pref_change_registrar_; |
90 | 97 |
91 scoped_ptr<ContentSettingsPref> content_settings_pref_; | 98 ScopedVector<ContentSettingsPref> content_settings_prefs_; |
92 | 99 |
93 DISALLOW_COPY_AND_ASSIGN(PrefProvider); | 100 DISALLOW_COPY_AND_ASSIGN(PrefProvider); |
101 | |
102 bool TestAllLocks() const; | |
103 | |
104 // All functionality regarding reading and writing of preferences has been | |
105 // moved to |ContentSettingsPref|, which manages one content type per | |
106 // instance. However, for backward compatibility, we need to be able to write | |
107 // to the old and deprecated aggregate dictionary preference which maintains | |
108 // all content types. Therefore, |ContentSettingsPrefProvider| must still | |
109 // retain some of the functionality of |ContentSettingsPref|. The following | |
110 // attributes and methods serve this purpose. | |
111 // TODO(msramek): Remove this migration code after two stable releases. | |
112 struct ContentSettingsPrefEntry { | |
113 ContentSettingsPrefEntry(const ContentSettingsPattern primary_pattern, | |
114 const ContentSettingsPattern secondary_pattern, | |
115 const ResourceIdentifier resource_identifier, | |
116 base::Value* value); | |
117 ContentSettingsPrefEntry(const ContentSettingsPrefEntry& entry); | |
118 ContentSettingsPrefEntry& operator=(const ContentSettingsPrefEntry& entry); | |
119 ~ContentSettingsPrefEntry(); | |
120 | |
121 ContentSettingsPattern primary_pattern; | |
122 ContentSettingsPattern secondary_pattern; | |
123 ResourceIdentifier resource_identifier; | |
124 scoped_ptr<base::Value> value; | |
125 }; | |
126 | |
127 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.
| |
128 pref_entry_map_[CONTENT_SETTINGS_NUM_TYPES]; | |
129 | |
130 void ClearPrefEntryMap(); | |
131 | |
132 mutable base::Lock old_lock_; | |
133 | |
134 bool updating_old_preferences_; | |
135 | |
136 void OnOldContentSettingsPatternPairsChanged(); | |
137 | |
138 void ReadContentSettingsFromOldPref(); | |
139 | |
140 base::ThreadChecker thread_checker_; | |
94 }; | 141 }; |
95 | 142 |
96 } // namespace content_settings | 143 } // namespace content_settings |
97 | 144 |
98 #endif // COMPONENTS_CONTENT_SETTINGS_CORE_BROWSER_CONTENT_SETTINGS_PREF_PROVID ER_H_ | 145 #endif // COMPONENTS_CONTENT_SETTINGS_CORE_BROWSER_CONTENT_SETTINGS_PREF_PROVID ER_H_ |
OLD | NEW |