From 0b1722f004e4424b18585a29234408b7112815cf Mon Sep 17 00:00:00 2001 From: sdefresne Date: Mon, 14 Sep 2015 11:12:12 -0700 Subject: Remove dependency of PrefSyncableService on PrefsTabHelper. In preparation of the componentization of PrefSyncableService (with the goal of sharing the code on iOS), remove the dependency on PrefsTabHelper by passing a list of preferences to register as overlaid. Add a helper method in chrome/browser/prefspref_service_syncable_util.cc to pass the list of preferences previously registered in PrefsTabHelper. Remove the method PrefsTabHelper::InitIncognitoUserPrefStore(). BUG=522536 TBR=jochen@chromium.org Review URL: https://codereview.chromium.org/1332283003 Cr-Commit-Position: refs/heads/master@{#348656} --- chrome/browser/prefs/pref_service_syncable_util.cc | 25 ++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'chrome/browser/prefs/pref_service_syncable_util.cc') diff --git a/chrome/browser/prefs/pref_service_syncable_util.cc b/chrome/browser/prefs/pref_service_syncable_util.cc index e3b099c..eac0df9 100644 --- a/chrome/browser/prefs/pref_service_syncable_util.cc +++ b/chrome/browser/prefs/pref_service_syncable_util.cc @@ -4,8 +4,17 @@ #include "chrome/browser/prefs/pref_service_syncable_util.h" +#include + +#include "base/logging.h" +#include "build/build_config.h" #include "chrome/browser/prefs/pref_service_syncable.h" #include "chrome/browser/profiles/profile.h" +#include "chrome/common/pref_names.h" + +#if defined(OS_ANDROID) || defined(OS_IOS) +#include "components/proxy_config/proxy_config_pref_names.h" +#endif PrefServiceSyncable* PrefServiceSyncableFromProfile(Profile* profile) { return static_cast(profile->GetPrefs()); @@ -14,3 +23,19 @@ PrefServiceSyncable* PrefServiceSyncableFromProfile(Profile* profile) { PrefServiceSyncable* PrefServiceSyncableIncognitoFromProfile(Profile* profile) { return static_cast(profile->GetOffTheRecordPrefs()); } + +PrefServiceSyncable* CreateIncognitoPrefServiceSyncable( + PrefServiceSyncable* pref_service, + PrefStore* incognito_extension_pref_store) { + // List of keys that cannot be changed in the user prefs file by the incognito + // profile. All preferences that store information about the browsing history + // or behavior of the user should have this property. + std::vector overlay_pref_names; + overlay_pref_names.push_back(prefs::kBrowserWindowPlacement); + overlay_pref_names.push_back(prefs::kSaveFileDefaultDirectory); +#if defined(OS_ANDROID) || defined(OS_IOS) + overlay_pref_names.push_back(proxy_config::prefs::kProxy); +#endif + return pref_service->CreateIncognitoPrefService( + incognito_extension_pref_store, overlay_pref_names); +} -- cgit v1.1