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_CONTENT_SETTINGS_CONTENT_SETTINGS_PREF_PROVIDER_H_ | 5 #ifndef CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_PREF_PROVIDER_H_ |
6 #define CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_PREF_PROVIDER_H_ | 6 #define CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_PREF_PROVIDER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 // A content settings provider that takes its settings out of the pref service. | 9 // A content settings provider that takes its settings out of the pref service. |
10 | 10 |
11 #include <map> | 11 #include <map> |
12 #include <string> | 12 #include <string> |
13 #include <utility> | 13 #include <utility> |
14 | 14 |
15 #include "base/basictypes.h" | 15 #include "base/basictypes.h" |
16 #include "base/synchronization/lock.h" | 16 #include "base/synchronization/lock.h" |
17 #include "chrome/browser/content_settings/content_settings_origin_identifier_val
ue_map.h" | 17 #include "chrome/browser/content_settings/content_settings_origin_identifier_val
ue_map.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/content_settings/content_settings_utils.h" | 19 #include "chrome/browser/content_settings/content_settings_utils.h" |
20 #include "chrome/browser/prefs/pref_change_registrar.h" | 20 #include "chrome/browser/prefs/pref_change_registrar.h" |
21 #include "content/common/notification_observer.h" | 21 #include "content/common/notification_observer.h" |
22 #include "content/common/notification_registrar.h" | 22 #include "content/common/notification_registrar.h" |
23 | 23 |
24 class ContentSettingsDetails; | 24 class ContentSettingsDetails; |
25 class DictionaryValue; | |
26 class HostContentSettingsMap; | 25 class HostContentSettingsMap; |
27 class PrefService; | 26 class PrefService; |
28 | 27 |
| 28 namespace base { |
| 29 class DictionaryValue; |
| 30 } |
| 31 |
29 namespace content_settings { | 32 namespace content_settings { |
30 | 33 |
31 // Content settings provider that provides default content settings based on | 34 // Content settings provider that provides default content settings based on |
32 // user prefs. | 35 // user prefs. |
33 class PrefDefaultProvider : public DefaultProviderInterface, | 36 class PrefDefaultProvider : public DefaultProviderInterface, |
34 public NotificationObserver { | 37 public NotificationObserver { |
35 public: | 38 public: |
36 PrefDefaultProvider(HostContentSettingsMap* map, | 39 PrefDefaultProvider(HostContentSettingsMap* map, |
37 PrefService* prefs, | 40 PrefService* prefs, |
38 bool incognito); | 41 bool incognito); |
(...skipping 16 matching lines...) Expand all Loading... |
55 const NotificationDetails& details); | 58 const NotificationDetails& details); |
56 | 59 |
57 private: | 60 private: |
58 // Informs observers that content settings have changed. Make sure that | 61 // Informs observers that content settings have changed. Make sure that |
59 // |lock_| is not held when calling this, as listeners will usually call one | 62 // |lock_| is not held when calling this, as listeners will usually call one |
60 // of the GetSettings functions in response, which would then lead to a | 63 // of the GetSettings functions in response, which would then lead to a |
61 // mutex deadlock. | 64 // mutex deadlock. |
62 void NotifyObservers(const ContentSettingsDetails& details); | 65 void NotifyObservers(const ContentSettingsDetails& details); |
63 | 66 |
64 // Sets the fields of |settings| based on the values in |dictionary|. | 67 // Sets the fields of |settings| based on the values in |dictionary|. |
65 void GetSettingsFromDictionary(const DictionaryValue* dictionary, | 68 void GetSettingsFromDictionary(const base::DictionaryValue* dictionary, |
66 ContentSettings* settings); | 69 ContentSettings* settings); |
67 | 70 |
68 // Forces the default settings to be explicitly set instead of themselves | 71 // Forces the default settings to be explicitly set instead of themselves |
69 // being CONTENT_SETTING_DEFAULT. | 72 // being CONTENT_SETTING_DEFAULT. |
70 void ForceDefaultsToBeExplicit(); | 73 void ForceDefaultsToBeExplicit(); |
71 | 74 |
72 // Reads the default settings from the preferences service. If |overwrite| is | 75 // Reads the default settings from the preferences service. If |overwrite| is |
73 // true and the preference is missing, the local copy will be cleared as well. | 76 // true and the preference is missing, the local copy will be cleared as well. |
74 void ReadDefaultSettings(bool overwrite); | 77 void ReadDefaultSettings(bool overwrite); |
75 | 78 |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 void MigrateObsoletePopupsPref(); | 183 void MigrateObsoletePopupsPref(); |
181 void MigrateObsoleteContentSettingsPatternPref(); | 184 void MigrateObsoleteContentSettingsPatternPref(); |
182 | 185 |
183 // Copies the value of the preference that stores the content settings | 186 // Copies the value of the preference that stores the content settings |
184 // exceptions to the obsolete preference for content settings exceptions. This | 187 // exceptions to the obsolete preference for content settings exceptions. This |
185 // is necessary to allow content settings exceptions beeing synced to older | 188 // is necessary to allow content settings exceptions beeing synced to older |
186 // versions of chrome that only use the obsolete. | 189 // versions of chrome that only use the obsolete. |
187 void SyncObsoletePref(); | 190 void SyncObsoletePref(); |
188 | 191 |
189 static void CanonicalizeContentSettingsExceptions( | 192 static void CanonicalizeContentSettingsExceptions( |
190 DictionaryValue* all_settings_dictionary); | 193 base::DictionaryValue* all_settings_dictionary); |
191 | 194 |
192 void NotifyObservers(const ContentSettingsDetails& details); | 195 void NotifyObservers(const ContentSettingsDetails& details); |
193 | 196 |
194 // Weak; owned by the Profile and reset in ShutdownOnUIThread. | 197 // Weak; owned by the Profile and reset in ShutdownOnUIThread. |
195 PrefService* prefs_; | 198 PrefService* prefs_; |
196 | 199 |
197 // Weak; owns us | 200 // Weak; owns us |
198 HostContentSettingsMap* host_content_settings_map_; | 201 HostContentSettingsMap* host_content_settings_map_; |
199 | 202 |
200 bool is_incognito_; | 203 bool is_incognito_; |
(...skipping 11 matching lines...) Expand all Loading... |
212 // Used around accesses to the value map objects to guarantee | 215 // Used around accesses to the value map objects to guarantee |
213 // thread safety. | 216 // thread safety. |
214 mutable base::Lock lock_; | 217 mutable base::Lock lock_; |
215 | 218 |
216 DISALLOW_COPY_AND_ASSIGN(PrefProvider); | 219 DISALLOW_COPY_AND_ASSIGN(PrefProvider); |
217 }; | 220 }; |
218 | 221 |
219 } // namespace content_settings | 222 } // namespace content_settings |
220 | 223 |
221 #endif // CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_PREF_PROVIDER_H_ | 224 #endif // CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_PREF_PROVIDER_H_ |
OLD | NEW |