#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "chrome/browser/prefs/chrome_pref_service_factory.h"
#include <stddef.h>
#include <string>
#include <utility>
#include <vector>
#include "base/command_line.h"
#include "base/compiler_specific.h"
#include "base/files/file_path.h"
#include "base/functional/bind.h"
#include "base/metrics/field_trial.h"
#include "base/metrics/histogram_macros.h"
#include "base/path_service.h"
#include "base/strings/stringprintf.h"
#include "base/task/sequenced_task_runner.h"
#include "base/task/single_thread_task_runner.h"
#include "base/time/time.h"
#include "base/trace_event/trace_event.h"
#include "build/branding_buildflags.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/enterprise/signin/enterprise_signin_prefs.h"
#include "chrome/browser/policy/chrome_browser_policy_connector.h"
#include "chrome/browser/prefs/chrome_command_line_pref_store.h"
#include "chrome/browser/prefs/chrome_pref_model_associator_client.h"
#include "chrome/browser/prefs/profile_pref_store_manager.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/sync/glue/sync_start_util.h"
#include "chrome/browser/sync/prefs/chrome_syncable_prefs_database.h"
#include "chrome/browser/ui/profiles/profile_error_dialog.h"
#include "chrome/common/buildflags.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/pref_names.h"
#include "chrome/grit/branded_strings.h"
#include "chrome/grit/browser_resources.h"
#include "chrome/grit/generated_resources.h"
#include "components/component_updater/pref_names.h"
#include "components/policy/core/browser/configuration_policy_pref_store.h"
#include "components/pref_registry/pref_registry_syncable.h"
#include "components/prefs/default_pref_store.h"
#include "components/prefs/json_pref_store.h"
#include "components/prefs/pref_filter.h"
#include "components/prefs/pref_notifier_impl.h"
#include "components/prefs/pref_registry.h"
#include "components/prefs/pref_registry_simple.h"
#include "components/prefs/pref_service.h"
#include "components/prefs/pref_store.h"
#include "components/prefs/pref_value_store.h"
#include "components/prefs/wrap_with_prefix_pref_store.h"
#include "components/safe_browsing/core/common/safe_browsing_prefs.h"
#include "components/search_engines/default_search_manager.h"
#include "components/search_engines/search_engines_pref_names.h"
#include "components/signin/public/base/signin_pref_names.h"
#include "components/supervised_user/core/browser/supervised_user_pref_store.h"
#include "components/sync/base/data_type.h"
#include "components/sync/base/features.h"
#include "components/sync/base/pref_names.h"
#include "components/sync_preferences/pref_model_associator.h"
#include "components/sync_preferences/pref_service_syncable.h"
#include "components/sync_preferences/pref_service_syncable_factory.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_thread.h"
#include "extensions/buildflags/buildflags.h"
#include "mojo/public/cpp/bindings/self_owned_receiver.h"
#include "rlz/buildflags/buildflags.h"
#include "services/preferences/public/cpp/tracked/configuration.h"
#include "services/preferences/public/cpp/tracked/pref_names.h"
#include "sql/error_delegate_util.h"
#include "ui/base/resource/resource_bundle.h"
#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "base/files/file_util.h"
#endif
#if BUILDFLAG(ENABLE_EXTENSIONS)
#include "extensions/browser/pref_names.h"
#endif
#if BUILDFLAG(IS_WIN)
#include "base/enterprise_util.h"
#if BUILDFLAG(ENABLE_RLZ)
#include "rlz/lib/machine_id.h"
#endif
#endif
BrowserContext;
BrowserThread;
EnforcementLevel;
PrefTrackingStrategy;
ValueType;
namespace {
#if BUILDFLAG(IS_WIN)
bool g_disable_domain_check_for_testing = false;
#endif
const prefs::TrackedPreferenceMetadata kTrackedPrefs[] = …;
const size_t kTrackedPrefsReportingIDsCount = …;
enum SettingsEnforcementGroup { … };
SettingsEnforcementGroup GetSettingsEnforcementGroup() { … }
std::vector<prefs::mojom::TrackedPreferenceMetadataPtr>
GetTrackingConfiguration() { … }
std::unique_ptr<ProfilePrefStoreManager> CreateProfilePrefStoreManager(
const base::FilePath& profile_path) { … }
#if BUILDFLAG(IS_CHROMEOS_ASH)
void CleanupObsoleteStandaloneBrowserPrefsFile() {
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;
}
LOG(WARNING) << "Removing obsolete " << obsolete_standalone_browser_file
<< " file: "
<< base::DeleteFile(obsolete_standalone_browser_file);
}
#endif
void PrepareFactory(
sync_preferences::PrefServiceSyncableFactory* factory,
const base::FilePath& pref_filename,
policy::PolicyService* policy_service,
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) { … }
class ResetOnLoadObserverImpl : public prefs::mojom::ResetOnLoadObserver { … };
}
namespace chrome_prefs {
const char kAccountPreferencesPrefix[] = …;
std::unique_ptr<PrefService> CreateLocalState(
const base::FilePath& pref_filename,
scoped_refptr<PersistentPrefStore> pref_store,
policy::PolicyService* policy_service,
scoped_refptr<PrefRegistry> pref_registry,
policy::BrowserPolicyConnector* policy_connector) { … }
std::unique_ptr<sync_preferences::PrefServiceSyncable> CreateProfilePrefs(
const base::FilePath& profile_path,
mojo::PendingRemote<prefs::mojom::TrackedPreferenceValidationDelegate>
validation_delegate,
policy::PolicyService* policy_service,
supervised_user::SupervisedUserSettingsService* supervised_user_settings,
scoped_refptr<PrefStore> extension_prefs,
scoped_refptr<user_prefs::PrefRegistrySyncable> pref_registry,
policy::BrowserPolicyConnector* connector,
bool async,
scoped_refptr<base::SequencedTaskRunner> io_task_runner) { … }
void DisableDomainCheckForTesting() { … }
bool InitializePrefsFromMasterPrefs(const base::FilePath& profile_path,
base::Value::Dict master_prefs) { … }
base::Time GetResetTime(Profile* profile) { … }
void ClearResetTime(Profile* profile) { … }
void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry) { … }
void HandlePersistentPrefStoreReadError(
const base::FilePath& pref_filename,
PersistentPrefStore::PrefReadError error) { … }
}