| 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_CONTENT_SETTINGS_STORE_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_CONTENT_SETTINGS_STORE_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_CONTENT_SETTINGS_STORE_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_CONTENT_SETTINGS_STORE_H_ |
| 7 | 7 |
| 8 #include <list> | 8 #include <list> |
| 9 #include <map> | 9 #include <map> |
| 10 #include <string> | 10 #include <string> |
| 11 | 11 |
| 12 #include "base/observer_list.h" | 12 #include "base/observer_list.h" |
| 13 #include "base/synchronization/lock.h" | 13 #include "base/synchronization/lock.h" |
| 14 #include "base/threading/thread_checker.h" | 14 #include "base/threading/thread_checker.h" |
| 15 #include "base/time.h" | 15 #include "base/time.h" |
| 16 #include "base/tuple.h" | 16 #include "base/tuple.h" |
| 17 #include "chrome/browser/content_settings/content_settings_pattern.h" | 17 #include "chrome/browser/content_settings/content_settings_pattern.h" |
| 18 #include "chrome/browser/content_settings/content_settings_provider.h" | 18 #include "chrome/browser/content_settings/content_settings_provider.h" |
| 19 #include "chrome/browser/extensions/extension_prefs_scope.h" | 19 #include "chrome/browser/extensions/extension_prefs_scope.h" |
| 20 #include "chrome/common/content_settings.h" | 20 #include "chrome/common/content_settings.h" |
| 21 #include "googleurl/src/gurl.h" | 21 #include "googleurl/src/gurl.h" |
| 22 | 22 |
| 23 class DictionaryValue; | 23 namespace base { |
| 24 class ListValue; | 24 class ListValue; |
| 25 } |
| 25 | 26 |
| 26 // This class is the backend for extension-defined content settings. It is used | 27 // This class is the backend for extension-defined content settings. It is used |
| 27 // by the content_settings::ExtensionProvider to integrate its settings into the | 28 // by the content_settings::ExtensionProvider to integrate its settings into the |
| 28 // HostContentSettingsMap and by the content settings extension API to provide | 29 // HostContentSettingsMap and by the content settings extension API to provide |
| 29 // extensions with access to content settings. | 30 // extensions with access to content settings. |
| 30 class ExtensionContentSettingsStore | 31 class ExtensionContentSettingsStore |
| 31 : public base::RefCountedThreadSafe<ExtensionContentSettingsStore> { | 32 : public base::RefCountedThreadSafe<ExtensionContentSettingsStore> { |
| 32 public: | 33 public: |
| 33 class Observer { | 34 class Observer { |
| 34 public: | 35 public: |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 // resource identifiers). | 76 // resource identifiers). |
| 76 void GetContentSettingsForContentType( | 77 void GetContentSettingsForContentType( |
| 77 ContentSettingsType type, | 78 ContentSettingsType type, |
| 78 const content_settings::ResourceIdentifier& identifier, | 79 const content_settings::ResourceIdentifier& identifier, |
| 79 bool incognito, | 80 bool incognito, |
| 80 content_settings::ProviderInterface::Rules* rules) const; | 81 content_settings::ProviderInterface::Rules* rules) const; |
| 81 | 82 |
| 82 // Serializes all content settings set by the extension with ID |extension_id| | 83 // Serializes all content settings set by the extension with ID |extension_id| |
| 83 // and returns them as a ListValue. The caller takes ownership of the returned | 84 // and returns them as a ListValue. The caller takes ownership of the returned |
| 84 // value. | 85 // value. |
| 85 ListValue* GetSettingsForExtension(const std::string& extension_id, | 86 base::ListValue* GetSettingsForExtension(const std::string& extension_id, |
| 86 ExtensionPrefsScope scope) const; | 87 ExtensionPrefsScope scope) const; |
| 87 | 88 |
| 88 // Deserializes content settings rules from |list| and applies them as set by | 89 // Deserializes content settings rules from |list| and applies them as set by |
| 89 // the extension with ID |extension_id|. | 90 // the extension with ID |extension_id|. |
| 90 void SetExtensionContentSettingsFromList(const std::string& extension_id, | 91 void SetExtensionContentSettingsFromList(const std::string& extension_id, |
| 91 const ListValue* list, | 92 const base::ListValue* list, |
| 92 ExtensionPrefsScope scope); | 93 ExtensionPrefsScope scope); |
| 93 | 94 |
| 94 // ////////////////////////////////////////////////////////////////////////// | 95 // ////////////////////////////////////////////////////////////////////////// |
| 95 | 96 |
| 96 // Registers the time when an extension |ext_id| is installed. | 97 // Registers the time when an extension |ext_id| is installed. |
| 97 void RegisterExtension(const std::string& ext_id, | 98 void RegisterExtension(const std::string& ext_id, |
| 98 const base::Time& install_time, | 99 const base::Time& install_time, |
| 99 bool is_enabled); | 100 bool is_enabled); |
| 100 | 101 |
| 101 // Deletes all entries related to extension |ext_id|. | 102 // Deletes all entries related to extension |ext_id|. |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 ExtensionEntryMap entries_; | 166 ExtensionEntryMap entries_; |
| 166 | 167 |
| 167 ObserverList<Observer, false> observers_; | 168 ObserverList<Observer, false> observers_; |
| 168 | 169 |
| 169 mutable base::Lock lock_; | 170 mutable base::Lock lock_; |
| 170 | 171 |
| 171 DISALLOW_COPY_AND_ASSIGN(ExtensionContentSettingsStore); | 172 DISALLOW_COPY_AND_ASSIGN(ExtensionContentSettingsStore); |
| 172 }; | 173 }; |
| 173 | 174 |
| 174 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_CONTENT_SETTINGS_STORE_H_ | 175 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_CONTENT_SETTINGS_STORE_H_ |
| OLD | NEW |