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/linked_ptr.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 std::vector<scoped_ptr<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(ContentSettingsPattern primary_pattern, |
| 114 ContentSettingsPattern secondary_pattern, |
| 115 ResourceIdentifier resource_identifier, |
| 116 base::Value* value); |
| 117 ~ContentSettingsPrefEntry(); |
| 118 |
| 119 const ContentSettingsPattern primary_pattern; |
| 120 const ContentSettingsPattern secondary_pattern; |
| 121 const ResourceIdentifier resource_identifier; |
| 122 base::Value* value; |
| 123 }; |
| 124 |
| 125 typedef std::map<ContentSettingsType, std::vector<ContentSettingsPrefEntry> > |
| 126 ContentSettingsPrefEntryMap; |
| 127 |
| 128 mutable base::Lock old_lock_; |
| 129 |
| 130 bool updating_old_preferences_; |
| 131 |
| 132 void OnOldContentSettingsPatternPairsChanged(); |
| 133 |
| 134 void ReadContentSettingsFromOldPref(ContentSettingsPrefEntryMap* entry_map); |
| 135 |
| 136 base::ThreadChecker thread_checker_; |
94 }; | 137 }; |
95 | 138 |
96 } // namespace content_settings | 139 } // namespace content_settings |
97 | 140 |
98 #endif // COMPONENTS_CONTENT_SETTINGS_CORE_BROWSER_CONTENT_SETTINGS_PREF_PROVID
ER_H_ | 141 #endif // COMPONENTS_CONTENT_SETTINGS_CORE_BROWSER_CONTENT_SETTINGS_PREF_PROVID
ER_H_ |
OLD | NEW |