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

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

Issue 11345008: Remove content::NotificationObserver dependency from most Prefs code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge to head for commit Created 8 years, 1 month 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_DEFAULT_PROVIDER_H_ 5 #ifndef CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_DEFAULT_PROVIDER_H_
6 #define CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_DEFAULT_PROVIDER_H_ 6 #define CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_DEFAULT_PROVIDER_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/basictypes.h" 12 #include "base/basictypes.h"
13 #include "base/memory/linked_ptr.h" 13 #include "base/memory/linked_ptr.h"
14 #include "base/prefs/public/pref_change_registrar.h" 14 #include "base/prefs/public/pref_change_registrar.h"
15 #include "base/prefs/public/pref_observer.h"
15 #include "base/synchronization/lock.h" 16 #include "base/synchronization/lock.h"
16 #include "chrome/browser/content_settings/content_settings_observable_provider.h " 17 #include "chrome/browser/content_settings/content_settings_observable_provider.h "
17 #include "content/public/browser/notification_observer.h"
18 #include "content/public/browser/notification_registrar.h"
19 18
20 class PrefService; 19 class PrefService;
21 20
22 namespace content_settings { 21 namespace content_settings {
23 22
24 // Provider that provides default content settings based on 23 // Provider that provides default content settings based on
25 // user prefs. If no default values are set by the user we use the hard coded 24 // user prefs. If no default values are set by the user we use the hard coded
26 // default values. 25 // default values.
27 class DefaultProvider : public ObservableProvider, 26 class DefaultProvider : public ObservableProvider,
28 public content::NotificationObserver { 27 public PrefObserver {
29 public: 28 public:
30 static void RegisterUserPrefs(PrefService* prefs); 29 static void RegisterUserPrefs(PrefService* prefs);
31 30
32 DefaultProvider(PrefService* prefs, 31 DefaultProvider(PrefService* prefs,
33 bool incognito); 32 bool incognito);
34 virtual ~DefaultProvider(); 33 virtual ~DefaultProvider();
35 34
36 // ProviderInterface implementations. 35 // ProviderInterface implementations.
37 virtual RuleIterator* GetRuleIterator( 36 virtual RuleIterator* GetRuleIterator(
38 ContentSettingsType content_type, 37 ContentSettingsType content_type,
39 const ResourceIdentifier& resource_identifier, 38 const ResourceIdentifier& resource_identifier,
40 bool incognito) const OVERRIDE; 39 bool incognito) const OVERRIDE;
41 40
42 virtual bool SetWebsiteSetting( 41 virtual bool SetWebsiteSetting(
43 const ContentSettingsPattern& primary_pattern, 42 const ContentSettingsPattern& primary_pattern,
44 const ContentSettingsPattern& secondary_pattern, 43 const ContentSettingsPattern& secondary_pattern,
45 ContentSettingsType content_type, 44 ContentSettingsType content_type,
46 const ResourceIdentifier& resource_identifier, 45 const ResourceIdentifier& resource_identifier,
47 Value* value) OVERRIDE; 46 Value* value) OVERRIDE;
48 47
49 virtual void ClearAllContentSettingsRules( 48 virtual void ClearAllContentSettingsRules(
50 ContentSettingsType content_type) OVERRIDE; 49 ContentSettingsType content_type) OVERRIDE;
51 50
52 virtual void ShutdownOnUIThread() OVERRIDE; 51 virtual void ShutdownOnUIThread() OVERRIDE;
53 52
54 // content::NotificationObserver implementation. 53 // PrefObserver implementation.
55 virtual void Observe(int type, 54 virtual void OnPreferenceChanged(PrefServiceBase* service,
56 const content::NotificationSource& source, 55 const std::string& pref_name) OVERRIDE;
57 const content::NotificationDetails& details) OVERRIDE;
58 56
59 private: 57 private:
60 // Sets the fields of |settings| based on the values in |dictionary|. 58 // Sets the fields of |settings| based on the values in |dictionary|.
61 void GetSettingsFromDictionary(const base::DictionaryValue* dictionary); 59 void GetSettingsFromDictionary(const base::DictionaryValue* dictionary);
62 60
63 // Forces the default settings to be explicitly set instead of themselves 61 // Forces the default settings to be explicitly set instead of themselves
64 // being CONTENT_SETTING_DEFAULT. 62 // being CONTENT_SETTING_DEFAULT.
65 void ForceDefaultsToBeExplicit(); 63 void ForceDefaultsToBeExplicit();
66 64
67 // Reads the default settings from the preferences service. If |overwrite| is 65 // Reads the default settings from the preferences service. If |overwrite| is
(...skipping 22 matching lines...) Expand all
90 // Whether we are currently updating preferences, this is used to ignore 88 // Whether we are currently updating preferences, this is used to ignore
91 // notifications from the preferences service that we triggered ourself. 89 // notifications from the preferences service that we triggered ourself.
92 bool updating_preferences_; 90 bool updating_preferences_;
93 91
94 DISALLOW_COPY_AND_ASSIGN(DefaultProvider); 92 DISALLOW_COPY_AND_ASSIGN(DefaultProvider);
95 }; 93 };
96 94
97 } // namespace content_settings 95 } // namespace content_settings
98 96
99 #endif // CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_DEFAULT_PROVIDER_H_ 97 #endif // CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_DEFAULT_PROVIDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698