summaryrefslogtreecommitdiffstats
path: root/chrome/installer
diff options
context:
space:
mode:
authorhuanr@chromium.org <huanr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-11-06 21:31:24 +0000
committerhuanr@chromium.org <huanr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-11-06 21:31:24 +0000
commita45efa0f820f622a3d2dbf8e42bea70cefbed2d6 (patch)
tree4640d0b256df4d9236b2018eb21989cbff5ac6a6 /chrome/installer
parent0528372f5fc79ee479957fcbf10cac1f3429642a (diff)
downloadchromium_src-a45efa0f820f622a3d2dbf8e42bea70cefbed2d6.zip
chromium_src-a45efa0f820f622a3d2dbf8e42bea70cefbed2d6.tar.gz
chromium_src-a45efa0f820f622a3d2dbf8e42bea70cefbed2d6.tar.bz2
Adding support to installerdata provided by Google update.
BUG=1442838 Review URL: http://codereview.chromium.org/9422 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@4913 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/installer')
-rw-r--r--chrome/installer/setup/main.cc85
-rwxr-xr-xchrome/installer/setup/setup.cc22
-rw-r--r--chrome/installer/setup/setup.h6
-rw-r--r--chrome/installer/util/master_preferences.cc33
-rw-r--r--chrome/installer/util/master_preferences.h25
-rwxr-xr-xchrome/installer/util/util_constants.cc4
-rwxr-xr-xchrome/installer/util/util_constants.h21
7 files changed, 158 insertions, 38 deletions
diff --git a/chrome/installer/setup/main.cc b/chrome/installer/setup/main.cc
index fec04a7..a553031 100644
--- a/chrome/installer/setup/main.cc
+++ b/chrome/installer/setup/main.cc
@@ -25,6 +25,7 @@
#include "chrome/installer/util/logging_installer.h"
#include "chrome/installer/util/lzma_util.h"
#include "chrome/installer/util/google_update_constants.h"
+#include "chrome/installer/util/master_preferences.h"
#include "chrome/installer/util/shell_util.h"
#include "chrome/installer/util/util_constants.h"
#include "chrome/installer/util/work_item.h"
@@ -160,6 +161,59 @@ installer::Version* GetVersionFromDir(const std::wstring& chrome_path) {
return version;
}
+// Parse command line and read master profile, if present, to get distribution
+// related install options.
+int GetInstallOptions(const CommandLine& cmd_line) {
+ int options = 0;
+ int preferences = 0;
+
+ if (cmd_line.HasSwitch(installer_util::switches::kInstallerData)) {
+ std::wstring prefs_path = cmd_line.GetSwitchValue(
+ installer_util::switches::kInstallerData);
+ preferences = installer_util::ParseDistributionPreferences(prefs_path);
+ if ((preferences & installer_util::MASTER_PROFILE_NOT_FOUND) == 0) {
+ options |= installer_util::MASTER_PROFILE_PRESENT;
+ if ((preferences & installer_util::MASTER_PROFILE_ERROR) == 0)
+ options |= installer_util::MASTER_PROFILE_VALID;
+ }
+ }
+
+ if (preferences & installer_util::MASTER_PROFILE_CREATE_ALL_SHORTCUTS ||
+ cmd_line.HasSwitch(installer_util::switches::kCreateAllShortcuts))
+ options |= installer_util::CREATE_ALL_SHORTCUTS;
+
+ if (preferences & installer_util::MASTER_PROFILE_DO_NOT_LAUNCH_CHROME ||
+ cmd_line.HasSwitch(installer_util::switches::kDoNotLaunchChrome))
+ options |= installer_util::DO_NOT_LAUNCH_CHROME;
+
+ if (preferences & installer_util::MASTER_PROFILE_MAKE_CHROME_DEFAULT ||
+ cmd_line.HasSwitch(installer_util::switches::kMakeChromeDefault))
+ options |= installer_util::MAKE_CHROME_DEFAULT;
+
+ if (preferences & installer_util::MASTER_PROFILE_SYSTEM_LEVEL ||
+ cmd_line.HasSwitch(installer_util::switches::kSystemLevel))
+ options |= installer_util::SYSTEM_LEVEL;
+
+ return options;
+}
+
+// Copy master preference file if provided to installer to the same path
+// of chrome.exe so Chrome first run can find it.
+// This function will be called only when Chrome is launched the first time.
+void CopyPreferenceFileForFirstRun(int options, const CommandLine& cmd_line) {
+ if (options & installer_util::MASTER_PROFILE_VALID) {
+ std::wstring prefs_source_path = cmd_line.GetSwitchValue(
+ installer_util::switches::kInstallerData);
+ bool system_install = (options & installer_util::SYSTEM_LEVEL) != 0;
+ std::wstring prefs_dest_path(
+ installer::GetChromeInstallPath(system_install));
+ file_util::AppendToPath(&prefs_dest_path,
+ installer_util::kDefaultMasterPrefs);
+ if (!file_util::CopyFile(prefs_source_path, prefs_dest_path))
+ LOG(ERROR) << "failed copying master profile";
+ }
+}
+
// This method is temporary and only called by UpdateChromeOpenCmd() below.
void ReplaceRegistryValue(const std::wstring& reg_key,
const std::wstring& old_val,
@@ -192,7 +246,8 @@ void UpdateChromeOpenCmd(bool system_install) {
}
installer_util::InstallStatus InstallChrome(const CommandLine& cmd_line,
- const installer::Version* installed_version, bool system_install) {
+ const installer::Version* installed_version, int options) {
+ bool system_install = (options & installer_util::SYSTEM_LEVEL) != 0;
// For install the default location for chrome.packed.7z is in current
// folder, so get that value first.
std::wstring archive = file_util::GetDirectoryFromPath(cmd_line.program());
@@ -249,7 +304,8 @@ installer_util::InstallStatus InstallChrome(const CommandLine& cmd_line,
LOG(ERROR) << "Higher version is already installed.";
install_status = installer_util::HIGHER_VERSION_EXISTS;
InstallUtil::WriteInstallerResult(system_install, install_status,
- IDS_INSTALL_HIGHER_VERSION_BASE, NULL);
+ IDS_INSTALL_HIGHER_VERSION_BASE,
+ NULL);
} else {
// We want to keep uncompressed archive (chrome.7z) that we get after
// uncompressing and binary patching. Get the location for this file.
@@ -257,12 +313,12 @@ installer_util::InstallStatus InstallChrome(const CommandLine& cmd_line,
file_util::AppendToPath(&archive_to_copy,
std::wstring(installer::kChromeArchive));
install_status = installer::InstallOrUpdateChrome(
- cmd_line.program(), archive_to_copy, temp_path, system_install,
+ cmd_line.program(), archive_to_copy, temp_path, options,
*installer_version, installed_version);
if (install_status == installer_util::FIRST_INSTALL_SUCCESS) {
LOG(INFO) << "First install successful.";
- if (cmd_line.HasSwitch(
- installer_util::switches::kDoNotLaunchChrome)) {
+ CopyPreferenceFileForFirstRun(options, cmd_line);
+ if (options & installer_util::DO_NOT_LAUNCH_CHROME) {
std::wstring chrome_exe =
installer::GetChromeInstallPath(system_install);
if (!chrome_exe.empty()) {
@@ -298,11 +354,17 @@ installer_util::InstallStatus InstallChrome(const CommandLine& cmd_line,
}
}
- // Delete install temporary directory.
+ // Delete temporary files. These include install temporary directory
+ // and master profile file if present.
+ scoped_ptr<WorkItemList> cleanup_list(WorkItem::CreateWorkItemList());
LOG(INFO) << "Deleting temporary directory " << temp_path;
- scoped_ptr<DeleteTreeWorkItem> delete_tree(
- WorkItem::CreateDeleteTreeWorkItem(temp_path, std::wstring()));
- delete_tree->Do();
+ cleanup_list->AddDeleteTreeWorkItem(temp_path, std::wstring());
+ if (options & installer_util::MASTER_PROFILE_PRESENT) {
+ std::wstring prefs_path = cmd_line.GetSwitchValue(
+ installer_util::switches::kInstallerData);
+ cleanup_list->AddDeleteTreeWorkItem(prefs_path, std::wstring());
+ }
+ cleanup_list->Do();
BrowserDistribution* dist = BrowserDistribution::GetDistribution();
dist->UpdateDiffInstallStatus(system_install, incremental_install,
@@ -328,6 +390,7 @@ installer_util::InstallStatus UninstallChrome(const CommandLine& cmd_line,
return installer_setup::UninstallChrome(cmd_line.program(), system_install,
*version, remove_all, force);
}
+
} // namespace
@@ -337,8 +400,8 @@ int WINAPI wWinMain(HINSTANCE instance, HINSTANCE prev_instance,
base::AtExitManager exit_manager;
CommandLine parsed_command_line;
installer::InitInstallerLogging(parsed_command_line);
- bool system_install =
- parsed_command_line.HasSwitch(installer_util::switches::kSystemLevel);
+ int options = GetInstallOptions(parsed_command_line);
+ bool system_install = (options & installer_util::SYSTEM_LEVEL) != 0;
LOG(INFO) << "system install is " << system_install;
// Check to make sure current system is WinXP or later. If not, log
diff --git a/chrome/installer/setup/setup.cc b/chrome/installer/setup/setup.cc
index d9a4298..b5d0ea8 100755
--- a/chrome/installer/setup/setup.cc
+++ b/chrome/installer/setup/setup.cc
@@ -40,7 +40,8 @@ void AddChromeToMediaPlayerList() {
}
-void DoFirstInstallTasks(std::wstring install_path, bool system_level) {
+void DoFirstInstallTasks(std::wstring install_path, int options) {
+ bool system_level = (options & installer_util::SYSTEM_LEVEL) != 0;
// Try to add Chrome to Media Player shim inclusion list. We don't do any
// error checking here because this operation will fail if user doesn't
// have admin rights and we want to ignore the error.
@@ -53,7 +54,7 @@ void DoFirstInstallTasks(std::wstring install_path, bool system_level) {
CommandLine cmd_line;
LOG(INFO) << "Registering Chrome as browser";
ShellUtil::RegisterStatus ret = ShellUtil::FAILURE;
- if (cmd_line.HasSwitch(installer_util::switches::kMakeChromeDefault)) {
+ if (options & installer_util::MAKE_CHROME_DEFAULT) {
ret = ShellUtil::AddChromeToSetAccessDefaults(chrome_exe, false);
if (ret == ShellUtil::SUCCESS) {
if (system_level) {
@@ -84,10 +85,11 @@ void DoFirstInstallTasks(std::wstring install_path, bool system_level) {
// If the shortcuts do not exist, the function does not recreate them during
// update.
bool CreateOrUpdateChromeShortcuts(const std::wstring& exe_path,
- bool system_install,
+ int options,
installer_util::InstallStatus install_status,
const std::wstring& install_path,
const std::wstring& new_version) {
+ bool system_install = (options & installer_util::SYSTEM_LEVEL) != 0;
std::wstring shortcut_path;
int dir_enum = (system_install) ? base::DIR_COMMON_START_MENU :
base::DIR_START_MENU;
@@ -161,10 +163,7 @@ bool CreateOrUpdateChromeShortcuts(const std::wstring& exe_path,
// Update Desktop and Quick Launch shortcuts. If --create-new-shortcuts
// is specified we want to create them, otherwise we update them only if
// they exist.
- bool create = false; // Only update; do not create, if they do not exist
- CommandLine cmd_line;
- if (cmd_line.HasSwitch(installer_util::switches::kCreateAllShortcuts))
- create = true;
+ bool create = (options & installer_util::CREATE_ALL_SHORTCUTS) != 0;
if (system_install) {
ret = ret && ShellUtil::CreateChromeDesktopShortcut(chrome_exe,
ShellUtil::SYSTEM_LEVEL, create);
@@ -193,9 +192,9 @@ std::wstring installer::GetInstallerPathUnderChrome(
installer_util::InstallStatus installer::InstallOrUpdateChrome(
const std::wstring& exe_path, const std::wstring& archive_path,
- const std::wstring& install_temp_path, bool system_install,
+ const std::wstring& install_temp_path, int options,
const Version& new_version, const Version* installed_version) {
-
+ bool system_install = (options & installer_util::SYSTEM_LEVEL) != 0;
std::wstring install_path(GetChromeInstallPath(system_install));
if (install_path.empty()) {
LOG(ERROR) << "Could not get installation destination path.";
@@ -236,13 +235,13 @@ installer_util::InstallStatus installer::InstallOrUpdateChrome(
NOTREACHED();
}
- if (!CreateOrUpdateChromeShortcuts(exe_path, system_install, result,
+ if (!CreateOrUpdateChromeShortcuts(exe_path, options, result,
install_path, new_version.GetString()))
LOG(WARNING) << "Failed to create/update start menu shortcut.";
if (result == installer_util::FIRST_INSTALL_SUCCESS ||
result == installer_util::INSTALL_REPAIRED) {
- DoFirstInstallTasks(install_path, system_install);
+ DoFirstInstallTasks(install_path, options);
} else {
RemoveOldVersionDirs(install_path, new_version.GetString());
}
@@ -250,4 +249,3 @@ installer_util::InstallStatus installer::InstallOrUpdateChrome(
return result;
}
-
diff --git a/chrome/installer/setup/setup.h b/chrome/installer/setup/setup.h
index d1e0220..26feefe 100644
--- a/chrome/installer/setup/setup.h
+++ b/chrome/installer/setup/setup.h
@@ -29,8 +29,7 @@ std::wstring GetInstallerPathUnderChrome(const std::wstring& install_path,
// install_temp_path: working directory used during install/update. It should
// also has a sub dir source that contains a complete
// and unpacked Chrome package.
-// system_install: if true, the function performs a system wide install/update.
-// Otherwise it installs/updates Chrome for the current user.
+// options: install options. See chrome/installer/util/util_constants.h.
// new_version: new Chrome version that needs to be installed
// installed_version: currently installed version of Chrome, if any, or
// NULL otherwise
@@ -39,7 +38,7 @@ std::wstring GetInstallerPathUnderChrome(const std::wstring& install_path,
// is responsible for cleaning up install_temp_path.
installer_util::InstallStatus InstallOrUpdateChrome(
const std::wstring& exe_path, const std::wstring& archive_path,
- const std::wstring& install_temp_path, bool system_install,
+ const std::wstring& install_temp_path, int options,
const Version& new_version, const Version* installed_version);
// This function installs a new version of Chrome to the specified location.
@@ -77,4 +76,3 @@ bool InstallNewVersion(const std::wstring& exe_path,
}
#endif // CHROME_INSTALLER_SETUP_SETUP_H__
-
diff --git a/chrome/installer/util/master_preferences.cc b/chrome/installer/util/master_preferences.cc
index 6b4102d..6d85d10 100644
--- a/chrome/installer/util/master_preferences.cc
+++ b/chrome/installer/util/master_preferences.cc
@@ -32,6 +32,27 @@ bool GetBooleanPref(const DictionaryValue* prefs, const std::wstring& name) {
namespace installer_util {
+// Boolean pref that triggers skipping the first run dialogs.
+const wchar_t kDistroSkipFirstRunPref[] = L"distribution.skip_first_run_ui";
+// Boolean pref that triggers loading the welcome page.
+const wchar_t kDistroShowWelcomePage[] = L"distribution.show_welcome_page";
+// Boolean pref that triggers silent import of the default search engine.
+const wchar_t kDistroImportSearchPref[] = L"distribution.import_search_engine";
+// Boolean pref that triggers silent import of the browse history.
+const wchar_t kDistroImportHistoryPref[] = L"distribution.import_history";
+// The following boolean prefs have the same semantics as the corresponding
+// setup command line switches. See chrome/installer/util/util_constants.cc
+// for more info.
+// Create Desktop and QuickLaunch shortcuts.
+const wchar_t kCreateAllShortcuts[] = L"distribution.create_all_shortcuts";
+// Prevent installer from launching Chrome after a successful first install.
+const wchar_t kDoNotLaunchChrome[] = L"distribution.do_not_launch_chrome";
+// Register Chrome as default browser on the system.
+const wchar_t kMakeChromeDefault[] = L"distribution.make_chrome_default";
+// Install Chrome to system wise location.
+const wchar_t kSystemLevel[] = L"distribution.system_level";
+
+
int ParseDistributionPreferences(const std::wstring& master_prefs_path) {
if (!file_util::PathExists(master_prefs_path))
@@ -61,6 +82,18 @@ int ParseDistributionPreferences(const std::wstring& master_prefs_path) {
if (GetBooleanPref(json_root.get(), kDistroImportHistoryPref))
parse_result |= MASTER_PROFILE_IMPORT_HISTORY;
+ if (GetBooleanPref(json_root.get(), kCreateAllShortcuts))
+ parse_result |= MASTER_PROFILE_CREATE_ALL_SHORTCUTS;
+
+ if (GetBooleanPref(json_root.get(), kDoNotLaunchChrome))
+ parse_result |= MASTER_PROFILE_DO_NOT_LAUNCH_CHROME;
+
+ if (GetBooleanPref(json_root.get(), kMakeChromeDefault))
+ parse_result |= MASTER_PROFILE_MAKE_CHROME_DEFAULT;
+
+ if (GetBooleanPref(json_root.get(), kSystemLevel))
+ parse_result |= MASTER_PROFILE_SYSTEM_LEVEL;
+
return parse_result;
}
diff --git a/chrome/installer/util/master_preferences.h b/chrome/installer/util/master_preferences.h
index d7004cc..c696f7b 100644
--- a/chrome/installer/util/master_preferences.h
+++ b/chrome/installer/util/master_preferences.h
@@ -16,15 +16,6 @@ namespace installer_util {
// values in the user profile at first run.
const wchar_t kDefaultMasterPrefs[] = L"master_preferences";
-// Boolean pref that triggers skipping the first run dialogs.
-const wchar_t kDistroSkipFirstRunPref[] = L"distribution.skip_first_run_ui";
-// Boolean pref that triggers loading the welcome page.
-const wchar_t kDistroShowWelcomePage[] = L"distribution.show_welcome_page";
-// Boolean pref that triggers silent import of the default search engine.
-const wchar_t kDistroImportSearchPref[] = L"distribution.import_search_engine";
-// Boolean pref that triggers silent import of the browse history.
-const wchar_t kDistroImportHistoryPref[] = L"distribution.import_history";
-
// These are the possible results of calling ParseDistributionPreferences.
// Some of the results can be combined, so they are bit flags.
enum MasterPrefResult {
@@ -39,6 +30,18 @@ enum MasterPrefResult {
MASTER_PROFILE_IMPORT_SEARCH_ENGINE = 0x1 << 4,
// Improt history from the default browser.
MASTER_PROFILE_IMPORT_HISTORY = 0x1 << 5,
+ // The following boolean prefs have the same semantics as the corresponding
+ // setup command line switches. See chrome/installer/util/util_constants.cc
+ // for more info.
+ // Create Desktop and QuickLaunch shortcuts.
+ MASTER_PROFILE_CREATE_ALL_SHORTCUTS = 0x1 << 6,
+ // Prevent installer from launching Chrome after a successful first install.
+ MASTER_PROFILE_DO_NOT_LAUNCH_CHROME = 0x1 << 7,
+ // Register Chrome as default browser on the system.
+ MASTER_PROFILE_MAKE_CHROME_DEFAULT = 0x1 << 8,
+ // Install Chrome to system wise location.
+ MASTER_PROFILE_SYSTEM_LEVEL = 0x1 << 9,
+
};
// The master preferences is a JSON file with the same entries as the
@@ -53,6 +56,10 @@ enum MasterPrefResult {
// "show_welcome_page": true,
// "import_search_engine": true,
// "import_history": false
+// "create_all_shortcuts": true,
+// "do_not_launch_chrome": false,
+// "make_chrome_default", false,
+// "system_level", false,
// },
// "browser": {
// "show_home_button": true
diff --git a/chrome/installer/util/util_constants.cc b/chrome/installer/util/util_constants.cc
index 8642cc6..886795e 100755
--- a/chrome/installer/util/util_constants.cc
+++ b/chrome/installer/util/util_constants.cc
@@ -32,6 +32,9 @@ const wchar_t kForceUninstall[] = L"force-uninstall";
// Specify the file path of Chrome archive for install.
const wchar_t kInstallArchive[] = L"install-archive";
+// Specify the file path of Chrome master preference file.
+const wchar_t kInstallerData[] = L"installerdata";
+
// If present, specify file path to write logging info.
const wchar_t kLogFile[] = L"log-file";
@@ -65,4 +68,3 @@ const wchar_t kSetupExe[] = L"setup.exe";
const wchar_t kUninstallStringField[] = L"UninstallString";
const wchar_t kUninstallDisplayNameField[] = L"DisplayName";
} // namespace installer_util
-
diff --git a/chrome/installer/util/util_constants.h b/chrome/installer/util/util_constants.h
index 459dff2..941cfe2 100755
--- a/chrome/installer/util/util_constants.h
+++ b/chrome/installer/util/util_constants.h
@@ -33,6 +33,25 @@ enum InstallStatus {
UNKNOWN_STATUS, // Unknown status (this should never happen)
};
+// These are distibution related install options specified through command
+// line switches (see below) or master preference file (see
+// chrome/installer/util/master_preference.h). The options can be combined,
+// so they are bit flags.
+enum InstallOption {
+ // A master profile file is provided to installer.
+ MASTER_PROFILE_PRESENT = 0x1,
+ // The master profile file provided is valid.
+ MASTER_PROFILE_VALID = 0x1 << 1,
+ // Create Desktop and QuickLaunch shortcuts.
+ CREATE_ALL_SHORTCUTS = 0x1 << 2,
+ // Prevent installer from launching Chrome after a successful first install.
+ DO_NOT_LAUNCH_CHROME = 0x1 << 3,
+ // Register Chrome as default browser on the system.
+ MAKE_CHROME_DEFAULT = 0x1 << 4,
+ // Install Chrome to system wise location.
+ SYSTEM_LEVEL = 0x1 << 5,
+};
+
namespace switches {
extern const wchar_t kCreateAllShortcuts[];
extern const wchar_t kDisableLogging[];
@@ -41,6 +60,7 @@ extern const wchar_t kDoNotRemoveSharedItems[];
extern const wchar_t kEnableLogging[];
extern const wchar_t kForceUninstall[];
extern const wchar_t kInstallArchive[];
+extern const wchar_t kInstallerData[];
extern const wchar_t kLogFile[];
extern const wchar_t kMakeChromeDefault[];
extern const wchar_t kRegisterChromeBrowser[];
@@ -59,4 +79,3 @@ extern const wchar_t kUninstallDisplayNameField[];
} // namespace installer_util
#endif // CHROME_INSTALLER_UTIL_UTIL_CONSTANTS_H__
-