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

Unified Diff: chrome/browser/pref_set_observer.h

Issue 3067017: Merge 53457 - Disable proxy config button and show banner if proxy prefs are managed. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: Created 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/pref_service.h ('k') | chrome/browser/pref_set_observer.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/pref_set_observer.h
diff --git a/chrome/browser/pref_set_observer.h b/chrome/browser/pref_set_observer.h
new file mode 100644
index 0000000000000000000000000000000000000000..47c947b6361b9fe52b78d6b2e27b535b10e09b78
--- /dev/null
+++ b/chrome/browser/pref_set_observer.h
@@ -0,0 +1,53 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_PREF_SET_OBSERVER_H_
+#define CHROME_BROWSER_PREF_SET_OBSERVER_H_
+
+#include <set>
+
+#include "base/basictypes.h"
+#include "chrome/browser/pref_service.h"
+#include "chrome/common/notification_observer.h"
+
+// Observes the state of a set of preferences and allows to query their combined
+// managed bits.
+class PrefSetObserver : public NotificationObserver {
+ public:
+ // Initialize with an empty set of preferences.
+ PrefSetObserver(PrefService* pref_service,
+ NotificationObserver* observer);
+ virtual ~PrefSetObserver();
+
+ // Add a |pref| to the set of preferences to observe.
+ void AddPref(const std::wstring& pref);
+ // Remove |pref| from the set of observed peferences.
+ void RemovePref(const std::wstring& pref);
+
+ // Check whether |pref| is in the set of observed preferences.
+ bool IsObserved(const std::wstring& pref);
+ // Check whether any of the observed preferences has the managed bit set.
+ bool IsManaged();
+
+ // Create a pref set observer for all preferences relavant to proxies.
+ static PrefSetObserver* CreateProxyPrefSetObserver(
+ PrefService* pref_service,
+ NotificationObserver* observer);
+
+ private:
+ // Overridden from NotificationObserver.
+ virtual void Observe(NotificationType type,
+ const NotificationSource& source,
+ const NotificationDetails& details);
+
+ typedef std::set<std::wstring> PrefSet;
+ PrefSet prefs_;
+
+ PrefService* pref_service_;
+ NotificationObserver* observer_;
+
+ DISALLOW_COPY_AND_ASSIGN(PrefSetObserver);
+};
+
+#endif // CHROME_BROWSER_PREF_SET_OBSERVER_H_
« no previous file with comments | « chrome/browser/pref_service.h ('k') | chrome/browser/pref_set_observer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698