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> |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 typedef struct { |
| 112 ContentSettingsPattern primary_pattern; |
| 113 ContentSettingsPattern secondary_pattern; |
| 114 const ResourceIdentifier resource_identifier; |
| 115 scoped_ptr<base::Value> value; |
| 116 } ContentSettingsPrefEntry; |
| 117 |
| 118 typedef std::map<ContentSettingsType, std::vector<ContentSettingsPrefEntry> > |
| 119 ContentSettingsPrefEntryMap; |
| 120 |
| 121 ContentSettingsPrefEntryMap old_value_map_; |
| 122 |
| 123 bool updating_old_preferences_; |
| 124 |
| 125 void OnOldContentSettingsPatternPairsChanged(); |
| 126 |
| 127 void ReadContentSettingsFromOldPref(); |
| 128 |
| 129 base::ThreadChecker thread_checker_; |
94 }; | 130 }; |
95 | 131 |
96 } // namespace content_settings | 132 } // namespace content_settings |
97 | 133 |
98 #endif // COMPONENTS_CONTENT_SETTINGS_CORE_BROWSER_CONTENT_SETTINGS_PREF_PROVID
ER_H_ | 134 #endif // COMPONENTS_CONTENT_SETTINGS_CORE_BROWSER_CONTENT_SETTINGS_PREF_PROVID
ER_H_ |
OLD | NEW |