summaryrefslogtreecommitdiffstats
path: root/chrome/browser/prefs/default_pref_store.cc
diff options
context:
space:
mode:
authorbattre@chromium.org <battre@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-25 14:25:33 +0000
committerbattre@chromium.org <battre@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-25 14:25:33 +0000
commit9a8c4020cf135d7a9073cf22a69427f1259c5ed5 (patch)
treea4125b4f356d75cdea03dab1a07f3ae14e579e89 /chrome/browser/prefs/default_pref_store.cc
parent31a3130fedb27670365b40bc8cb6dc875957531f (diff)
downloadchromium_src-9a8c4020cf135d7a9073cf22a69427f1259c5ed5.zip
chromium_src-9a8c4020cf135d7a9073cf22a69427f1259c5ed5.tar.gz
chromium_src-9a8c4020cf135d7a9073cf22a69427f1259c5ed5.tar.bz2
Introduce incognito preference settings.
This CL introduces preference settings for incognito windows. The semantics are the following: - An extension can set regular preferences as before. These affect regular and incognito windows. - An extension can set regular preferences *and* incognito preferences. In this case, the incognito preferences affect only incognito windows. - If extension A sets reg+incognito, extension B sets reg but no incognito, extension B has higher precedence than A --> B's preferences hold for all regular and incognito windows. - Incognito preferences are never persisted to disk. In order to realize this, the ExtensionPrefs class allows setting regular and incognito extension controlled preferences. It allows creating an incognito version of the PrefService with an independent PrefValueStore. This (incognito) PrefValueStore and the original PrefValueStore share several of their PrefStores (i.e. DefaultPrefStore, CommandLinePrefStore, Configuration PrefStores) but differ in two pref stores: - We maintain two separate ExtensionPrefStores containing the effective preferences for regular and incognito windows. - We maintain two separate user pref stores. The regular JsonPrefStore is expanded by an OverlayPersistentPrefStore that maintains all write-operations in an in-memory overlay. Therefore, incognito changes are not visible in the file-backed JsonPrefStore. The two ExtensionPrefStores retrieve their effective values from a shared ExtensionPrefValueMap. The OffTheRecordProfileImpl provides a request_context_ that uses the new PrefService already. BUG=66027,69057 TEST=unit tests, will be fully testable once the Proxy Settings API allows incognito settings. Review URL: http://codereview.chromium.org/5915004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@72489 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/prefs/default_pref_store.cc')
-rw-r--r--chrome/browser/prefs/default_pref_store.cc20
1 files changed, 20 insertions, 0 deletions
diff --git a/chrome/browser/prefs/default_pref_store.cc b/chrome/browser/prefs/default_pref_store.cc
new file mode 100644
index 0000000..cacc833
--- /dev/null
+++ b/chrome/browser/prefs/default_pref_store.cc
@@ -0,0 +1,20 @@
+// 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/default_pref_store.h"
+
+DefaultPrefStore::DefaultPrefStore() {}
+
+DefaultPrefStore::~DefaultPrefStore() {}
+
+void DefaultPrefStore::SetDefaultValue(const std::string& key, Value* value) {
+ CHECK(GetValue(key, NULL) == READ_NO_VALUE);
+ SetValue(key, value);
+}
+
+Value::ValueType DefaultPrefStore::GetType(const std::string& key) const {
+ Value* value;
+ return GetValue(key, &value) == READ_OK ? value->GetType()
+ : Value::TYPE_NULL;
+}