Commit 275d9f6a authored by Ramin Halavati's avatar Ramin Halavati Committed by Commit Bot

Move incognito persistent preferences list.

The list of preferences that are stored in user profile when changed
from incognito mode are moved from
'chrome/browser/prefs/pref_service_syncable_util.cc'
to
'chrome/browser/prefs/pref_service_incognito_whitelist.cc'.

Bug: 861722
Change-Id: Ic13e7c45f5c82193bf29cfdeac2d3ffe7c186fc9
Reviewed-on: https://chromium-review.googlesource.com/1158064
Commit-Queue: Ramin Halavati <rhalavati@chromium.org>
Reviewed-by: default avatarGabriel Charette <gab@chromium.org>
Cr-Commit-Position: refs/heads/master@{#579832}
parent d9116474
......@@ -3,8 +3,6 @@ bauerb@chromium.org
gab@chromium.org
pam@chromium.org
# For Incognito Whitelist
per-file pref_service_incognito_whitelist.cc=rhalavati@chromium.org
per-file pref_service_syncable_util.cc=rhalavati@chromium.org
# COMPONENT: UI>Browser>Preferences
......@@ -60,13 +60,46 @@
namespace {
// TODO(https://crbug.com/861722): Remove this list and file.
//
// WARNING: PLEASE DO NOT ADD ANYTHING TO THIS FILE.
// This file is temporarily added for transition of incognito preferences
// List of keys that can be changed in the user prefs file by the incognito
// profile.
const char* persistent_pref_names[] = {
#if defined(OS_CHROMEOS)
// Accessibility preferences should be persisted if they are changed in
// incognito mode.
ash::prefs::kAccessibilityLargeCursorEnabled,
ash::prefs::kAccessibilityLargeCursorDipSize,
ash::prefs::kAccessibilityStickyKeysEnabled,
ash::prefs::kAccessibilitySpokenFeedbackEnabled,
ash::prefs::kAccessibilityHighContrastEnabled,
ash::prefs::kAccessibilityScreenMagnifierCenterFocus,
ash::prefs::kAccessibilityScreenMagnifierEnabled,
ash::prefs::kAccessibilityScreenMagnifierScale,
ash::prefs::kAccessibilityVirtualKeyboardEnabled,
ash::prefs::kAccessibilityMonoAudioEnabled,
ash::prefs::kAccessibilityAutoclickEnabled,
ash::prefs::kAccessibilityAutoclickDelayMs,
ash::prefs::kAccessibilityCaretHighlightEnabled,
ash::prefs::kAccessibilityCursorHighlightEnabled,
ash::prefs::kAccessibilityFocusHighlightEnabled,
ash::prefs::kAccessibilitySelectToSpeakEnabled,
ash::prefs::kAccessibilitySwitchAccessEnabled,
ash::prefs::kAccessibilityDictationEnabled,
ash::prefs::kDockedMagnifierEnabled,
ash::prefs::kDockedMagnifierScale,
ash::prefs::kDockedMagnifierAcceleratorDialogHasBeenAccepted,
ash::prefs::kHighContrastAcceleratorDialogHasBeenAccepted,
ash::prefs::kScreenMagnifierAcceleratorDialogHasBeenAccepted,
ash::prefs::kShouldAlwaysShowAccessibilityMenu
#endif // defined(OS_CHROMEOS)
};
// TODO(https://crbug.com/861722): Remove this list.
// WARNING: PLEASE DO NOT ADD ANYTHING TO THIS LIST.
// This list is temporarily added for transition of incognito preferences
// storage default, from on disk to in memory. All items in this list will be
// audited and checked with owners and removed from whitelist.
const char* incognito_whitelist[] = {
// audited, checked with owners, and removed or transfered to
// |persistent_pref_names|.
const char* temporary_incognito_whitelist[] = {
// ash/public/cpp/ash_pref_names.h
#if defined(OS_CHROMEOS)
ash::prefs::kDetachableBaseDevices, ash::prefs::kEnableStylusTools,
......@@ -969,14 +1002,20 @@ const char* incognito_whitelist[] = {
namespace prefs {
// TODO(https://crbug.com/861722): Remove this function and file.
// WARNING: PLEASE DO NOT ADD ANYTHING TO THIS FILE.
// This is temporarily added for transition of incognito preferences
// storage default, from on disk to in memory. All items in this list will be
// audited and checked with owners and removed from whitelist.
void GetIncognitoWhitelist(std::vector<const char*>* whitelist) {
whitelist->insert(whitelist->end(), incognito_whitelist,
incognito_whitelist + base::size(incognito_whitelist));
std::vector<const char*> GetIncognitoPersistentPrefsWhitelist() {
std::vector<const char*> whitelist;
// TODO(https://crbug.com/861722): Change to base::size when the list is non-
// empty for all platforms.
whitelist.insert(
whitelist.end(), persistent_pref_names,
persistent_pref_names + sizeof(persistent_pref_names) / sizeof(char*));
// TODO(https://crbug.com/861722): Remove after the list is audited and
// emptied.
whitelist.insert(whitelist.end(), temporary_incognito_whitelist,
temporary_incognito_whitelist +
base::size(temporary_incognito_whitelist));
return whitelist;
}
} // namespace prefs
......@@ -9,9 +9,10 @@
namespace prefs {
// Populate a whitelist of all preferences that are stored on disk in incognito
// mode. Please refer to the comments in .cc file.
void GetIncognitoWhitelist(std::vector<const char*>* whitelist);
// Populate a list of all preferences that are stored in user profile in
// incognito mode.
// Please refer to the comments in .cc file.
std::vector<const char*> GetIncognitoPersistentPrefsWhitelist();
} // namespace prefs
......
......@@ -10,9 +10,6 @@
#include "chrome/browser/profiles/profile.h"
#include "components/sync_preferences/pref_service_syncable.h"
#if defined(OS_CHROMEOS)
#include "ash/public/cpp/ash_pref_names.h"
#endif // defined(OS_CHROMEOS)
sync_preferences::PrefServiceSyncable* PrefServiceSyncableFromProfile(
Profile* profile) {
......@@ -31,51 +28,11 @@ CreateIncognitoPrefServiceSyncable(
sync_preferences::PrefServiceSyncable* pref_service,
PrefStore* incognito_extension_pref_store,
std::unique_ptr<PrefValueStore::Delegate> delegate) {
// List of keys that can be changed in the user prefs file by the incognito
// profile.
static const char* persistent_pref_names[] = {
#if defined(OS_CHROMEOS)
// Accessibility preferences should be persisted if they are changed in
// incognito mode.
ash::prefs::kAccessibilityLargeCursorEnabled,
ash::prefs::kAccessibilityLargeCursorDipSize,
ash::prefs::kAccessibilityStickyKeysEnabled,
ash::prefs::kAccessibilitySpokenFeedbackEnabled,
ash::prefs::kAccessibilityHighContrastEnabled,
ash::prefs::kAccessibilityScreenMagnifierCenterFocus,
ash::prefs::kAccessibilityScreenMagnifierEnabled,
ash::prefs::kAccessibilityScreenMagnifierScale,
ash::prefs::kAccessibilityVirtualKeyboardEnabled,
ash::prefs::kAccessibilityMonoAudioEnabled,
ash::prefs::kAccessibilityAutoclickEnabled,
ash::prefs::kAccessibilityAutoclickDelayMs,
ash::prefs::kAccessibilityCaretHighlightEnabled,
ash::prefs::kAccessibilityCursorHighlightEnabled,
ash::prefs::kAccessibilityFocusHighlightEnabled,
ash::prefs::kAccessibilitySelectToSpeakEnabled,
ash::prefs::kAccessibilitySwitchAccessEnabled,
ash::prefs::kAccessibilityDictationEnabled,
ash::prefs::kDockedMagnifierEnabled,
ash::prefs::kDockedMagnifierScale,
ash::prefs::kDockedMagnifierAcceleratorDialogHasBeenAccepted,
ash::prefs::kHighContrastAcceleratorDialogHasBeenAccepted,
ash::prefs::kScreenMagnifierAcceleratorDialogHasBeenAccepted,
ash::prefs::kShouldAlwaysShowAccessibilityMenu
#endif // defined(OS_CHROMEOS)
};
// TODO(https://crbug.com/861722): Remove |GetIncognitoWhitelist|, its
// file, and |persistent_prefs|.
// This list is ONLY added for transition of code from blacklist to whitelist.
std::vector<const char*> persistent_prefs;
prefs::GetIncognitoWhitelist(&persistent_prefs);
persistent_prefs.insert(
persistent_prefs.end(), persistent_pref_names,
persistent_pref_names + sizeof(persistent_pref_names) / sizeof(char*));
// TODO(https://crbug.com/861722): Current implementation does not cover
// preferences from iOS. The code should be refactored to cover it.
return pref_service->CreateIncognitoPrefService(
incognito_extension_pref_store, persistent_prefs, std::move(delegate));
incognito_extension_pref_store,
prefs::GetIncognitoPersistentPrefsWhitelist(), std::move(delegate));
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment