| 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_API_CONTENT_SETTINGS_CONTENT_SETTINGS_STORE_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_CONTENT_SETTINGS_CONTENT_SETTINGS_STORE_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_API_CONTENT_SETTINGS_CONTENT_SETTINGS_STORE_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_API_CONTENT_SETTINGS_CONTENT_SETTINGS_STORE_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <memory> |
| 9 #include <string> | 10 #include <string> |
| 11 #include <vector> |
| 10 | 12 |
| 11 #include "base/macros.h" | 13 #include "base/macros.h" |
| 12 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
| 13 #include "base/observer_list.h" | 15 #include "base/observer_list.h" |
| 14 #include "base/synchronization/lock.h" | 16 #include "base/synchronization/lock.h" |
| 15 #include "base/threading/thread_checker.h" | 17 #include "base/threading/thread_checker.h" |
| 16 #include "base/time/time.h" | 18 #include "base/time/time.h" |
| 17 #include "components/content_settings/core/browser/content_settings_provider.h" | 19 #include "components/content_settings/core/browser/content_settings_provider.h" |
| 18 #include "components/content_settings/core/common/content_settings.h" | 20 #include "components/content_settings/core/common/content_settings.h" |
| 19 #include "components/content_settings/core/common/content_settings_pattern.h" | 21 #include "components/content_settings/core/common/content_settings_pattern.h" |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 void AddObserver(Observer* observer); | 107 void AddObserver(Observer* observer); |
| 106 | 108 |
| 107 // Remove |observer|. This method should only be called on the UI thread. | 109 // Remove |observer|. This method should only be called on the UI thread. |
| 108 void RemoveObserver(Observer* observer); | 110 void RemoveObserver(Observer* observer); |
| 109 | 111 |
| 110 private: | 112 private: |
| 111 friend class base::RefCountedThreadSafe<ContentSettingsStore>; | 113 friend class base::RefCountedThreadSafe<ContentSettingsStore>; |
| 112 | 114 |
| 113 struct ExtensionEntry; | 115 struct ExtensionEntry; |
| 114 | 116 |
| 115 typedef std::multimap<base::Time, ExtensionEntry*> ExtensionEntryMap; | 117 // A list of the entries, maintained in reverse-chronological order (most- |
| 118 // recently installed items first) to facilitate search. |
| 119 using ExtensionEntries = std::vector<std::unique_ptr<ExtensionEntry>>; |
| 116 | 120 |
| 117 virtual ~ContentSettingsStore(); | 121 virtual ~ContentSettingsStore(); |
| 118 | 122 |
| 119 content_settings::OriginIdentifierValueMap* GetValueMap( | 123 content_settings::OriginIdentifierValueMap* GetValueMap( |
| 120 const std::string& ext_id, | 124 const std::string& ext_id, |
| 121 ExtensionPrefsScope scope); | 125 ExtensionPrefsScope scope); |
| 122 | 126 |
| 123 const content_settings::OriginIdentifierValueMap* GetValueMap( | 127 const content_settings::OriginIdentifierValueMap* GetValueMap( |
| 124 const std::string& ext_id, | 128 const std::string& ext_id, |
| 125 ExtensionPrefsScope scope) const; | 129 ExtensionPrefsScope scope) const; |
| 126 | 130 |
| 127 void NotifyOfContentSettingChanged(const std::string& extension_id, | 131 void NotifyOfContentSettingChanged(const std::string& extension_id, |
| 128 bool incognito); | 132 bool incognito); |
| 129 | 133 |
| 130 bool OnCorrectThread(); | 134 bool OnCorrectThread(); |
| 131 | 135 |
| 132 ExtensionEntryMap::iterator FindEntry(const std::string& ext_id); | 136 ExtensionEntry* FindEntry(const std::string& ext_id) const; |
| 133 ExtensionEntryMap::const_iterator FindEntry(const std::string& ext_id) const; | 137 ExtensionEntries::iterator FindIterator(const std::string& ext_id); |
| 134 | 138 |
| 135 ExtensionEntryMap entries_; | 139 // The entries. |
| 140 ExtensionEntries entries_; |
| 136 | 141 |
| 137 base::ObserverList<Observer, false> observers_; | 142 base::ObserverList<Observer, false> observers_; |
| 138 | 143 |
| 139 mutable base::Lock lock_; | 144 mutable base::Lock lock_; |
| 140 | 145 |
| 141 DISALLOW_COPY_AND_ASSIGN(ContentSettingsStore); | 146 DISALLOW_COPY_AND_ASSIGN(ContentSettingsStore); |
| 142 }; | 147 }; |
| 143 | 148 |
| 144 } // namespace extensions | 149 } // namespace extensions |
| 145 | 150 |
| 146 #endif // CHROME_BROWSER_EXTENSIONS_API_CONTENT_SETTINGS_CONTENT_SETTINGS_STORE
_H_ | 151 #endif // CHROME_BROWSER_EXTENSIONS_API_CONTENT_SETTINGS_CONTENT_SETTINGS_STORE
_H_ |
| OLD | NEW |