| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/extensions/extension_pref_store.h" | 5 #include "chrome/browser/extensions/extension_pref_store.h" |
| 6 | 6 |
| 7 ExtensionPrefStore::ExtensionPrefStore() | 7 #include "base/values.h" |
| 8 : initialization_complete_(false) { | 8 #include "chrome/browser/extensions/extension_pref_value_map.h" |
| 9 |
| 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); |
| 9 } | 16 } |
| 10 | 17 |
| 11 void ExtensionPrefStore::SetExtensionPref(const std::string& key, | 18 ExtensionPrefStore::~ExtensionPrefStore() { |
| 12 Value* value) { | 19 if (extension_pref_value_map_) |
| 13 SetValue(key, value); | 20 extension_pref_value_map_->RemoveObserver(this); |
| 14 } | |
| 15 | |
| 16 void ExtensionPrefStore::RemoveExtensionPref(const std::string& key) { | |
| 17 RemoveValue(key); | |
| 18 } | 21 } |
| 19 | 22 |
| 20 void ExtensionPrefStore::OnInitializationCompleted() { | 23 void ExtensionPrefStore::OnInitializationCompleted() { |
| 21 DCHECK(!initialization_complete_); | |
| 22 initialization_complete_ = true; | |
| 23 NotifyInitializationCompleted(); | 24 NotifyInitializationCompleted(); |
| 24 } | 25 } |
| 25 | 26 |
| 26 bool ExtensionPrefStore::IsInitializationComplete() const { | 27 void ExtensionPrefStore::OnPrefValueChanged(const std::string& key) { |
| 27 return initialization_complete_; | 28 CHECK(extension_pref_value_map_); |
| 29 const Value *winner = |
| 30 extension_pref_value_map_->GetEffectivePrefValue(key, |
| 31 incognito_pref_store_); |
| 32 if (winner) |
| 33 SetValue(key, winner->DeepCopy()); |
| 34 else |
| 35 RemoveValue(key); |
| 28 } | 36 } |
| 37 |
| 38 void ExtensionPrefStore::OnExtensionPrefValueMapDestruction() { |
| 39 CHECK(extension_pref_value_map_); |
| 40 extension_pref_value_map_->RemoveObserver(this); |
| 41 extension_pref_value_map_ = NULL; |
| 42 } |
| OLD | NEW |