OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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> |
11 #include <string> | 11 #include <string> |
12 | 12 |
13 #include "base/time.h" | 13 #include "base/time.h" |
14 #include "chrome/browser/prefs/value_map_pref_store.h" | 14 #include "chrome/browser/prefs/value_map_pref_store.h" |
15 #include "chrome/browser/extensions/extension_prefs_scope.h" | |
Matt Perry
2011/05/24 18:23:24
I don't see this file in the CL.
battre
2011/05/24 18:24:59
Done.
| |
15 | 16 |
16 // Non-persistent data container that is shared by ExtensionPrefStores. All | 17 // Non-persistent data container that is shared by ExtensionPrefStores. All |
17 // extension pref values (incognito and regular) are stored herein and | 18 // extension pref values (incognito and regular) are stored herein and |
18 // provided to ExtensionPrefStores. | 19 // provided to ExtensionPrefStores. |
19 // | 20 // |
20 // The semantics of the ExtensionPrefValueMap are: | 21 // The semantics of the ExtensionPrefValueMap are: |
21 // - The precedence of extensions is determined by their installation time. | 22 // - The precedence of extensions is determined by their installation time. |
22 // The extension that has been installed later takes higher precedence. | 23 // The extension that has been installed later takes higher precedence. |
23 // - If two extensions set a value for the same preference, the following | 24 // - If two extensions set a value for the same preference, the following |
24 // rules determine which value becomes effective (visible). | 25 // rules determine which value becomes effective (visible). |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
63 ExtensionPrefValueMap(); | 64 ExtensionPrefValueMap(); |
64 virtual ~ExtensionPrefValueMap(); | 65 virtual ~ExtensionPrefValueMap(); |
65 | 66 |
66 // Set an extension preference |value| for |key| of extension |ext_id|. | 67 // Set an extension preference |value| for |key| of extension |ext_id|. |
67 // Takes ownership of |value|. | 68 // Takes ownership of |value|. |
68 // Note that regular extension pref values need to be reported to | 69 // Note that regular extension pref values need to be reported to |
69 // incognito and to regular ExtensionPrefStores. | 70 // incognito and to regular ExtensionPrefStores. |
70 // Precondition: the extension must be registered. | 71 // Precondition: the extension must be registered. |
71 void SetExtensionPref(const std::string& ext_id, | 72 void SetExtensionPref(const std::string& ext_id, |
72 const std::string& key, | 73 const std::string& key, |
73 bool incognito, | 74 extension_prefs_scope::Scope scope, |
74 Value* value); | 75 Value* value); |
75 | 76 |
76 // Remove the extension preference value for |key| of extension |ext_id|. | 77 // Remove the extension preference value for |key| of extension |ext_id|. |
77 // Precondition: the extension must be registered. | 78 // Precondition: the extension must be registered. |
78 void RemoveExtensionPref(const std::string& ext_id, | 79 void RemoveExtensionPref(const std::string& ext_id, |
79 const std::string& key, | 80 const std::string& key, |
80 bool incognito); | 81 extension_prefs_scope::Scope scope); |
81 | 82 |
82 // Returns true if currently no extension with higher precedence controls the | 83 // Returns true if currently no extension with higher precedence controls the |
83 // preference. | 84 // preference. |
84 // Note that the this function does does not consider the existence of | 85 // Note that the this function does does not consider the existence of |
85 // policies. An extension is only really able to control a preference if | 86 // policies. An extension is only really able to control a preference if |
86 // PrefService::Preference::IsExtensionModifiable() returns true as well. | 87 // PrefService::Preference::IsExtensionModifiable() returns true as well. |
87 bool CanExtensionControlPref(const std::string& extension_id, | 88 bool CanExtensionControlPref(const std::string& extension_id, |
88 const std::string& pref_key, | 89 const std::string& pref_key, |
89 bool incognito) const; | 90 bool incognito) const; |
90 | 91 |
(...skipping 29 matching lines...) Expand all Loading... | |
120 | 121 |
121 const Value* GetEffectivePrefValue(const std::string& key, | 122 const Value* GetEffectivePrefValue(const std::string& key, |
122 bool incognito, | 123 bool incognito, |
123 bool* from_incognito) const; | 124 bool* from_incognito) const; |
124 | 125 |
125 private: | 126 private: |
126 struct ExtensionEntry; | 127 struct ExtensionEntry; |
127 | 128 |
128 typedef std::map<std::string, ExtensionEntry*> ExtensionEntryMap; | 129 typedef std::map<std::string, ExtensionEntry*> ExtensionEntryMap; |
129 | 130 |
130 const PrefValueMap* GetExtensionPrefValueMap(const std::string& ext_id, | 131 const PrefValueMap* GetExtensionPrefValueMap( |
131 bool incognito) const; | 132 const std::string& ext_id, |
133 extension_prefs_scope::Scope scope) const; | |
132 | 134 |
133 PrefValueMap* GetExtensionPrefValueMap(const std::string& ext_id, | 135 PrefValueMap* GetExtensionPrefValueMap( |
134 bool incognito); | 136 const std::string& ext_id, |
137 extension_prefs_scope::Scope scope); | |
135 | 138 |
136 // Returns all keys of pref values that are set by the extension of |entry|, | 139 // Returns all keys of pref values that are set by the extension of |entry|, |
137 // regardless whether they are set for incognito or regular pref values. | 140 // regardless whether they are set for incognito or regular pref values. |
138 void GetExtensionControlledKeys(const ExtensionEntry& entry, | 141 void GetExtensionControlledKeys(const ExtensionEntry& entry, |
139 std::set<std::string>* out) const; | 142 std::set<std::string>* out) const; |
140 | 143 |
141 // Returns an iterator to the extension which controls the preference |key|. | 144 // Returns an iterator to the extension which controls the preference |key|. |
142 // If |incognito| is true, looks at incognito preferences first. In that case, | 145 // If |incognito| is true, looks at incognito preferences first. In that case, |
143 // if |from_incognito| is not NULL, it is set to true if the effective pref | 146 // if |from_incognito| is not NULL, it is set to true if the effective pref |
144 // value is coming from the incognito preferences, false if it is coming from | 147 // value is coming from the incognito preferences, false if it is coming from |
(...skipping 11 matching lines...) Expand all Loading... | |
156 // preferences values (i.e. the ones with the highest precedence) | 159 // preferences values (i.e. the ones with the highest precedence) |
157 // are stored in ExtensionPrefStores. | 160 // are stored in ExtensionPrefStores. |
158 ExtensionEntryMap entries_; | 161 ExtensionEntryMap entries_; |
159 | 162 |
160 ObserverList<Observer, true> observers_; | 163 ObserverList<Observer, true> observers_; |
161 | 164 |
162 DISALLOW_COPY_AND_ASSIGN(ExtensionPrefValueMap); | 165 DISALLOW_COPY_AND_ASSIGN(ExtensionPrefValueMap); |
163 }; | 166 }; |
164 | 167 |
165 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_PREF_VALUE_MAP_H_ | 168 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_PREF_VALUE_MAP_H_ |
OLD | NEW |