Commit 701592b0 authored by Elly Fong-Jones's avatar Elly Fong-Jones Committed by Commit Bot

inclusion: start renaming installer::MasterPreferences

This is part of the process described in r783671. This change:
1) Adds an alias from installer::InitialPreferences to the existing
   installer::MasterPreferences
2) Migrates the chrome first run code to use that new alias

Next steps are migrating every other client of MasterPreferences to use
the new alias, then renaming the class itself.

Bug: 1097204
Change-Id: I8c2f5d5a61aa127f116a255dbc2727b2f027559e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2300600Reviewed-by: default avatarGreg Thompson <grt@chromium.org>
Reviewed-by: default avatarAvi Drissman <avi@chromium.org>
Reviewed-by: default avatarIlya Sherman <isherman@chromium.org>
Commit-Queue: Elly Fong-Jones <ellyjones@chromium.org>
Cr-Commit-Position: refs/heads/master@{#790092}
parent c8ab1d5a
...@@ -813,24 +813,24 @@ int ChromeBrowserMainParts::ApplyFirstRunPrefs() { ...@@ -813,24 +813,24 @@ int ChromeBrowserMainParts::ApplyFirstRunPrefs() {
#if !defined(OS_ANDROID) && !defined(OS_CHROMEOS) #if !defined(OS_ANDROID) && !defined(OS_CHROMEOS)
master_prefs_ = std::make_unique<first_run::MasterPrefs>(); master_prefs_ = std::make_unique<first_run::MasterPrefs>();
std::unique_ptr<installer::MasterPreferences> installer_master_prefs = std::unique_ptr<installer::InitialPreferences> installer_initial_prefs =
startup_data_->chrome_feature_list_creator()->TakeMasterPrefs(); startup_data_->chrome_feature_list_creator()->TakeInitialPrefs();
if (!installer_master_prefs) if (!installer_initial_prefs)
return service_manager::RESULT_CODE_NORMAL_EXIT; return service_manager::RESULT_CODE_NORMAL_EXIT;
// On first run, we need to process the predictor preferences before the // On first run, we need to process the predictor preferences before the
// browser's profile_manager object is created, but after ResourceBundle // browser's profile_manager object is created, but after ResourceBundle
// is initialized. // is initialized.
first_run::ProcessMasterPreferencesResult pmp_result = first_run::ProcessInitialPreferencesResult pip_result =
first_run::ProcessMasterPreferences(user_data_dir_, first_run::ProcessInitialPreferences(user_data_dir_,
std::move(installer_master_prefs), std::move(installer_initial_prefs),
master_prefs_.get()); master_prefs_.get());
if (pmp_result == first_run::EULA_EXIT_NOW) if (pip_result == first_run::EULA_EXIT_NOW)
return chrome::RESULT_CODE_EULA_REFUSED; return chrome::RESULT_CODE_EULA_REFUSED;
// TODO(macourteau): refactor preferences that are copied from // TODO(macourteau): refactor preferences that are copied from
// master_preferences into local_state, as a "local_state" section in // master_preferences into local_state, as a "local_state" section in
// master preferences. If possible, a generic solution would be preferred // initial preferences. If possible, a generic solution would be preferred
// over a copy one-by-one of specific preferences. Also see related TODO // over a copy one-by-one of specific preferences. Also see related TODO
// in first_run.h. // in first_run.h.
......
...@@ -233,7 +233,7 @@ namespace first_run { ...@@ -233,7 +233,7 @@ namespace first_run {
namespace internal { namespace internal {
void SetupInitialPrefsFromInstallPrefs( void SetupInitialPrefsFromInstallPrefs(
const installer::MasterPreferences& install_prefs, const installer::InitialPreferences& install_prefs,
MasterPrefs* out_prefs) { MasterPrefs* out_prefs) {
ConvertStringVectorToGURLVector( ConvertStringVectorToGURLVector(
install_prefs.GetFirstRunTabs(), &out_prefs->new_tabs); install_prefs.GetFirstRunTabs(), &out_prefs->new_tabs);
...@@ -376,7 +376,7 @@ void SetInitialPrefsPathForTesting(const base::FilePath& initial_prefs) { ...@@ -376,7 +376,7 @@ void SetInitialPrefsPathForTesting(const base::FilePath& initial_prefs) {
GetInitialPrefsPathForTesting() = initial_prefs; GetInitialPrefsPathForTesting() = initial_prefs;
} }
std::unique_ptr<installer::MasterPreferences> LoadInitialPrefs() { std::unique_ptr<installer::InitialPreferences> LoadInitialPrefs() {
base::FilePath initial_prefs_path; base::FilePath initial_prefs_path;
if (!GetInitialPrefsPathForTesting().empty()) if (!GetInitialPrefsPathForTesting().empty())
initial_prefs_path = GetInitialPrefsPathForTesting(); initial_prefs_path = GetInitialPrefsPathForTesting();
...@@ -387,15 +387,15 @@ std::unique_ptr<installer::MasterPreferences> LoadInitialPrefs() { ...@@ -387,15 +387,15 @@ std::unique_ptr<installer::MasterPreferences> LoadInitialPrefs() {
if (initial_prefs_path.empty()) if (initial_prefs_path.empty())
return nullptr; return nullptr;
auto initial_prefs = auto initial_prefs =
std::make_unique<installer::MasterPreferences>(initial_prefs_path); std::make_unique<installer::InitialPreferences>(initial_prefs_path);
if (!initial_prefs->read_from_file()) if (!initial_prefs->read_from_file())
return nullptr; return nullptr;
return initial_prefs; return initial_prefs;
} }
ProcessMasterPreferencesResult ProcessMasterPreferences( ProcessInitialPreferencesResult ProcessInitialPreferences(
const base::FilePath& user_data_dir, const base::FilePath& user_data_dir,
std::unique_ptr<installer::MasterPreferences> initial_prefs, std::unique_ptr<installer::InitialPreferences> initial_prefs,
MasterPrefs* out_prefs) { MasterPrefs* out_prefs) {
DCHECK(!user_data_dir.empty()); DCHECK(!user_data_dir.empty());
...@@ -437,8 +437,8 @@ void AutoImport( ...@@ -437,8 +437,8 @@ void AutoImport(
// Use |profile|'s PrefService to determine what to import. It will reflect in // Use |profile|'s PrefService to determine what to import. It will reflect in
// order: // order:
// 1) Policies. // 1) Policies.
// 2) Master preferences (used to initialize user prefs in // 2) Initial preferences (used to initialize user prefs in
// ProcessMasterPreferences()). // ProcessInitialPreferences()).
// 3) Recommended policies. // 3) Recommended policies.
// 4) Registered default. // 4) Registered default.
PrefService* prefs = profile->GetPrefs(); PrefService* prefs = profile->GetPrefs();
......
...@@ -48,17 +48,17 @@ enum AutoImportState { ...@@ -48,17 +48,17 @@ enum AutoImportState {
AUTO_IMPORT_BOOKMARKS_FILE_IMPORTED = 1 << 2, AUTO_IMPORT_BOOKMARKS_FILE_IMPORTED = 1 << 2,
}; };
enum ProcessMasterPreferencesResult { enum ProcessInitialPreferencesResult {
FIRST_RUN_PROCEED = 0, // Proceed with first run. FIRST_RUN_PROCEED = 0, // Proceed with first run.
EULA_EXIT_NOW, // Should immediately exit due to EULA flow. EULA_EXIT_NOW, // Should immediately exit due to EULA flow.
}; };
// See ProcessMasterPreferences for more info about this structure. // See ProcessInitialPreferences for more info about this structure.
struct MasterPrefs { struct MasterPrefs {
MasterPrefs(); MasterPrefs();
~MasterPrefs(); ~MasterPrefs();
// TODO(macourteau): as part of the master preferences refactoring effort, // TODO(macourteau): as part of the initial preferences refactoring effort,
// remove items from here which are being stored temporarily only to be later // remove items from here which are being stored temporarily only to be later
// dumped into local_state. Also see related TODO in chrome_browser_main.cc. // dumped into local_state. Also see related TODO in chrome_browser_main.cc.
...@@ -119,10 +119,6 @@ bool ShouldShowWelcomePage(); ...@@ -119,10 +119,6 @@ bool ShouldShowWelcomePage();
// Returns true if |contents| hosts one of the welcome pages. // Returns true if |contents| hosts one of the welcome pages.
bool IsOnWelcomePage(content::WebContents* contents); bool IsOnWelcomePage(content::WebContents* contents);
// Iterates over the given tabs, replacing "magic words" designated for
// use in Master Preferences files with corresponding URLs.
std::vector<GURL> ProcessMasterPrefsTabs(const std::vector<GURL>& tabs);
// Sets a flag that will cause ShouldDoPersonalDataManagerFirstRun() // Sets a flag that will cause ShouldDoPersonalDataManagerFirstRun()
// to return true exactly once, so that the browser loads // to return true exactly once, so that the browser loads
// PersonalDataManager once the main message loop gets going. // PersonalDataManager once the main message loop gets going.
...@@ -136,7 +132,7 @@ void SetShouldDoPersonalDataManagerFirstRun(); ...@@ -136,7 +132,7 @@ void SetShouldDoPersonalDataManagerFirstRun();
bool ShouldDoPersonalDataManagerFirstRun(); bool ShouldDoPersonalDataManagerFirstRun();
// Automatically imports items requested by |profile|'s configuration (sum of // Automatically imports items requested by |profile|'s configuration (sum of
// policies and master prefs). Also imports bookmarks from file if // policies and initial prefs). Also imports bookmarks from file if
// |import_bookmarks_path| is not empty. // |import_bookmarks_path| is not empty.
void AutoImport(Profile* profile, void AutoImport(Profile* profile,
const std::string& import_bookmarks_path); const std::string& import_bookmarks_path);
...@@ -151,19 +147,19 @@ void DoPostImportTasks(Profile* profile, bool make_chrome_default_for_user); ...@@ -151,19 +147,19 @@ void DoPostImportTasks(Profile* profile, bool make_chrome_default_for_user);
// values in AutoImportState. // values in AutoImportState.
uint16_t auto_import_state(); uint16_t auto_import_state();
// Set a master preferences file path that overrides platform defaults. // Set a initial preferences file path that overrides platform defaults.
void SetInitialPrefsPathForTesting(const base::FilePath& master_prefs); void SetInitialPrefsPathForTesting(const base::FilePath& master_prefs);
// Loads master preferences from the master preference file into the installer // Loads initial preferences from the initial preference file into the installer
// master preferences. Returns the pointer to installer::MasterPreferences // initial preferences. Returns the pointer to installer::InitialPreferences
// object if successful; otherwise, returns nullptr. // object if successful; otherwise, returns nullptr.
std::unique_ptr<installer::MasterPreferences> LoadInitialPrefs(); std::unique_ptr<installer::InitialPreferences> LoadInitialPrefs();
// The master_preferences is a JSON file with the same entries as the // The master_preferences is a JSON file with the same entries as the
// 'Default\Preferences' file. This function locates this file from a standard // 'Default\Preferences' file. This function locates this file from a standard
// location, processes it, and uses its content to initialize the preferences // location, processes it, and uses its content to initialize the preferences
// for the profile pointed to by |user_data_dir|. After processing the file, // for the profile pointed to by |user_data_dir|. After processing the file,
// this function returns a value from the ProcessMasterPreferencesResult enum, // this function returns a value from the ProcessInitialPreferencesResult enum,
// indicating whether the first run flow should be shown, skipped, or whether // indicating whether the first run flow should be shown, skipped, or whether
// the browser should exit. // the browser should exit.
// //
...@@ -172,9 +168,9 @@ std::unique_ptr<installer::MasterPreferences> LoadInitialPrefs(); ...@@ -172,9 +168,9 @@ std::unique_ptr<installer::MasterPreferences> LoadInitialPrefs();
// //
// See chrome/installer/util/master_preferences.h for a description of // See chrome/installer/util/master_preferences.h for a description of
// 'master_preferences' file. // 'master_preferences' file.
ProcessMasterPreferencesResult ProcessMasterPreferences( ProcessInitialPreferencesResult ProcessInitialPreferences(
const base::FilePath& user_data_dir, const base::FilePath& user_data_dir,
std::unique_ptr<installer::MasterPreferences> install_prefs, std::unique_ptr<installer::InitialPreferences> initial_prefs,
MasterPrefs* out_prefs); MasterPrefs* out_prefs);
} // namespace first_run } // namespace first_run
......
...@@ -15,6 +15,7 @@ class FilePath; ...@@ -15,6 +15,7 @@ class FilePath;
namespace installer { namespace installer {
class MasterPreferences; class MasterPreferences;
using InitialPreferences = MasterPreferences;
} }
namespace first_run { namespace first_run {
...@@ -31,7 +32,7 @@ enum FirstRunState { ...@@ -31,7 +32,7 @@ enum FirstRunState {
// Sets up initial preferences by preferences passed by installer. // Sets up initial preferences by preferences passed by installer.
void SetupInitialPrefsFromInstallPrefs( void SetupInitialPrefsFromInstallPrefs(
const installer::MasterPreferences& install_prefs, const installer::InitialPreferences& install_prefs,
MasterPrefs* out_prefs); MasterPrefs* out_prefs);
// Get the file path of the first run sentinel; returns false on failure. // Get the file path of the first run sentinel; returns false on failure.
...@@ -54,7 +55,7 @@ bool IsOrganicFirstRun(); ...@@ -54,7 +55,7 @@ bool IsOrganicFirstRun();
// Shows the EULA dialog if required. Returns true if the EULA is accepted, // Shows the EULA dialog if required. Returns true if the EULA is accepted,
// returns false if the EULA has not been accepted, in which case the browser // returns false if the EULA has not been accepted, in which case the browser
// should exit. // should exit.
bool ShowPostInstallEULAIfNeeded(installer::MasterPreferences* install_prefs); bool ShowPostInstallEULAIfNeeded(installer::InitialPreferences* install_prefs);
// Returns the path for the initial preferences file. // Returns the path for the initial preferences file.
base::FilePath InitialPrefsPath(); base::FilePath InitialPrefsPath();
......
...@@ -113,7 +113,7 @@ bool IsFirstRunSentinelPresent() { ...@@ -113,7 +113,7 @@ bool IsFirstRunSentinelPresent() {
return !GetFirstRunSentinelFilePath(&sentinel) || base::PathExists(sentinel); return !GetFirstRunSentinelFilePath(&sentinel) || base::PathExists(sentinel);
} }
bool ShowPostInstallEULAIfNeeded(installer::MasterPreferences* install_prefs) { bool ShowPostInstallEULAIfNeeded(installer::InitialPreferences* install_prefs) {
// The EULA is only handled on Windows. // The EULA is only handled on Windows.
return true; return true;
} }
......
...@@ -69,7 +69,7 @@ bool LaunchSetupForEula(const base::FilePath::StringType& value, ...@@ -69,7 +69,7 @@ bool LaunchSetupForEula(const base::FilePath::StringType& value,
// Returns true if the EULA is required but has not been accepted by this user. // Returns true if the EULA is required but has not been accepted by this user.
// The EULA is considered having been accepted if the user has gotten past // The EULA is considered having been accepted if the user has gotten past
// first run in the "other" environment (desktop or metro). // first run in the "other" environment (desktop or metro).
bool IsEULANotAccepted(installer::MasterPreferences* install_prefs) { bool IsEULANotAccepted(installer::InitialPreferences* install_prefs) {
bool value = false; bool value = false;
if (install_prefs->GetBool(installer::master_preferences::kRequireEula, if (install_prefs->GetBool(installer::master_preferences::kRequireEula,
&value) && value) { &value) && value) {
...@@ -125,7 +125,7 @@ bool IsFirstRunSentinelPresent() { ...@@ -125,7 +125,7 @@ bool IsFirstRunSentinelPresent() {
return !GetFirstRunSentinelFilePath(&sentinel) || base::PathExists(sentinel); return !GetFirstRunSentinelFilePath(&sentinel) || base::PathExists(sentinel);
} }
bool ShowPostInstallEULAIfNeeded(installer::MasterPreferences* install_prefs) { bool ShowPostInstallEULAIfNeeded(installer::InitialPreferences* install_prefs) {
if (IsEULANotAccepted(install_prefs)) { if (IsEULANotAccepted(install_prefs)) {
// Show the post-installation EULA. This is done by setup.exe and the // Show the post-installation EULA. This is done by setup.exe and the
// result determines if we continue or not. We wait here until the user // result determines if we continue or not. We wait here until the user
......
...@@ -34,7 +34,7 @@ class FirstRunTest : public testing::Test { ...@@ -34,7 +34,7 @@ class FirstRunTest : public testing::Test {
}; };
TEST_F(FirstRunTest, SetupInitialPrefsFromInstallPrefs_NoVariationsSeed) { TEST_F(FirstRunTest, SetupInitialPrefsFromInstallPrefs_NoVariationsSeed) {
installer::MasterPreferences install_prefs("{ }"); installer::InitialPreferences install_prefs("{ }");
EXPECT_TRUE(install_prefs.master_dictionary().empty()); EXPECT_TRUE(install_prefs.master_dictionary().empty());
EXPECT_TRUE(install_prefs.GetCompressedVariationsSeed().empty()); EXPECT_TRUE(install_prefs.GetCompressedVariationsSeed().empty());
...@@ -43,7 +43,7 @@ TEST_F(FirstRunTest, SetupInitialPrefsFromInstallPrefs_NoVariationsSeed) { ...@@ -43,7 +43,7 @@ TEST_F(FirstRunTest, SetupInitialPrefsFromInstallPrefs_NoVariationsSeed) {
TEST_F(FirstRunTest, TEST_F(FirstRunTest,
SetupInitialPrefsFromInstallPrefs_VariationsSeedSignature) { SetupInitialPrefsFromInstallPrefs_VariationsSeedSignature) {
installer::MasterPreferences install_prefs( installer::InitialPreferences install_prefs(
"{\"variations_compressed_seed\":\"xyz\"," "{\"variations_compressed_seed\":\"xyz\","
" \"variations_seed_signature\":\"abc\"}"); " \"variations_seed_signature\":\"abc\"}");
EXPECT_EQ(2U, install_prefs.master_dictionary().size()); EXPECT_EQ(2U, install_prefs.master_dictionary().size());
......
...@@ -58,7 +58,7 @@ void ChromeFeatureListCreator::CreateFeatureList() { ...@@ -58,7 +58,7 @@ void ChromeFeatureListCreator::CreateFeatureList() {
CreatePrefService(); CreatePrefService();
ConvertFlagsToSwitches(); ConvertFlagsToSwitches();
CreateMetricsServices(); CreateMetricsServices();
SetupMasterPrefs(); SetupInitialPrefs();
SetupFieldTrials(); SetupFieldTrials();
} }
...@@ -91,9 +91,9 @@ ChromeFeatureListCreator::TakeChromeBrowserPolicyConnector() { ...@@ -91,9 +91,9 @@ ChromeFeatureListCreator::TakeChromeBrowserPolicyConnector() {
} }
#if !defined(OS_ANDROID) && !defined(OS_CHROMEOS) #if !defined(OS_ANDROID) && !defined(OS_CHROMEOS)
std::unique_ptr<installer::MasterPreferences> std::unique_ptr<installer::InitialPreferences>
ChromeFeatureListCreator::TakeMasterPrefs() { ChromeFeatureListCreator::TakeInitialPrefs() {
return std::move(installer_master_prefs_); return std::move(installer_initial_prefs_);
} }
#endif #endif
...@@ -199,7 +199,7 @@ void ChromeFeatureListCreator::CreateMetricsServices() { ...@@ -199,7 +199,7 @@ void ChromeFeatureListCreator::CreateMetricsServices() {
std::move(client)); std::move(client));
} }
void ChromeFeatureListCreator::SetupMasterPrefs() { void ChromeFeatureListCreator::SetupInitialPrefs() {
// Android does first run in Java instead of native. // Android does first run in Java instead of native.
// Chrome OS has its own out-of-box-experience code. // Chrome OS has its own out-of-box-experience code.
#if !defined(OS_ANDROID) && !defined(OS_CHROMEOS) #if !defined(OS_ANDROID) && !defined(OS_CHROMEOS)
...@@ -209,8 +209,8 @@ void ChromeFeatureListCreator::SetupMasterPrefs() { ...@@ -209,8 +209,8 @@ void ChromeFeatureListCreator::SetupMasterPrefs() {
if (!first_run::IsChromeFirstRun()) if (!first_run::IsChromeFirstRun())
return; return;
installer_master_prefs_ = first_run::LoadInitialPrefs(); installer_initial_prefs_ = first_run::LoadInitialPrefs();
if (!installer_master_prefs_) if (!installer_initial_prefs_)
return; return;
// Store the initial VariationsService seed in local state, if it exists // Store the initial VariationsService seed in local state, if it exists
...@@ -218,9 +218,9 @@ void ChromeFeatureListCreator::SetupMasterPrefs() { ...@@ -218,9 +218,9 @@ void ChromeFeatureListCreator::SetupMasterPrefs() {
// master prefs, which is why both the seed and signature are retrieved here // master prefs, which is why both the seed and signature are retrieved here
// and not within the ifs below. // and not within the ifs below.
std::string compressed_variations_seed = std::string compressed_variations_seed =
installer_master_prefs_->GetCompressedVariationsSeed(); installer_initial_prefs_->GetCompressedVariationsSeed();
std::string variations_seed_signature = std::string variations_seed_signature =
installer_master_prefs_->GetVariationsSeedSignature(); installer_initial_prefs_->GetVariationsSeedSignature();
if (!compressed_variations_seed.empty()) { if (!compressed_variations_seed.empty()) {
local_state_->SetString(variations::prefs::kVariationsCompressedSeed, local_state_->SetString(variations::prefs::kVariationsCompressedSeed,
......
...@@ -58,7 +58,7 @@ class ChromeFeatureListCreator { ...@@ -58,7 +58,7 @@ class ChromeFeatureListCreator {
TakeChromeBrowserPolicyConnector(); TakeChromeBrowserPolicyConnector();
#if !defined(OS_ANDROID) && !defined(OS_CHROMEOS) #if !defined(OS_ANDROID) && !defined(OS_CHROMEOS)
std::unique_ptr<installer::MasterPreferences> TakeMasterPrefs(); std::unique_ptr<installer::InitialPreferences> TakeInitialPrefs();
#endif #endif
PrefService* local_state() { return local_state_.get(); } PrefService* local_state() { return local_state_.get(); }
...@@ -77,10 +77,10 @@ class ChromeFeatureListCreator { ...@@ -77,10 +77,10 @@ class ChromeFeatureListCreator {
void SetupFieldTrials(); void SetupFieldTrials();
void CreateMetricsServices(); void CreateMetricsServices();
// Imports variations master preference any preferences (to local state) // Imports variations initial preference any preferences (to local state)
// needed for first run. This is always called and early outs if not // needed for first run. This is always called and early outs if not
// first-run. // first-run.
void SetupMasterPrefs(); void SetupInitialPrefs();
// Must be destroyed after |local_state_|. // Must be destroyed after |local_state_|.
std::unique_ptr<policy::ChromeBrowserPolicyConnector> std::unique_ptr<policy::ChromeBrowserPolicyConnector>
...@@ -103,7 +103,7 @@ class ChromeFeatureListCreator { ...@@ -103,7 +103,7 @@ class ChromeFeatureListCreator {
std::unique_ptr<ChromeBrowserFieldTrials> browser_field_trials_; std::unique_ptr<ChromeBrowserFieldTrials> browser_field_trials_;
#if !defined(OS_ANDROID) && !defined(OS_CHROMEOS) #if !defined(OS_ANDROID) && !defined(OS_CHROMEOS)
std::unique_ptr<installer::MasterPreferences> installer_master_prefs_; std::unique_ptr<installer::InitialPreferences> installer_initial_prefs_;
#endif #endif
DISALLOW_COPY_AND_ASSIGN(ChromeFeatureListCreator); DISALLOW_COPY_AND_ASSIGN(ChromeFeatureListCreator);
......
...@@ -201,6 +201,8 @@ class MasterPreferences { ...@@ -201,6 +201,8 @@ class MasterPreferences {
DISALLOW_COPY_AND_ASSIGN(MasterPreferences); DISALLOW_COPY_AND_ASSIGN(MasterPreferences);
}; };
using InitialPreferences = MasterPreferences;
} // namespace installer } // namespace installer
#endif // CHROME_INSTALLER_UTIL_MASTER_PREFERENCES_H_ #endif // CHROME_INSTALLER_UTIL_MASTER_PREFERENCES_H_
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