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_PREFERENCE_PREFERENCE_API_H__ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_PREFERENCE_PREFERENCE_API_H__ |
6 #define CHROME_BROWSER_EXTENSIONS_API_PREFERENCE_PREFERENCE_API_H__ | 6 #define CHROME_BROWSER_EXTENSIONS_API_PREFERENCE_PREFERENCE_API_H__ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
| 10 #include "base/memory/ref_counted.h" |
10 #include "base/prefs/pref_change_registrar.h" | 11 #include "base/prefs/pref_change_registrar.h" |
11 #include "chrome/browser/extensions/api/content_settings/content_settings_store.
h" | 12 #include "chrome/browser/extensions/api/content_settings/content_settings_store.
h" |
12 #include "chrome/browser/extensions/chrome_extension_function.h" | 13 #include "chrome/browser/extensions/chrome_extension_function.h" |
13 #include "content/public/browser/notification_observer.h" | 14 #include "content/public/browser/notification_observer.h" |
14 #include "extensions/browser/browser_context_keyed_api_factory.h" | 15 #include "extensions/browser/browser_context_keyed_api_factory.h" |
15 #include "extensions/browser/event_router.h" | 16 #include "extensions/browser/event_router.h" |
16 #include "extensions/browser/extension_prefs_scope.h" | 17 #include "extensions/browser/extension_prefs_scope.h" |
17 | 18 |
18 class ExtensionPrefValueMap; | 19 class ExtensionPrefValueMap; |
19 class PrefService; | 20 class PrefService; |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 // coming from the incognito preferences, false if it is coming from the | 80 // coming from the incognito preferences, false if it is coming from the |
80 // normal ones. | 81 // normal ones. |
81 bool DoesExtensionControlPref(const std::string& extension_id, | 82 bool DoesExtensionControlPref(const std::string& extension_id, |
82 const std::string& pref_key, | 83 const std::string& pref_key, |
83 bool* from_incognito); | 84 bool* from_incognito); |
84 | 85 |
85 protected: | 86 protected: |
86 // Virtual for testing. | 87 // Virtual for testing. |
87 virtual ExtensionPrefs* extension_prefs() = 0; | 88 virtual ExtensionPrefs* extension_prefs() = 0; |
88 virtual ExtensionPrefValueMap* extension_pref_value_map() = 0; | 89 virtual ExtensionPrefValueMap* extension_pref_value_map() = 0; |
| 90 virtual scoped_refptr<ContentSettingsStore> content_settings_store() = 0; |
89 }; | 91 }; |
90 | 92 |
91 class PreferenceAPI : public PreferenceAPIBase, | 93 class PreferenceAPI : public PreferenceAPIBase, |
92 public BrowserContextKeyedAPI, | 94 public BrowserContextKeyedAPI, |
93 public EventRouter::Observer, | 95 public EventRouter::Observer, |
94 public ContentSettingsStore::Observer { | 96 public ContentSettingsStore::Observer { |
95 public: | 97 public: |
96 explicit PreferenceAPI(content::BrowserContext* context); | 98 explicit PreferenceAPI(content::BrowserContext* context); |
97 virtual ~PreferenceAPI(); | 99 virtual ~PreferenceAPI(); |
98 | 100 |
(...skipping 15 matching lines...) Expand all Loading... |
114 // ContentSettingsStore::Observer implementation. | 116 // ContentSettingsStore::Observer implementation. |
115 virtual void OnContentSettingChanged(const std::string& extension_id, | 117 virtual void OnContentSettingChanged(const std::string& extension_id, |
116 bool incognito) OVERRIDE; | 118 bool incognito) OVERRIDE; |
117 | 119 |
118 // Clears incognito session-only content settings for all extensions. | 120 // Clears incognito session-only content settings for all extensions. |
119 void ClearIncognitoSessionOnlyContentSettings(); | 121 void ClearIncognitoSessionOnlyContentSettings(); |
120 | 122 |
121 // PreferenceAPIBase implementation. | 123 // PreferenceAPIBase implementation. |
122 virtual ExtensionPrefs* extension_prefs() OVERRIDE; | 124 virtual ExtensionPrefs* extension_prefs() OVERRIDE; |
123 virtual ExtensionPrefValueMap* extension_pref_value_map() OVERRIDE; | 125 virtual ExtensionPrefValueMap* extension_pref_value_map() OVERRIDE; |
| 126 virtual scoped_refptr<ContentSettingsStore> content_settings_store() OVERRIDE; |
124 | 127 |
125 Profile* profile_; | 128 Profile* profile_; |
126 | 129 |
127 // BrowserContextKeyedAPI implementation. | 130 // BrowserContextKeyedAPI implementation. |
128 static const char* service_name() { | 131 static const char* service_name() { |
129 return "PreferenceAPI"; | 132 return "PreferenceAPI"; |
130 } | 133 } |
131 static const bool kServiceIsNULLWhileTesting = true; | 134 static const bool kServiceIsNULLWhileTesting = true; |
132 static const bool kServiceRedirectedInIncognito = true; | 135 static const bool kServiceRedirectedInIncognito = true; |
133 | 136 |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 protected: | 211 protected: |
209 virtual ~ClearPreferenceFunction(); | 212 virtual ~ClearPreferenceFunction(); |
210 | 213 |
211 // ExtensionFunction: | 214 // ExtensionFunction: |
212 virtual bool RunImpl() OVERRIDE; | 215 virtual bool RunImpl() OVERRIDE; |
213 }; | 216 }; |
214 | 217 |
215 } // namespace extensions | 218 } // namespace extensions |
216 | 219 |
217 #endif // CHROME_BROWSER_EXTENSIONS_API_PREFERENCE_PREFERENCE_API_H__ | 220 #endif // CHROME_BROWSER_EXTENSIONS_API_PREFERENCE_PREFERENCE_API_H__ |
OLD | NEW |