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

Side by Side Diff: chrome/browser/managed_mode/managed_user_settings_service.cc

Issue 23466004: Add ManagedUserSettingsService and a SupervisedUserPrefStore using it. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years, 3 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 2013 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/managed_mode/managed_user_settings_service.h"
6
7 #include "base/callback.h"
8 #include "base/logging.h"
9
10 void ManagedUserSettingsService::Subscribe(const SettingsCallback& callback) {
11 if (IsReady()) {
12 scoped_ptr<base::DictionaryValue> settings = GetSettingsIfActive();
13 callback.Run(settings.get());
14 }
15
16 subscribers_.push_back(callback);
17 }
18
19 void ManagedUserSettingsService::Activate() {
20 active_ = true;
21 NotifySettingsChanged();
22 }
23
24 ManagedUserSettingsService::ManagedUserSettingsService() : active_(false) {}
25 ManagedUserSettingsService::~ManagedUserSettingsService() {}
26
27 scoped_ptr<base::DictionaryValue>
28 ManagedUserSettingsService::GetSettingsIfActive() {
29 DCHECK(IsReady());
30 if (!active_)
31 return scoped_ptr<base::DictionaryValue>();
32
33 return GetSettings();
34 }
35
36 void ManagedUserSettingsService::NotifySettingsChanged() {
37 if (!IsReady())
38 return;
39
40 scoped_ptr<base::DictionaryValue> settings = GetSettingsIfActive();
41 for (std::vector<SettingsCallback>::iterator it = subscribers_.begin();
42 it != subscribers_.end(); ++it) {
43 it->Run(settings.get());
44 }
45 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698