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

Side by Side Diff: chrome/browser/prefs/pref_set_observer.h

Issue 3304015: Use PrefChangeRegistrar everywhere (Closed)
Patch Set: final version for commit Created 10 years, 2 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
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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_PREFS_PREF_SET_OBSERVER_H_ 5 #ifndef CHROME_BROWSER_PREFS_PREF_SET_OBSERVER_H_
6 #define CHROME_BROWSER_PREFS_PREF_SET_OBSERVER_H_ 6 #define CHROME_BROWSER_PREFS_PREF_SET_OBSERVER_H_
7 #pragma once 7 #pragma once
8 8
9 #include <set> 9 #include <set>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "chrome/browser/prefs/pref_service.h" 12 #include "chrome/browser/prefs/pref_service.h"
13 #include "chrome/browser/prefs/pref_change_registrar.h"
13 #include "chrome/common/notification_observer.h" 14 #include "chrome/common/notification_observer.h"
14 15
15 // Observes the state of a set of preferences and allows to query their combined 16 // Observes the state of a set of preferences and allows to query their combined
16 // managed bits. 17 // managed bits.
17 class PrefSetObserver : public NotificationObserver { 18 class PrefSetObserver : public NotificationObserver {
18 public: 19 public:
19 // Initialize with an empty set of preferences. 20 // Initialize with an empty set of preferences.
20 PrefSetObserver(PrefService* pref_service, 21 PrefSetObserver(PrefService* pref_service,
21 NotificationObserver* observer); 22 NotificationObserver* observer);
22 virtual ~PrefSetObserver(); 23 virtual ~PrefSetObserver() {}
23 24
24 // Add a |pref| to the set of preferences to observe. 25 // Add a |pref| to the set of preferences to observe.
25 void AddPref(const std::string& pref); 26 void AddPref(const std::string& pref);
26 // Remove |pref| from the set of observed peferences. 27 // Remove |pref| from the set of observed peferences.
27 void RemovePref(const std::string& pref); 28 void RemovePref(const std::string& pref);
28 29
29 // Check whether |pref| is in the set of observed preferences. 30 // Check whether |pref| is in the set of observed preferences.
30 bool IsObserved(const std::string& pref); 31 bool IsObserved(const std::string& pref);
31 // Check whether any of the observed preferences has the managed bit set. 32 // Check whether any of the observed preferences has the managed bit set.
32 bool IsManaged(); 33 bool IsManaged();
(...skipping 11 matching lines...) Expand all
44 private: 45 private:
45 // Overridden from NotificationObserver. 46 // Overridden from NotificationObserver.
46 virtual void Observe(NotificationType type, 47 virtual void Observe(NotificationType type,
47 const NotificationSource& source, 48 const NotificationSource& source,
48 const NotificationDetails& details); 49 const NotificationDetails& details);
49 50
50 typedef std::set<std::string> PrefSet; 51 typedef std::set<std::string> PrefSet;
51 PrefSet prefs_; 52 PrefSet prefs_;
52 53
53 PrefService* pref_service_; 54 PrefService* pref_service_;
55 PrefChangeRegistrar registrar_;
54 NotificationObserver* observer_; 56 NotificationObserver* observer_;
55 57
56 DISALLOW_COPY_AND_ASSIGN(PrefSetObserver); 58 DISALLOW_COPY_AND_ASSIGN(PrefSetObserver);
57 }; 59 };
58 60
59 #endif // CHROME_BROWSER_PREFS_PREF_SET_OBSERVER_H_ 61 #endif // CHROME_BROWSER_PREFS_PREF_SET_OBSERVER_H_
OLDNEW
« no previous file with comments | « chrome/browser/prefs/pref_service_unittest.cc ('k') | chrome/browser/prefs/pref_set_observer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698