1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome/browser/prefs/pref_service_syncable_util.h"
9 #include "base/logging.h"
10 #include "build/build_config.h"
11 #include "chrome/browser/profiles/profile.h"
12 #include "chrome/common/pref_names.h"
13 #include "components/syncable_prefs/pref_service_syncable.h"
15 #if defined(OS_ANDROID) || defined(OS_IOS)
16 #include "components/proxy_config/proxy_config_pref_names.h"
19 syncable_prefs::PrefServiceSyncable
* PrefServiceSyncableFromProfile(
21 return static_cast<syncable_prefs::PrefServiceSyncable
*>(profile
->GetPrefs());
24 syncable_prefs::PrefServiceSyncable
* PrefServiceSyncableIncognitoFromProfile(
26 return static_cast<syncable_prefs::PrefServiceSyncable
*>(
27 profile
->GetOffTheRecordPrefs());
30 syncable_prefs::PrefServiceSyncable
* CreateIncognitoPrefServiceSyncable(
31 syncable_prefs::PrefServiceSyncable
* pref_service
,
32 PrefStore
* incognito_extension_pref_store
) {
33 // List of keys that cannot be changed in the user prefs file by the incognito
34 // profile. All preferences that store information about the browsing history
35 // or behavior of the user should have this property.
36 std::vector
<const char*> overlay_pref_names
;
37 overlay_pref_names
.push_back(prefs::kBrowserWindowPlacement
);
38 overlay_pref_names
.push_back(prefs::kSaveFileDefaultDirectory
);
39 #if defined(OS_ANDROID) || defined(OS_IOS)
40 overlay_pref_names
.push_back(proxy_config::prefs::kProxy
);
42 return pref_service
->CreateIncognitoPrefService(
43 incognito_extension_pref_store
, overlay_pref_names
);