Chromium Code Reviews| 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/common/content_settings.h" | 20 #include "chrome/common/content_settings.h" |
| 20 #include "googleurl/src/gurl.h" | 21 #include "googleurl/src/gurl.h" |
| 21 | 22 |
| 22 class DictionaryValue; | 23 class DictionaryValue; |
| 23 class ListValue; | 24 class ListValue; |
| 24 | 25 |
| 25 // This class is the backend for extension-defined content settings. It is used | 26 // This class is the backend for extension-defined content settings. It is used |
| 26 // by the content_settings::ExtensionProvider to integrate its settings into the | 27 // by the content_settings::ExtensionProvider to integrate its settings into the |
| 27 // HostContentSettingsMap and by the content settings extension API to provide | 28 // HostContentSettingsMap and by the content settings extension API to provide |
| 28 // extensions with access to content settings. | 29 // extensions with access to content settings. |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 53 // incognito mode only. | 54 // incognito mode only. |
| 54 // Precondition: the extension must be registered. | 55 // Precondition: the extension must be registered. |
| 55 // This method should only be called on the UI thread. | 56 // This method should only be called on the UI thread. |
| 56 void SetExtensionContentSetting( | 57 void SetExtensionContentSetting( |
| 57 const std::string& ext_id, | 58 const std::string& ext_id, |
| 58 const ContentSettingsPattern& embedded_pattern, | 59 const ContentSettingsPattern& embedded_pattern, |
| 59 const ContentSettingsPattern& top_level_pattern, | 60 const ContentSettingsPattern& top_level_pattern, |
| 60 ContentSettingsType type, | 61 ContentSettingsType type, |
| 61 const content_settings::ResourceIdentifier& identifier, | 62 const content_settings::ResourceIdentifier& identifier, |
| 62 ContentSetting setting, | 63 ContentSetting setting, |
| 63 bool incognito); | 64 extension_prefs_scope::Scope scope); |
| 64 | 65 |
| 65 ContentSetting GetEffectiveContentSetting( | 66 ContentSetting GetEffectiveContentSetting( |
| 66 const GURL& embedded_url, | 67 const GURL& embedded_url, |
| 67 const GURL& top_level_url, | 68 const GURL& top_level_url, |
| 68 ContentSettingsType type, | 69 ContentSettingsType type, |
| 69 const content_settings::ResourceIdentifier& identifier, | 70 const content_settings::ResourceIdentifier& identifier, |
| 70 bool incognito) const; | 71 bool incognito) const; |
| 71 | 72 |
| 73 // Clears all contents settings set by the extension |ext_id|. | |
| 74 void ClearContentSettingsForExtension(const std::string& ext_id, | |
| 75 extension_prefs_scope::Scope scope); | |
| 76 | |
| 72 // Returns a list of all content setting rules for the content type |type| | 77 // Returns a list of all content setting rules for the content type |type| |
| 73 // and the resource identifier (if specified and the content type uses | 78 // and the resource identifier (if specified and the content type uses |
| 74 // resource identifiers). | 79 // resource identifiers). |
| 75 void GetContentSettingsForContentType( | 80 void GetContentSettingsForContentType( |
| 76 ContentSettingsType type, | 81 ContentSettingsType type, |
| 77 const content_settings::ResourceIdentifier& identifier, | 82 const content_settings::ResourceIdentifier& identifier, |
| 78 bool incognito, | 83 bool incognito, |
| 79 content_settings::ProviderInterface::Rules* rules) const; | 84 content_settings::ProviderInterface::Rules* rules) const; |
| 80 | 85 |
| 81 // Serializes all content settings set by the extension with ID |extension_id| | 86 // Serializes all content settings set by the extension with ID |extension_id| |
| 82 // and returns them as a ListValue. The caller takes ownership of the returned | 87 // and returns them as a ListValue. The caller takes ownership of the returned |
| 83 // value. | 88 // value. |
| 84 ListValue* GetSettingsForExtension(const std::string& extension_id) const; | 89 ListValue* GetSettingsForExtension(const std::string& extension_id, |
| 90 extension_prefs_scope::Scope scope) const; | |
| 85 | 91 |
| 86 // Deserializes content settings rules from |list| and applies them as set by | 92 // Deserializes content settings rules from |list| and applies them as set by |
| 87 // the extension with ID |extension_id|. | 93 // the extension with ID |extension_id|. |
| 88 void SetExtensionContentSettingsFromList(const std::string& extension_id, | 94 void SetExtensionContentSettingsFromList(const std::string& extension_id, |
| 89 const ListValue* dict); | 95 const ListValue* dict, |
|
battre
2011/06/03 18:48:36
nit: |dict| -> |list| (see line 92)
Bernhard Bauer
2011/06/03 20:34:28
Done.
| |
| 96 extension_prefs_scope::Scope scope); | |
| 90 | 97 |
| 91 // ////////////////////////////////////////////////////////////////////////// | 98 // ////////////////////////////////////////////////////////////////////////// |
| 92 | 99 |
| 93 // Registers the time when an extension |ext_id| is installed. | 100 // Registers the time when an extension |ext_id| is installed. |
| 94 void RegisterExtension(const std::string& ext_id, | 101 void RegisterExtension(const std::string& ext_id, |
| 95 const base::Time& install_time, | 102 const base::Time& install_time, |
| 96 bool is_enabled); | 103 bool is_enabled); |
| 97 | 104 |
| 98 // Deletes all entries related to extension |ext_id|. | 105 // Deletes all entries related to extension |ext_id|. |
| 99 void UnregisterExtension(const std::string& ext_id); | 106 void UnregisterExtension(const std::string& ext_id); |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 130 | 137 |
| 131 ContentSetting GetContentSettingFromSpecList( | 138 ContentSetting GetContentSettingFromSpecList( |
| 132 const GURL& embedded_url, | 139 const GURL& embedded_url, |
| 133 const GURL& top_level_url, | 140 const GURL& top_level_url, |
| 134 ContentSettingsType type, | 141 ContentSettingsType type, |
| 135 const content_settings::ResourceIdentifier& identifier, | 142 const content_settings::ResourceIdentifier& identifier, |
| 136 const ContentSettingSpecList& setting_spec_list) const; | 143 const ContentSettingSpecList& setting_spec_list) const; |
| 137 | 144 |
| 138 ContentSettingSpecList* GetContentSettingSpecList( | 145 ContentSettingSpecList* GetContentSettingSpecList( |
| 139 const std::string& ext_id, | 146 const std::string& ext_id, |
| 140 bool incognito); | 147 extension_prefs_scope::Scope scope); |
| 141 | 148 |
| 142 const ContentSettingSpecList* GetContentSettingSpecList( | 149 const ContentSettingSpecList* GetContentSettingSpecList( |
| 143 const std::string& ext_id, | 150 const std::string& ext_id, |
| 144 bool incognito) const; | 151 extension_prefs_scope::Scope scope) const; |
| 152 | |
| 153 static void AddRules(ContentSettingsType type, | |
|
battre
2011/06/03 18:48:36
Add a comment?
Bernhard Bauer
2011/06/03 20:34:28
Done.
| |
| 154 const content_settings::ResourceIdentifier& identifier, | |
| 155 content_settings::ProviderInterface::Rules* rules, | |
| 156 const ContentSettingSpecList* setting_spec_list); | |
|
battre
2011/06/03 18:48:36
Order of parameters: You search for a match of |ty
Bernhard Bauer
2011/06/03 20:34:28
Good idea. Done.
| |
| 145 | 157 |
| 146 void NotifyOfContentSettingChanged(const std::string& extension_id, | 158 void NotifyOfContentSettingChanged(const std::string& extension_id, |
| 147 bool incognito); | 159 bool incognito); |
| 148 | 160 |
| 149 void NotifyOfDestruction(); | 161 void NotifyOfDestruction(); |
| 150 | 162 |
| 151 bool OnCorrectThread(); | 163 bool OnCorrectThread(); |
| 152 | 164 |
| 153 ExtensionEntryMap entries_; | 165 ExtensionEntryMap entries_; |
| 154 | 166 |
| 155 ObserverList<Observer, false> observers_; | 167 ObserverList<Observer, false> observers_; |
| 156 | 168 |
| 157 mutable base::Lock lock_; | 169 mutable base::Lock lock_; |
| 158 | 170 |
| 159 DISALLOW_COPY_AND_ASSIGN(ExtensionContentSettingsStore); | 171 DISALLOW_COPY_AND_ASSIGN(ExtensionContentSettingsStore); |
| 160 }; | 172 }; |
| 161 | 173 |
| 162 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_CONTENT_SETTINGS_STORE_H_ | 174 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_CONTENT_SETTINGS_STORE_H_ |
| OLD | NEW |