1 // Copyright 2014 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.
5 #include "extensions/browser/extension_pref_store.h"
7 #include "base/values.h"
8 #include "extensions/browser/extension_pref_value_map.h"
10 ExtensionPrefStore::ExtensionPrefStore(
11 ExtensionPrefValueMap
* extension_pref_value_map
,
12 bool incognito_pref_store
)
13 : extension_pref_value_map_(extension_pref_value_map
),
14 incognito_pref_store_(incognito_pref_store
) {
15 extension_pref_value_map_
->AddObserver(this);
18 void ExtensionPrefStore::OnInitializationCompleted() {
19 NotifyInitializationCompleted();
22 void ExtensionPrefStore::OnPrefValueChanged(const std::string
& key
) {
23 CHECK(extension_pref_value_map_
);
24 const base::Value
*winner
=
25 extension_pref_value_map_
->GetEffectivePrefValue(key
,
26 incognito_pref_store_
,
29 SetValue(key
, winner
->DeepCopy());
34 void ExtensionPrefStore::OnExtensionPrefValueMapDestruction() {
35 CHECK(extension_pref_value_map_
);
36 extension_pref_value_map_
->RemoveObserver(this);
37 extension_pref_value_map_
= NULL
;
40 ExtensionPrefStore::~ExtensionPrefStore() {
41 if (extension_pref_value_map_
)
42 extension_pref_value_map_
->RemoveObserver(this);