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

Side by Side Diff: chrome/browser/extensions/extension_pref_store.cc

Issue 5915004: Introduce incognito preference settings. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed Mattias' feedback Created 9 years, 11 months 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
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 if (extension_pref_value_map_)
Mattias Nissler (ping if slow) 2011/01/07 10:12:58 Why the conditional? This parameter should always
battre 2011/01/10 16:55:47 Done.
16 extension_pref_value_map_->AddObserver(this);
9 } 17 }
10 18
11 void ExtensionPrefStore::SetExtensionPref(const std::string& key, 19 ExtensionPrefStore::~ExtensionPrefStore() {
12 Value* value) { 20 if (extension_pref_value_map_)
13 SetValue(key, value); 21 extension_pref_value_map_->RemoveObserver(this);
14 }
15
16 void ExtensionPrefStore::RemoveExtensionPref(const std::string& key) {
17 RemoveValue(key);
18 } 22 }
19 23
20 void ExtensionPrefStore::OnInitializationCompleted() { 24 void ExtensionPrefStore::OnInitializationCompleted() {
21 DCHECK(!initialization_complete_);
22 initialization_complete_ = true;
23 NotifyInitializationCompleted(); 25 NotifyInitializationCompleted();
24 } 26 }
25 27
26 bool ExtensionPrefStore::IsInitializationComplete() const { 28 void ExtensionPrefStore::OnPrefValueChanged(const std::string& key) {
27 return initialization_complete_; 29 CHECK(extension_pref_value_map_);
30 const Value *winner =
31 extension_pref_value_map_->GetEffectivePrefValue(key,
32 incognito_pref_store_);
33 if (winner)
34 SetValue(key, winner->DeepCopy());
35 else
36 RemoveValue(key);
28 } 37 }
38
39 void ExtensionPrefStore::OnExtensionPrefValueMapDestruction() {
40 CHECK(extension_pref_value_map_);
41 extension_pref_value_map_->RemoveObserver(this);
42 extension_pref_value_map_ = NULL;
43 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698