Logo Search packages:      
Sourcecode: chromium-browser version File versions  Download package


// 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.


#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 {
  // 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);

  // 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_;



Generated by  Doxygen 1.6.0   Back to index