blob: b7708b3700fdddfd22aafadb43ad9564cd6dc07c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
// Copyright (c) 2012 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/protector/base_prefs_change.h"
#include "base/bind.h"
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/protector/protected_prefs_watcher.h"
#include "chrome/browser/protector/protector_service.h"
#include "chrome/browser/protector/protector_service_factory.h"
#include "chrome/browser/protector/protector_utils.h"
#include "chrome/common/chrome_notification_types.h"
#include "content/public/browser/notification_service.h"
namespace protector {
BasePrefsChange::BasePrefsChange() {
}
BasePrefsChange::~BasePrefsChange() {
}
bool BasePrefsChange::Init(Profile* profile) {
if (!BaseSettingChange::Init(profile))
return false;
pref_observer_.Init(profile->GetPrefs());
return true;
}
void BasePrefsChange::InitWhenDisabled(Profile* profile) {
// Forcibly set backup to match the actual settings so that no changes are
// detected on future runs.
ProtectorServiceFactory::GetForProfile(profile)->GetPrefsWatcher()->
ForceUpdateBackup();
}
void BasePrefsChange::DismissOnPrefChange(const std::string& pref_name) {
DCHECK(!pref_observer_.IsObserved(pref_name));
pref_observer_.Add(pref_name.c_str(),
base::Bind(&BasePrefsChange::OnPreferenceChanged,
base::Unretained(this)));
}
void BasePrefsChange::IgnorePrefChanges() {
pref_observer_.RemoveAll();
}
void BasePrefsChange::OnPreferenceChanged(const std::string& pref_name) {
DCHECK(pref_observer_.IsObserved(pref_name));
// Will delete this instance.
ProtectorServiceFactory::GetForProfile(profile())->DismissChange(this);
}
} // namespace protector
|