ash: Remove obsolete standalone browser pref store
The store was used for Lacros and is not needed anymore. Remove the code but leave a cleanup function that deletes any remaining pref file (this function existed already because the storage location had changed - extend it to handle the last location as well). Bug: b:365741912 Change-Id: I72c4e70e5797c4f090831ffa62eaf2101659c718 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6108538 Code-Coverage: findit-for-me@appspot.gserviceaccount.com <findit-for-me@appspot.gserviceaccount.com> Reviewed-by: Hidehiko Abe <hidehiko@chromium.org> Reviewed-by: Colin Blundell <blundell@chromium.org> Commit-Queue: Georg Neis <neis@chromium.org> Cr-Commit-Position: refs/heads/main@{#1398973}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
d1a452b79e
commit
2e0831901a
ash
chrome
browser
ash
crosapi
password_manager
prefs
ui
test
components
@ -34,8 +34,6 @@ class PolicyRecommendationRestorerTest : public NoSessionAshTestBase {
|
||||
/*managed_prefs=*/base::MakeRefCounted<TestingPrefStore>(),
|
||||
/*supervised_user_prefs=*/base::MakeRefCounted<TestingPrefStore>(),
|
||||
/*extension_prefs=*/base::MakeRefCounted<TestingPrefStore>(),
|
||||
/*standalone_browser_prefs=*/
|
||||
base::MakeRefCounted<TestingPrefStore>(),
|
||||
/*user_prefs=*/base::MakeRefCounted<TestingPrefStore>(),
|
||||
recommended_prefs_,
|
||||
base::MakeRefCounted<user_prefs::PrefRegistrySyncable>(),
|
||||
|
@ -255,13 +255,12 @@ class PowerPrefsTest : public NoSessionAshTestBase {
|
||||
auto pref_value_store = std::make_unique<PrefValueStore>(
|
||||
managed_pref_store_.get() /* managed_prefs */,
|
||||
nullptr /* supervised_user_prefs */, nullptr /* extension_prefs */,
|
||||
nullptr /* standalone_browser_prefs */,
|
||||
nullptr /* command_line_prefs */, user_pref_store_.get(),
|
||||
nullptr /* recommended_prefs */, pref_registry_->defaults().get(),
|
||||
pref_notifier.get());
|
||||
local_state_ = std::make_unique<PrefService>(
|
||||
std::move(pref_notifier), std::move(pref_value_store), user_pref_store_,
|
||||
nullptr, pref_registry_, base::DoNothing(), false);
|
||||
pref_registry_, base::DoNothing(), false);
|
||||
|
||||
PowerPrefs::RegisterLocalStatePrefs(pref_registry_.get());
|
||||
|
||||
|
@ -203,11 +203,6 @@ void BrowserManager::OnLacrosUserDataDirRemoved(bool cleared) {
|
||||
CHECK_IS_TEST();
|
||||
return;
|
||||
}
|
||||
PrefService* pref_service = user_prefs::UserPrefs::Get(context);
|
||||
|
||||
// Clear prefs set by Lacros and stored in
|
||||
// 'standalone_browser_preferences.json' if Lacros is disabled.
|
||||
pref_service->RemoveAllStandaloneBrowserPrefs();
|
||||
|
||||
// Do a one time clearing of `kUserUninstalledPreinstalledWebAppPref`. This is
|
||||
// because some users who had Lacros enabled before M114 had this pref set by
|
||||
@ -216,6 +211,7 @@ void BrowserManager::OnLacrosUserDataDirRemoved(bool cleared) {
|
||||
// uninstalled (and cannot easily be reinstalled). Note that this means that
|
||||
// some users who intentionally uninstalled these apps on Lacros will find
|
||||
// these apps reappear until they unistall them again.
|
||||
PrefService* pref_service = user_prefs::UserPrefs::Get(context);
|
||||
web_app::UserUninstalledPreinstalledWebAppPrefs(pref_service).ClearAllApps();
|
||||
}
|
||||
|
||||
|
@ -1047,7 +1047,6 @@ class UsesSplitStoresAndUPMForLocalTest : public ::testing::Test {
|
||||
base::MakeRefCounted<TestingPrefStore>(),
|
||||
base::MakeRefCounted<TestingPrefStore>(),
|
||||
base::MakeRefCounted<TestingPrefStore>(),
|
||||
base::MakeRefCounted<TestingPrefStore>(),
|
||||
/*user_pref_store=*/user_pref_store_,
|
||||
base::MakeRefCounted<TestingPrefStore>(), pref_registry,
|
||||
std::make_unique<PrefNotifierImpl>()));
|
||||
|
@ -418,10 +418,6 @@ source_set("unit_tests") {
|
||||
"//ui/base",
|
||||
"//url",
|
||||
]
|
||||
|
||||
if (is_chromeos) {
|
||||
sources += [ "chrome_pref_service_factory_ash_unittest.cc" ]
|
||||
}
|
||||
}
|
||||
|
||||
if (!is_android) {
|
||||
|
@ -295,31 +295,22 @@ std::unique_ptr<ProfilePrefStoreManager> CreateProfilePrefStoreManager(
|
||||
}
|
||||
|
||||
#if BUILDFLAG(IS_CHROMEOS_ASH)
|
||||
// The initial implementation of the standalone browser store
|
||||
// saved the preferences associated with a user under /home/chronos, which made
|
||||
// the prefs available for all users which subsequently log in on the device.
|
||||
// Currently the preferences are stored under the user profile directory. This
|
||||
// method cleans up the standalone browser preferences file under /home/chronos.
|
||||
// Note that the standalone browser preferences can't be migrated from the
|
||||
// /home/chronos directory to the profile directory because it's not possible to
|
||||
// know which profile has configured the settings. Once the user signs into the
|
||||
// user session and starts the Lacros browser, the standalone browser settings
|
||||
// will be restored in Ash and saved to the correct location.
|
||||
// TODO(b/304685319): Remove this cleanup method.
|
||||
void CleanupObsoleteStandaloneBrowserPrefsFile() {
|
||||
// The standalone browser prefs store does not exist anymore but there may still
|
||||
// be files left on disk. Delete them.
|
||||
// TODO(crbug.com/380780352): Remove this code after the stepping stone.
|
||||
void CleanupObsoleteStandaloneBrowserPrefsFile(
|
||||
const base::FilePath& profile_path) {
|
||||
base::FilePath file(FILE_PATH_LITERAL("standalone_browser_preferences.json"));
|
||||
base::FilePath user_data_dir;
|
||||
CHECK(base::PathService::Get(chrome::DIR_USER_DATA, &user_data_dir));
|
||||
|
||||
base::FilePath obsolete_standalone_browser_file = user_data_dir.Append(
|
||||
FILE_PATH_LITERAL("standalone_browser_preferences.json"));
|
||||
|
||||
if (!base::PathExists(obsolete_standalone_browser_file)) {
|
||||
return;
|
||||
base::FilePath obsolete_paths[] = {user_data_dir.Append(file),
|
||||
profile_path.Append(file)};
|
||||
for (const auto& path : obsolete_paths) {
|
||||
if (base::PathExists(path)) {
|
||||
bool success = base::DeleteFile(path);
|
||||
LOG(WARNING) << "Removing obsolete " << path << " file: " << success;
|
||||
}
|
||||
}
|
||||
|
||||
LOG(WARNING) << "Removing obsolete " << obsolete_standalone_browser_file
|
||||
<< " file: "
|
||||
<< base::DeleteFile(obsolete_standalone_browser_file);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -330,7 +321,6 @@ void PrepareFactory(
|
||||
supervised_user::SupervisedUserSettingsService* supervised_user_settings,
|
||||
scoped_refptr<PersistentPrefStore> user_pref_store,
|
||||
scoped_refptr<PrefStore> extension_prefs,
|
||||
scoped_refptr<PersistentPrefStore> standalone_browser_prefs,
|
||||
bool async,
|
||||
policy::BrowserPolicyConnector* policy_connector) {
|
||||
factory->SetManagedPolicies(policy_service, policy_connector);
|
||||
@ -342,10 +332,6 @@ void PrepareFactory(
|
||||
factory->set_supervised_user_prefs(supervised_user_prefs);
|
||||
}
|
||||
|
||||
#if BUILDFLAG(IS_CHROMEOS_ASH)
|
||||
factory->set_standalone_browser_prefs(std::move(standalone_browser_prefs));
|
||||
#endif
|
||||
|
||||
factory->set_async(async);
|
||||
factory->set_extension_prefs(std::move(extension_prefs));
|
||||
factory->set_command_line_prefs(
|
||||
@ -398,7 +384,6 @@ std::unique_ptr<PrefService> CreateLocalState(
|
||||
nullptr, // supervised_user_settings
|
||||
pref_store,
|
||||
nullptr, // extension_prefs
|
||||
nullptr, // standalone_browser_prefs
|
||||
/*async=*/false, policy_connector);
|
||||
|
||||
return factory.Create(std::move(pref_registry));
|
||||
@ -422,7 +407,6 @@ std::unique_ptr<sync_preferences::PrefServiceSyncable> CreateProfilePrefs(
|
||||
std::make_unique<ResetOnLoadObserverImpl>(profile_path),
|
||||
reset_on_load_observer.InitWithNewPipeAndPassReceiver());
|
||||
sync_preferences::PrefServiceSyncableFactory factory;
|
||||
scoped_refptr<JsonPrefStore> standalone_browser_prefs = nullptr;
|
||||
|
||||
scoped_refptr<PersistentPrefStore> user_pref_store =
|
||||
CreateProfilePrefStoreManager(profile_path)
|
||||
@ -432,23 +416,14 @@ std::unique_ptr<sync_preferences::PrefServiceSyncable> CreateProfilePrefs(
|
||||
std::move(validation_delegate));
|
||||
|
||||
#if BUILDFLAG(IS_CHROMEOS_ASH)
|
||||
// In ash, load the standalone_browser_prefs. This PrefStore
|
||||
// contains data about prefs set by extensions in lacros where the feature
|
||||
// lives in ash (for example, screen magnifier). The values are persisted in
|
||||
// ash so they can be loaded on startup or when lacros is not running.
|
||||
standalone_browser_prefs = base::MakeRefCounted<JsonPrefStore>(
|
||||
profile_path.Append(
|
||||
FILE_PATH_LITERAL("standalone_browser_preferences.json")),
|
||||
std::unique_ptr<PrefFilter>(), io_task_runner);
|
||||
|
||||
io_task_runner->PostTask(
|
||||
FROM_HERE, base::BindOnce(&CleanupObsoleteStandaloneBrowserPrefsFile));
|
||||
FROM_HERE,
|
||||
base::BindOnce(&CleanupObsoleteStandaloneBrowserPrefsFile, profile_path));
|
||||
#endif
|
||||
|
||||
PrepareFactory(&factory, profile_path, policy_service,
|
||||
supervised_user_settings, user_pref_store,
|
||||
std::move(extension_prefs),
|
||||
std::move(standalone_browser_prefs), async, connector);
|
||||
std::move(extension_prefs), async, connector);
|
||||
|
||||
if (base::FeatureList::IsEnabled(syncer::kEnablePreferencesAccountStorage)) {
|
||||
// Desktop and Mobile platforms have different implementation for account
|
||||
|
@ -1,172 +0,0 @@
|
||||
// Copyright 2023 The Chromium Authors
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "base/memory/raw_ptr.h"
|
||||
#include "chrome/browser/prefs/chrome_pref_service_factory.h"
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "base/files/file_util.h"
|
||||
#include "base/files/scoped_temp_dir.h"
|
||||
#include "base/json/json_file_value_serializer.h"
|
||||
#include "base/logging.h"
|
||||
#include "base/memory/ref_counted.h"
|
||||
#include "base/path_service.h"
|
||||
#include "base/test/scoped_path_override.h"
|
||||
#include "base/test/task_environment.h"
|
||||
#include "base/test/test_file_util.h"
|
||||
#include "base/test/values_test_util.h"
|
||||
#include "base/values.h"
|
||||
#include "chrome/browser/policy/chrome_browser_policy_connector.h"
|
||||
#include "chrome/common/chrome_paths.h"
|
||||
#include "chrome/test/base/testing_browser_process.h"
|
||||
#include "chromeos/ash/components/install_attributes/install_attributes.h"
|
||||
#include "chromeos/ash/components/install_attributes/stub_install_attributes.h"
|
||||
#include "components/policy/core/browser/browser_policy_connector_base.h"
|
||||
#include "components/policy/core/common/mock_configuration_policy_provider.h"
|
||||
#include "components/policy/core/common/policy_service_impl.h"
|
||||
#include "components/pref_registry/pref_registry_syncable.h"
|
||||
#include "components/prefs/default_pref_store.h"
|
||||
#include "components/prefs/pref_service.h"
|
||||
#include "components/sync_preferences/pref_service_syncable.h"
|
||||
#include "mojo/public/cpp/bindings/pending_remote.h"
|
||||
#include "services/preferences/public/cpp/tracked/configuration.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
|
||||
namespace {
|
||||
|
||||
const char kPrefKey[] = "pref_key";
|
||||
const char kPrefValue[] = "pref_val";
|
||||
const char kDefaultPrefValue[] = "default_pref_value";
|
||||
|
||||
void WriteTestPrefToFile(base::FilePath path) {
|
||||
base::Value::Dict pref_dict = base::Value::Dict().Set(kPrefKey, kPrefValue);
|
||||
JSONFileValueSerializer serializer(path);
|
||||
ASSERT_TRUE(serializer.Serialize(pref_dict));
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
namespace chrome_prefs {
|
||||
|
||||
class ChromePrefServiceFactoryTest : public testing::Test {
|
||||
public:
|
||||
ChromePrefServiceFactoryTest()
|
||||
: pref_store_(base::MakeRefCounted<DefaultPrefStore>()),
|
||||
pref_registry_(
|
||||
base::MakeRefCounted<user_prefs::PrefRegistrySyncable>()) {}
|
||||
~ChromePrefServiceFactoryTest() override = default;
|
||||
|
||||
protected:
|
||||
void SetUp() override {
|
||||
install_attributes_ = std::make_unique<ash::StubInstallAttributes>();
|
||||
ash::InstallAttributes::SetForTesting(install_attributes_.get());
|
||||
policy_provider_ = std::make_unique<
|
||||
testing::NiceMock<policy::MockConfigurationPolicyProvider>>();
|
||||
policy_provider_->SetDefaultReturns(
|
||||
/*is_initialization_complete_return=*/true,
|
||||
/*is_first_policy_load_complete_return=*/true);
|
||||
std::vector<
|
||||
raw_ptr<policy::ConfigurationPolicyProvider, VectorExperimental>>
|
||||
providers = {policy_provider_.get()};
|
||||
policy_service_ = std::make_unique<policy::PolicyServiceImpl>(providers);
|
||||
|
||||
policy::BrowserPolicyConnectorBase::SetPolicyServiceForTesting(
|
||||
policy_service_.get());
|
||||
|
||||
// Create a temp user directory.
|
||||
ASSERT_TRUE(user_dir_.CreateUniqueTempDir());
|
||||
user_data_override_ = std::make_unique<base::ScopedPathOverride>(
|
||||
chrome::DIR_USER_DATA, user_dir_.GetPath(), true, true);
|
||||
// Create the profile directory
|
||||
profile_path_ = user_dir_.GetPath().Append(FILE_PATH_LITERAL("u-test"));
|
||||
EXPECT_TRUE(base::CreateDirectory(profile_path_));
|
||||
|
||||
// Register the fake pref that will be written in the standalone browser
|
||||
// preferences file (see `WriteTestPrefToFile`).
|
||||
pref_registry_->RegisterStringPref(kPrefKey, kDefaultPrefValue);
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
g_browser_process->browser_policy_connector()->Shutdown();
|
||||
policy_service_.reset();
|
||||
ash::InstallAttributes::ShutdownForTesting();
|
||||
}
|
||||
|
||||
const base::FilePath& profile_path() const { return profile_path_; }
|
||||
|
||||
std::unique_ptr<sync_preferences::PrefServiceSyncable> GetProfilePrefs(
|
||||
const base::FilePath& profile_path) {
|
||||
std::unique_ptr<sync_preferences::PrefServiceSyncable> pref_service =
|
||||
chrome_prefs::CreateProfilePrefs(
|
||||
profile_path,
|
||||
mojo::PendingRemote<
|
||||
prefs::mojom::TrackedPreferenceValidationDelegate>(),
|
||||
policy_service_.get(), nullptr, pref_store_, pref_registry_,
|
||||
g_browser_process->browser_policy_connector(), false,
|
||||
task_environment_.GetMainThreadTaskRunner());
|
||||
// Run the message loop to process the async request which removes the
|
||||
// obsolete standalone browser pref file.
|
||||
task_environment_.RunUntilIdle();
|
||||
|
||||
return pref_service;
|
||||
}
|
||||
|
||||
private:
|
||||
base::ScopedTempDir user_dir_;
|
||||
std::unique_ptr<base::ScopedPathOverride> user_data_override_;
|
||||
base::FilePath profile_path_;
|
||||
base::test::TaskEnvironment task_environment_;
|
||||
std::unique_ptr<ash::StubInstallAttributes> install_attributes_;
|
||||
std::unique_ptr<policy::PolicyServiceImpl> policy_service_;
|
||||
std::unique_ptr<policy::MockConfigurationPolicyProvider> policy_provider_;
|
||||
scoped_refptr<DefaultPrefStore> pref_store_;
|
||||
scoped_refptr<user_prefs::PrefRegistrySyncable> pref_registry_;
|
||||
};
|
||||
|
||||
// Verify that the preferences are not read from the wrong standalone browser
|
||||
// preferences file (outside the profile directory). See b/300645795.
|
||||
TEST_F(ChromePrefServiceFactoryTest,
|
||||
PrefsNotReadFromDeprecatedStandaloneBrowserFile) {
|
||||
base::FilePath user_data_directory;
|
||||
ASSERT_TRUE(
|
||||
base::PathService::Get(chrome::DIR_USER_DATA, &user_data_directory));
|
||||
base::FilePath standalone_browser_preferences_path =
|
||||
user_data_directory.Append(
|
||||
FILE_PATH_LITERAL("standalone_browser_preferences.json"));
|
||||
|
||||
WriteTestPrefToFile(standalone_browser_preferences_path);
|
||||
|
||||
auto pref_service = GetProfilePrefs(profile_path());
|
||||
ASSERT_TRUE(pref_service);
|
||||
|
||||
const PrefService::Preference* pref = pref_service->FindPreference(kPrefKey);
|
||||
ASSERT_TRUE(pref);
|
||||
const base::Value* value = pref->GetValue();
|
||||
ASSERT_TRUE(value);
|
||||
base::ExpectStringValue(kDefaultPrefValue, *value);
|
||||
|
||||
// The file should be removed because it's not at the the correct location.
|
||||
EXPECT_FALSE(base::PathExists(standalone_browser_preferences_path));
|
||||
}
|
||||
|
||||
// Verify that the preferences are read from the standalone browser file in the
|
||||
// profile directory.
|
||||
TEST_F(ChromePrefServiceFactoryTest,
|
||||
PrefsAreReadFromTheProfileStandaloneBrowserFile) {
|
||||
WriteTestPrefToFile(profile_path().Append(
|
||||
FILE_PATH_LITERAL("standalone_browser_preferences.json")));
|
||||
|
||||
auto pref_service = GetProfilePrefs(profile_path());
|
||||
ASSERT_TRUE(pref_service);
|
||||
|
||||
const PrefService::Preference* pref = pref_service->FindPreference(kPrefKey);
|
||||
ASSERT_TRUE(pref);
|
||||
const base::Value* value = pref->GetValue();
|
||||
ASSERT_TRUE(value);
|
||||
base::ExpectStringValue(kPrefValue, *value);
|
||||
}
|
||||
|
||||
} // namespace chrome_prefs
|
@ -137,8 +137,7 @@ class ProfileSigninConfirmationHelperTest : public testing::Test {
|
||||
new sync_preferences::TestingPrefServiceSyncable(
|
||||
/*managed_prefs=*/new TestingPrefStore(),
|
||||
/*supervised_user_prefs=*/new TestingPrefStore(),
|
||||
/*extension_prefs=*/new TestingPrefStore(),
|
||||
/*standalone_browser_prefs=*/new TestingPrefStore(), user_prefs_,
|
||||
/*extension_prefs=*/new TestingPrefStore(), user_prefs_,
|
||||
/*recommended_prefs=*/new TestingPrefStore(),
|
||||
new user_prefs::PrefRegistrySyncable(),
|
||||
std::make_unique<PrefNotifierImpl>());
|
||||
|
@ -778,7 +778,6 @@ void TestingProfile::CreatePrefServiceForSupervisedUser() {
|
||||
/*managed_prefs=*/base::MakeRefCounted<TestingPrefStore>(),
|
||||
supervised_user_pref_store_,
|
||||
/*extension_prefs=*/base::MakeRefCounted<TestingPrefStore>(),
|
||||
/*standalone_browser_prefs=*/base::MakeRefCounted<TestingPrefStore>(),
|
||||
/*user_prefs=*/base::MakeRefCounted<TestingPrefStore>(),
|
||||
/*recommended_prefs=*/base::MakeRefCounted<TestingPrefStore>(),
|
||||
base::MakeRefCounted<user_prefs::PrefRegistrySyncable>(),
|
||||
|
@ -16,7 +16,6 @@ TestingPrefServiceBase<PrefService, user_prefs::PrefRegistrySyncable>::
|
||||
scoped_refptr<TestingPrefStore> managed_prefs,
|
||||
scoped_refptr<TestingPrefStore> supervised_user_prefs,
|
||||
scoped_refptr<TestingPrefStore> extension_prefs,
|
||||
scoped_refptr<TestingPrefStore> standalone_browser_prefs,
|
||||
scoped_refptr<TestingPrefStore> user_prefs,
|
||||
scoped_refptr<TestingPrefStore> recommended_prefs,
|
||||
scoped_refptr<user_prefs::PrefRegistrySyncable> pref_registry,
|
||||
@ -29,14 +28,12 @@ TestingPrefServiceBase<PrefService, user_prefs::PrefRegistrySyncable>::
|
||||
std::make_unique<PrefValueStore>(managed_prefs.get(),
|
||||
supervised_user_prefs.get(),
|
||||
extension_prefs.get(),
|
||||
standalone_browser_prefs.get(),
|
||||
/*command_line_prefs=*/nullptr,
|
||||
user_prefs.get(),
|
||||
recommended_prefs.get(),
|
||||
pref_registry->defaults().get(),
|
||||
pref_notifier),
|
||||
user_prefs,
|
||||
standalone_browser_prefs,
|
||||
pref_registry,
|
||||
base::BindRepeating(
|
||||
&TestingPrefServiceBase<PrefService,
|
||||
@ -45,7 +42,6 @@ TestingPrefServiceBase<PrefService, user_prefs::PrefRegistrySyncable>::
|
||||
managed_prefs_(managed_prefs),
|
||||
supervised_user_prefs_(supervised_user_prefs),
|
||||
extension_prefs_(extension_prefs),
|
||||
standalone_browser_prefs_(standalone_browser_prefs),
|
||||
user_prefs_(user_prefs),
|
||||
recommended_prefs_(recommended_prefs) {}
|
||||
|
||||
@ -56,7 +52,6 @@ AutofillTestingPrefService::AutofillTestingPrefService()
|
||||
/*managed_prefs=*/base::MakeRefCounted<TestingPrefStore>(),
|
||||
/*supervised_user_prefs=*/base::MakeRefCounted<TestingPrefStore>(),
|
||||
/*extension_prefs=*/base::MakeRefCounted<TestingPrefStore>(),
|
||||
/*standalone_browser_prefs=*/base::MakeRefCounted<TestingPrefStore>(),
|
||||
/*user_prefs=*/base::MakeRefCounted<TestingPrefStore>(),
|
||||
/*recommended_prefs=*/base::MakeRefCounted<TestingPrefStore>(),
|
||||
base::MakeRefCounted<user_prefs::PrefRegistrySyncable>(),
|
||||
|
@ -43,7 +43,6 @@ TestingPrefServiceBase<PrefService, user_prefs::PrefRegistrySyncable>::
|
||||
scoped_refptr<TestingPrefStore> managed_prefs,
|
||||
scoped_refptr<TestingPrefStore> supervised_user_prefs,
|
||||
scoped_refptr<TestingPrefStore> extension_prefs,
|
||||
scoped_refptr<TestingPrefStore> standalone_browser_prefs,
|
||||
scoped_refptr<TestingPrefStore> user_prefs,
|
||||
scoped_refptr<TestingPrefStore> recommended_prefs,
|
||||
scoped_refptr<user_prefs::PrefRegistrySyncable> pref_registry,
|
||||
|
@ -46,20 +46,10 @@ base::Value::List GetPrefsMetadata(
|
||||
#else
|
||||
NOTREACHED();
|
||||
#endif
|
||||
case PrefValueStore::PrefStoreType::STANDALONE_BROWSER_STORE:
|
||||
#if BUILDFLAG(IS_CHROMEOS)
|
||||
metadata.Append("standalone_browser_controlled");
|
||||
metadata.Append("standalone_browser_modifiable");
|
||||
#endif
|
||||
metadata.Append("extension_modifiable");
|
||||
break;
|
||||
case PrefValueStore::PrefStoreType::COMMAND_LINE_STORE:
|
||||
metadata.Append("command_line_controlled");
|
||||
#if BUILDFLAG(ENABLE_EXTENSIONS)
|
||||
metadata.Append("extension_modifiable");
|
||||
#endif
|
||||
#if BUILDFLAG(IS_CHROMEOS)
|
||||
metadata.Append("standalone_browser_modifiable");
|
||||
#endif
|
||||
break;
|
||||
case PrefValueStore::PrefStoreType::USER_STORE:
|
||||
@ -67,9 +57,6 @@ base::Value::List GetPrefsMetadata(
|
||||
metadata.Append("user_modifiable");
|
||||
#if BUILDFLAG(ENABLE_EXTENSIONS)
|
||||
metadata.Append("extension_modifiable");
|
||||
#endif
|
||||
#if BUILDFLAG(IS_CHROMEOS)
|
||||
metadata.Append("standalone_browser_modifiable");
|
||||
#endif
|
||||
break;
|
||||
case PrefValueStore::PrefStoreType::RECOMMENDED_STORE:
|
||||
@ -77,9 +64,6 @@ base::Value::List GetPrefsMetadata(
|
||||
metadata.Append("user_modifiable");
|
||||
#if BUILDFLAG(ENABLE_EXTENSIONS)
|
||||
metadata.Append("extension_modifiable");
|
||||
#endif
|
||||
#if BUILDFLAG(IS_CHROMEOS)
|
||||
metadata.Append("standalone_browser_modifiable");
|
||||
#endif
|
||||
break;
|
||||
case PrefValueStore::PrefStoreType::DEFAULT_STORE:
|
||||
@ -87,18 +71,12 @@ base::Value::List GetPrefsMetadata(
|
||||
metadata.Append("user_modifiable");
|
||||
#if BUILDFLAG(ENABLE_EXTENSIONS)
|
||||
metadata.Append("extension_modifiable");
|
||||
#endif
|
||||
#if BUILDFLAG(IS_CHROMEOS)
|
||||
metadata.Append("standalone_browser_modifiable");
|
||||
#endif
|
||||
break;
|
||||
case PrefValueStore::PrefStoreType::INVALID_STORE:
|
||||
metadata.Append("user_modifiable");
|
||||
#if BUILDFLAG(ENABLE_EXTENSIONS)
|
||||
metadata.Append("extension_modifiable");
|
||||
#endif
|
||||
#if BUILDFLAG(IS_CHROMEOS)
|
||||
metadata.Append("standalone_browser_modifiable");
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
|
@ -19,10 +19,6 @@ CanMakePaymentPreferenceSetter GetCanMakePaymentPreferenceSetter(
|
||||
const PrefService::Preference* pref) {
|
||||
if (pref->IsUserControlled()) {
|
||||
return CanMakePaymentPreferenceSetter::kUserSetting;
|
||||
#if BUILDFLAG(IS_CHROMEOS_ASH)
|
||||
} else if (pref->IsStandaloneBrowserControlled()) {
|
||||
return CanMakePaymentPreferenceSetter::kStandaloneBrowser;
|
||||
#endif
|
||||
} else if (pref->IsExtensionControlled()) {
|
||||
return CanMakePaymentPreferenceSetter::kExtension;
|
||||
} else if (pref->IsManagedByCustodian()) {
|
||||
|
@ -33,10 +33,6 @@
|
||||
#include "components/prefs/pref_notifier_impl.h"
|
||||
#include "components/prefs/pref_registry.h"
|
||||
|
||||
#if BUILDFLAG(IS_CHROMEOS_ASH)
|
||||
#include "components/prefs/value_map_pref_store.h"
|
||||
#endif
|
||||
|
||||
#if BUILDFLAG(IS_ANDROID)
|
||||
#include "components/prefs/android/pref_service_android.h"
|
||||
#endif
|
||||
@ -84,7 +80,6 @@ PrefService::PrefService(
|
||||
std::unique_ptr<PrefNotifierImpl> pref_notifier,
|
||||
std::unique_ptr<PrefValueStore> pref_value_store,
|
||||
scoped_refptr<PersistentPrefStore> user_prefs,
|
||||
scoped_refptr<PersistentPrefStore> standalone_browser_prefs,
|
||||
scoped_refptr<PrefRegistry> pref_registry,
|
||||
base::RepeatingCallback<void(PersistentPrefStore::PrefReadError)>
|
||||
read_error_callback,
|
||||
@ -92,7 +87,6 @@ PrefService::PrefService(
|
||||
: pref_notifier_(std::move(pref_notifier)),
|
||||
pref_value_store_(std::move(pref_value_store)),
|
||||
user_pref_store_(std::move(user_prefs)),
|
||||
standalone_browser_pref_store_(std::move(standalone_browser_prefs)),
|
||||
read_error_callback_(std::move(read_error_callback)),
|
||||
pref_registry_(std::move(pref_registry)),
|
||||
pref_store_observer_(
|
||||
@ -112,9 +106,6 @@ PrefService::~PrefService() {
|
||||
// Remove observers. This could be necessary if this service is destroyed
|
||||
// before the prefs are fully loaded.
|
||||
user_pref_store_->RemoveObserver(pref_store_observer_.get());
|
||||
if (standalone_browser_pref_store_) {
|
||||
standalone_browser_pref_store_->RemoveObserver(pref_store_observer_.get());
|
||||
}
|
||||
|
||||
// TODO(crbug.com/942491, 946668, 945772) The following code collects
|
||||
// augments stack dumps created by ~PrefNotifierImpl() with information
|
||||
@ -136,10 +127,6 @@ void PrefService::InitFromStorage(bool async) {
|
||||
if (!user_pref_store_->IsInitializationComplete()) {
|
||||
user_pref_store_->ReadPrefs();
|
||||
}
|
||||
if (standalone_browser_pref_store_ &&
|
||||
!standalone_browser_pref_store_->IsInitializationComplete()) {
|
||||
standalone_browser_pref_store_->ReadPrefs();
|
||||
}
|
||||
CheckPrefsLoaded();
|
||||
return;
|
||||
}
|
||||
@ -150,54 +137,19 @@ void PrefService::InitFromStorage(bool async) {
|
||||
user_pref_store_->AddObserver(pref_store_observer_.get());
|
||||
user_pref_store_->ReadPrefsAsync(nullptr);
|
||||
}
|
||||
|
||||
if (standalone_browser_pref_store_ &&
|
||||
!standalone_browser_pref_store_->IsInitializationComplete()) {
|
||||
standalone_browser_pref_store_->AddObserver(pref_store_observer_.get());
|
||||
standalone_browser_pref_store_->ReadPrefsAsync(nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
void PrefService::CheckPrefsLoaded() {
|
||||
if (!(user_pref_store_->IsInitializationComplete() &&
|
||||
(!standalone_browser_pref_store_ ||
|
||||
standalone_browser_pref_store_->IsInitializationComplete()))) {
|
||||
// Not done initializing both prefstores.
|
||||
if (!user_pref_store_->IsInitializationComplete()) {
|
||||
return;
|
||||
}
|
||||
|
||||
user_pref_store_->RemoveObserver(pref_store_observer_.get());
|
||||
if (standalone_browser_pref_store_) {
|
||||
standalone_browser_pref_store_->RemoveObserver(pref_store_observer_.get());
|
||||
}
|
||||
|
||||
// Both prefstores are initialized, get the read errors.
|
||||
// Pref store is initialized, get the read errors.
|
||||
PersistentPrefStore::PrefReadError user_store_error =
|
||||
user_pref_store_->GetReadError();
|
||||
if (!standalone_browser_pref_store_) {
|
||||
read_error_callback_.Run(user_store_error);
|
||||
return;
|
||||
}
|
||||
PersistentPrefStore::PrefReadError standalone_browser_store_error =
|
||||
standalone_browser_pref_store_->GetReadError();
|
||||
|
||||
// If both stores have the same error (or no error), run the callback with
|
||||
// either one. This avoids double-reporting (either way prefs weren't
|
||||
// successfully fully loaded)
|
||||
if (user_store_error == standalone_browser_store_error) {
|
||||
read_error_callback_.Run(user_store_error);
|
||||
} else if (user_store_error == PersistentPrefStore::PREF_READ_ERROR_NONE ||
|
||||
user_store_error == PersistentPrefStore::PREF_READ_ERROR_NO_FILE) {
|
||||
// Prefer to report the standalone_browser_pref_store error if the
|
||||
// user_pref_store error is not significant.
|
||||
read_error_callback_.Run(standalone_browser_store_error);
|
||||
} else {
|
||||
// Either the user_pref_store error is significant, or
|
||||
// both stores failed to load but for different reasons.
|
||||
// The user_store error is more significant in essentially all cases,
|
||||
// so prefer to report that.
|
||||
read_error_callback_.Run(user_store_error);
|
||||
}
|
||||
read_error_callback_.Run(user_store_error);
|
||||
}
|
||||
|
||||
void PrefService::CommitPendingWrite(
|
||||
@ -668,16 +620,6 @@ bool PrefService::Preference::IsExtensionModifiable() const {
|
||||
return pref_value_store()->PrefValueExtensionModifiable(name_);
|
||||
}
|
||||
|
||||
#if BUILDFLAG(IS_CHROMEOS_ASH)
|
||||
bool PrefService::Preference::IsStandaloneBrowserControlled() const {
|
||||
return pref_value_store()->PrefValueFromStandaloneBrowserStore(name_);
|
||||
}
|
||||
|
||||
bool PrefService::Preference::IsStandaloneBrowserModifiable() const {
|
||||
return pref_value_store()->PrefValueStandaloneBrowserModifiable(name_);
|
||||
}
|
||||
#endif
|
||||
|
||||
const base::Value* PrefService::GetPreferenceValue(
|
||||
std::string_view path) const {
|
||||
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
|
||||
@ -701,35 +643,6 @@ const base::Value* PrefService::GetPreferenceValue(
|
||||
return found_value;
|
||||
}
|
||||
|
||||
#if BUILDFLAG(IS_CHROMEOS_ASH)
|
||||
void PrefService::SetStandaloneBrowserPref(std::string_view path,
|
||||
const base::Value& value) {
|
||||
if (!standalone_browser_pref_store_) {
|
||||
LOG(WARNING) << "Failure to set value of " << path
|
||||
<< " in standalone browser store";
|
||||
return;
|
||||
}
|
||||
standalone_browser_pref_store_->SetValue(
|
||||
path, value.Clone(), WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS);
|
||||
}
|
||||
|
||||
void PrefService::RemoveAllStandaloneBrowserPrefs() {
|
||||
if (!standalone_browser_pref_store_) {
|
||||
LOG(WARNING) << "standalone_browser_pref_store_ is null";
|
||||
return;
|
||||
}
|
||||
|
||||
std::vector<std::string> paths;
|
||||
pref_service_util::GetAllDottedPaths(
|
||||
standalone_browser_pref_store_->GetValues(), paths);
|
||||
|
||||
for (const std::string& path : paths) {
|
||||
standalone_browser_pref_store_->RemoveValue(
|
||||
path, WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// static
|
||||
uint32_t PrefService::GetWriteFlags(const PrefService::Preference* pref) {
|
||||
uint32_t write_flags = WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS;
|
||||
|
@ -170,17 +170,6 @@ class COMPONENTS_PREFS_EXPORT PrefService {
|
||||
// the Preference.
|
||||
bool IsExtensionModifiable() const;
|
||||
|
||||
#if BUILDFLAG(IS_CHROMEOS_ASH)
|
||||
// Returns true if the Preference value is currently being controlled by a
|
||||
// standalone browser (lacros) and not by any higher-priority source.
|
||||
bool IsStandaloneBrowserControlled() const;
|
||||
|
||||
// Returns true if a standalone browser (lacros) can change the Preference
|
||||
// value, which is the case if no higher-priority source than the standalone
|
||||
// browser store controls the Preference.
|
||||
bool IsStandaloneBrowserModifiable() const;
|
||||
#endif
|
||||
|
||||
// Return the registration flags for this pref as a bitmask of
|
||||
// PrefRegistry::PrefRegistrationFlags.
|
||||
uint32_t registration_flags() const { return registration_flags_; }
|
||||
@ -207,7 +196,6 @@ class COMPONENTS_PREFS_EXPORT PrefService {
|
||||
PrefService(std::unique_ptr<PrefNotifierImpl> pref_notifier,
|
||||
std::unique_ptr<PrefValueStore> pref_value_store,
|
||||
scoped_refptr<PersistentPrefStore> user_prefs,
|
||||
scoped_refptr<PersistentPrefStore> standalone_browser_prefs,
|
||||
scoped_refptr<PrefRegistry> pref_registry,
|
||||
base::RepeatingCallback<void(PersistentPrefStore::PrefReadError)>
|
||||
read_error_callback,
|
||||
@ -409,16 +397,6 @@ class COMPONENTS_PREFS_EXPORT PrefService {
|
||||
void AddPrefObserverAllPrefs(PrefObserver* obs);
|
||||
void RemovePrefObserverAllPrefs(PrefObserver* obs);
|
||||
|
||||
#if BUILDFLAG(IS_CHROMEOS_ASH)
|
||||
// Write extension-controlled prefs from Lacros in ash.
|
||||
void SetStandaloneBrowserPref(std::string_view path,
|
||||
const base::Value& value);
|
||||
|
||||
// Clear all prefs in standalone_browser_pref_store_. Use it when rolling back
|
||||
// to Ash (i.e. disabling Lacros).
|
||||
void RemoveAllStandaloneBrowserPrefs();
|
||||
#endif
|
||||
|
||||
#if BUILDFLAG(IS_ANDROID)
|
||||
base::android::ScopedJavaLocalRef<jobject> GetJavaObject();
|
||||
#endif
|
||||
@ -438,7 +416,6 @@ class COMPONENTS_PREFS_EXPORT PrefService {
|
||||
|
||||
// Pref Stores and profile that we passed to the PrefValueStore.
|
||||
const scoped_refptr<PersistentPrefStore> user_pref_store_;
|
||||
const scoped_refptr<PersistentPrefStore> standalone_browser_pref_store_;
|
||||
|
||||
// Callback to call when a read error occurs. Always invoked on the sequence
|
||||
// this PrefService was created own.
|
||||
@ -479,9 +456,9 @@ class COMPONENTS_PREFS_EXPORT PrefService {
|
||||
virtual void RemovePrefObserver(std::string_view path, PrefObserver* obs);
|
||||
|
||||
// A PrefStore::Observer which reports loading errors from
|
||||
// PersistentPrefStores after they are loaded. Usually this is only user_prefs
|
||||
// however in ash it additionally includes standalone_browser_prefs. Errors
|
||||
// are only reported once even though multiple files may be loaded.
|
||||
// PersistentPrefStores after they are loaded. Usually this is only
|
||||
// user_prefs. Errors are only reported once even though multiple files may
|
||||
// be loaded.
|
||||
class PersistentPrefStoreLoadingObserver : public PrefStore::Observer {
|
||||
public:
|
||||
explicit PersistentPrefStoreLoadingObserver(PrefService* pref_service_);
|
||||
|
@ -33,11 +33,10 @@ std::unique_ptr<PrefService> PrefServiceFactory::Create(
|
||||
auto pref_notifier = std::make_unique<PrefNotifierImpl>();
|
||||
auto pref_value_store = std::make_unique<PrefValueStore>(
|
||||
managed_prefs_.get(), supervised_user_prefs_.get(),
|
||||
extension_prefs_.get(), standalone_browser_prefs_.get(),
|
||||
command_line_prefs_.get(), user_prefs_.get(), recommended_prefs_.get(),
|
||||
pref_registry->defaults().get(), pref_notifier.get());
|
||||
extension_prefs_.get(), command_line_prefs_.get(), user_prefs_.get(),
|
||||
recommended_prefs_.get(), pref_registry->defaults().get(),
|
||||
pref_notifier.get());
|
||||
return std::make_unique<PrefService>(
|
||||
std::move(pref_notifier), std::move(pref_value_store), user_prefs_.get(),
|
||||
standalone_browser_prefs_.get(), std::move(pref_registry),
|
||||
read_error_callback_, async_);
|
||||
std::move(pref_registry), read_error_callback_, async_);
|
||||
}
|
||||
|
@ -43,10 +43,6 @@ class COMPONENTS_PREFS_EXPORT PrefServiceFactory {
|
||||
extension_prefs_.swap(prefs);
|
||||
}
|
||||
|
||||
void set_standalone_browser_prefs(scoped_refptr<PersistentPrefStore> prefs) {
|
||||
standalone_browser_prefs_.swap(prefs);
|
||||
}
|
||||
|
||||
void set_command_line_prefs(scoped_refptr<PrefStore> prefs) {
|
||||
command_line_prefs_.swap(prefs);
|
||||
}
|
||||
@ -85,7 +81,6 @@ class COMPONENTS_PREFS_EXPORT PrefServiceFactory {
|
||||
scoped_refptr<PrefStore> managed_prefs_;
|
||||
scoped_refptr<PrefStore> supervised_user_prefs_;
|
||||
scoped_refptr<PrefStore> extension_prefs_;
|
||||
scoped_refptr<PersistentPrefStore> standalone_browser_prefs_;
|
||||
scoped_refptr<PrefStore> command_line_prefs_;
|
||||
scoped_refptr<PersistentPrefStore> user_prefs_;
|
||||
scoped_refptr<PrefStore> recommended_prefs_;
|
||||
|
@ -28,7 +28,6 @@ using testing::Mock;
|
||||
namespace {
|
||||
|
||||
const char kPrefName[] = "pref.name";
|
||||
const char kStandaloneBrowserPref[] = "standalone_browser_pref";
|
||||
|
||||
} // namespace
|
||||
|
||||
@ -510,75 +509,3 @@ TEST_F(PrefServiceSetValueTest, SetListValue) {
|
||||
prefs_.Set(kName, empty);
|
||||
Mock::VerifyAndClearExpectations(&observer_);
|
||||
}
|
||||
|
||||
class PrefStandaloneBrowserPrefsTest : public testing::Test {
|
||||
protected:
|
||||
PrefStandaloneBrowserPrefsTest()
|
||||
: user_pref_store_(base::MakeRefCounted<TestingPrefStore>()),
|
||||
standalone_browser_pref_store_(
|
||||
base::MakeRefCounted<TestingPrefStore>()),
|
||||
pref_registry_(base::MakeRefCounted<PrefRegistrySimple>()) {}
|
||||
|
||||
~PrefStandaloneBrowserPrefsTest() override = default;
|
||||
|
||||
void SetUp() override {
|
||||
auto pref_notifier = std::make_unique<PrefNotifierImpl>();
|
||||
auto pref_value_store = std::make_unique<PrefValueStore>(
|
||||
nullptr /* managed_prefs */, nullptr /* supervised_user_prefs */,
|
||||
nullptr /* extension_prefs */, standalone_browser_pref_store_.get(),
|
||||
new TestingPrefStore(), user_pref_store_.get(),
|
||||
nullptr /* recommended_prefs */, pref_registry_->defaults().get(),
|
||||
pref_notifier.get());
|
||||
pref_service_ = std::make_unique<PrefService>(
|
||||
std::move(pref_notifier), std::move(pref_value_store), user_pref_store_,
|
||||
standalone_browser_pref_store_, pref_registry_, base::DoNothing(),
|
||||
false);
|
||||
pref_registry_->RegisterIntegerPref(kStandaloneBrowserPref, 4);
|
||||
}
|
||||
|
||||
std::unique_ptr<PrefService> pref_service_;
|
||||
scoped_refptr<TestingPrefStore> user_pref_store_;
|
||||
scoped_refptr<TestingPrefStore> standalone_browser_pref_store_;
|
||||
scoped_refptr<PrefRegistrySimple> pref_registry_;
|
||||
};
|
||||
|
||||
// Check that the standalone browser pref store is correctly initialized,
|
||||
// written to, read, and has correct precedence.
|
||||
TEST_F(PrefStandaloneBrowserPrefsTest, CheckStandaloneBrowserPref) {
|
||||
const PrefService::Preference* preference =
|
||||
pref_service_->FindPreference(kStandaloneBrowserPref);
|
||||
EXPECT_TRUE(preference->IsDefaultValue());
|
||||
EXPECT_EQ(base::Value(4), *(preference->GetValue()));
|
||||
user_pref_store_->SetInteger(kStandaloneBrowserPref, 11);
|
||||
EXPECT_EQ(base::Value(11), *(preference->GetValue()));
|
||||
// The standalone_browser_pref_store has higher precedence.
|
||||
standalone_browser_pref_store_->SetInteger(kStandaloneBrowserPref, 10);
|
||||
ASSERT_EQ(base::Value(10), *(preference->GetValue()));
|
||||
// Removing user_pref_store value shouldn't change the pref value.
|
||||
user_pref_store_->RemoveValue(kStandaloneBrowserPref,
|
||||
WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS);
|
||||
ASSERT_EQ(base::Value(10), *(preference->GetValue()));
|
||||
// Now removing the standalone_browser_pref_store value should revert the
|
||||
// value to default.
|
||||
standalone_browser_pref_store_->RemoveValue(
|
||||
kStandaloneBrowserPref, WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS);
|
||||
EXPECT_EQ(base::Value(4), *(preference->GetValue()));
|
||||
}
|
||||
|
||||
#if BUILDFLAG(IS_CHROMEOS_ASH)
|
||||
TEST_F(PrefStandaloneBrowserPrefsTest, RemoveAllStandaloneBrowserPrefs) {
|
||||
const char int_pref_name[] = "int.name";
|
||||
const char str_pref_name[] = "str.pref.name";
|
||||
pref_registry_->RegisterIntegerPref(int_pref_name, 0);
|
||||
pref_registry_->RegisterStringPref(str_pref_name, "");
|
||||
|
||||
pref_service_->SetStandaloneBrowserPref(int_pref_name, base::Value(4));
|
||||
pref_service_->SetStandaloneBrowserPref(str_pref_name, base::Value("value"));
|
||||
EXPECT_EQ(base::Value(4), pref_service_->GetValue(int_pref_name));
|
||||
EXPECT_EQ(base::Value("value"), pref_service_->GetValue(str_pref_name));
|
||||
|
||||
pref_service_->RemoveAllStandaloneBrowserPrefs();
|
||||
EXPECT_EQ(base::Value(0), pref_service_->GetValue(int_pref_name));
|
||||
EXPECT_EQ(base::Value(""), pref_service_->GetValue(str_pref_name));
|
||||
}
|
||||
#endif
|
||||
|
@ -51,7 +51,6 @@ void PrefValueStore::PrefStoreKeeper::OnInitializationCompleted(
|
||||
PrefValueStore::PrefValueStore(PrefStore* managed_prefs,
|
||||
PrefStore* supervised_user_prefs,
|
||||
PrefStore* extension_prefs,
|
||||
PrefStore* standalone_browser_prefs,
|
||||
PrefStore* command_line_prefs,
|
||||
PrefStore* user_prefs,
|
||||
PrefStore* recommended_prefs,
|
||||
@ -61,7 +60,6 @@ PrefValueStore::PrefValueStore(PrefStore* managed_prefs,
|
||||
InitPrefStore(MANAGED_STORE, managed_prefs);
|
||||
InitPrefStore(SUPERVISED_USER_STORE, supervised_user_prefs);
|
||||
InitPrefStore(EXTENSION_STORE, extension_prefs);
|
||||
InitPrefStore(STANDALONE_BROWSER_STORE, standalone_browser_prefs);
|
||||
InitPrefStore(COMMAND_LINE_STORE, command_line_prefs);
|
||||
InitPrefStore(USER_STORE, user_prefs);
|
||||
InitPrefStore(RECOMMENDED_STORE, recommended_prefs);
|
||||
@ -76,7 +74,6 @@ std::unique_ptr<PrefValueStore> PrefValueStore::CloneAndSpecialize(
|
||||
PrefStore* managed_prefs,
|
||||
PrefStore* supervised_user_prefs,
|
||||
PrefStore* extension_prefs,
|
||||
PrefStore* standalone_browser_prefs,
|
||||
PrefStore* command_line_prefs,
|
||||
PrefStore* user_prefs,
|
||||
PrefStore* recommended_prefs,
|
||||
@ -89,8 +86,6 @@ std::unique_ptr<PrefValueStore> PrefValueStore::CloneAndSpecialize(
|
||||
supervised_user_prefs = GetPrefStore(SUPERVISED_USER_STORE);
|
||||
if (!extension_prefs)
|
||||
extension_prefs = GetPrefStore(EXTENSION_STORE);
|
||||
if (!standalone_browser_prefs)
|
||||
standalone_browser_prefs = GetPrefStore(STANDALONE_BROWSER_STORE);
|
||||
if (!command_line_prefs)
|
||||
command_line_prefs = GetPrefStore(COMMAND_LINE_STORE);
|
||||
if (!user_prefs)
|
||||
@ -101,9 +96,8 @@ std::unique_ptr<PrefValueStore> PrefValueStore::CloneAndSpecialize(
|
||||
default_prefs = GetPrefStore(DEFAULT_STORE);
|
||||
|
||||
return std::make_unique<PrefValueStore>(
|
||||
managed_prefs, supervised_user_prefs, extension_prefs,
|
||||
standalone_browser_prefs, command_line_prefs, user_prefs,
|
||||
recommended_prefs, default_prefs, pref_notifier);
|
||||
managed_prefs, supervised_user_prefs, extension_prefs, command_line_prefs,
|
||||
user_prefs, recommended_prefs, default_prefs, pref_notifier);
|
||||
}
|
||||
|
||||
PrefValueStore::PrefStoreType PrefValueStore::ControllingPrefStoreForPref(
|
||||
@ -175,11 +169,6 @@ bool PrefValueStore::PrefValueFromRecommendedStore(
|
||||
return ControllingPrefStoreForPref(name) == RECOMMENDED_STORE;
|
||||
}
|
||||
|
||||
bool PrefValueStore::PrefValueFromStandaloneBrowserStore(
|
||||
const std::string& name) const {
|
||||
return ControllingPrefStoreForPref(name) == STANDALONE_BROWSER_STORE;
|
||||
}
|
||||
|
||||
bool PrefValueStore::PrefValueFromDefaultStore(const std::string& name) const {
|
||||
return ControllingPrefStoreForPref(name) == DEFAULT_STORE;
|
||||
}
|
||||
@ -197,13 +186,6 @@ bool PrefValueStore::PrefValueExtensionModifiable(
|
||||
effective_store == INVALID_STORE;
|
||||
}
|
||||
|
||||
bool PrefValueStore::PrefValueStandaloneBrowserModifiable(
|
||||
const std::string& name) const {
|
||||
PrefStoreType effective_store = ControllingPrefStoreForPref(name);
|
||||
return effective_store >= STANDALONE_BROWSER_STORE ||
|
||||
effective_store == INVALID_STORE;
|
||||
}
|
||||
|
||||
void PrefValueStore::UpdateCommandLinePrefStore(PrefStore* command_line_prefs) {
|
||||
InitPrefStore(COMMAND_LINE_STORE, command_line_prefs);
|
||||
}
|
||||
|
@ -56,7 +56,6 @@ class COMPONENTS_PREFS_EXPORT PrefValueStore {
|
||||
MANAGED_STORE = 0,
|
||||
SUPERVISED_USER_STORE,
|
||||
EXTENSION_STORE,
|
||||
STANDALONE_BROWSER_STORE,
|
||||
COMMAND_LINE_STORE,
|
||||
USER_STORE,
|
||||
RECOMMENDED_STORE,
|
||||
@ -82,7 +81,6 @@ class COMPONENTS_PREFS_EXPORT PrefValueStore {
|
||||
PrefValueStore(PrefStore* managed_prefs,
|
||||
PrefStore* supervised_user_prefs,
|
||||
PrefStore* extension_prefs,
|
||||
PrefStore* standalone_browser_prefs,
|
||||
PrefStore* command_line_prefs,
|
||||
PrefStore* user_prefs,
|
||||
PrefStore* recommended_prefs,
|
||||
@ -102,7 +100,6 @@ class COMPONENTS_PREFS_EXPORT PrefValueStore {
|
||||
PrefStore* managed_prefs,
|
||||
PrefStore* supervised_user_prefs,
|
||||
PrefStore* extension_prefs,
|
||||
PrefStore* standalone_browser_prefs,
|
||||
PrefStore* command_line_prefs,
|
||||
PrefStore* user_prefs,
|
||||
PrefStore* recommended_prefs,
|
||||
@ -141,7 +138,6 @@ class COMPONENTS_PREFS_EXPORT PrefValueStore {
|
||||
bool PrefValueInSupervisedStore(const std::string& name) const;
|
||||
bool PrefValueInExtensionStore(const std::string& name) const;
|
||||
bool PrefValueInUserStore(const std::string& name) const;
|
||||
bool PrefValueInStandaloneBrowserStore(const std::string& name) const;
|
||||
|
||||
// These methods return true if a preference with the given name is actually
|
||||
// being controlled by the indicated pref store and not being overridden by
|
||||
@ -150,7 +146,6 @@ class COMPONENTS_PREFS_EXPORT PrefValueStore {
|
||||
bool PrefValueFromUserStore(const std::string& name) const;
|
||||
bool PrefValueFromRecommendedStore(const std::string& name) const;
|
||||
bool PrefValueFromDefaultStore(const std::string& name) const;
|
||||
bool PrefValueFromStandaloneBrowserStore(const std::string& name) const;
|
||||
|
||||
// Check whether a Preference value is modifiable by the user, i.e. whether
|
||||
// there is no higher-priority source controlling it.
|
||||
@ -160,10 +155,6 @@ class COMPONENTS_PREFS_EXPORT PrefValueStore {
|
||||
// whether there is no higher-priority source controlling it.
|
||||
bool PrefValueExtensionModifiable(const std::string& name) const;
|
||||
|
||||
// Check whether a Preference value is modifiable by a standalone browser
|
||||
// (lacros), i.e. whether there is no higher-priority source controlling it.
|
||||
bool PrefValueStandaloneBrowserModifiable(const std::string& name) const;
|
||||
|
||||
// Update the command line PrefStore with |command_line_prefs|.
|
||||
void UpdateCommandLinePrefStore(PrefStore* command_line_prefs);
|
||||
|
||||
|
@ -35,7 +35,6 @@ const char kManagedPref[] = "this.pref.managed";
|
||||
const char kSupervisedUserPref[] = "this.pref.supervised_user";
|
||||
const char kCommandLinePref[] = "this.pref.command_line";
|
||||
const char kExtensionPref[] = "this.pref.extension";
|
||||
const char kStandaloneBrowserPref[] = "this.pref.standalone_browser";
|
||||
const char kUserPref[] = "this.pref.user";
|
||||
const char kRecommendedPref[] = "this.pref.recommended";
|
||||
const char kDefaultPref[] = "this.pref.default";
|
||||
@ -58,18 +57,10 @@ const char kSupervisedUserValue[] = "extension:supervised_user";
|
||||
const char kExtensionValue[] = "extension:extension";
|
||||
}
|
||||
|
||||
namespace standalone_browser_pref {
|
||||
const char kManagedValue[] = "standalone_browser:managed";
|
||||
const char kSupervisedUserValue[] = "standalone_browser:supervised_user";
|
||||
const char kExtensionValue[] = "standalone_browser:extension";
|
||||
const char kStandaloneBrowserValue[] = "standalone_browser:standalone_browser";
|
||||
} // namespace standalone_browser_pref
|
||||
|
||||
namespace command_line_pref {
|
||||
const char kManagedValue[] = "command_line:managed";
|
||||
const char kSupervisedUserValue[] = "command_line:supervised_user";
|
||||
const char kExtensionValue[] = "command_line:extension";
|
||||
const char kStandaloneBrowserValue[] = "command_line:standalone_browser";
|
||||
const char kCommandLineValue[] = "command_line:command_line";
|
||||
}
|
||||
|
||||
@ -77,7 +68,6 @@ namespace user_pref {
|
||||
const char kManagedValue[] = "user:managed";
|
||||
const char kSupervisedUserValue[] = "supervised_user:supervised_user";
|
||||
const char kExtensionValue[] = "user:extension";
|
||||
const char kStandaloneBrowserValue[] = "user:standalone_browser";
|
||||
const char kCommandLineValue[] = "user:command_line";
|
||||
const char kUserValue[] = "user:user";
|
||||
}
|
||||
@ -86,7 +76,6 @@ namespace recommended_pref {
|
||||
const char kManagedValue[] = "recommended:managed";
|
||||
const char kSupervisedUserValue[] = "recommended:supervised_user";
|
||||
const char kExtensionValue[] = "recommended:extension";
|
||||
const char kStandaloneBrowserValue[] = "recommended:standalone_browser";
|
||||
const char kCommandLineValue[] = "recommended:command_line";
|
||||
const char kUserValue[] = "recommended:user";
|
||||
const char kRecommendedValue[] = "recommended:recommended";
|
||||
@ -96,7 +85,6 @@ namespace default_pref {
|
||||
const char kManagedValue[] = "default:managed";
|
||||
const char kSupervisedUserValue[] = "default:supervised_user";
|
||||
const char kExtensionValue[] = "default:extension";
|
||||
const char kStandaloneBrowserValue[] = "default:standalone_browser";
|
||||
const char kCommandLineValue[] = "default:command_line";
|
||||
const char kUserValue[] = "default:user";
|
||||
const char kRecommendedValue[] = "default:recommended";
|
||||
@ -110,7 +98,6 @@ class PrefValueStoreTest : public testing::Test {
|
||||
CreateManagedPrefs();
|
||||
CreateSupervisedUserPrefs();
|
||||
CreateExtensionPrefs();
|
||||
CreateStandaloneBrowserPrefs();
|
||||
CreateCommandLinePrefs();
|
||||
CreateUserPrefs();
|
||||
CreateRecommendedPrefs();
|
||||
@ -119,10 +106,9 @@ class PrefValueStoreTest : public testing::Test {
|
||||
// Create a fresh PrefValueStore.
|
||||
pref_value_store_ = std::make_unique<PrefValueStore>(
|
||||
managed_pref_store_.get(), supervised_user_pref_store_.get(),
|
||||
extension_pref_store_.get(), standalone_browser_pref_store_.get(),
|
||||
command_line_pref_store_.get(), user_pref_store_.get(),
|
||||
recommended_pref_store_.get(), default_pref_store_.get(),
|
||||
&pref_notifier_);
|
||||
extension_pref_store_.get(), command_line_pref_store_.get(),
|
||||
user_pref_store_.get(), recommended_pref_store_.get(),
|
||||
default_pref_store_.get(), &pref_notifier_);
|
||||
}
|
||||
|
||||
void CreateManagedPrefs() {
|
||||
@ -155,20 +141,6 @@ class PrefValueStoreTest : public testing::Test {
|
||||
extension_pref::kExtensionValue);
|
||||
}
|
||||
|
||||
void CreateStandaloneBrowserPrefs() {
|
||||
standalone_browser_pref_store_ = new TestingPrefStore;
|
||||
standalone_browser_pref_store_->SetString(
|
||||
prefs::kManagedPref, standalone_browser_pref::kManagedValue);
|
||||
standalone_browser_pref_store_->SetString(
|
||||
prefs::kSupervisedUserPref,
|
||||
standalone_browser_pref::kSupervisedUserValue);
|
||||
standalone_browser_pref_store_->SetString(
|
||||
prefs::kExtensionPref, standalone_browser_pref::kExtensionValue);
|
||||
standalone_browser_pref_store_->SetString(
|
||||
prefs::kStandaloneBrowserPref,
|
||||
standalone_browser_pref::kStandaloneBrowserValue);
|
||||
}
|
||||
|
||||
void CreateCommandLinePrefs() {
|
||||
command_line_pref_store_ = new TestingPrefStore;
|
||||
command_line_pref_store_->SetString(
|
||||
@ -180,9 +152,6 @@ class PrefValueStoreTest : public testing::Test {
|
||||
command_line_pref_store_->SetString(
|
||||
prefs::kExtensionPref,
|
||||
command_line_pref::kExtensionValue);
|
||||
command_line_pref_store_->SetString(
|
||||
prefs::kStandaloneBrowserPref,
|
||||
command_line_pref::kStandaloneBrowserValue);
|
||||
command_line_pref_store_->SetString(
|
||||
prefs::kCommandLinePref,
|
||||
command_line_pref::kCommandLineValue);
|
||||
@ -202,8 +171,6 @@ class PrefValueStoreTest : public testing::Test {
|
||||
user_pref_store_->SetString(
|
||||
prefs::kExtensionPref,
|
||||
user_pref::kExtensionValue);
|
||||
user_pref_store_->SetString(prefs::kStandaloneBrowserPref,
|
||||
user_pref::kStandaloneBrowserValue);
|
||||
user_pref_store_->SetString(
|
||||
prefs::kUserPref,
|
||||
user_pref::kUserValue);
|
||||
@ -223,9 +190,6 @@ class PrefValueStoreTest : public testing::Test {
|
||||
recommended_pref_store_->SetString(
|
||||
prefs::kExtensionPref,
|
||||
recommended_pref::kExtensionValue);
|
||||
recommended_pref_store_->SetString(
|
||||
prefs::kStandaloneBrowserPref,
|
||||
recommended_pref::kStandaloneBrowserValue);
|
||||
recommended_pref_store_->SetString(
|
||||
prefs::kUserPref,
|
||||
recommended_pref::kUserValue);
|
||||
@ -248,8 +212,6 @@ class PrefValueStoreTest : public testing::Test {
|
||||
default_pref_store_->SetString(
|
||||
prefs::kExtensionPref,
|
||||
default_pref::kExtensionValue);
|
||||
default_pref_store_->SetString(prefs::kStandaloneBrowserPref,
|
||||
default_pref::kStandaloneBrowserValue);
|
||||
default_pref_store_->SetString(
|
||||
prefs::kUserPref,
|
||||
default_pref::kUserValue);
|
||||
@ -275,7 +237,6 @@ class PrefValueStoreTest : public testing::Test {
|
||||
scoped_refptr<TestingPrefStore> managed_pref_store_;
|
||||
scoped_refptr<TestingPrefStore> supervised_user_pref_store_;
|
||||
scoped_refptr<TestingPrefStore> extension_pref_store_;
|
||||
scoped_refptr<TestingPrefStore> standalone_browser_pref_store_;
|
||||
scoped_refptr<TestingPrefStore> command_line_pref_store_;
|
||||
scoped_refptr<TestingPrefStore> user_pref_store_;
|
||||
scoped_refptr<TestingPrefStore> recommended_pref_store_;
|
||||
@ -505,7 +466,6 @@ TEST_F(PrefValueStoreTest, OnInitializationCompleted) {
|
||||
managed_pref_store_->SetInitializationCompleted();
|
||||
supervised_user_pref_store_->SetInitializationCompleted();
|
||||
extension_pref_store_->SetInitializationCompleted();
|
||||
standalone_browser_pref_store_->SetInitializationCompleted();
|
||||
command_line_pref_store_->SetInitializationCompleted();
|
||||
recommended_pref_store_->SetInitializationCompleted();
|
||||
default_pref_store_->SetInitializationCompleted();
|
||||
@ -524,8 +484,6 @@ TEST_F(PrefValueStoreTest, PrefValueInManagedStore) {
|
||||
prefs::kSupervisedUserPref));
|
||||
EXPECT_FALSE(pref_value_store_->PrefValueInManagedStore(
|
||||
prefs::kExtensionPref));
|
||||
EXPECT_FALSE(pref_value_store_->PrefValueInManagedStore(
|
||||
prefs::kStandaloneBrowserPref));
|
||||
EXPECT_FALSE(pref_value_store_->PrefValueInManagedStore(
|
||||
prefs::kCommandLinePref));
|
||||
EXPECT_FALSE(pref_value_store_->PrefValueInManagedStore(
|
||||
@ -545,8 +503,6 @@ TEST_F(PrefValueStoreTest, PrefValueInExtensionStore) {
|
||||
prefs::kSupervisedUserPref));
|
||||
EXPECT_TRUE(pref_value_store_->PrefValueInExtensionStore(
|
||||
prefs::kExtensionPref));
|
||||
EXPECT_FALSE(pref_value_store_->PrefValueInExtensionStore(
|
||||
prefs::kStandaloneBrowserPref));
|
||||
EXPECT_FALSE(pref_value_store_->PrefValueInExtensionStore(
|
||||
prefs::kCommandLinePref));
|
||||
EXPECT_FALSE(pref_value_store_->PrefValueInExtensionStore(
|
||||
@ -566,8 +522,6 @@ TEST_F(PrefValueStoreTest, PrefValueInUserStore) {
|
||||
prefs::kSupervisedUserPref));
|
||||
EXPECT_TRUE(pref_value_store_->PrefValueInUserStore(
|
||||
prefs::kExtensionPref));
|
||||
EXPECT_TRUE(
|
||||
pref_value_store_->PrefValueInUserStore(prefs::kStandaloneBrowserPref));
|
||||
EXPECT_TRUE(pref_value_store_->PrefValueInUserStore(
|
||||
prefs::kCommandLinePref));
|
||||
EXPECT_TRUE(pref_value_store_->PrefValueInUserStore(
|
||||
@ -587,8 +541,6 @@ TEST_F(PrefValueStoreTest, PrefValueFromExtensionStore) {
|
||||
prefs::kSupervisedUserPref));
|
||||
EXPECT_TRUE(pref_value_store_->PrefValueFromExtensionStore(
|
||||
prefs::kExtensionPref));
|
||||
EXPECT_FALSE(pref_value_store_->PrefValueFromExtensionStore(
|
||||
prefs::kStandaloneBrowserPref));
|
||||
EXPECT_FALSE(pref_value_store_->PrefValueFromExtensionStore(
|
||||
prefs::kCommandLinePref));
|
||||
EXPECT_FALSE(pref_value_store_->PrefValueFromExtensionStore(
|
||||
@ -608,8 +560,6 @@ TEST_F(PrefValueStoreTest, PrefValueFromUserStore) {
|
||||
prefs::kSupervisedUserPref));
|
||||
EXPECT_FALSE(pref_value_store_->PrefValueFromUserStore(
|
||||
prefs::kExtensionPref));
|
||||
EXPECT_FALSE(
|
||||
pref_value_store_->PrefValueFromUserStore(prefs::kStandaloneBrowserPref));
|
||||
EXPECT_FALSE(pref_value_store_->PrefValueFromUserStore(
|
||||
prefs::kCommandLinePref));
|
||||
EXPECT_TRUE(pref_value_store_->PrefValueFromUserStore(
|
||||
@ -629,8 +579,6 @@ TEST_F(PrefValueStoreTest, PrefValueFromRecommendedStore) {
|
||||
prefs::kSupervisedUserPref));
|
||||
EXPECT_FALSE(pref_value_store_->PrefValueFromRecommendedStore(
|
||||
prefs::kExtensionPref));
|
||||
EXPECT_FALSE(pref_value_store_->PrefValueFromRecommendedStore(
|
||||
prefs::kStandaloneBrowserPref));
|
||||
EXPECT_FALSE(pref_value_store_->PrefValueFromRecommendedStore(
|
||||
prefs::kCommandLinePref));
|
||||
EXPECT_FALSE(pref_value_store_->PrefValueFromRecommendedStore(
|
||||
@ -650,8 +598,6 @@ TEST_F(PrefValueStoreTest, PrefValueFromDefaultStore) {
|
||||
prefs::kSupervisedUserPref));
|
||||
EXPECT_FALSE(pref_value_store_->PrefValueFromDefaultStore(
|
||||
prefs::kExtensionPref));
|
||||
EXPECT_FALSE(pref_value_store_->PrefValueFromDefaultStore(
|
||||
prefs::kStandaloneBrowserPref));
|
||||
EXPECT_FALSE(pref_value_store_->PrefValueFromDefaultStore(
|
||||
prefs::kCommandLinePref));
|
||||
EXPECT_FALSE(pref_value_store_->PrefValueFromDefaultStore(
|
||||
@ -671,8 +617,6 @@ TEST_F(PrefValueStoreTest, PrefValueUserModifiable) {
|
||||
prefs::kSupervisedUserPref));
|
||||
EXPECT_FALSE(pref_value_store_->PrefValueUserModifiable(
|
||||
prefs::kExtensionPref));
|
||||
EXPECT_FALSE(pref_value_store_->PrefValueUserModifiable(
|
||||
prefs::kStandaloneBrowserPref));
|
||||
EXPECT_FALSE(pref_value_store_->PrefValueUserModifiable(
|
||||
prefs::kCommandLinePref));
|
||||
EXPECT_TRUE(pref_value_store_->PrefValueUserModifiable(
|
||||
@ -692,8 +636,6 @@ TEST_F(PrefValueStoreTest, PrefValueExtensionModifiable) {
|
||||
prefs::kSupervisedUserPref));
|
||||
EXPECT_TRUE(pref_value_store_->PrefValueExtensionModifiable(
|
||||
prefs::kExtensionPref));
|
||||
EXPECT_TRUE(pref_value_store_->PrefValueExtensionModifiable(
|
||||
prefs::kStandaloneBrowserPref));
|
||||
EXPECT_TRUE(pref_value_store_->PrefValueExtensionModifiable(
|
||||
prefs::kCommandLinePref));
|
||||
EXPECT_TRUE(pref_value_store_->PrefValueExtensionModifiable(
|
||||
|
@ -19,7 +19,6 @@ TestingPrefServiceBase<PrefService, PrefRegistry>::TestingPrefServiceBase(
|
||||
scoped_refptr<TestingPrefStore> managed_prefs,
|
||||
scoped_refptr<TestingPrefStore> supervised_user_prefs,
|
||||
scoped_refptr<TestingPrefStore> extension_prefs,
|
||||
scoped_refptr<TestingPrefStore> standalone_browser_prefs,
|
||||
scoped_refptr<TestingPrefStore> user_prefs,
|
||||
scoped_refptr<TestingPrefStore> recommended_prefs,
|
||||
scoped_refptr<PrefRegistry> pref_registry,
|
||||
@ -32,14 +31,12 @@ TestingPrefServiceBase<PrefService, PrefRegistry>::TestingPrefServiceBase(
|
||||
std::make_unique<PrefValueStore>(managed_prefs.get(),
|
||||
supervised_user_prefs.get(),
|
||||
extension_prefs.get(),
|
||||
standalone_browser_prefs.get(),
|
||||
/*command_line_prefs=*/nullptr,
|
||||
user_prefs.get(),
|
||||
recommended_prefs.get(),
|
||||
pref_registry->defaults().get(),
|
||||
pref_notifier),
|
||||
user_prefs,
|
||||
standalone_browser_prefs,
|
||||
pref_registry,
|
||||
base::BindRepeating(
|
||||
&TestingPrefServiceBase<PrefService,
|
||||
@ -48,7 +45,6 @@ TestingPrefServiceBase<PrefService, PrefRegistry>::TestingPrefServiceBase(
|
||||
managed_prefs_(managed_prefs),
|
||||
supervised_user_prefs_(supervised_user_prefs),
|
||||
extension_prefs_(extension_prefs),
|
||||
standalone_browser_prefs_(standalone_browser_prefs),
|
||||
user_prefs_(user_prefs),
|
||||
recommended_prefs_(recommended_prefs) {}
|
||||
|
||||
@ -57,7 +53,6 @@ TestingPrefServiceSimple::TestingPrefServiceSimple()
|
||||
/*managed_prefs=*/base::MakeRefCounted<TestingPrefStore>(),
|
||||
/*supervised_user_prefs=*/base::MakeRefCounted<TestingPrefStore>(),
|
||||
/*extension_prefs=*/base::MakeRefCounted<TestingPrefStore>(),
|
||||
/*standalone_browser_prefs=*/base::MakeRefCounted<TestingPrefStore>(),
|
||||
/*user_prefs=*/base::MakeRefCounted<TestingPrefStore>(),
|
||||
/*recommended_prefs=*/base::MakeRefCounted<TestingPrefStore>(),
|
||||
base::MakeRefCounted<PrefRegistrySimple>(),
|
||||
|
@ -97,7 +97,6 @@ class TestingPrefServiceBase : public SuperPrefService {
|
||||
scoped_refptr<TestingPrefStore> managed_prefs,
|
||||
scoped_refptr<TestingPrefStore> supervised_user_prefs,
|
||||
scoped_refptr<TestingPrefStore> extension_prefs,
|
||||
scoped_refptr<TestingPrefStore> standalone_browser_prefs,
|
||||
scoped_refptr<TestingPrefStore> user_prefs,
|
||||
scoped_refptr<TestingPrefStore> recommended_prefs,
|
||||
scoped_refptr<ConstructionPrefRegistry> pref_registry,
|
||||
@ -122,7 +121,6 @@ class TestingPrefServiceBase : public SuperPrefService {
|
||||
scoped_refptr<TestingPrefStore> managed_prefs_;
|
||||
scoped_refptr<TestingPrefStore> supervised_user_prefs_;
|
||||
scoped_refptr<TestingPrefStore> extension_prefs_;
|
||||
scoped_refptr<TestingPrefStore> standalone_browser_prefs_;
|
||||
scoped_refptr<TestingPrefStore> user_prefs_;
|
||||
scoped_refptr<TestingPrefStore> recommended_prefs_;
|
||||
};
|
||||
@ -151,7 +149,6 @@ TestingPrefServiceBase<PrefService, PrefRegistry>::TestingPrefServiceBase(
|
||||
scoped_refptr<TestingPrefStore> managed_prefs,
|
||||
scoped_refptr<TestingPrefStore> supervised_user_prefs,
|
||||
scoped_refptr<TestingPrefStore> extension_prefs,
|
||||
scoped_refptr<TestingPrefStore> standalone_browser_prefs,
|
||||
scoped_refptr<TestingPrefStore> user_prefs,
|
||||
scoped_refptr<TestingPrefStore> recommended_prefs,
|
||||
scoped_refptr<PrefRegistry> pref_registry,
|
||||
@ -383,8 +380,8 @@ void TestingPrefServiceBase<SuperPrefService, ConstructionPrefRegistry>::
|
||||
supervised_user_prefs_->SetInitializationCompleted();
|
||||
extension_prefs_->SetInitializationCompleted();
|
||||
recommended_prefs_->SetInitializationCompleted();
|
||||
// |user_prefs_| and |standalone_browser_prefs_| are initialized in
|
||||
// PrefService constructor so no need to set initialization status again.
|
||||
// |user_prefs_| is initialized in PrefService constructor so no need to set
|
||||
// initialization status again.
|
||||
}
|
||||
|
||||
#endif // COMPONENTS_PREFS_TESTING_PREF_SERVICE_H_
|
||||
|
@ -72,7 +72,6 @@ PrefServiceSyncable::PrefServiceSyncable(
|
||||
std::unique_ptr<PrefNotifierImpl> pref_notifier,
|
||||
std::unique_ptr<PrefValueStore> pref_value_store,
|
||||
scoped_refptr<PersistentPrefStore> user_prefs,
|
||||
scoped_refptr<PersistentPrefStore> standalone_browser_prefs,
|
||||
scoped_refptr<user_prefs::PrefRegistrySyncable> pref_registry,
|
||||
scoped_refptr<PrefModelAssociatorClient> pref_model_associator_client,
|
||||
base::RepeatingCallback<void(PersistentPrefStore::PrefReadError)>
|
||||
@ -81,7 +80,6 @@ PrefServiceSyncable::PrefServiceSyncable(
|
||||
: PrefService(std::move(pref_notifier),
|
||||
std::move(pref_value_store),
|
||||
user_prefs,
|
||||
standalone_browser_prefs,
|
||||
pref_registry,
|
||||
std::move(read_error_callback),
|
||||
async),
|
||||
@ -107,7 +105,6 @@ PrefServiceSyncable::PrefServiceSyncable(
|
||||
std::unique_ptr<PrefNotifierImpl> pref_notifier,
|
||||
std::unique_ptr<PrefValueStore> pref_value_store,
|
||||
scoped_refptr<DualLayerUserPrefStore> dual_layer_user_prefs,
|
||||
scoped_refptr<PersistentPrefStore> standalone_browser_prefs,
|
||||
scoped_refptr<user_prefs::PrefRegistrySyncable> pref_registry,
|
||||
scoped_refptr<PrefModelAssociatorClient> pref_model_associator_client,
|
||||
base::RepeatingCallback<void(PersistentPrefStore::PrefReadError)>
|
||||
@ -116,7 +113,6 @@ PrefServiceSyncable::PrefServiceSyncable(
|
||||
: PrefService(std::move(pref_notifier),
|
||||
std::move(pref_value_store),
|
||||
dual_layer_user_prefs,
|
||||
standalone_browser_prefs,
|
||||
pref_registry,
|
||||
std::move(read_error_callback),
|
||||
async),
|
||||
@ -185,13 +181,10 @@ PrefServiceSyncable::CreateIncognitoPrefService(
|
||||
incognito_pref_store->RegisterPersistentPref(persistent_pref_name);
|
||||
}
|
||||
|
||||
// Only the primary profile can configure the standalone_browser_store.
|
||||
auto standalone_browser_store = base::MakeRefCounted<InMemoryPrefStore>();
|
||||
|
||||
auto pref_value_store = pref_value_store_->CloneAndSpecialize(
|
||||
nullptr, // managed
|
||||
nullptr, // supervised_user
|
||||
incognito_extension_pref_store, standalone_browser_store.get(),
|
||||
incognito_extension_pref_store,
|
||||
nullptr, // command_line_prefs
|
||||
incognito_pref_store.get(),
|
||||
nullptr, // recommended
|
||||
@ -199,7 +192,6 @@ PrefServiceSyncable::CreateIncognitoPrefService(
|
||||
return std::make_unique<PrefServiceSyncable>(
|
||||
std::move(pref_notifier), std::move(pref_value_store),
|
||||
incognito_pref_store,
|
||||
nullptr, // standalone_browser_prefs
|
||||
std::move(forked_registry), pref_sync_associator_.client(),
|
||||
read_error_callback_, false);
|
||||
}
|
||||
|
@ -45,7 +45,6 @@ class PrefServiceSyncable : public PrefService,
|
||||
std::unique_ptr<PrefNotifierImpl> pref_notifier,
|
||||
std::unique_ptr<PrefValueStore> pref_value_store,
|
||||
scoped_refptr<PersistentPrefStore> user_prefs,
|
||||
scoped_refptr<PersistentPrefStore> standalone_browser_prefs,
|
||||
scoped_refptr<user_prefs::PrefRegistrySyncable> pref_registry,
|
||||
scoped_refptr<PrefModelAssociatorClient> pref_model_associator_client,
|
||||
base::RepeatingCallback<void(PersistentPrefStore::PrefReadError)>
|
||||
@ -63,7 +62,6 @@ class PrefServiceSyncable : public PrefService,
|
||||
std::unique_ptr<PrefNotifierImpl> pref_notifier,
|
||||
std::unique_ptr<PrefValueStore> pref_value_store,
|
||||
scoped_refptr<DualLayerUserPrefStore> dual_layer_user_prefs,
|
||||
scoped_refptr<PersistentPrefStore> standalone_browser_prefs,
|
||||
scoped_refptr<user_prefs::PrefRegistrySyncable> pref_registry,
|
||||
scoped_refptr<PrefModelAssociatorClient> pref_model_associator_client,
|
||||
base::RepeatingCallback<void(PersistentPrefStore::PrefReadError)>
|
||||
|
@ -76,27 +76,25 @@ std::unique_ptr<PrefServiceSyncable> PrefServiceSyncableFactory::CreateSyncable(
|
||||
user_prefs_, account_pref_store_, pref_model_associator_client_);
|
||||
auto pref_value_store = std::make_unique<PrefValueStore>(
|
||||
managed_prefs_.get(), supervised_user_prefs_.get(),
|
||||
extension_prefs_.get(), standalone_browser_prefs_.get(),
|
||||
command_line_prefs_.get(), dual_layer_user_pref_store.get(),
|
||||
recommended_prefs_.get(), pref_registry->defaults().get(),
|
||||
pref_notifier.get());
|
||||
extension_prefs_.get(), command_line_prefs_.get(),
|
||||
dual_layer_user_pref_store.get(), recommended_prefs_.get(),
|
||||
pref_registry->defaults().get(), pref_notifier.get());
|
||||
return std::make_unique<PrefServiceSyncable>(
|
||||
std::move(pref_notifier), std::move(pref_value_store),
|
||||
std::move(dual_layer_user_pref_store), standalone_browser_prefs_,
|
||||
std::move(pref_registry), pref_model_associator_client_,
|
||||
read_error_callback_, async_);
|
||||
std::move(dual_layer_user_pref_store), std::move(pref_registry),
|
||||
pref_model_associator_client_, read_error_callback_, async_);
|
||||
}
|
||||
|
||||
auto pref_value_store = std::make_unique<PrefValueStore>(
|
||||
managed_prefs_.get(), supervised_user_prefs_.get(),
|
||||
extension_prefs_.get(), standalone_browser_prefs_.get(),
|
||||
command_line_prefs_.get(), user_prefs_.get(), recommended_prefs_.get(),
|
||||
pref_registry->defaults().get(), pref_notifier.get());
|
||||
extension_prefs_.get(), command_line_prefs_.get(), user_prefs_.get(),
|
||||
recommended_prefs_.get(), pref_registry->defaults().get(),
|
||||
pref_notifier.get());
|
||||
|
||||
return std::make_unique<PrefServiceSyncable>(
|
||||
std::move(pref_notifier), std::move(pref_value_store), user_prefs_,
|
||||
standalone_browser_prefs_, std::move(pref_registry),
|
||||
pref_model_associator_client_, read_error_callback_, async_);
|
||||
std::move(pref_registry), pref_model_associator_client_,
|
||||
read_error_callback_, async_);
|
||||
}
|
||||
|
||||
} // namespace sync_preferences
|
||||
|
@ -435,11 +435,9 @@ class PrefServiceSyncableMergeTest : public testing::Test {
|
||||
new TestingPrefStore,
|
||||
new TestingPrefStore,
|
||||
user_prefs_.get(),
|
||||
standalone_browser_prefs_.get(),
|
||||
pref_registry_->defaults().get(),
|
||||
pref_notifier_),
|
||||
user_prefs_,
|
||||
standalone_browser_prefs_,
|
||||
pref_registry_,
|
||||
client_,
|
||||
/*read_error_callback=*/base::DoNothing(),
|
||||
@ -521,8 +519,6 @@ class PrefServiceSyncableMergeTest : public testing::Test {
|
||||
base::MakeRefCounted<TestingPrefStore>();
|
||||
scoped_refptr<TestingPrefStore> user_prefs_ =
|
||||
base::MakeRefCounted<TestingPrefStore>();
|
||||
scoped_refptr<TestingPrefStore> standalone_browser_prefs_ =
|
||||
base::MakeRefCounted<TestingPrefStore>();
|
||||
scoped_refptr<TestPrefModelAssociatorClient> client_ =
|
||||
base::MakeRefCounted<TestPrefModelAssociatorClient>();
|
||||
PrefServiceSyncable prefs_;
|
||||
@ -1001,7 +997,6 @@ class PrefServiceSyncableChromeOsTest : public testing::Test {
|
||||
: pref_registry_(base::MakeRefCounted<PrefRegistrySyncable>()),
|
||||
pref_notifier_(new PrefNotifierImpl),
|
||||
user_prefs_(base::MakeRefCounted<TestingPrefStore>()),
|
||||
standalone_browser_prefs_(base::MakeRefCounted<TestingPrefStore>()),
|
||||
managed_prefs_(base::MakeRefCounted<TestingPrefStore>()),
|
||||
supervised_user_prefs_(base::MakeRefCounted<TestingPrefStore>()),
|
||||
extension_prefs_(base::MakeRefCounted<TestingPrefStore>()),
|
||||
@ -1029,11 +1024,10 @@ class PrefServiceSyncableChromeOsTest : public testing::Test {
|
||||
std::unique_ptr<PrefNotifierImpl>(pref_notifier_),
|
||||
std::make_unique<PrefValueStore>(
|
||||
managed_prefs_.get(), supervised_user_prefs_.get(),
|
||||
extension_prefs_.get(), standalone_browser_prefs_.get(),
|
||||
command_line_prefs_.get(), user_prefs_.get(),
|
||||
recommended_prefs_.get(), pref_registry_->defaults().get(),
|
||||
pref_notifier_),
|
||||
user_prefs_, standalone_browser_prefs_, pref_registry_, client_,
|
||||
extension_prefs_.get(), command_line_prefs_.get(),
|
||||
user_prefs_.get(), recommended_prefs_.get(),
|
||||
pref_registry_->defaults().get(), pref_notifier_),
|
||||
user_prefs_, pref_registry_, client_,
|
||||
/*read_error_callback=*/base::DoNothing(),
|
||||
/*async=*/false);
|
||||
}
|
||||
@ -1083,7 +1077,6 @@ class PrefServiceSyncableChromeOsTest : public testing::Test {
|
||||
raw_ptr<PrefNotifierImpl, DanglingUntriaged>
|
||||
pref_notifier_; // Owned by |prefs_|.
|
||||
scoped_refptr<TestingPrefStore> user_prefs_;
|
||||
scoped_refptr<TestingPrefStore> standalone_browser_prefs_;
|
||||
scoped_refptr<TestingPrefStore> managed_prefs_;
|
||||
scoped_refptr<TestingPrefStore> supervised_user_prefs_;
|
||||
scoped_refptr<TestingPrefStore> extension_prefs_;
|
||||
@ -1344,52 +1337,6 @@ TEST_F(PrefServiceSyncableChromeOsTest, SyncedPrefObserver_EmptyCloud) {
|
||||
|
||||
prefs_->RemoveSyncedPrefObserver(kOsPrefName, &observer);
|
||||
}
|
||||
|
||||
TEST_F(PrefServiceSyncableChromeOsTest,
|
||||
StandaloneBrowserPrefsNotLeakedInIncognito) {
|
||||
CreatePrefService();
|
||||
|
||||
prefs_->SetStandaloneBrowserPref(kOsPrefName, base::Value("test_value"));
|
||||
|
||||
scoped_refptr<TestingPrefStore> incognito_extension_pref_store =
|
||||
base::MakeRefCounted<TestingPrefStore>();
|
||||
|
||||
std::unique_ptr<PrefServiceSyncable> incognito_prefs =
|
||||
prefs_->CreateIncognitoPrefService(incognito_extension_pref_store.get(),
|
||||
/*persistent_pref_names=*/{});
|
||||
|
||||
// Verify that the primary profile has the `kOsPrefName` pref set.
|
||||
{
|
||||
const PrefService::Preference* main_profile_pref =
|
||||
prefs_->FindPreference(kOsPrefName);
|
||||
ASSERT_TRUE(main_profile_pref);
|
||||
EXPECT_TRUE(main_profile_pref->IsStandaloneBrowserControlled());
|
||||
EXPECT_EQ(*main_profile_pref->GetValue(), base::Value("test_value"));
|
||||
}
|
||||
|
||||
// Verify that the incognito profile does not have the `kOsPrefName` pref set.
|
||||
{
|
||||
const PrefService::Preference* incognito_pref =
|
||||
incognito_prefs->FindPreference(kOsPrefName);
|
||||
ASSERT_TRUE(incognito_pref);
|
||||
EXPECT_FALSE(incognito_pref->IsStandaloneBrowserControlled());
|
||||
EXPECT_EQ(*incognito_pref->GetValue(), base::Value(""));
|
||||
}
|
||||
|
||||
// Ensure this does not crash if it's accidentally called.
|
||||
incognito_prefs->SetStandaloneBrowserPref(kOsPrefName,
|
||||
base::Value("test_value"));
|
||||
// Verify that standalone browser settings cannot be configured by the
|
||||
// Incognito profile.
|
||||
{
|
||||
const PrefService::Preference* incognito_pref =
|
||||
incognito_prefs->FindPreference(kOsPrefName);
|
||||
ASSERT_TRUE(incognito_pref);
|
||||
EXPECT_FALSE(incognito_pref->IsStandaloneBrowserControlled());
|
||||
EXPECT_EQ(*incognito_pref->GetValue(), base::Value(""));
|
||||
}
|
||||
}
|
||||
|
||||
#endif // BUILDFLAG(IS_CHROMEOS)
|
||||
|
||||
class PrefServiceSyncableFactoryTest : public PrefServiceSyncableTest {
|
||||
|
@ -19,7 +19,6 @@ TestingPrefServiceBase<sync_preferences::PrefServiceSyncable,
|
||||
scoped_refptr<TestingPrefStore> managed_prefs,
|
||||
scoped_refptr<TestingPrefStore> supervised_user_prefs,
|
||||
scoped_refptr<TestingPrefStore> extension_prefs,
|
||||
scoped_refptr<TestingPrefStore> standalone_browser_prefs,
|
||||
scoped_refptr<TestingPrefStore> user_prefs,
|
||||
scoped_refptr<TestingPrefStore> recommended_prefs,
|
||||
scoped_refptr<user_prefs::PrefRegistrySyncable> pref_registry,
|
||||
@ -29,14 +28,12 @@ TestingPrefServiceBase<sync_preferences::PrefServiceSyncable,
|
||||
std::make_unique<PrefValueStore>(managed_prefs.get(),
|
||||
supervised_user_prefs.get(),
|
||||
extension_prefs.get(),
|
||||
standalone_browser_prefs.get(),
|
||||
/*command_line_prefs=*/nullptr,
|
||||
user_prefs.get(),
|
||||
recommended_prefs.get(),
|
||||
pref_registry->defaults().get(),
|
||||
pref_notifier),
|
||||
user_prefs,
|
||||
standalone_browser_prefs,
|
||||
pref_registry,
|
||||
/*pref_model_associator_client=*/nullptr,
|
||||
base::BindRepeating(
|
||||
@ -47,7 +44,6 @@ TestingPrefServiceBase<sync_preferences::PrefServiceSyncable,
|
||||
managed_prefs_(managed_prefs),
|
||||
supervised_user_prefs_(supervised_user_prefs),
|
||||
extension_prefs_(extension_prefs),
|
||||
standalone_browser_prefs_(standalone_browser_prefs),
|
||||
user_prefs_(user_prefs),
|
||||
recommended_prefs_(recommended_prefs) {}
|
||||
|
||||
@ -58,7 +54,6 @@ TestingPrefServiceSyncable::TestingPrefServiceSyncable()
|
||||
/*managed_prefs=*/base::MakeRefCounted<TestingPrefStore>(),
|
||||
/*supervised_user_prefs=*/base::MakeRefCounted<TestingPrefStore>(),
|
||||
/*extension_prefs=*/base::MakeRefCounted<TestingPrefStore>(),
|
||||
/*standalone_browser_prefs=*/base::MakeRefCounted<TestingPrefStore>(),
|
||||
/*user_prefs=*/base::MakeRefCounted<TestingPrefStore>(),
|
||||
/*recommended_prefs=*/base::MakeRefCounted<TestingPrefStore>(),
|
||||
base::MakeRefCounted<user_prefs::PrefRegistrySyncable>(),
|
||||
@ -68,7 +63,6 @@ TestingPrefServiceSyncable::TestingPrefServiceSyncable(
|
||||
scoped_refptr<TestingPrefStore> managed_prefs,
|
||||
scoped_refptr<TestingPrefStore> supervised_user_prefs,
|
||||
scoped_refptr<TestingPrefStore> extension_prefs,
|
||||
scoped_refptr<TestingPrefStore> standalone_browser_prefs,
|
||||
scoped_refptr<TestingPrefStore> user_prefs,
|
||||
scoped_refptr<TestingPrefStore> recommended_prefs,
|
||||
scoped_refptr<user_prefs::PrefRegistrySyncable> pref_registry,
|
||||
@ -78,7 +72,6 @@ TestingPrefServiceSyncable::TestingPrefServiceSyncable(
|
||||
managed_prefs,
|
||||
supervised_user_prefs,
|
||||
extension_prefs,
|
||||
standalone_browser_prefs,
|
||||
user_prefs,
|
||||
recommended_prefs,
|
||||
pref_registry,
|
||||
|
@ -37,7 +37,6 @@ class TestingPrefServiceSyncable
|
||||
scoped_refptr<TestingPrefStore> managed_prefs,
|
||||
scoped_refptr<TestingPrefStore> supervised_user_prefs,
|
||||
scoped_refptr<TestingPrefStore> extension_prefs,
|
||||
scoped_refptr<TestingPrefStore> standalone_browser_prefs,
|
||||
scoped_refptr<TestingPrefStore> user_prefs,
|
||||
scoped_refptr<TestingPrefStore> recommended_prefs,
|
||||
scoped_refptr<user_prefs::PrefRegistrySyncable> pref_registry,
|
||||
@ -64,7 +63,6 @@ TestingPrefServiceBase<sync_preferences::PrefServiceSyncable,
|
||||
scoped_refptr<TestingPrefStore> managed_prefs,
|
||||
scoped_refptr<TestingPrefStore> supervised_user_prefs,
|
||||
scoped_refptr<TestingPrefStore> extension_prefs,
|
||||
scoped_refptr<TestingPrefStore> standalone_browser_prefs,
|
||||
scoped_refptr<TestingPrefStore> user_prefs,
|
||||
scoped_refptr<TestingPrefStore> recommended_prefs,
|
||||
scoped_refptr<user_prefs::PrefRegistrySyncable> pref_registry,
|
||||
|
Reference in New Issue
Block a user