Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(422)

Side by Side Diff: chrome/browser/content_settings/content_settings_pref_provider.h

Issue 7344008: Make the hcsm and its providers communicate via an observer interface. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: " Created 9 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_observable_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; 25 class DictionaryValue;
26 class HostContentSettingsMap; 26 class HostContentSettingsMap;
27 class PrefService; 27 class PrefService;
28 28
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 92
93 // Whether we are currently updating preferences, this is used to ignore 93 // Whether we are currently updating preferences, this is used to ignore
94 // notifications from the preferences service that we triggered ourself. 94 // notifications from the preferences service that we triggered ourself.
95 bool updating_preferences_; 95 bool updating_preferences_;
96 96
97 DISALLOW_COPY_AND_ASSIGN(PrefDefaultProvider); 97 DISALLOW_COPY_AND_ASSIGN(PrefDefaultProvider);
98 }; 98 };
99 99
100 // Content settings provider that provides content settings from the user 100 // Content settings provider that provides content settings from the user
101 // preference. 101 // preference.
102 class PrefProvider : public ProviderInterface, 102 class PrefProvider : public ObservableProvider,
103 public NotificationObserver { 103 public NotificationObserver {
104 public: 104 public:
105 static void RegisterUserPrefs(PrefService* prefs); 105 static void RegisterUserPrefs(PrefService* prefs);
106 106
107 PrefProvider(HostContentSettingsMap* map, 107 PrefProvider(PrefService* prefs,
108 PrefService* prefs,
109 bool incognito); 108 bool incognito);
110 virtual ~PrefProvider(); 109 virtual ~PrefProvider();
111 110
112 // ProviderInterface implementations. 111 // ProviderInterface implementations.
113 virtual void SetContentSetting( 112 virtual void SetContentSetting(
114 const ContentSettingsPattern& primary_pattern, 113 const ContentSettingsPattern& primary_pattern,
115 const ContentSettingsPattern& secondary_pattern, 114 const ContentSettingsPattern& secondary_pattern,
116 ContentSettingsType content_type, 115 ContentSettingsType content_type,
117 const ResourceIdentifier& resource_identifier, 116 const ResourceIdentifier& resource_identifier,
118 ContentSetting content_setting); 117 ContentSetting content_setting);
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 181
183 // Copies the value of the preference that stores the content settings 182 // Copies the value of the preference that stores the content settings
184 // exceptions to the obsolete preference for content settings exceptions. This 183 // exceptions to the obsolete preference for content settings exceptions. This
185 // is necessary to allow content settings exceptions beeing synced to older 184 // is necessary to allow content settings exceptions beeing synced to older
186 // versions of chrome that only use the obsolete. 185 // versions of chrome that only use the obsolete.
187 void SyncObsoletePref(); 186 void SyncObsoletePref();
188 187
189 static void CanonicalizeContentSettingsExceptions( 188 static void CanonicalizeContentSettingsExceptions(
190 DictionaryValue* all_settings_dictionary); 189 DictionaryValue* all_settings_dictionary);
191 190
192 void NotifyObservers(const ContentSettingsDetails& details);
193
194 // Weak; owned by the Profile and reset in ShutdownOnUIThread. 191 // Weak; owned by the Profile and reset in ShutdownOnUIThread.
195 PrefService* prefs_; 192 PrefService* prefs_;
196 193
197 // Weak; owns us
198 HostContentSettingsMap* host_content_settings_map_;
199
200 bool is_incognito_; 194 bool is_incognito_;
201 195
202 PrefChangeRegistrar pref_change_registrar_; 196 PrefChangeRegistrar pref_change_registrar_;
203 197
204 // Whether we are currently updating preferences, this is used to ignore 198 // Whether we are currently updating preferences, this is used to ignore
205 // notifications from the preferences service that we triggered ourself. 199 // notifications from the preferences service that we triggered ourself.
206 bool updating_preferences_; 200 bool updating_preferences_;
207 201
208 OriginIdentifierValueMap value_map_; 202 OriginIdentifierValueMap value_map_;
209 203
210 OriginIdentifierValueMap incognito_value_map_; 204 OriginIdentifierValueMap incognito_value_map_;
211 205
212 // Used around accesses to the value map objects to guarantee 206 // Used around accesses to the value map objects to guarantee
213 // thread safety. 207 // thread safety.
214 mutable base::Lock lock_; 208 mutable base::Lock lock_;
215 209
216 DISALLOW_COPY_AND_ASSIGN(PrefProvider); 210 DISALLOW_COPY_AND_ASSIGN(PrefProvider);
217 }; 211 };
218 212
219 } // namespace content_settings 213 } // namespace content_settings
220 214
221 #endif // CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_PREF_PROVIDER_H_ 215 #endif // CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_PREF_PROVIDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698