| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_BROWSER_PREF_SET_OBSERVER_H_ |
| 6 #define CHROME_BROWSER_PREF_SET_OBSERVER_H_ |
| 7 |
| 8 #include <set> |
| 9 |
| 10 #include "base/basictypes.h" |
| 11 #include "chrome/browser/pref_service.h" |
| 12 #include "chrome/common/notification_observer.h" |
| 13 |
| 14 // Observes the state of a set of preferences and allows to query their combined |
| 15 // managed bits. |
| 16 class PrefSetObserver : public NotificationObserver { |
| 17 public: |
| 18 // Initialize with an empty set of preferences. |
| 19 PrefSetObserver(PrefService* pref_service, |
| 20 NotificationObserver* observer); |
| 21 virtual ~PrefSetObserver(); |
| 22 |
| 23 // Add a |pref| to the set of preferences to observe. |
| 24 void AddPref(const std::wstring& pref); |
| 25 // Remove |pref| from the set of observed peferences. |
| 26 void RemovePref(const std::wstring& pref); |
| 27 |
| 28 // Check whether |pref| is in the set of observed preferences. |
| 29 bool IsObserved(const std::wstring& pref); |
| 30 // Check whether any of the observed preferences has the managed bit set. |
| 31 bool IsManaged(); |
| 32 |
| 33 // Create a pref set observer for all preferences relavant to proxies. |
| 34 static PrefSetObserver* CreateProxyPrefSetObserver( |
| 35 PrefService* pref_service, |
| 36 NotificationObserver* observer); |
| 37 |
| 38 private: |
| 39 // Overridden from NotificationObserver. |
| 40 virtual void Observe(NotificationType type, |
| 41 const NotificationSource& source, |
| 42 const NotificationDetails& details); |
| 43 |
| 44 typedef std::set<std::wstring> PrefSet; |
| 45 PrefSet prefs_; |
| 46 |
| 47 PrefService* pref_service_; |
| 48 NotificationObserver* observer_; |
| 49 |
| 50 DISALLOW_COPY_AND_ASSIGN(PrefSetObserver); |
| 51 }; |
| 52 |
| 53 #endif // CHROME_BROWSER_PREF_SET_OBSERVER_H_ |
| OLD | NEW |