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

Side by Side Diff: chrome/browser/protector/base_prefs_change.cc

Issue 11493003: Remove the protector service. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix implicit ExtensionSystem -> TemplateURLService dependency Created 8 years 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 (c) 2012 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/protector/base_prefs_change.h"
6
7 #include "base/bind.h"
8 #include "chrome/browser/prefs/pref_service.h"
9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/protector/protected_prefs_watcher.h"
11 #include "chrome/browser/protector/protector_service.h"
12 #include "chrome/browser/protector/protector_service_factory.h"
13 #include "chrome/browser/protector/protector_utils.h"
14 #include "chrome/common/chrome_notification_types.h"
15 #include "content/public/browser/notification_service.h"
16
17 namespace protector {
18
19 BasePrefsChange::BasePrefsChange() {
20 }
21
22 BasePrefsChange::~BasePrefsChange() {
23 }
24
25 bool BasePrefsChange::Init(Profile* profile) {
26 if (!BaseSettingChange::Init(profile))
27 return false;
28 pref_observer_.Init(profile->GetPrefs());
29 return true;
30 }
31
32 void BasePrefsChange::InitWhenDisabled(Profile* profile) {
33 // Forcibly set backup to match the actual settings so that no changes are
34 // detected on future runs.
35 ProtectorServiceFactory::GetForProfile(profile)->GetPrefsWatcher()->
36 ForceUpdateBackup();
37 }
38
39 void BasePrefsChange::DismissOnPrefChange(const std::string& pref_name) {
40 DCHECK(!pref_observer_.IsObserved(pref_name));
41 pref_observer_.Add(pref_name.c_str(),
42 base::Bind(&BasePrefsChange::OnPreferenceChanged,
43 base::Unretained(this)));
44 }
45
46 void BasePrefsChange::IgnorePrefChanges() {
47 pref_observer_.RemoveAll();
48 }
49
50 void BasePrefsChange::OnPreferenceChanged(const std::string& pref_name) {
51 DCHECK(pref_observer_.IsObserved(pref_name));
52 // Will delete this instance.
53 ProtectorServiceFactory::GetForProfile(profile())->DismissChange(this);
54 }
55
56 } // namespace protector
OLDNEW
« no previous file with comments | « chrome/browser/protector/base_prefs_change.h ('k') | chrome/browser/protector/base_setting_change.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698