diff options
author | evan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-26 00:22:02 +0000 |
---|---|---|
committer | evan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-26 00:22:02 +0000 |
commit | 37858e5c2f58f4b46117c65df2ab3da8a7b2e6e2 (patch) | |
tree | f3acb53adbd2d0ffe5e113d6c057fdee9bcc6dcd /chrome/browser/policy/managed_prefs_banner_base.h | |
parent | feecbf07dbc4b4c94dceb5e0043889126d213f6e (diff) | |
download | chromium_src-37858e5c2f58f4b46117c65df2ab3da8a7b2e6e2.zip chromium_src-37858e5c2f58f4b46117c65df2ab3da8a7b2e6e2.tar.gz chromium_src-37858e5c2f58f4b46117c65df2ab3da8a7b2e6e2.tar.bz2 |
Move prefs-related files under chrome/browser/ into a prefs/ subdir.
Rename includes, resort header include order in places where the rename
changed the order.
BUG=50548
TEST=compiles
Review URL: http://codereview.chromium.org/3203008
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@57434 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/policy/managed_prefs_banner_base.h')
-rw-r--r-- | chrome/browser/policy/managed_prefs_banner_base.h | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/chrome/browser/policy/managed_prefs_banner_base.h b/chrome/browser/policy/managed_prefs_banner_base.h new file mode 100644 index 0000000..eb5bf90 --- /dev/null +++ b/chrome/browser/policy/managed_prefs_banner_base.h @@ -0,0 +1,68 @@ +// 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_POLICY_MANAGED_PREFS_BANNER_BASE_H_ +#define CHROME_BROWSER_POLICY_MANAGED_PREFS_BANNER_BASE_H_ +#pragma once + +#include "base/basictypes.h" +#include "base/scoped_ptr.h" +#include "chrome/browser/options_window.h" +#include "chrome/browser/prefs/pref_set_observer.h" +#include "chrome/common/notification_observer.h" + +class PrefService; + +// Common base functionality for the managed prefs warning banner displayed in +// the preference dialogs when there are options that are controlled by +// configuration policy and thus cannot be changed by the user. +class ManagedPrefsBannerBase : public NotificationObserver { + public: + // Initialize the banner with a set of preferences suitable for the given + // options |page|. Subclasses may change that set by calling AddPref() and + // RemovePref() afterwards. + ManagedPrefsBannerBase(PrefService* local_state, + PrefService* user_prefs, + OptionsPage page); + + // Convenience constructor that fetches the local state PrefService from the + // global g_browser_process. + ManagedPrefsBannerBase(PrefService* user_prefs, OptionsPage page); + + // Determine whether the banner should be visible. + bool DetermineVisibility() const; + + // Add a local state preference as visibility trigger. + void AddLocalStatePref(const char* pref); + // Remove a local state preference from being a visibility trigger. + void RemoveLocalStatePref(const char* pref); + + // Add a user preference as visibility trigger. + void AddUserPref(const char* pref); + // Remove a user preference from being a visibility trigger. + void RemoveUserPref(const char* pref); + + protected: + // Update banner visibility. This is called whenever a preference change is + // observed that may lead to changed visibility of the banner. Subclasses may + // override this in order to show/hide the banner. + virtual void OnUpdateVisibility() { } + + private: + // Initialization helper, called from the constructors. + void Init(PrefService* local_state, + PrefService* user_prefs, + OptionsPage page); + + // |NotificationObserver| implementation. + virtual void Observe(NotificationType type, + const NotificationSource& source, + const NotificationDetails& details); + + scoped_ptr<PrefSetObserver> local_state_set_; + scoped_ptr<PrefSetObserver> user_pref_set_; + + DISALLOW_COPY_AND_ASSIGN(ManagedPrefsBannerBase); +}; +#endif // CHROME_BROWSER_POLICY_MANAGED_PREFS_BANNER_BASE_H_ |