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 CHROME_BROWSER_EXTENSIONS_EXTENSION_PREF_VALUE_MAP_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_PREF_VALUE_MAP_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_PREF_VALUE_MAP_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_PREF_VALUE_MAP_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 #include <set> | 10 #include <set> |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 // ProfileKeyedService implementation. | 79 // ProfileKeyedService implementation. |
80 virtual void Shutdown() OVERRIDE; | 80 virtual void Shutdown() OVERRIDE; |
81 | 81 |
82 // Set an extension preference |value| for |key| of extension |ext_id|. | 82 // Set an extension preference |value| for |key| of extension |ext_id|. |
83 // Takes ownership of |value|. | 83 // Takes ownership of |value|. |
84 // Note that regular extension pref values need to be reported to | 84 // Note that regular extension pref values need to be reported to |
85 // incognito and to regular ExtensionPrefStores. | 85 // incognito and to regular ExtensionPrefStores. |
86 // Precondition: the extension must be registered. | 86 // Precondition: the extension must be registered. |
87 void SetExtensionPref(const std::string& ext_id, | 87 void SetExtensionPref(const std::string& ext_id, |
88 const std::string& key, | 88 const std::string& key, |
89 ExtensionPrefsScope scope, | 89 extensions::ExtensionPrefsScope scope, |
90 base::Value* value); | 90 base::Value* value); |
91 | 91 |
92 // Remove the extension preference value for |key| of extension |ext_id|. | 92 // Remove the extension preference value for |key| of extension |ext_id|. |
93 // Precondition: the extension must be registered. | 93 // Precondition: the extension must be registered. |
94 void RemoveExtensionPref(const std::string& ext_id, | 94 void RemoveExtensionPref(const std::string& ext_id, |
95 const std::string& key, | 95 const std::string& key, |
96 ExtensionPrefsScope scope); | 96 extensions::ExtensionPrefsScope scope); |
97 | 97 |
98 // Returns true if currently no extension with higher precedence controls the | 98 // Returns true if currently no extension with higher precedence controls the |
99 // preference. | 99 // preference. |
100 // Note that the this function does does not consider the existence of | 100 // Note that the this function does does not consider the existence of |
101 // policies. An extension is only really able to control a preference if | 101 // policies. An extension is only really able to control a preference if |
102 // PrefService::Preference::IsExtensionModifiable() returns true as well. | 102 // PrefService::Preference::IsExtensionModifiable() returns true as well. |
103 bool CanExtensionControlPref(const std::string& extension_id, | 103 bool CanExtensionControlPref(const std::string& extension_id, |
104 const std::string& pref_key, | 104 const std::string& pref_key, |
105 bool incognito) const; | 105 bool incognito) const; |
106 | 106 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 bool incognito, | 144 bool incognito, |
145 bool* from_incognito) const; | 145 bool* from_incognito) const; |
146 | 146 |
147 private: | 147 private: |
148 struct ExtensionEntry; | 148 struct ExtensionEntry; |
149 | 149 |
150 typedef std::map<std::string, ExtensionEntry*> ExtensionEntryMap; | 150 typedef std::map<std::string, ExtensionEntry*> ExtensionEntryMap; |
151 | 151 |
152 const PrefValueMap* GetExtensionPrefValueMap( | 152 const PrefValueMap* GetExtensionPrefValueMap( |
153 const std::string& ext_id, | 153 const std::string& ext_id, |
154 ExtensionPrefsScope scope) const; | 154 extensions::ExtensionPrefsScope scope) const; |
155 | 155 |
156 PrefValueMap* GetExtensionPrefValueMap( | 156 PrefValueMap* GetExtensionPrefValueMap( |
157 const std::string& ext_id, | 157 const std::string& ext_id, |
158 ExtensionPrefsScope scope); | 158 extensions::ExtensionPrefsScope scope); |
159 | 159 |
160 // Returns all keys of pref values that are set by the extension of |entry|, | 160 // Returns all keys of pref values that are set by the extension of |entry|, |
161 // regardless whether they are set for incognito or regular pref values. | 161 // regardless whether they are set for incognito or regular pref values. |
162 void GetExtensionControlledKeys(const ExtensionEntry& entry, | 162 void GetExtensionControlledKeys(const ExtensionEntry& entry, |
163 std::set<std::string>* out) const; | 163 std::set<std::string>* out) const; |
164 | 164 |
165 // Returns an iterator to the extension which controls the preference |key|. | 165 // Returns an iterator to the extension which controls the preference |key|. |
166 // If |incognito| is true, looks at incognito preferences first. In that case, | 166 // If |incognito| is true, looks at incognito preferences first. In that case, |
167 // if |from_incognito| is not NULL, it is set to true if the effective pref | 167 // if |from_incognito| is not NULL, it is set to true if the effective pref |
168 // value is coming from the incognito preferences, false if it is coming from | 168 // value is coming from the incognito preferences, false if it is coming from |
(...skipping 16 matching lines...) Expand all Loading... |
185 // being destroyed. In tests, it isn't called, so the notification must | 185 // being destroyed. In tests, it isn't called, so the notification must |
186 // be done in the destructor. This bit tracks whether it has been done yet. | 186 // be done in the destructor. This bit tracks whether it has been done yet. |
187 bool destroyed_; | 187 bool destroyed_; |
188 | 188 |
189 ObserverList<Observer, true> observers_; | 189 ObserverList<Observer, true> observers_; |
190 | 190 |
191 DISALLOW_COPY_AND_ASSIGN(ExtensionPrefValueMap); | 191 DISALLOW_COPY_AND_ASSIGN(ExtensionPrefValueMap); |
192 }; | 192 }; |
193 | 193 |
194 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_PREF_VALUE_MAP_H_ | 194 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_PREF_VALUE_MAP_H_ |
OLD | NEW |