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

Side by Side Diff: chrome/browser/pref_set_observer.cc

Issue 3038013: Disable proxy config button and show banner if proxy prefs are managed. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: fix nits 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 unified diff | Download patch
« no previous file with comments | « chrome/browser/pref_set_observer.h ('k') | chrome/browser/pref_set_observer_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 #include "chrome/browser/pref_set_observer.h"
6
7 #include "chrome/common/notification_type.h"
8 #include "chrome/common/pref_names.h"
9
10 PrefSetObserver::PrefSetObserver(PrefService* pref_service,
11 NotificationObserver* observer)
12 : pref_service_(pref_service),
13 observer_(observer) {
14 }
15
16 PrefSetObserver::~PrefSetObserver() {
17 for (PrefSet::const_iterator i(prefs_.begin()); i != prefs_.end(); ++i)
18 pref_service_->RemovePrefObserver(i->c_str(), this);
19 }
20
21 void PrefSetObserver::AddPref(const std::wstring& pref) {
22 if (!prefs_.count(pref) && pref_service_->FindPreference(pref.c_str())) {
23 prefs_.insert(pref);
24 pref_service_->AddPrefObserver(pref.c_str(), this);
25 }
26 }
27
28 void PrefSetObserver::RemovePref(const std::wstring& pref) {
29 if (prefs_.erase(pref))
30 pref_service_->RemovePrefObserver(pref.c_str(), this);
31 }
32
33 bool PrefSetObserver::IsObserved(const std::wstring& pref) {
34 return prefs_.count(pref) > 0;
35 }
36
37 bool PrefSetObserver::IsManaged() {
38 for (PrefSet::const_iterator i(prefs_.begin()); i != prefs_.end(); ++i) {
39 const PrefService::Preference* pref =
40 pref_service_->FindPreference(i->c_str());
41 if (pref && pref->IsManaged())
42 return true;
43 }
44 return false;
45 }
46
47 // static
48 PrefSetObserver* PrefSetObserver::CreateProxyPrefSetObserver(
49 PrefService* pref_service,
50 NotificationObserver* observer) {
51 PrefSetObserver* pref_set = new PrefSetObserver(pref_service, observer);
52 pref_set->AddPref(prefs::kNoProxyServer);
53 pref_set->AddPref(prefs::kProxyAutoDetect);
54 pref_set->AddPref(prefs::kProxyServer);
55 pref_set->AddPref(prefs::kProxyPacUrl);
56 pref_set->AddPref(prefs::kProxyBypassList);
57
58 return pref_set;
59 }
60
61 void PrefSetObserver::Observe(NotificationType type,
62 const NotificationSource& source,
63 const NotificationDetails& details) {
64 if (observer_)
65 observer_->Observe(type, source, details);
66 }
OLDNEW
« no previous file with comments | « chrome/browser/pref_set_observer.h ('k') | chrome/browser/pref_set_observer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698