OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 EXTENSIONS_BROWSER_EXTENSION_PREF_VALUE_MAP_H_ | 5 #ifndef EXTENSIONS_BROWSER_EXTENSION_PREF_VALUE_MAP_H_ |
6 #define EXTENSIONS_BROWSER_EXTENSION_PREF_VALUE_MAP_H_ | 6 #define EXTENSIONS_BROWSER_EXTENSION_PREF_VALUE_MAP_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 extensions::ExtensionPrefsScope scope, | 88 extensions::ExtensionPrefsScope scope, |
89 base::Value* value); | 89 base::Value* value); |
90 | 90 |
91 // Remove the extension preference value for |key| of extension |ext_id|. | 91 // Remove the extension preference value for |key| of extension |ext_id|. |
92 // Precondition: the extension must be registered. | 92 // Precondition: the extension must be registered. |
93 void RemoveExtensionPref(const std::string& ext_id, | 93 void RemoveExtensionPref(const std::string& ext_id, |
94 const std::string& key, | 94 const std::string& key, |
95 extensions::ExtensionPrefsScope scope); | 95 extensions::ExtensionPrefsScope scope); |
96 | 96 |
97 // Returns true if currently no extension with higher precedence controls the | 97 // Returns true if currently no extension with higher precedence controls the |
98 // preference. | 98 // preference. If |incognito| is true and the extension does not have |
99 // Note that the this function does does not consider the existence of | 99 // incognito permission, CanExtensionControlPref returns false. |
| 100 // Note that this function does does not consider the existence of |
100 // 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 |
101 // PrefService::Preference::IsExtensionModifiable() returns true as well. | 102 // PrefService::Preference::IsExtensionModifiable() returns true as well. |
102 bool CanExtensionControlPref(const std::string& extension_id, | 103 bool CanExtensionControlPref(const std::string& extension_id, |
103 const std::string& pref_key, | 104 const std::string& pref_key, |
104 bool incognito) const; | 105 bool incognito) const; |
105 | 106 |
106 // Removes all "incognito session only" preference values. | 107 // Removes all "incognito session only" preference values. |
107 void ClearAllIncognitoSessionOnlyPreferences(); | 108 void ClearAllIncognitoSessionOnlyPreferences(); |
108 | 109 |
109 // Returns true if an extension identified by |extension_id| controls the | 110 // Returns true if an extension identified by |extension_id| controls the |
110 // preference. This means this extension has set a preference value and no | 111 // preference. This means this extension has set a preference value and no |
111 // other extension with higher precedence overrides it. If |from_incognito| | 112 // other extension with higher precedence overrides it. If |from_incognito| |
112 // is not NULL, looks at incognito preferences first, and |from_incognito| is | 113 // is not NULL, looks at incognito preferences first, and |from_incognito| is |
113 // set to true if the effective pref value is coming from the incognito | 114 // set to true if the effective pref value is coming from the incognito |
114 // preferences, false if it is coming from the normal ones. | 115 // preferences, false if it is coming from the normal ones. |
115 // Note that the this function does does not consider the existence of | 116 // Note that the this function does does not consider the existence of |
116 // policies. An extension is only really able to control a preference if | 117 // policies. An extension is only really able to control a preference if |
117 // PrefService::Preference::IsExtensionModifiable() returns true as well. | 118 // PrefService::Preference::IsExtensionModifiable() returns true as well. |
118 bool DoesExtensionControlPref(const std::string& extension_id, | 119 bool DoesExtensionControlPref(const std::string& extension_id, |
119 const std::string& pref_key, | 120 const std::string& pref_key, |
120 bool* from_incognito) const; | 121 bool* from_incognito) const; |
121 | 122 |
122 // Returns the ID of the extension that currently controls this preference. | 123 // Returns the ID of the extension that currently controls this preference |
| 124 // for a regular profile. Incognito settings are ignored. |
123 // Returns an empty string if this preference is not controlled by an | 125 // Returns an empty string if this preference is not controlled by an |
124 // extension. | 126 // extension. |
125 std::string GetExtensionControllingPref(const std::string& pref_key) const; | 127 std::string GetExtensionControllingPref(const std::string& pref_key) const; |
126 | 128 |
127 // Tell the store it's now fully initialized. | 129 // Tell the store it's now fully initialized. |
128 void NotifyInitializationCompleted(); | 130 void NotifyInitializationCompleted(); |
129 | 131 |
130 // Registers the time when an extension |ext_id| is installed. | 132 // Registers the time when an extension |ext_id| is installed. |
131 void RegisterExtension(const std::string& ext_id, | 133 void RegisterExtension(const std::string& ext_id, |
132 const base::Time& install_time, | 134 const base::Time& install_time, |
133 bool is_enabled); | 135 bool is_enabled, |
| 136 bool is_incognito_enabled); |
134 | 137 |
135 // Deletes all entries related to extension |ext_id|. | 138 // Deletes all entries related to extension |ext_id|. |
136 void UnregisterExtension(const std::string& ext_id); | 139 void UnregisterExtension(const std::string& ext_id); |
137 | 140 |
138 // Hides or makes the extension preference values of the specified extension | 141 // Hides or makes the extension preference values of the specified extension |
139 // visible. | 142 // visible. |
140 void SetExtensionState(const std::string& ext_id, bool is_enabled); | 143 void SetExtensionState(const std::string& ext_id, bool is_enabled); |
141 | 144 |
| 145 // Sets whether the extension has permission to access incognito state. |
| 146 void SetExtensionIncognitoState(const std::string& ext_id, |
| 147 bool is_incognito_enabled); |
| 148 |
142 // Adds an observer and notifies it about the currently stored keys. | 149 // Adds an observer and notifies it about the currently stored keys. |
143 void AddObserver(Observer* observer); | 150 void AddObserver(Observer* observer); |
144 | 151 |
145 void RemoveObserver(Observer* observer); | 152 void RemoveObserver(Observer* observer); |
146 | 153 |
147 const base::Value* GetEffectivePrefValue(const std::string& key, | 154 const base::Value* GetEffectivePrefValue(const std::string& key, |
148 bool incognito, | 155 bool incognito, |
149 bool* from_incognito) const; | 156 bool* from_incognito) const; |
150 | 157 |
151 private: | 158 private: |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 // being destroyed. In tests, it isn't called, so the notification must | 196 // being destroyed. In tests, it isn't called, so the notification must |
190 // be done in the destructor. This bit tracks whether it has been done yet. | 197 // be done in the destructor. This bit tracks whether it has been done yet. |
191 bool destroyed_; | 198 bool destroyed_; |
192 | 199 |
193 ObserverList<Observer, true> observers_; | 200 ObserverList<Observer, true> observers_; |
194 | 201 |
195 DISALLOW_COPY_AND_ASSIGN(ExtensionPrefValueMap); | 202 DISALLOW_COPY_AND_ASSIGN(ExtensionPrefValueMap); |
196 }; | 203 }; |
197 | 204 |
198 #endif // EXTENSIONS_BROWSER_EXTENSION_PREF_VALUE_MAP_H_ | 205 #endif // EXTENSIONS_BROWSER_EXTENSION_PREF_VALUE_MAP_H_ |
OLD | NEW |