summaryrefslogtreecommitdiffstats
path: root/chrome/browser/managed_prefs_banner_base.cc
diff options
context:
space:
mode:
authormnissler@chromium.org <mnissler@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-08 09:55:47 +0000
committermnissler@chromium.org <mnissler@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-08 09:55:47 +0000
commit1703157a0410dbd23b8968aa8e6ce9e4adc45def (patch)
treeef2744a079dd79302e9e334c47bf227341243c94 /chrome/browser/managed_prefs_banner_base.cc
parentc7f143e3f200aa626af2e29fec1f801081b2e31a (diff)
downloadchromium_src-1703157a0410dbd23b8968aa8e6ce9e4adc45def.zip
chromium_src-1703157a0410dbd23b8968aa8e6ce9e4adc45def.tar.gz
chromium_src-1703157a0410dbd23b8968aa8e6ce9e4adc45def.tar.bz2
Managed preferences warning banner for the Linux preferences dialog.
BUG=43423 TEST=Unit test in managed_prefs_banner_base_unittest.cc, manual UI tests Review URL: http://codereview.chromium.org/2425006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@49151 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/managed_prefs_banner_base.cc')
-rw-r--r--chrome/browser/managed_prefs_banner_base.cc47
1 files changed, 47 insertions, 0 deletions
diff --git a/chrome/browser/managed_prefs_banner_base.cc b/chrome/browser/managed_prefs_banner_base.cc
new file mode 100644
index 0000000..5251d7f
--- /dev/null
+++ b/chrome/browser/managed_prefs_banner_base.cc
@@ -0,0 +1,47 @@
+// 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 "chrome/browser/managed_prefs_banner_base.h"
+
+#include "chrome/browser/pref_service.h"
+#include "chrome/common/notification_details.h"
+#include "chrome/common/notification_source.h"
+#include "chrome/common/notification_type.h"
+
+ManagedPrefsBannerBase::ManagedPrefsBannerBase(PrefService* prefs,
+ const wchar_t** relevant_prefs,
+ size_t count)
+ : prefs_(prefs),
+ relevant_prefs_(relevant_prefs, relevant_prefs + count) {
+ for (PrefSet::const_iterator pref(relevant_prefs_.begin());
+ pref != relevant_prefs_.end(); ++pref)
+ prefs_->AddPrefObserver(pref->c_str(), this);
+}
+
+ManagedPrefsBannerBase::~ManagedPrefsBannerBase() {
+ for (PrefSet::const_iterator pref(relevant_prefs_.begin());
+ pref != relevant_prefs_.end(); ++pref)
+ prefs_->RemovePrefObserver(pref->c_str(), this);
+}
+
+void ManagedPrefsBannerBase::Observe(NotificationType type,
+ const NotificationSource& source,
+ const NotificationDetails& details) {
+ if (NotificationType::PREF_CHANGED == type) {
+ std::wstring* pref = Details<std::wstring>(details).ptr();
+ if (pref && relevant_prefs_.count(*pref))
+ OnUpdateVisibility();
+ }
+}
+
+bool ManagedPrefsBannerBase::DetermineVisibility() const {
+ for (PrefSet::const_iterator pref_name(relevant_prefs_.begin());
+ pref_name != relevant_prefs_.end(); ++pref_name) {
+ const PrefService::Preference* pref =
+ prefs_->FindPreference(pref_name->c_str());
+ if (pref && pref->IsManaged())
+ return true;
+ }
+ return false;
+}