blob: 01a0d62c275b726eb25ae5f6d84d5a8850cb7fb8 (
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
|
// Copyright (c) 2011 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/prefs/scoped_user_pref_update.h"
#include "base/logging.h"
#include "base/prefs/pref_notifier.h"
#include "chrome/browser/prefs/pref_service.h"
namespace subtle {
ScopedUserPrefUpdateBase::ScopedUserPrefUpdateBase(PrefService* service,
const char* path)
: service_(service),
path_(path),
value_(NULL) {}
ScopedUserPrefUpdateBase::~ScopedUserPrefUpdateBase() {
Notify();
}
Value* ScopedUserPrefUpdateBase::GetValueOfType(base::Value::Type type) {
if (!value_)
value_ = service_->GetMutableUserPref(path_.c_str(), type);
return value_;
}
void ScopedUserPrefUpdateBase::Notify() {
if (value_) {
service_->ReportUserPrefChanged(path_);
value_ = NULL;
}
}
} // namespace subtle
|