| OLD | NEW |
| 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/browser/prefs/pref_change_registrar.h" |
| 14 #include "chrome/common/notification_observer.h" | 14 #include "chrome/common/notification_observer.h" |
| 15 | 15 |
| 16 // 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 |
| 17 // managed bits. | 17 // managed bits. |
| 18 class PrefSetObserver : public NotificationObserver { | 18 class PrefSetObserver : public NotificationObserver { |
| 19 public: | 19 public: |
| 20 // Initialize with an empty set of preferences. | 20 // Initialize with an empty set of preferences. |
| 21 PrefSetObserver(PrefService* pref_service, | 21 PrefSetObserver(PrefService* pref_service, |
| 22 NotificationObserver* observer); | 22 NotificationObserver* observer); |
| 23 virtual ~PrefSetObserver() {} | 23 virtual ~PrefSetObserver(); |
| 24 | 24 |
| 25 // Add a |pref| to the set of preferences to observe. | 25 // Add a |pref| to the set of preferences to observe. |
| 26 void AddPref(const std::string& pref); | 26 void AddPref(const std::string& pref); |
| 27 // Remove |pref| from the set of observed peferences. | 27 // Remove |pref| from the set of observed peferences. |
| 28 void RemovePref(const std::string& pref); | 28 void RemovePref(const std::string& pref); |
| 29 | 29 |
| 30 // Check whether |pref| is in the set of observed preferences. | 30 // Check whether |pref| is in the set of observed preferences. |
| 31 bool IsObserved(const std::string& pref); | 31 bool IsObserved(const std::string& pref); |
| 32 // 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. |
| 33 bool IsManaged(); | 33 bool IsManaged(); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 52 PrefSet prefs_; | 52 PrefSet prefs_; |
| 53 | 53 |
| 54 PrefService* pref_service_; | 54 PrefService* pref_service_; |
| 55 PrefChangeRegistrar registrar_; | 55 PrefChangeRegistrar registrar_; |
| 56 NotificationObserver* observer_; | 56 NotificationObserver* observer_; |
| 57 | 57 |
| 58 DISALLOW_COPY_AND_ASSIGN(PrefSetObserver); | 58 DISALLOW_COPY_AND_ASSIGN(PrefSetObserver); |
| 59 }; | 59 }; |
| 60 | 60 |
| 61 #endif // CHROME_BROWSER_PREFS_PREF_SET_OBSERVER_H_ | 61 #endif // CHROME_BROWSER_PREFS_PREF_SET_OBSERVER_H_ |
| OLD | NEW |