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

installer: most remaining 'master' -> 'initial'

This change renames all remaining variables & updates all remaining
strings describing the master_preferences file except for strings/
variables/comments that are describing the filename on disk, which
remains unchanged. The next step in this work is to add support for
a new "initial_preferences" file, then deprecate support for the old
"master_preferences" file.

Bug: 1097209
Change-Id: I98ab16002669346239e9b7642302ad832429c3e3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2551281Reviewed-by: default avatarGabriel Charette <gab@chromium.org>
Commit-Queue: Elly Fong-Jones <ellyjones@chromium.org>
Cr-Commit-Position: refs/heads/master@{#830243}
parent d543ff67
...@@ -412,7 +412,7 @@ ProcessInitialPreferencesResult ProcessInitialPreferences( ...@@ -412,7 +412,7 @@ ProcessInitialPreferencesResult ProcessInitialPreferences(
return EULA_EXIT_NOW; return EULA_EXIT_NOW;
std::unique_ptr<base::DictionaryValue> initial_dictionary = std::unique_ptr<base::DictionaryValue> initial_dictionary =
initial_prefs->master_dictionary().CreateDeepCopy(); initial_prefs->initial_dictionary().CreateDeepCopy();
// The distribution dictionary (and any prefs below it) are never registered // The distribution dictionary (and any prefs below it) are never registered
// for use in Chrome's PrefService. Strip them from the initial dictionary // for use in Chrome's PrefService. Strip them from the initial dictionary
// before mapping it to prefs. // before mapping it to prefs.
......
...@@ -22,7 +22,7 @@ base::FilePath InitialPrefsPath() { ...@@ -22,7 +22,7 @@ base::FilePath InitialPrefsPath() {
base::FilePath initial_prefs; base::FilePath initial_prefs;
if (!base::PathService::Get(base::DIR_EXE, &initial_prefs)) if (!base::PathService::Get(base::DIR_EXE, &initial_prefs))
return base::FilePath(); return base::FilePath();
return initial_prefs.AppendASCII(installer::kDefaultMasterPrefs); return initial_prefs.AppendASCII(installer::kDefaultInitialPrefs);
} }
} // namespace internal } // namespace internal
......
...@@ -157,7 +157,7 @@ base::FilePath InitialPrefsPath() { ...@@ -157,7 +157,7 @@ base::FilePath InitialPrefsPath() {
base::FilePath initial_prefs; base::FilePath initial_prefs;
if (!base::PathService::Get(base::DIR_EXE, &initial_prefs)) if (!base::PathService::Get(base::DIR_EXE, &initial_prefs))
return base::FilePath(); return base::FilePath();
return initial_prefs.AppendASCII(installer::kDefaultMasterPrefs); return initial_prefs.AppendASCII(installer::kDefaultInitialPrefs);
} }
} // namespace internal } // namespace internal
......
...@@ -35,7 +35,7 @@ class FirstRunTest : public testing::Test { ...@@ -35,7 +35,7 @@ class FirstRunTest : public testing::Test {
TEST_F(FirstRunTest, SetupInitialPrefsFromInstallPrefs_NoVariationsSeed) { TEST_F(FirstRunTest, SetupInitialPrefsFromInstallPrefs_NoVariationsSeed) {
installer::InitialPreferences install_prefs("{ }"); installer::InitialPreferences install_prefs("{ }");
EXPECT_TRUE(install_prefs.master_dictionary().empty()); EXPECT_TRUE(install_prefs.initial_dictionary().empty());
EXPECT_TRUE(install_prefs.GetCompressedVariationsSeed().empty()); EXPECT_TRUE(install_prefs.GetCompressedVariationsSeed().empty());
EXPECT_TRUE(install_prefs.GetVariationsSeedSignature().empty()); EXPECT_TRUE(install_prefs.GetVariationsSeedSignature().empty());
...@@ -46,12 +46,12 @@ TEST_F(FirstRunTest, ...@@ -46,12 +46,12 @@ TEST_F(FirstRunTest,
installer::InitialPreferences 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.initial_dictionary().size());
EXPECT_EQ("xyz", install_prefs.GetCompressedVariationsSeed()); EXPECT_EQ("xyz", install_prefs.GetCompressedVariationsSeed());
EXPECT_EQ("abc", install_prefs.GetVariationsSeedSignature()); EXPECT_EQ("abc", install_prefs.GetVariationsSeedSignature());
// Variations prefs should have been extracted (removed) from the dictionary. // Variations prefs should have been extracted (removed) from the dictionary.
EXPECT_TRUE(install_prefs.master_dictionary().empty()); EXPECT_TRUE(install_prefs.initial_dictionary().empty());
} }
// No switches and no sentinel present. This is the standard case for first run. // No switches and no sentinel present. This is the standard case for first run.
......
...@@ -148,9 +148,9 @@ void AddChromeToMediaPlayerList() { ...@@ -148,9 +148,9 @@ void AddChromeToMediaPlayerList() {
void CopyPreferenceFileForFirstRun(const InstallerState& installer_state, void CopyPreferenceFileForFirstRun(const InstallerState& installer_state,
const base::FilePath& prefs_source_path) { const base::FilePath& prefs_source_path) {
base::FilePath prefs_dest_path( base::FilePath prefs_dest_path(
installer_state.target_path().AppendASCII(kDefaultMasterPrefs)); installer_state.target_path().AppendASCII(kDefaultInitialPrefs));
if (!base::CopyFile(prefs_source_path, prefs_dest_path)) { if (!base::CopyFile(prefs_source_path, prefs_dest_path)) {
VLOG(1) << "Failed to copy master preferences from:" VLOG(1) << "Failed to copy initial preferences from:"
<< prefs_source_path.value() << " gle: " << ::GetLastError(); << prefs_source_path.value() << " gle: " << ::GetLastError();
} }
} }
...@@ -578,7 +578,7 @@ void HandleOsUpgradeForBrowser(const InstallerState& installer_state, ...@@ -578,7 +578,7 @@ void HandleOsUpgradeForBrowser(const InstallerState& installer_state,
// Read master_preferences copied beside chrome.exe at install. // Read master_preferences copied beside chrome.exe at install.
const InitialPreferences prefs( const InitialPreferences prefs(
installer_state.target_path().AppendASCII(kDefaultMasterPrefs)); installer_state.target_path().AppendASCII(kDefaultInitialPrefs));
// Update shortcuts at this install level (per-user shortcuts on system-level // Update shortcuts at this install level (per-user shortcuts on system-level
// installs will be updated through Active Setup). // installs will be updated through Active Setup).
...@@ -655,7 +655,7 @@ void HandleActiveSetupForBrowser(const InstallerState& installer_state, ...@@ -655,7 +655,7 @@ void HandleActiveSetupForBrowser(const InstallerState& installer_state,
// Read master_preferences copied beside chrome.exe at install for the sake of // Read master_preferences copied beside chrome.exe at install for the sake of
// creating/updating shortcuts. // creating/updating shortcuts.
const base::FilePath installation_root = installer_state.target_path(); const base::FilePath installation_root = installer_state.target_path();
InitialPreferences prefs(installation_root.AppendASCII(kDefaultMasterPrefs)); InitialPreferences prefs(installation_root.AppendASCII(kDefaultInitialPrefs));
base::FilePath chrome_exe(installation_root.Append(kChromeExe)); base::FilePath chrome_exe(installation_root.Append(kChromeExe));
CreateOrUpdateShortcuts(chrome_exe, prefs, CURRENT_USER, install_operation); CreateOrUpdateShortcuts(chrome_exe, prefs, CURRENT_USER, install_operation);
......
...@@ -70,7 +70,7 @@ void CreateOrUpdateShortcuts(const base::FilePath& target, ...@@ -70,7 +70,7 @@ void CreateOrUpdateShortcuts(const base::FilePath& target,
// install status (failed, new_install, updated etc). // install status (failed, new_install, updated etc).
// //
// install_params: See install_params.h // install_params: See install_params.h
// prefs: master preferences. See chrome/installer/util/initial_preferences.h. // prefs: initial preferences. See chrome/installer/util/initial_preferences.h.
// //
// Note: since caller unpacks Chrome to install_temp_path\source, the caller // Note: since caller unpacks Chrome to install_temp_path\source, the caller
// is responsible for cleaning up install_temp_path. // is responsible for cleaning up install_temp_path.
......
...@@ -286,16 +286,16 @@ class InstallShortcutTest : public testing::Test { ...@@ -286,16 +286,16 @@ class InstallShortcutTest : public testing::Test {
do_not_create_quick_launch_shortcut}, do_not_create_quick_launch_shortcut},
}; };
std::string master_prefs("{\"distribution\":{"); std::string initial_prefs("{\"distribution\":{");
for (size_t i = 0; i < base::size(desired_prefs); ++i) { for (size_t i = 0; i < base::size(desired_prefs); ++i) {
master_prefs += (i == 0 ? "\"" : ",\""); initial_prefs += (i == 0 ? "\"" : ",\"");
master_prefs += desired_prefs[i].pref_name; initial_prefs += desired_prefs[i].pref_name;
master_prefs += "\":"; initial_prefs += "\":";
master_prefs += desired_prefs[i].is_desired ? "true" : "false"; initial_prefs += desired_prefs[i].is_desired ? "true" : "false";
} }
master_prefs += "}}"; initial_prefs += "}}";
return new installer::InitialPreferences(master_prefs); return new installer::InitialPreferences(initial_prefs);
} }
base::win::ScopedCOMInitializer com_initializer_; base::win::ScopedCOMInitializer com_initializer_;
......
...@@ -26,7 +26,7 @@ class InstallationState; ...@@ -26,7 +26,7 @@ class InstallationState;
class InitialPreferences; class InitialPreferences;
// Encapsulates the state of the current installation operation. This class // Encapsulates the state of the current installation operation. This class
// interprets the command-line arguments and master preferences and determines // interprets the command-line arguments and initial preferences and determines
// the operations to be performed. // the operations to be performed.
class InstallerState { class InstallerState {
public: public:
...@@ -69,7 +69,7 @@ class InstallerState { ...@@ -69,7 +69,7 @@ class InstallerState {
bool is_msi() const { return msi_; } bool is_msi() const { return msi_; }
// True if the --verbose-logging command-line flag is set or if the // True if the --verbose-logging command-line flag is set or if the
// verbose_logging master preferences option is true. // verbose_logging initial preferences option is true.
bool verbose_logging() const { return verbose_logging_; } bool verbose_logging() const { return verbose_logging_; }
HKEY root_key() const { return root_key_; } HKEY root_key() const { return root_key_; }
......
...@@ -37,14 +37,14 @@ const install_static::InstallConstants* FindInstallMode( ...@@ -37,14 +37,14 @@ const install_static::InstallConstants* FindInstallMode(
void InitializeInstallDetails( void InitializeInstallDetails(
const base::CommandLine& command_line, const base::CommandLine& command_line,
const installer::InitialPreferences& master_preferences) { const installer::InitialPreferences& initial_preferences) {
install_static::InstallDetails::SetForProcess( install_static::InstallDetails::SetForProcess(
MakeInstallDetails(command_line, master_preferences)); MakeInstallDetails(command_line, initial_preferences));
} }
std::unique_ptr<install_static::PrimaryInstallDetails> MakeInstallDetails( std::unique_ptr<install_static::PrimaryInstallDetails> MakeInstallDetails(
const base::CommandLine& command_line, const base::CommandLine& command_line,
const installer::InitialPreferences& master_preferences) { const installer::InitialPreferences& initial_preferences) {
std::unique_ptr<install_static::PrimaryInstallDetails> details( std::unique_ptr<install_static::PrimaryInstallDetails> details(
std::make_unique<install_static::PrimaryInstallDetails>()); std::make_unique<install_static::PrimaryInstallDetails>());
...@@ -54,14 +54,14 @@ std::unique_ptr<install_static::PrimaryInstallDetails> MakeInstallDetails( ...@@ -54,14 +54,14 @@ std::unique_ptr<install_static::PrimaryInstallDetails> MakeInstallDetails(
details->set_mode(mode); details->set_mode(mode);
// The install level may be set by any of: // The install level may be set by any of:
// - distribution.system_level=true in master_preferences, // - distribution.system_level=true in initial_preferences,
// - --system-level on the command line, or // - --system-level on the command line, or
// - the GoogleUpdateIsMachine=1 environment variable. // - the GoogleUpdateIsMachine=1 environment variable.
// In all three cases the value is sussed out in InitialPreferences // In all three cases the value is sussed out in InitialPreferences
// initialization. // initialization.
bool system_level = false; bool system_level = false;
master_preferences.GetBool(installer::initial_preferences::kSystemLevel, initial_preferences.GetBool(installer::initial_preferences::kSystemLevel,
&system_level); &system_level);
details->set_system_level(system_level); details->set_system_level(system_level);
// The channel is determined based on the brand and the mode's // The channel is determined based on the brand and the mode's
......
...@@ -24,11 +24,11 @@ class InitialPreferences; ...@@ -24,11 +24,11 @@ class InitialPreferences;
// global InstallDetails for the process. // global InstallDetails for the process.
void InitializeInstallDetails( void InitializeInstallDetails(
const base::CommandLine& command_line, const base::CommandLine& command_line,
const installer::InitialPreferences& master_preferences); const installer::InitialPreferences& initial_preferences);
// Returns a PrimaryInstallDetails instance for the installer. // Returns a PrimaryInstallDetails instance for the installer.
std::unique_ptr<install_static::PrimaryInstallDetails> MakeInstallDetails( std::unique_ptr<install_static::PrimaryInstallDetails> MakeInstallDetails(
const base::CommandLine& command_line, const base::CommandLine& command_line,
const installer::InitialPreferences& master_preferences); const installer::InitialPreferences& initial_preferences);
#endif // CHROME_INSTALLER_SETUP_SETUP_INSTALL_DETAILS_H_ #endif // CHROME_INSTALLER_SETUP_SETUP_INSTALL_DETAILS_H_
...@@ -453,7 +453,7 @@ class MakeInstallDetailsTest : public testing::TestWithParam<TestData> { ...@@ -453,7 +453,7 @@ class MakeInstallDetailsTest : public testing::TestWithParam<TestData> {
command_line_(base::CommandLine::NO_PROGRAM) { command_line_(base::CommandLine::NO_PROGRAM) {
// Prepare the inputs from the process command line. // Prepare the inputs from the process command line.
command_line_.ParseFromString(test_data_.command_line); command_line_.ParseFromString(test_data_.command_line);
master_preferences_ = initial_preferences_ =
std::make_unique<installer::InitialPreferences>(command_line_); std::make_unique<installer::InitialPreferences>(command_line_);
} }
...@@ -482,8 +482,8 @@ class MakeInstallDetailsTest : public testing::TestWithParam<TestData> { ...@@ -482,8 +482,8 @@ class MakeInstallDetailsTest : public testing::TestWithParam<TestData> {
const base::CommandLine& command_line() const { return command_line_; } const base::CommandLine& command_line() const { return command_line_; }
const installer::InitialPreferences& master_preferences() const { const installer::InitialPreferences& initial_preferences() const {
return *master_preferences_; return *initial_preferences_;
} }
private: private:
...@@ -528,14 +528,14 @@ class MakeInstallDetailsTest : public testing::TestWithParam<TestData> { ...@@ -528,14 +528,14 @@ class MakeInstallDetailsTest : public testing::TestWithParam<TestData> {
HKEY root_key_; HKEY root_key_;
nt::ROOT_KEY nt_root_key_; nt::ROOT_KEY nt_root_key_;
base::CommandLine command_line_; base::CommandLine command_line_;
std::unique_ptr<installer::InitialPreferences> master_preferences_; std::unique_ptr<installer::InitialPreferences> initial_preferences_;
DISALLOW_COPY_AND_ASSIGN(MakeInstallDetailsTest); DISALLOW_COPY_AND_ASSIGN(MakeInstallDetailsTest);
}; };
TEST_P(MakeInstallDetailsTest, Test) { TEST_P(MakeInstallDetailsTest, Test) {
std::unique_ptr<install_static::PrimaryInstallDetails> details( std::unique_ptr<install_static::PrimaryInstallDetails> details(
MakeInstallDetails(command_line(), master_preferences())); MakeInstallDetails(command_line(), initial_preferences()));
EXPECT_THAT(details->install_mode_index(), Eq(test_data().index)); EXPECT_THAT(details->install_mode_index(), Eq(test_data().index));
EXPECT_THAT(details->system_level(), Eq(test_data().system_level)); EXPECT_THAT(details->system_level(), Eq(test_data().system_level));
EXPECT_THAT(details->channel(), Eq(test_data().channel)); EXPECT_THAT(details->channel(), Eq(test_data().channel));
......
...@@ -678,14 +678,14 @@ installer::InstallStatus InstallProducts(InstallationState& original_state, ...@@ -678,14 +678,14 @@ installer::InstallStatus InstallProducts(InstallationState& original_state,
DCHECK_NE(install_status, installer::UNKNOWN_STATUS); DCHECK_NE(install_status, installer::UNKNOWN_STATUS);
} }
// Delete the master preferences file if present. Note that we do not care // Delete the initial preferences file if present. Note that we do not care
// about rollback here and we schedule for deletion on reboot if the delete // about rollback here and we schedule for deletion on reboot if the delete
// fails. As such, we do not use DeleteTreeWorkItem. // fails. As such, we do not use DeleteTreeWorkItem.
if (cmd_line.HasSwitch(installer::switches::kInstallerData)) { if (cmd_line.HasSwitch(installer::switches::kInstallerData)) {
base::FilePath prefs_path( base::FilePath prefs_path(
cmd_line.GetSwitchValuePath(installer::switches::kInstallerData)); cmd_line.GetSwitchValuePath(installer::switches::kInstallerData));
if (!base::DeleteFile(prefs_path)) { if (!base::DeleteFile(prefs_path)) {
LOG(ERROR) << "Failed deleting master preferences file " LOG(ERROR) << "Failed deleting initial preferences file "
<< prefs_path.value() << prefs_path.value()
<< ", scheduling for deletion after reboot."; << ", scheduling for deletion after reboot.";
ScheduleFileSystemEntityForDeletion(prefs_path); ScheduleFileSystemEntityForDeletion(prefs_path);
...@@ -1233,13 +1233,13 @@ InstallStatus InstallProductsHelper(InstallationState& original_state, ...@@ -1233,13 +1233,13 @@ InstallStatus InstallProductsHelper(InstallationState& original_state,
// If the installation completed successfully... // If the installation completed successfully...
if (InstallUtil::GetInstallReturnCode(install_status) == 0) { if (InstallUtil::GetInstallReturnCode(install_status) == 0) {
// Update the DisplayVersion created by an MSI-based install. // Update the DisplayVersion created by an MSI-based install.
base::FilePath master_preferences_file( base::FilePath initial_preferences_file(
installer_state.target_path().AppendASCII( installer_state.target_path().AppendASCII(
installer::kDefaultMasterPrefs)); installer::kDefaultInitialPrefs));
std::string install_id; std::string install_id;
if (prefs.GetString(installer::initial_preferences::kMsiProductId, if (prefs.GetString(installer::initial_preferences::kMsiProductId,
&install_id)) { &install_id)) {
// A currently active MSI install will have specified the master- // A currently active MSI install will have specified the initial-
// preferences file on the command-line that includes the product-id. // preferences file on the command-line that includes the product-id.
// We must delay the setting of the DisplayVersion until after the // We must delay the setting of the DisplayVersion until after the
// grandparent "msiexec" process has exited. // grandparent "msiexec" process has exited.
......
...@@ -20,7 +20,7 @@ namespace installer { ...@@ -20,7 +20,7 @@ namespace installer {
std::unique_ptr<SetupSingleton> SetupSingleton::Acquire( std::unique_ptr<SetupSingleton> SetupSingleton::Acquire(
const base::CommandLine& command_line, const base::CommandLine& command_line,
const InitialPreferences& master_preferences, const InitialPreferences& initial_preferences,
InstallationState* original_state, InstallationState* original_state,
InstallerState* installer_state) { InstallerState* installer_state) {
DCHECK(original_state); DCHECK(original_state);
...@@ -84,7 +84,7 @@ std::unique_ptr<SetupSingleton> SetupSingleton::Acquire( ...@@ -84,7 +84,7 @@ std::unique_ptr<SetupSingleton> SetupSingleton::Acquire(
// Update |original_state| and |installer_state|. // Update |original_state| and |installer_state|.
original_state->Initialize(); original_state->Initialize();
installer_state->Initialize(command_line, master_preferences, installer_state->Initialize(command_line, initial_preferences,
*original_state); *original_state);
// UMA data indicates that this method succeeds > 99% of the time. // UMA data indicates that this method succeeds > 99% of the time.
......
...@@ -34,11 +34,11 @@ class SetupSingleton { ...@@ -34,11 +34,11 @@ class SetupSingleton {
// process the exclusive right to modify the Chrome installation described by // process the exclusive right to modify the Chrome installation described by
// |installer_state| (installation directory and associated registry keys). // |installer_state| (installation directory and associated registry keys).
// May block. |original_state| and |installer_state| are updated using // May block. |original_state| and |installer_state| are updated using
// |command_line| and |master_preferences| to reflect the new state of the // |command_line| and |initial_preferences| to reflect the new state of the
// installation after acquisition. Returns nullptr on failure. // installation after acquisition. Returns nullptr on failure.
static std::unique_ptr<SetupSingleton> Acquire( static std::unique_ptr<SetupSingleton> Acquire(
const base::CommandLine& command_line, const base::CommandLine& command_line,
const InitialPreferences& master_preferences, const InitialPreferences& initial_preferences,
InstallationState* original_state, InstallationState* original_state,
InstallerState* installer_state); InstallerState* installer_state);
......
...@@ -334,14 +334,14 @@ void BeginUserExperiment(const InstallerState& installer_state, ...@@ -334,14 +334,14 @@ void BeginUserExperiment(const InstallerState& installer_state,
// setup.exe immediately after a successful update or following user logon as a // setup.exe immediately after a successful update or following user logon as a
// result of Active Setup. // result of Active Setup.
void RunUserExperiment(const base::CommandLine& command_line, void RunUserExperiment(const base::CommandLine& command_line,
const InitialPreferences& master_preferences, const InitialPreferences& initial_preferences,
InstallationState* original_state, InstallationState* original_state,
InstallerState* installer_state) { InstallerState* installer_state) {
VLOG(1) << __func__; VLOG(1) << __func__;
ExperimentStorage storage; ExperimentStorage storage;
std::unique_ptr<SetupSingleton> setup_singleton(SetupSingleton::Acquire( std::unique_ptr<SetupSingleton> setup_singleton(SetupSingleton::Acquire(
command_line, master_preferences, original_state, installer_state)); command_line, initial_preferences, original_state, installer_state));
if (!setup_singleton) { if (!setup_singleton) {
VLOG(1) << "Timed out while waiting for setup singleton"; VLOG(1) << "Timed out while waiting for setup singleton";
WriteInitialState(&storage, ExperimentMetrics::kSingletonWaitTimeout); WriteInitialState(&storage, ExperimentMetrics::kSingletonWaitTimeout);
......
...@@ -38,7 +38,7 @@ void BeginUserExperiment(const InstallerState& installer_state, ...@@ -38,7 +38,7 @@ void BeginUserExperiment(const InstallerState& installer_state,
// Runs the experiment for the current user. // Runs the experiment for the current user.
void RunUserExperiment(const base::CommandLine& command_line, void RunUserExperiment(const base::CommandLine& command_line,
const InitialPreferences& master_preferences, const InitialPreferences& initial_preferences,
InstallationState* original_state, InstallationState* original_state,
InstallerState* installer_state); InstallerState* installer_state);
......
...@@ -27,7 +27,7 @@ namespace { ...@@ -27,7 +27,7 @@ namespace {
const char kFirstRunTabs[] = "first_run_tabs"; const char kFirstRunTabs[] = "first_run_tabs";
base::LazyInstance<installer::InitialPreferences>::DestructorAtExit base::LazyInstance<installer::InitialPreferences>::DestructorAtExit
g_master_preferences = LAZY_INSTANCE_INITIALIZER; g_initial_preferences = LAZY_INSTANCE_INITIALIZER;
bool GetURLFromValue(const base::Value* in_value, std::string* out_value) { bool GetURLFromValue(const base::Value* in_value, std::string* out_value) {
return in_value && out_value && in_value->GetAsString(out_value); return in_value && out_value && in_value->GetAsString(out_value);
...@@ -62,11 +62,11 @@ base::DictionaryValue* ParseDistributionPreferences( ...@@ -62,11 +62,11 @@ base::DictionaryValue* ParseDistributionPreferences(
std::string error; std::string error;
std::unique_ptr<base::Value> root(json.Deserialize(nullptr, &error)); std::unique_ptr<base::Value> root(json.Deserialize(nullptr, &error));
if (!root.get()) { if (!root.get()) {
LOG(WARNING) << "Failed to parse master prefs file: " << error; LOG(WARNING) << "Failed to parse initial prefs file: " << error;
return nullptr; return nullptr;
} }
if (!root->is_dict()) { if (!root->is_dict()) {
LOG(WARNING) << "Failed to parse master prefs file: " LOG(WARNING) << "Failed to parse initial prefs file: "
<< "Root item must be a dictionary."; << "Root item must be a dictionary.";
return nullptr; return nullptr;
} }
...@@ -103,10 +103,10 @@ void InitialPreferences::InitializeFromCommandLine( ...@@ -103,10 +103,10 @@ void InitialPreferences::InitializeFromCommandLine(
cmd_line.GetSwitchValuePath(installer::switches::kInstallerData)); cmd_line.GetSwitchValuePath(installer::switches::kInstallerData));
InitializeFromFilePath(prefs_path); InitializeFromFilePath(prefs_path);
} else { } else {
master_dictionary_.reset(new base::DictionaryValue()); initial_dictionary_.reset(new base::DictionaryValue());
} }
DCHECK(master_dictionary_.get()); DCHECK(initial_dictionary_.get());
// A simple map from command line switches to equivalent switches in the // A simple map from command line switches to equivalent switches in the
// distribution dictionary. Currently all switches added will be set to // distribution dictionary. Currently all switches added will be set to
...@@ -137,7 +137,7 @@ void InitialPreferences::InitializeFromCommandLine( ...@@ -137,7 +137,7 @@ void InitialPreferences::InitializeFromCommandLine(
if (cmd_line.HasSwitch(translate_switches[i].cmd_line_switch)) { if (cmd_line.HasSwitch(translate_switches[i].cmd_line_switch)) {
name.assign(installer::initial_preferences::kDistroDict); name.assign(installer::initial_preferences::kDistroDict);
name.append(".").append(translate_switches[i].distribution_switch); name.append(".").append(translate_switches[i].distribution_switch);
master_dictionary_->SetBoolean(name, true); initial_dictionary_->SetBoolean(name, true);
} }
} }
...@@ -147,7 +147,7 @@ void InitialPreferences::InitializeFromCommandLine( ...@@ -147,7 +147,7 @@ void InitialPreferences::InitializeFromCommandLine(
if (!str_value.empty()) { if (!str_value.empty()) {
name.assign(installer::initial_preferences::kDistroDict); name.assign(installer::initial_preferences::kDistroDict);
name.append(".").append(installer::initial_preferences::kLogFile); name.append(".").append(installer::initial_preferences::kLogFile);
master_dictionary_->SetString(name, str_value); initial_dictionary_->SetString(name, str_value);
} }
// Handle the special case of --system-level being implied by the presence of // Handle the special case of --system-level being implied by the presence of
...@@ -160,13 +160,13 @@ void InitialPreferences::InitializeFromCommandLine( ...@@ -160,13 +160,13 @@ void InitialPreferences::InitializeFromCommandLine(
VLOG(1) << "Taking system-level from environment."; VLOG(1) << "Taking system-level from environment.";
name.assign(installer::initial_preferences::kDistroDict); name.assign(installer::initial_preferences::kDistroDict);
name.append(".").append(installer::initial_preferences::kSystemLevel); name.append(".").append(installer::initial_preferences::kSystemLevel);
master_dictionary_->SetBoolean(name, true); initial_dictionary_->SetBoolean(name, true);
} }
} }
// Cache a pointer to the distribution dictionary. Ignore errors if any. // Cache a pointer to the distribution dictionary. Ignore errors if any.
master_dictionary_->GetDictionary(installer::initial_preferences::kDistroDict, initial_dictionary_->GetDictionary(
&distribution_); installer::initial_preferences::kDistroDict, &distribution_);
#endif #endif
} }
...@@ -186,15 +186,15 @@ void InitialPreferences::InitializeFromFilePath( ...@@ -186,15 +186,15 @@ void InitialPreferences::InitializeFromFilePath(
bool InitialPreferences::InitializeFromString(const std::string& json_data) { bool InitialPreferences::InitializeFromString(const std::string& json_data) {
if (!json_data.empty()) if (!json_data.empty())
master_dictionary_.reset(ParseDistributionPreferences(json_data)); initial_dictionary_.reset(ParseDistributionPreferences(json_data));
bool data_is_valid = true; bool data_is_valid = true;
if (!master_dictionary_.get()) { if (!initial_dictionary_.get()) {
master_dictionary_.reset(new base::DictionaryValue()); initial_dictionary_.reset(new base::DictionaryValue());
data_is_valid = false; data_is_valid = false;
} else { } else {
// Cache a pointer to the distribution dictionary. // Cache a pointer to the distribution dictionary.
master_dictionary_->GetDictionary( initial_dictionary_->GetDictionary(
installer::initial_preferences::kDistroDict, &distribution_); installer::initial_preferences::kDistroDict, &distribution_);
} }
...@@ -221,8 +221,8 @@ void InitialPreferences::EnforceLegacyPreferences() { ...@@ -221,8 +221,8 @@ void InitialPreferences::EnforceLegacyPreferences() {
installer::initial_preferences::kDoNotCreateQuickLaunchShortcut, true); installer::initial_preferences::kDoNotCreateQuickLaunchShortcut, true);
} }
// Deprecated boolean import master preferences now mapped to their duplicates // Deprecated boolean import initial preferences now mapped to their
// in prefs::. // duplicates in prefs::.
static constexpr char kDistroImportHistoryPref[] = "import_history"; static constexpr char kDistroImportHistoryPref[] = "import_history";
static constexpr char kDistroImportHomePagePref[] = "import_home_page"; static constexpr char kDistroImportHomePagePref[] = "import_home_page";
static constexpr char kDistroImportSearchPref[] = "import_search_engine"; static constexpr char kDistroImportSearchPref[] = "import_search_engine";
...@@ -241,7 +241,7 @@ void InitialPreferences::EnforceLegacyPreferences() { ...@@ -241,7 +241,7 @@ void InitialPreferences::EnforceLegacyPreferences() {
for (const auto& mapping : kLegacyDistroImportPrefMappings) { for (const auto& mapping : kLegacyDistroImportPrefMappings) {
bool value = false; bool value = false;
if (GetBool(mapping.old_distro_pref_path, &value)) if (GetBool(mapping.old_distro_pref_path, &value))
master_dictionary_->SetBoolean(mapping.modern_pref_path, value); initial_dictionary_->SetBoolean(mapping.modern_pref_path, value);
} }
#if BUILDFLAG(ENABLE_RLZ) #if BUILDFLAG(ENABLE_RLZ)
...@@ -250,7 +250,8 @@ void InitialPreferences::EnforceLegacyPreferences() { ...@@ -250,7 +250,8 @@ void InitialPreferences::EnforceLegacyPreferences() {
static constexpr char kDistroPingDelay[] = "ping_delay"; static constexpr char kDistroPingDelay[] = "ping_delay";
int rlz_ping_delay = 0; int rlz_ping_delay = 0;
if (GetInt(kDistroPingDelay, &rlz_ping_delay)) if (GetInt(kDistroPingDelay, &rlz_ping_delay))
master_dictionary_->SetInteger(prefs::kRlzPingDelaySeconds, rlz_ping_delay); initial_dictionary_->SetInteger(prefs::kRlzPingDelaySeconds,
rlz_ping_delay);
#endif // BUILDFLAG(ENABLE_RLZ) #endif // BUILDFLAG(ENABLE_RLZ)
} }
...@@ -277,12 +278,12 @@ bool InitialPreferences::GetString(const std::string& name, ...@@ -277,12 +278,12 @@ bool InitialPreferences::GetString(const std::string& name,
} }
std::vector<std::string> InitialPreferences::GetFirstRunTabs() const { std::vector<std::string> InitialPreferences::GetFirstRunTabs() const {
return GetNamedList(kFirstRunTabs, master_dictionary_.get()); return GetNamedList(kFirstRunTabs, initial_dictionary_.get());
} }
bool InitialPreferences::GetExtensionsBlock( bool InitialPreferences::GetExtensionsBlock(
base::DictionaryValue** extensions) const { base::DictionaryValue** extensions) const {
return master_dictionary_->GetDictionary( return initial_dictionary_->GetDictionary(
initial_preferences::kExtensionsBlock, extensions); initial_preferences::kExtensionsBlock, extensions);
} }
...@@ -298,7 +299,7 @@ std::string InitialPreferences::ExtractPrefString( ...@@ -298,7 +299,7 @@ std::string InitialPreferences::ExtractPrefString(
const std::string& name) const { const std::string& name) const {
std::string result; std::string result;
std::unique_ptr<base::Value> pref_value; std::unique_ptr<base::Value> pref_value;
if (master_dictionary_->Remove(name, &pref_value)) { if (initial_dictionary_->Remove(name, &pref_value)) {
if (!pref_value->GetAsString(&result)) if (!pref_value->GetAsString(&result))
NOTREACHED(); NOTREACHED();
} }
...@@ -307,7 +308,7 @@ std::string InitialPreferences::ExtractPrefString( ...@@ -307,7 +308,7 @@ std::string InitialPreferences::ExtractPrefString(
// static // static
const InitialPreferences& InitialPreferences::ForCurrentProcess() { const InitialPreferences& InitialPreferences::ForCurrentProcess() {
return g_master_preferences.Get(); return g_initial_preferences.Get();
} }
} // namespace installer } // namespace installer
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// //
// This file contains functions processing master preference file used by // This file contains functions processing initial preference file used by
// setup and first run. // setup and first run.
#ifndef CHROME_INSTALLER_UTIL_INITIAL_PREFERENCES_H_ #ifndef CHROME_INSTALLER_UTIL_INITIAL_PREFERENCES_H_
...@@ -24,12 +24,12 @@ class FilePath; ...@@ -24,12 +24,12 @@ class FilePath;
namespace installer { namespace installer {
#if !defined(OS_MAC) #if !defined(OS_MAC)
// This is the default name for the master preferences file used to pre-set // This is the default name for the initial preferences file used to pre-set
// values in the user profile at first run. // values in the user profile at first run.
const char kDefaultMasterPrefs[] = "master_preferences"; const char kDefaultInitialPrefs[] = "master_preferences";
#endif #endif
// The master preferences is a JSON file with the same entries as the // The initial preferences is a JSON file with the same entries as the
// 'Default\Preferences' file. This function parses the distribution // 'Default\Preferences' file. This function parses the distribution
// section of the preferences file. // section of the preferences file.
// //
...@@ -75,12 +75,12 @@ const char kDefaultMasterPrefs[] = "master_preferences"; ...@@ -75,12 +75,12 @@ const char kDefaultMasterPrefs[] = "master_preferences";
class InitialPreferences { class InitialPreferences {
public: public:
// Construct a master preferences from the current process' current command // Construct a initial preferences from the current process' current command
// line. Equivalent to calling // line. Equivalent to calling
// InitialPreferences(*CommandLine::ForCurrentProcess()). // InitialPreferences(*CommandLine::ForCurrentProcess()).
InitialPreferences(); InitialPreferences();
// Parses the command line and optionally reads the master preferences file // Parses the command line and optionally reads the initial preferences file
// to get distribution related install options (if the "installerdata" switch // to get distribution related install options (if the "installerdata" switch
// is present in the command line. // is present in the command line.
// The options from the preference file and command line are merged, with the // The options from the preference file and command line are merged, with the
...@@ -104,7 +104,7 @@ class InitialPreferences { ...@@ -104,7 +104,7 @@ class InitialPreferences {
bool GetInt(const std::string& name, int* value) const; bool GetInt(const std::string& name, int* value) const;
bool GetString(const std::string& name, std::string* value) const; bool GetString(const std::string& name, std::string* value) const;
// As part of the master preferences an optional section indicates the tabs // As part of the initial preferences an optional section indicates the tabs
// to open during first run. An example is the following: // to open during first run. An example is the following:
// //
// { // {
...@@ -119,10 +119,10 @@ class InitialPreferences { ...@@ -119,10 +119,10 @@ class InitialPreferences {
// An empty vector is returned if the first_run_tabs preference is absent. // An empty vector is returned if the first_run_tabs preference is absent.
std::vector<std::string> GetFirstRunTabs() const; std::vector<std::string> GetFirstRunTabs() const;
// The master preferences can also contain a regular extensions // The initial preferences can also contain a regular extensions
// preference block. If so, the extensions referenced there will be // preference block. If so, the extensions referenced there will be
// installed during the first run experience. // installed during the first run experience.
// An extension can go in the master prefs needs just the basic // An extension can go in the initial prefs needs just the basic
// elements such as: // elements such as:
// 1- An extension entry under settings, assigned by the gallery // 1- An extension entry under settings, assigned by the gallery
// 2- The "location" : 1 entry // 2- The "location" : 1 entry
...@@ -132,7 +132,7 @@ class InitialPreferences { ...@@ -132,7 +132,7 @@ class InitialPreferences {
// 4- The "path" entry with the version as last component // 4- The "path" entry with the version as last component
// 5- The "state" : 1 entry // 5- The "state" : 1 entry
// //
// The following is an example of a master pref file that installs // The following is an example of a initial pref file that installs
// Google XYZ: // Google XYZ:
// //
// { // {
...@@ -156,18 +156,19 @@ class InitialPreferences { ...@@ -156,18 +156,19 @@ class InitialPreferences {
// //
bool GetExtensionsBlock(base::DictionaryValue** extensions) const; bool GetExtensionsBlock(base::DictionaryValue** extensions) const;
// Returns the compressed variations seed entry from the master prefs. // Returns the compressed variations seed entry from the initial prefs.
std::string GetCompressedVariationsSeed() const; std::string GetCompressedVariationsSeed() const;
// Returns the variations seed signature entry from the master prefs. // Returns the variations seed signature entry from the initial prefs.
std::string GetVariationsSeedSignature() const; std::string GetVariationsSeedSignature() const;
// Returns true iff the master preferences were successfully read from a file. // Returns true iff the initial preferences were successfully read from a
// file.
bool read_from_file() const { return preferences_read_from_file_; } bool read_from_file() const { return preferences_read_from_file_; }
// Returns a reference to this InitialPreferences' root dictionary of values. // Returns a reference to this InitialPreferences' root dictionary of values.
const base::DictionaryValue& master_dictionary() const { const base::DictionaryValue& initial_dictionary() const {
return *master_dictionary_.get(); return *initial_dictionary_.get();
} }
// Returns a static preference object that has been initialized with the // Returns a static preference object that has been initialized with the
...@@ -188,12 +189,12 @@ class InitialPreferences { ...@@ -188,12 +189,12 @@ class InitialPreferences {
// found in older master_preferences files. // found in older master_preferences files.
void EnforceLegacyPreferences(); void EnforceLegacyPreferences();
// Removes the specified string pref from the master preferences and returns // Removes the specified string pref from the initial preferences and returns
// its value. Should be used for master prefs that shouldn't be automatically // its value. Should be used for initial prefs that shouldn't be automatically
// copied over to profile preferences. // copied over to profile preferences.
std::string ExtractPrefString(const std::string& name) const; std::string ExtractPrefString(const std::string& name) const;
std::unique_ptr<base::DictionaryValue> master_dictionary_; std::unique_ptr<base::DictionaryValue> initial_dictionary_;
base::DictionaryValue* distribution_ = nullptr; base::DictionaryValue* distribution_ = nullptr;
bool preferences_read_from_file_ = false; bool preferences_read_from_file_ = false;
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// //
// Unit tests for master preferences related methods. // Unit tests for initial preferences related methods.
#include "chrome/installer/util/initial_preferences.h" #include "chrome/installer/util/initial_preferences.h"
...@@ -221,7 +221,7 @@ TEST(MasterPrefsExtension, ValidateExtensionJSON) { ...@@ -221,7 +221,7 @@ TEST(MasterPrefsExtension, ValidateExtensionJSON) {
"behllobkkfkfnphdnhnkndlbkcpglgmj.manifest.version", &version)); "behllobkkfkfnphdnhnkndlbkcpglgmj.manifest.version", &version));
} }
// Test that we are parsing master preferences correctly. // Test that we are parsing initial preferences correctly.
TEST_F(InitialPreferencesTest, GetInstallPreferencesTest) { TEST_F(InitialPreferencesTest, GetInstallPreferencesTest) {
// Create a temporary prefs file. // Create a temporary prefs file.
base::FilePath prefs_file; base::FilePath prefs_file;
...@@ -239,7 +239,7 @@ TEST_F(InitialPreferencesTest, GetInstallPreferencesTest) { ...@@ -239,7 +239,7 @@ TEST_F(InitialPreferencesTest, GetInstallPreferencesTest) {
EXPECT_TRUE( EXPECT_TRUE(
base::WriteFile(prefs_file, text, static_cast<int>(strlen(text)))); base::WriteFile(prefs_file, text, static_cast<int>(strlen(text))));
// Make sure command line values override the values in master preferences. // Make sure command line values override the values in initial preferences.
std::wstring cmd_str(L"setup.exe --installerdata=\"" + prefs_file.value() + std::wstring cmd_str(L"setup.exe --installerdata=\"" + prefs_file.value() +
L"\""); L"\"");
cmd_str.append(L" --do-not-launch-chrome"); cmd_str.append(L" --do-not-launch-chrome");
...@@ -263,7 +263,7 @@ TEST_F(InitialPreferencesTest, GetInstallPreferencesTest) { ...@@ -263,7 +263,7 @@ TEST_F(InitialPreferencesTest, GetInstallPreferencesTest) {
// Delete temporary prefs file. // Delete temporary prefs file.
EXPECT_TRUE(base::DeleteFile(prefs_file)); EXPECT_TRUE(base::DeleteFile(prefs_file));
// Check that if master prefs doesn't exist, we can still parse the common // Check that if initial prefs doesn't exist, we can still parse the common
// prefs. // prefs.
cmd_str = L"setup.exe --do-not-launch-chrome"; cmd_str = L"setup.exe --do-not-launch-chrome";
cmd_line.ParseFromString(cmd_str); cmd_line.ParseFromString(cmd_str);
...@@ -326,23 +326,23 @@ TEST_F(InitialPreferencesTest, EnforceLegacyPreferences) { ...@@ -326,23 +326,23 @@ TEST_F(InitialPreferencesTest, EnforceLegacyPreferences) {
EXPECT_FALSE(do_not_create_taskbar_shortcut); EXPECT_FALSE(do_not_create_taskbar_shortcut);
bool actual_value = false; bool actual_value = false;
EXPECT_TRUE(prefs.master_dictionary().GetBoolean(prefs::kImportBookmarks, EXPECT_TRUE(prefs.initial_dictionary().GetBoolean(prefs::kImportBookmarks,
&actual_value)); &actual_value));
EXPECT_TRUE(actual_value); EXPECT_TRUE(actual_value);
EXPECT_TRUE(prefs.master_dictionary().GetBoolean(prefs::kImportHistory, EXPECT_TRUE(prefs.initial_dictionary().GetBoolean(prefs::kImportHistory,
&actual_value)); &actual_value));
EXPECT_TRUE(actual_value); EXPECT_TRUE(actual_value);
EXPECT_TRUE(prefs.master_dictionary().GetBoolean(prefs::kImportHomepage, EXPECT_TRUE(prefs.initial_dictionary().GetBoolean(prefs::kImportHomepage,
&actual_value)); &actual_value));
EXPECT_TRUE(actual_value); EXPECT_TRUE(actual_value);
EXPECT_TRUE(prefs.master_dictionary().GetBoolean(prefs::kImportSearchEngine, EXPECT_TRUE(prefs.initial_dictionary().GetBoolean(prefs::kImportSearchEngine,
&actual_value)); &actual_value));
EXPECT_TRUE(actual_value); EXPECT_TRUE(actual_value);
#if BUILDFLAG(ENABLE_RLZ) #if BUILDFLAG(ENABLE_RLZ)
int rlz_ping_delay = 0; int rlz_ping_delay = 0;
EXPECT_TRUE(prefs.master_dictionary().GetInteger(prefs::kRlzPingDelaySeconds, EXPECT_TRUE(prefs.initial_dictionary().GetInteger(prefs::kRlzPingDelaySeconds,
&rlz_ping_delay)); &rlz_ping_delay));
EXPECT_EQ(40, rlz_ping_delay); EXPECT_EQ(40, rlz_ping_delay);
#endif // BUILDFLAG(ENABLE_RLZ) #endif // BUILDFLAG(ENABLE_RLZ)
} }
......
...@@ -76,7 +76,7 @@ const char kInputFile[] = "input-file"; ...@@ -76,7 +76,7 @@ const char kInputFile[] = "input-file";
// of an uncompressed archive). // of an uncompressed archive).
const char kInstallArchive[] = "install-archive"; const char kInstallArchive[] = "install-archive";
// Specify the file path of Chrome master preference file. // Specify the file path of Chrome initial preference file.
const char kInstallerData[] = "installerdata"; const char kInstallerData[] = "installerdata";
// If present, specify file path to write logging info. // If present, specify file path to write logging info.
......
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