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

inclusion: kDefaultInitialPrefs -> kLegacyInitialPrefs

This is preparatory to adding a new kDefaultInitialPrefs, which will be
"initial_preferences", and adding support for reading preferences from
that file in addition to the legacy file.

Bug: 1097209
Change-Id: I35508175274451171eb6bd5fa10a528de7bdfe1f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2555563
Commit-Queue: Elly Fong-Jones <ellyjones@chromium.org>
Reviewed-by: default avatarAvi Drissman <avi@chromium.org>
Reviewed-by: default avatarGreg Thompson <grt@chromium.org>
Cr-Commit-Position: refs/heads/master@{#830708}
parent afdbbd8f
......@@ -22,7 +22,7 @@ base::FilePath InitialPrefsPath() {
base::FilePath initial_prefs;
if (!base::PathService::Get(base::DIR_EXE, &initial_prefs))
return base::FilePath();
return initial_prefs.AppendASCII(installer::kDefaultInitialPrefs);
return initial_prefs.AppendASCII(installer::kLegacyInitialPrefs);
}
} // namespace internal
......
......@@ -157,7 +157,7 @@ base::FilePath InitialPrefsPath() {
base::FilePath initial_prefs;
if (!base::PathService::Get(base::DIR_EXE, &initial_prefs))
return base::FilePath();
return initial_prefs.AppendASCII(installer::kDefaultInitialPrefs);
return initial_prefs.AppendASCII(installer::kLegacyInitialPrefs);
}
} // namespace internal
......
......@@ -23,11 +23,12 @@ const NSSearchPathDirectory kSearchPath = NSLibraryDirectory;
// so changing this filename will require some care.
// See https://crbug.com/1097204 for details.
const char kInitialPreferencesDirectory[] = "Google";
const char kInitialPreferencesFileName[] = "Google Chrome Master Preferences";
const char kLegacyInitialPreferencesFileName[] =
"Google Chrome Master Preferences";
#else
const NSSearchPathDirectory kSearchPath = NSApplicationSupportDirectory;
const char kInitialPreferencesDirectory[] = "Chromium";
const char kInitialPreferencesFileName[] = "Chromium Master Preferences";
const char kLegacyInitialPreferencesFileName[] = "Chromium Master Preferences";
#endif // BUILDFLAG(GOOGLE_CHROME_BRANDING)
} // namespace
......@@ -50,7 +51,7 @@ base::FilePath InitialPrefsPath() {
base::FilePath user_application_support_path;
if (chrome::GetDefaultUserDataDirectory(&user_application_support_path)) {
user_application_support_path =
user_application_support_path.Append(kInitialPreferencesFileName);
user_application_support_path.Append(kLegacyInitialPreferencesFileName);
if (base::PathExists(user_application_support_path))
return user_application_support_path;
}
......@@ -63,7 +64,7 @@ base::FilePath InitialPrefsPath() {
return base::FilePath();
return search_path.Append(kInitialPreferencesDirectory)
.Append(kInitialPreferencesFileName);
.Append(kLegacyInitialPreferencesFileName);
}
} // namespace initial_prefs
......@@ -142,13 +142,13 @@ void AddChromeToMediaPlayerList() {
LOG(ERROR) << "Could not add Chrome to media player inclusion list.";
}
// Copy master_preferences file provided to installer, in the same folder
// Copy the initial preferences file provided to installer, in the same folder
// as chrome.exe so Chrome first run can find it. This function will be called
// only on the first install of Chrome.
void CopyPreferenceFileForFirstRun(const InstallerState& installer_state,
const base::FilePath& prefs_source_path) {
base::FilePath prefs_dest_path(
installer_state.target_path().AppendASCII(kDefaultInitialPrefs));
installer_state.target_path().AppendASCII(kLegacyInitialPrefs));
if (!base::CopyFile(prefs_source_path, prefs_dest_path)) {
VLOG(1) << "Failed to copy initial preferences from:"
<< prefs_source_path.value() << " gle: " << ::GetLastError();
......@@ -510,7 +510,7 @@ InstallStatus InstallOrUpdateProduct(const InstallParams& install_params,
// If this is not the user's first Chrome install, but they have chosen
// Chrome to become their default browser on the download page, we must
// force it here because the master_preferences file will not get copied
// force it here because the initial preferences file will not get copied
// into the build.
bool force_chrome_default_for_user = false;
if (result == NEW_VERSION_UPDATED || result == INSTALL_REPAIRED ||
......@@ -576,9 +576,9 @@ void HandleOsUpgradeForBrowser(const InstallerState& installer_state,
const base::Version& installed_version) {
VLOG(1) << "Updating and registering shortcuts for --on-os-upgrade.";
// Read master_preferences copied beside chrome.exe at install.
// Read the initial preferences copied beside chrome.exe at install.
const InitialPreferences prefs(
installer_state.target_path().AppendASCII(kDefaultInitialPrefs));
installer_state.target_path().AppendASCII(kLegacyInitialPrefs));
// Update shortcuts at this install level (per-user shortcuts on system-level
// installs will be updated through Active Setup).
......@@ -652,10 +652,10 @@ void HandleActiveSetupForBrowser(const InstallerState& installer_state,
? INSTALL_SHORTCUT_REPLACE_EXISTING
: INSTALL_SHORTCUT_CREATE_EACH_IF_NO_SYSTEM_LEVEL;
// Read master_preferences copied beside chrome.exe at install for the sake of
// creating/updating shortcuts.
// Read the initial preferences copied beside chrome.exe at install for the
// sake of creating/updating shortcuts.
const base::FilePath installation_root = installer_state.target_path();
InitialPreferences prefs(installation_root.AppendASCII(kDefaultInitialPrefs));
InitialPreferences prefs(installation_root.AppendASCII(kLegacyInitialPrefs));
base::FilePath chrome_exe(installation_root.Append(kChromeExe));
CreateOrUpdateShortcuts(chrome_exe, prefs, CURRENT_USER, install_operation);
......
......@@ -1235,7 +1235,7 @@ InstallStatus InstallProductsHelper(InstallationState& original_state,
// Update the DisplayVersion created by an MSI-based install.
base::FilePath initial_preferences_file(
installer_state.target_path().AppendASCII(
installer::kDefaultInitialPrefs));
installer::kLegacyInitialPrefs));
std::string install_id;
if (prefs.GetString(installer::initial_preferences::kMsiProductId,
&install_id)) {
......
......@@ -26,14 +26,14 @@ namespace installer {
#if !defined(OS_MAC)
// This is the default name for the initial preferences file used to pre-set
// values in the user profile at first run.
const char kDefaultInitialPrefs[] = "master_preferences";
const char kLegacyInitialPrefs[] = "master_preferences";
#endif
// The initial preferences is a JSON file with the same entries as the
// 'Default\Preferences' file. This function parses the distribution
// section of the preferences file.
//
// A prototypical 'master_preferences' file looks like this:
// A prototypical initial preferences file looks like this:
//
// {
// "distribution": {
......@@ -70,8 +70,6 @@ const char kDefaultInitialPrefs[] = "master_preferences";
//
// A reserved "distribution" entry in the file is used to group related
// installation properties. This entry will be ignored at other times.
// This function parses the 'distribution' entry and returns a combination
// of MasterPrefResult.
class InitialPreferences {
public:
......@@ -186,7 +184,7 @@ class InitialPreferences {
bool InitializeFromString(const std::string& json_data);
// Enforces legacy preferences that should no longer be used, but could be
// found in older master_preferences files.
// found in older initial preferences files.
void EnforceLegacyPreferences();
// Removes the specified string pref from the initial preferences and returns
......@@ -202,8 +200,6 @@ class InitialPreferences {
DISALLOW_COPY_AND_ASSIGN(InitialPreferences);
};
using InitialPreferences = InitialPreferences;
} // namespace installer
#endif // CHROME_INSTALLER_UTIL_INITIAL_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