| 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 // 1 | 2 | 3 | 4 | 3 | 4 | 44 // 1 | 2 | 3 | 4 | 3 | 4 |
| 45 // A = extension A, B = extension B, E = effective value | 45 // A = extension A, B = extension B, E = effective value |
| 46 // .reg = regular value | 46 // .reg = regular value |
| 47 // .inc = incognito value | 47 // .inc = incognito value |
| 48 // Extension B has higher precedence than A. | 48 // Extension B has higher precedence than A. |
| 49 class ExtensionPrefValueMap : public ProfileKeyedService { | 49 class ExtensionPrefValueMap : public ProfileKeyedService { |
| 50 public: | 50 public: |
| 51 // Observer interface for monitoring ExtensionPrefValueMap. | 51 // Observer interface for monitoring ExtensionPrefValueMap. |
| 52 class Observer { | 52 class Observer { |
| 53 public: | 53 public: |
| 54 virtual ~Observer() {} | |
| 55 | |
| 56 // Called when the value for the given |key| set by one of the extensions | 54 // Called when the value for the given |key| set by one of the extensions |
| 57 // changes. This does not necessarily mean that the effective value has | 55 // changes. This does not necessarily mean that the effective value has |
| 58 // changed. | 56 // changed. |
| 59 virtual void OnPrefValueChanged(const std::string& key) = 0; | 57 virtual void OnPrefValueChanged(const std::string& key) = 0; |
| 60 // Notification about the ExtensionPrefValueMap being fully initialized. | 58 // Notification about the ExtensionPrefValueMap being fully initialized. |
| 61 virtual void OnInitializationCompleted() = 0; | 59 virtual void OnInitializationCompleted() = 0; |
| 62 // Called when the ExtensionPrefValueMap is being destroyed. When called, | 60 // Called when the ExtensionPrefValueMap is being destroyed. When called, |
| 63 // observers must unsubscribe. | 61 // observers must unsubscribe. |
| 64 virtual void OnExtensionPrefValueMapDestruction() = 0; | 62 virtual void OnExtensionPrefValueMapDestruction() = 0; |
| 63 |
| 64 protected: |
| 65 virtual ~Observer() {} |
| 65 }; | 66 }; |
| 66 | 67 |
| 67 ExtensionPrefValueMap(); | 68 ExtensionPrefValueMap(); |
| 68 virtual ~ExtensionPrefValueMap(); | 69 virtual ~ExtensionPrefValueMap(); |
| 69 | 70 |
| 70 // ProfileKeyedService implementation. | 71 // ProfileKeyedService implementation. |
| 71 virtual void Shutdown() OVERRIDE; | 72 virtual void Shutdown() OVERRIDE; |
| 72 | 73 |
| 73 // Set an extension preference |value| for |key| of extension |ext_id|. | 74 // Set an extension preference |value| for |key| of extension |ext_id|. |
| 74 // Takes ownership of |value|. | 75 // Takes ownership of |value|. |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 // being destroyed. In tests, it isn't called, so the notification must | 174 // being destroyed. In tests, it isn't called, so the notification must |
| 174 // be done in the destructor. This bit tracks whether it has been done yet. | 175 // be done in the destructor. This bit tracks whether it has been done yet. |
| 175 bool destroyed_; | 176 bool destroyed_; |
| 176 | 177 |
| 177 ObserverList<Observer, true> observers_; | 178 ObserverList<Observer, true> observers_; |
| 178 | 179 |
| 179 DISALLOW_COPY_AND_ASSIGN(ExtensionPrefValueMap); | 180 DISALLOW_COPY_AND_ASSIGN(ExtensionPrefValueMap); |
| 180 }; | 181 }; |
| 181 | 182 |
| 182 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_PREF_VALUE_MAP_H_ | 183 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_PREF_VALUE_MAP_H_ |
| OLD | NEW |