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

Unified Diff: chrome/browser/prefs/pref_service.cc

Issue 7838030: WIP: Introduce per-TabContents PrefService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/prefs/pref_service.cc
diff --git a/chrome/browser/prefs/pref_service.cc b/chrome/browser/prefs/pref_service.cc
index 6cb98364ed38ee4d05345c2c50f46859adb20509..6118a3abe4eb5fb5e8f548ccd7f2b1e07d8c0c3f 100644
--- a/chrome/browser/prefs/pref_service.cc
+++ b/chrome/browser/prefs/pref_service.cc
@@ -27,6 +27,7 @@
#include "chrome/browser/prefs/pref_model_associator.h"
#include "chrome/browser/prefs/pref_notifier_impl.h"
#include "chrome/browser/prefs/pref_value_store.h"
+#include "chrome/browser/prefs/tab_contents_user_pref_store.h"
#include "chrome/browser/ui/profile_error_dialog.h"
#include "chrome/common/json_pref_store.h"
#include "content/browser/browser_thread.h"
@@ -151,64 +152,86 @@ PrefService* PrefService::CreatePrefService(const FilePath& pref_filename,
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE));
DefaultPrefStore* default_pref_store = new DefaultPrefStore();
- return new PrefService(
- managed_platform, managed_cloud, extension_prefs,
- command_line, user, recommended_platform,
- recommended_cloud, default_pref_store, async);
+ PrefNotifierImpl* notifier = new PrefNotifierImpl();
+ PrefService* prefs = new PrefService(
+ new PrefValueStore(managed_platform,
+ managed_cloud,
+ extension_prefs,
+ command_line,
+ user,
+ recommended_platform,
+ recommended_cloud,
+ default_pref_store,
+ notifier),
+ user,
+ default_pref_store,
+ notifier,
+ async);
+ PrefModelAssociator* associator = new PrefModelAssociator(prefs);
+ prefs->pref_sync_associator_.reset(associator);
+ notifier->SetPrefModelAssociator(associator);
+ return prefs;
}
PrefService* PrefService::CreateIncognitoPrefService(
PrefStore* incognito_extension_prefs) {
- return new PrefService(*this, incognito_extension_prefs);
+ PersistentPrefStore* incognito_user_prefs =
+ new IncognitoUserPrefStore(user_pref_store_.get());
+ // TODO(mnissler): This PrefNotifier needs to listen for notifications from
+ // the original |pref_notifier_| and forward notifications. We need to
+ // implement a wrapper that does this.
+ PrefNotifierImpl* pref_notifier = new PrefNotifierImpl();
+ return new PrefService(
+ pref_value_store_->CloneAndSpecialize(
+ NULL, // managed_platform_prefs
+ NULL, // managed_cloud_prefs
+ incognito_extension_prefs,
+ NULL, // command_line_prefs
+ incognito_user_prefs,
+ NULL, // recommended_platform_prefs
+ NULL, // recommended_cloud_prefs
+ default_store_.get(),
+ pref_notifier),
+ incognito_user_prefs,
+ default_store_.get(),
+ pref_notifier,
+ false);
}
-PrefService::PrefService(PrefStore* managed_platform_prefs,
- PrefStore* managed_cloud_prefs,
- PrefStore* extension_prefs,
- PrefStore* command_line_prefs,
+PrefService* PrefService::CreateTabContentsPrefService() {
+ PersistentPrefStore* tab_contents_user_prefs = new TabContentsUserPrefStore();
+ DefaultPrefStore* default_store = new DefaultPrefStore();
+ PrefNotifierImpl* pref_notifier = new PrefNotifierImpl();
+ return new PrefService(
+ pref_value_store_->CloneAndSpecialize(
+ NULL, // managed_platform_prefs
+ NULL, // managed_cloud_prefs
+ NULL, // extension_prefs
+ NULL, // command_line_prefs
+ tab_contents_user_prefs,
+ NULL, // recommended_platform_prefs
+ NULL, // recommended_cloud_prefs
+ default_store,
+ pref_notifier),
+ tab_contents_user_prefs,
+ default_store,
+ pref_notifier,
+ false);
+}
+
+PrefService::PrefService(PrefValueStore* pref_value_store,
PersistentPrefStore* user_prefs,
- PrefStore* recommended_platform_prefs,
- PrefStore* recommended_cloud_prefs,
DefaultPrefStore* default_store,
+ PrefNotifierImpl* pref_notifier,
bool async)
- : user_pref_store_(user_prefs),
+ : pref_notifier_(pref_notifier),
+ pref_value_store_(pref_value_store),
+ user_pref_store_(user_prefs),
default_store_(default_store) {
- pref_sync_associator_.reset(new PrefModelAssociator(this));
- pref_notifier_.reset(new PrefNotifierImpl(this));
- pref_value_store_.reset(
- new PrefValueStore(managed_platform_prefs,
- managed_cloud_prefs,
- extension_prefs,
- command_line_prefs,
- user_pref_store_,
- recommended_platform_prefs,
- recommended_cloud_prefs,
- default_store,
- pref_sync_associator_.get(),
- pref_notifier_.get()));
+ pref_notifier_->SetSource(this);
InitFromStorage(async);
}
-PrefService::PrefService(const PrefService& original,
- PrefStore* incognito_extension_prefs)
- : user_pref_store_(
- new IncognitoUserPrefStore(original.user_pref_store_.get())),
- default_store_(original.default_store_.get()) {
- // Incognito mode doesn't sync, so no need to create PrefModelAssociator.
- pref_notifier_.reset(new PrefNotifierImpl(this));
- pref_value_store_.reset(original.pref_value_store_->CloneAndSpecialize(
- NULL, // managed_platform_prefs
- NULL, // managed_cloud_prefs
- incognito_extension_prefs,
- NULL, // command_line_prefs
- user_pref_store_.get(),
- NULL, // recommended_platform_prefs
- NULL, // recommended_cloud_prefs
- default_store_.get(),
- NULL, // pref_sync_associator_
- pref_notifier_.get()));
-}
-
PrefService::~PrefService() {
DCHECK(CalledOnValidThread());
STLDeleteContainerPointers(prefs_.begin(), prefs_.end());

Powered by Google App Engine
This is Rietveld 408576698