summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorkuchhal@chromium.org <kuchhal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-31 22:16:26 +0000
committerkuchhal@chromium.org <kuchhal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-31 22:16:26 +0000
commit84c03ef3a5631759c66ee5c82f71106a77563bd0 (patch)
treef20ba055c4ce76c787bc04a59b9791f34062f198 /chrome
parentb5930829068618a12e95ffb5de7d27a87766e687 (diff)
downloadchromium_src-84c03ef3a5631759c66ee5c82f71106a77563bd0.zip
chromium_src-84c03ef3a5631759c66ee5c82f71106a77563bd0.tar.gz
chromium_src-84c03ef3a5631759c66ee5c82f71106a77563bd0.tar.bz2
Revert changes from r22198 to r22204 and r22194. None of these changes were
supposed to be commited. Seems like git took all the temporary commits from the base branch and uploaded them to svn. Review URL: http://codereview.chromium.org/159736 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@22206 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/browser_main.cc12
-rw-r--r--chrome/browser/first_run.h6
-rw-r--r--chrome/browser/first_run_win.cc48
-rw-r--r--chrome/common/temp_scaffolding_stubs.cc4
-rw-r--r--chrome/installer/setup/install.cc56
-rw-r--r--chrome/installer/setup/install.h7
-rw-r--r--chrome/installer/setup/setup_main.cc141
-rw-r--r--chrome/installer/util/browser_distribution.cc2
-rw-r--r--chrome/installer/util/browser_distribution.h2
-rw-r--r--chrome/installer/util/google_chrome_distribution.cc2
-rw-r--r--chrome/installer/util/google_chrome_distribution.h2
-rw-r--r--chrome/installer/util/google_chrome_distribution_unittest.cc77
-rw-r--r--chrome/installer/util/master_preferences.cc180
-rw-r--r--chrome/installer/util/master_preferences.h127
-rw-r--r--chrome/installer/util/shell_util.cc2
-rw-r--r--chrome/installer/util/util_constants.h25
16 files changed, 367 insertions, 326 deletions
diff --git a/chrome/browser/browser_main.cc b/chrome/browser/browser_main.cc
index e54471c..302385d 100644
--- a/chrome/browser/browser_main.cc
+++ b/chrome/browser/browser_main.cc
@@ -445,16 +445,14 @@ int BrowserMain(const MainFunctionParams& parameters) {
BrowserInit browser_init;
- int ping_delay = 0;
if (is_first_run) {
// On first run, we need to process the master preferences before the
// browser's profile_manager object is created, but after ResourceBundle
// is initialized.
std::vector<std::wstring> first_run_tabs;
- first_run_ui_bypass = !FirstRun::ProcessMasterPreferences(user_data_dir,
- FilePath(),
- &first_run_tabs,
- &ping_delay);
+ first_run_ui_bypass =
+ !FirstRun::ProcessMasterPreferences(user_data_dir, FilePath(), NULL,
+ &first_run_tabs);
// The master prefs might specify a set of urls to display.
if (first_run_tabs.size())
AddFirstRunNewTabs(&browser_init, first_run_tabs);
@@ -660,10 +658,12 @@ int BrowserMain(const MainFunctionParams& parameters) {
win_util::ScopedCOMInitializer com_initializer;
+ int delay = 0;
+ installer_util::GetDistributionPingDelay(FilePath(), delay);
// Init the RLZ library. This just binds the dll and schedules a task on the
// file thread to be run sometime later. If this is the first run we record
// the installation event.
- RLZTracker::InitRlzDelayed(base::DIR_MODULE, is_first_run, ping_delay);
+ RLZTracker::InitRlzDelayed(base::DIR_MODULE, is_first_run, delay);
#endif
// Config the network module so it has access to resources.
diff --git a/chrome/browser/first_run.h b/chrome/browser/first_run.h
index 0914e9f..030c535 100644
--- a/chrome/browser/first_run.h
+++ b/chrome/browser/first_run.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -69,8 +69,8 @@ class FirstRun {
// 'master_preferences' file.
static bool ProcessMasterPreferences(const FilePath& user_data_dir,
const FilePath& master_prefs_path,
- std::vector<std::wstring>* new_tabs,
- int* ping_delay);
+ int* preference_details,
+ std::vector<std::wstring>* new_tabs);
// Sets the kShouldShowFirstRunBubble local state pref so that the browser
// shows the bubble once the main message loop gets going. Returns false if
diff --git a/chrome/browser/first_run_win.cc b/chrome/browser/first_run_win.cc
index c0ffb6fe..a00f456 100644
--- a/chrome/browser/first_run_win.cc
+++ b/chrome/browser/first_run_win.cc
@@ -167,9 +167,12 @@ bool FirstRun::CreateChromeQuickLaunchShortcut() {
bool FirstRun::ProcessMasterPreferences(const FilePath& user_data_dir,
const FilePath& master_prefs_path,
- std::vector<std::wstring>* new_tabs,
- int* ping_delay) {
+ int* preference_details,
+ std::vector<std::wstring>* new_tabs) {
DCHECK(!user_data_dir.empty());
+ if (preference_details)
+ *preference_details = 0;
+
FilePath master_prefs = master_prefs_path;
if (master_prefs.empty()) {
// The default location of the master prefs is next to the chrome exe.
@@ -179,18 +182,18 @@ bool FirstRun::ProcessMasterPreferences(const FilePath& user_data_dir,
master_prefs = master_prefs.Append(installer_util::kDefaultMasterPrefs);
}
- scoped_ptr<DictionaryValue> prefs(
- installer_util::ParseDistributionPreferences(master_prefs));
- if (!prefs.get())
+ int parse_result = installer_util::ParseDistributionPreferences(
+ master_prefs.ToWStringHack());
+ if (preference_details)
+ *preference_details = parse_result;
+
+ if (parse_result & installer_util::MASTER_PROFILE_ERROR)
return true;
if (new_tabs)
- *new_tabs = installer_util::GetFirstRunTabs(prefs.get());
- if (ping_delay)
- installer_util::GetDistributionPingDelay(prefs.get(), ping_delay);
+ *new_tabs = installer_util::ParseFirstRunTabs(master_prefs.ToWStringHack());
- if (installer_util::GetDistroBooleanPreference(prefs.get(),
- installer_util::master_preferences::kRequireEula)) {
+ if (parse_result & installer_util::MASTER_PROFILE_REQUIRE_EULA) {
// 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
// dismisses the dialog.
@@ -216,8 +219,7 @@ bool FirstRun::ProcessMasterPreferences(const FilePath& user_data_dir,
}
}
- if (installer_util::GetDistroBooleanPreference(prefs.get(),
- installer_util::master_preferences::kAltFirstRunBubble))
+ if (parse_result & installer_util::MASTER_PROFILE_OEM_FIRST_RUN_BUBBLE)
FirstRun::SetOEMFirstRunBubblePref();
FilePath user_prefs = GetDefaultPrefFilePath(true, user_data_dir);
@@ -229,8 +231,7 @@ bool FirstRun::ProcessMasterPreferences(const FilePath& user_data_dir,
if (!file_util::CopyFile(master_prefs, user_prefs))
return true;
- if (!installer_util::GetDistroBooleanPreference(prefs.get(),
- installer_util::master_preferences::kDistroSkipFirstRunPref))
+ if (!(parse_result & installer_util::MASTER_PROFILE_NO_FIRST_RUN_UI))
return true;
// From here on we won't show first run so we need to do the work to set the
@@ -243,22 +244,17 @@ bool FirstRun::ProcessMasterPreferences(const FilePath& user_data_dir,
if (!FirstRun::CreateSentinel())
return false;
- if (installer_util::GetDistroBooleanPreference(prefs.get(),
- installer_util::master_preferences::kDistroShowWelcomePage))
+ if (parse_result & installer_util::MASTER_PROFILE_SHOW_WELCOME)
FirstRun::SetShowWelcomePagePref();
int import_items = 0;
- if (installer_util::GetDistroBooleanPreference(prefs.get(),
- installer_util::master_preferences::kDistroImportSearchPref))
+ if (parse_result & installer_util::MASTER_PROFILE_IMPORT_SEARCH_ENGINE)
import_items += SEARCH_ENGINES;
- if (installer_util::GetDistroBooleanPreference(prefs.get(),
- installer_util::master_preferences::kDistroImportHistoryPref))
+ if (parse_result & installer_util::MASTER_PROFILE_IMPORT_HISTORY)
import_items += HISTORY;
- if (installer_util::GetDistroBooleanPreference(prefs.get(),
- installer_util::master_preferences::kDistroImportBookmarksPref))
+ if (parse_result & installer_util::MASTER_PROFILE_IMPORT_BOOKMARKS)
import_items += FAVORITES;
- if (installer_util::GetDistroBooleanPreference(prefs.get(),
- installer_util::master_preferences::kDistroImportHomePagePref))
+ if (parse_result & installer_util::MASTER_PROFILE_IMPORT_HOME_PAGE)
import_items += HOME_PAGE;
if (import_items) {
@@ -272,8 +268,8 @@ bool FirstRun::ProcessMasterPreferences(const FilePath& user_data_dir,
}
}
- if (installer_util::GetDistroBooleanPreference(prefs.get(),
- installer_util::master_preferences::kMakeChromeDefaultForUser))
+ if (parse_result &
+ installer_util::MASTER_PROFILE_MAKE_CHROME_DEFAULT_FOR_USER)
ShellIntegration::SetAsDefaultBrowser();
return false;
diff --git a/chrome/common/temp_scaffolding_stubs.cc b/chrome/common/temp_scaffolding_stubs.cc
index b1d6f40..8d914ac 100644
--- a/chrome/common/temp_scaffolding_stubs.cc
+++ b/chrome/common/temp_scaffolding_stubs.cc
@@ -145,8 +145,8 @@ void AutomationProvider::OnMessageFromExternalHost(
// static
bool FirstRun::ProcessMasterPreferences(const FilePath& user_data_dir,
const FilePath& master_prefs_path,
- std::vector<std::wstring>* new_tabs,
- int* ping_delay) {
+ int* preference_details,
+ std::vector<std::wstring>* new_tabs) {
// http://code.google.com/p/chromium/issues/detail?id=11971
// Pretend we processed them correctly.
return true;
diff --git a/chrome/installer/setup/install.cc b/chrome/installer/setup/install.cc
index ba62f0c..2a3bc3a 100644
--- a/chrome/installer/setup/install.cc
+++ b/chrome/installer/setup/install.cc
@@ -7,21 +7,24 @@
#include "chrome/installer/setup/install.h"
+#include "base/command_line.h"
#include "base/file_util.h"
-#include "base/logging.h"
#include "base/path_service.h"
#include "base/registry.h"
#include "base/scoped_ptr.h"
+#include "base/string_util.h"
+#include "chrome/common/chrome_constants.h"
#include "chrome/installer/setup/setup_constants.h"
#include "chrome/installer/util/browser_distribution.h"
#include "chrome/installer/util/create_reg_key_work_item.h"
#include "chrome/installer/util/google_update_constants.h"
#include "chrome/installer/util/helper.h"
#include "chrome/installer/util/install_util.h"
-#include "chrome/installer/util/master_preferences.h"
#include "chrome/installer/util/set_reg_value_work_item.h"
#include "chrome/installer/util/shell_util.h"
#include "chrome/installer/util/util_constants.h"
+#include "chrome/installer/util/work_item.h"
+#include "chrome/installer/util/version.h"
#include "chrome/installer/util/work_item_list.h"
// Build-time generated include file.
@@ -157,12 +160,11 @@ void AddUninstallShortcutWorkItems(HKEY reg_root,
// If the shortcuts do not exist, the function does not recreate them during
// update.
bool CreateOrUpdateChromeShortcuts(const std::wstring& exe_path,
- const std::wstring& install_path,
- const std::wstring& new_version,
+ int options,
installer_util::InstallStatus install_status,
- bool system_install,
- bool create_all_shortcut,
- bool alt_shortcut) {
+ const std::wstring& install_path,
+ const std::wstring& new_version) {
+ bool system_install = (options & installer_util::SYSTEM_LEVEL) != 0;
FilePath shortcut_path;
int dir_enum = (system_install) ? base::DIR_COMMON_START_MENU :
base::DIR_START_MENU;
@@ -240,18 +242,20 @@ 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 = (options & installer_util::CREATE_ALL_SHORTCUTS) != 0;
+ // In some cases the main desktop shortcut has an alternate name.
+ bool alt_shortcut = (options & installer_util::ALT_DESKTOP_SHORTCUT) != 0;
+
if (system_install) {
ret = ret && ShellUtil::CreateChromeDesktopShortcut(chrome_exe,
- product_desc, ShellUtil::SYSTEM_LEVEL, alt_shortcut,
- create_all_shortcut);
+ product_desc, ShellUtil::SYSTEM_LEVEL, alt_shortcut, create);
ret = ret && ShellUtil::CreateChromeQuickLaunchShortcut(chrome_exe,
- ShellUtil::CURRENT_USER | ShellUtil::SYSTEM_LEVEL, create_all_shortcut);
+ ShellUtil::CURRENT_USER | ShellUtil::SYSTEM_LEVEL, create);
} else {
ret = ret && ShellUtil::CreateChromeDesktopShortcut(chrome_exe,
- product_desc, ShellUtil::CURRENT_USER, alt_shortcut,
- create_all_shortcut);
+ product_desc, ShellUtil::CURRENT_USER, alt_shortcut, create);
ret = ret && ShellUtil::CreateChromeQuickLaunchShortcut(chrome_exe,
- ShellUtil::CURRENT_USER, create_all_shortcut);
+ ShellUtil::CURRENT_USER, create);
}
return ret;
@@ -275,9 +279,8 @@ bool Is64bit() {
return false;
}
-void RegisterChromeOnMachine(const std::wstring& install_path,
- bool system_level,
- bool make_chrome_default) {
+void RegisterChromeOnMachine(const 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.
@@ -288,7 +291,7 @@ void RegisterChromeOnMachine(const std::wstring& install_path,
std::wstring chrome_exe(install_path);
file_util::AppendToPath(&chrome_exe, installer_util::kChromeExe);
LOG(INFO) << "Registering Chrome as browser";
- if (make_chrome_default) {
+ if (options & installer_util::MAKE_CHROME_DEFAULT) {
int level = ShellUtil::CURRENT_USER;
if (system_level)
level = level | ShellUtil::SYSTEM_LEVEL;
@@ -480,10 +483,9 @@ bool installer::InstallNewVersion(const std::wstring& exe_path,
installer_util::InstallStatus installer::InstallOrUpdateChrome(
const std::wstring& exe_path, const std::wstring& archive_path,
- const std::wstring& install_temp_path, const DictionaryValue* prefs,
+ const std::wstring& install_temp_path, int options,
const Version& new_version, const Version* installed_version) {
- bool system_install = installer_util::GetDistroBooleanPreference(prefs,
- installer_util::master_preferences::kSystemLevel);
+ 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.";
@@ -524,21 +526,13 @@ installer_util::InstallStatus installer::InstallOrUpdateChrome(
result = installer_util::NEW_VERSION_UPDATED;
}
- bool create_all_shortcut = installer_util::GetDistroBooleanPreference(prefs,
- installer_util::master_preferences::kCreateAllShortcuts);
- bool alt_shortcut = installer_util::GetDistroBooleanPreference(prefs,
- installer_util::master_preferences::kAltShortcutText);
- if (!CreateOrUpdateChromeShortcuts(exe_path, install_path,
- new_version.GetString(), result,
- system_install, create_all_shortcut,
- alt_shortcut))
+ if (!CreateOrUpdateChromeShortcuts(exe_path, options, result,
+ install_path, new_version.GetString()))
LOG(WARNING) << "Failed to create/update start menu shortcut.";
RemoveOldVersionDirs(install_path, new_version.GetString());
- bool make_chrome_default = installer_util::GetDistroBooleanPreference(prefs,
- installer_util::master_preferences::kMakeChromeDefault);
- RegisterChromeOnMachine(install_path, system_install, make_chrome_default);
+ RegisterChromeOnMachine(install_path, options);
}
return result;
diff --git a/chrome/installer/setup/install.h b/chrome/installer/setup/install.h
index de468b3..6613e6fb 100644
--- a/chrome/installer/setup/install.h
+++ b/chrome/installer/setup/install.h
@@ -7,7 +7,8 @@
#ifndef CHROME_INSTALLER_SETUP_INSTALL_H_
#define CHROME_INSTALLER_SETUP_INSTALL_H_
-#include <base/values.h>
+#include <string>
+#include <windows.h>
#include "chrome/installer/util/util_constants.h"
#include "chrome/installer/util/version.h"
@@ -28,7 +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.
-// prefs: master preferences. See chrome/installer/util/master_preferences.h.
+// 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
@@ -37,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, const DictionaryValue* prefs,
+ 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.
diff --git a/chrome/installer/setup/setup_main.cc b/chrome/installer/setup/setup_main.cc
index eb2e8ba..d73e4db 100644
--- a/chrome/installer/setup/setup_main.cc
+++ b/chrome/installer/setup/setup_main.cc
@@ -206,63 +206,74 @@ installer_util::InstallStatus RenameChromeExecutables(bool system_install) {
// Parse command line and read master profile, if present, to get distribution
// related install options.
-DictionaryValue* GetInstallPreferences(const CommandLine& cmd_line) {
- DictionaryValue* prefs = NULL;
+int GetInstallOptions(const CommandLine& cmd_line) {
+ int options = 0;
+ int preferences = 0;
if (cmd_line.HasSwitch(installer_util::switches::kInstallerData)) {
- FilePath prefs_path(
- cmd_line.GetSwitchValue(installer_util::switches::kInstallerData));
- prefs = installer_util::ParseDistributionPreferences(prefs_path);
+ 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;
+ }
+ // While there is a --show-eula command line flag, we don't process
+ // it in this function because it requires special handling.
+ if (preferences & installer_util::MASTER_PROFILE_REQUIRE_EULA)
+ options |= installer_util::SHOW_EULA_DIALOG;
}
- if (!prefs)
- prefs = new DictionaryValue();
+ if (preferences & installer_util::MASTER_PROFILE_CREATE_ALL_SHORTCUTS ||
+ cmd_line.HasSwitch(installer_util::switches::kCreateAllShortcuts))
+ options |= installer_util::CREATE_ALL_SHORTCUTS;
- if (cmd_line.HasSwitch(installer_util::switches::kCreateAllShortcuts))
- installer_util::SetDistroBooleanPreference(
- prefs, installer_util::master_preferences::kCreateAllShortcuts, true);
+ 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 (cmd_line.HasSwitch(installer_util::switches::kDoNotLaunchChrome))
- installer_util::SetDistroBooleanPreference(
- prefs, installer_util::master_preferences::kDoNotLaunchChrome, true);
+ if (preferences & installer_util::MASTER_PROFILE_MAKE_CHROME_DEFAULT ||
+ cmd_line.HasSwitch(installer_util::switches::kMakeChromeDefault))
+ options |= installer_util::MAKE_CHROME_DEFAULT;
- if (cmd_line.HasSwitch(installer_util::switches::kMakeChromeDefault))
- installer_util::SetDistroBooleanPreference(
- prefs, installer_util::master_preferences::kMakeChromeDefault, true);
+ if (preferences & installer_util::MASTER_PROFILE_SYSTEM_LEVEL ||
+ cmd_line.HasSwitch(installer_util::switches::kSystemLevel))
+ options |= installer_util::SYSTEM_LEVEL;
- if (cmd_line.HasSwitch(installer_util::switches::kSystemLevel))
- installer_util::SetDistroBooleanPreference(
- prefs, installer_util::master_preferences::kSystemLevel, true);
+ if (preferences & installer_util::MASTER_PROFILE_VERBOSE_LOGGING ||
+ cmd_line.HasSwitch(installer_util::switches::kVerboseLogging))
+ options |= installer_util::VERBOSE_LOGGING;
- if (cmd_line.HasSwitch(installer_util::switches::kVerboseLogging))
- installer_util::SetDistroBooleanPreference(
- prefs, installer_util::master_preferences::kVerboseLogging, true);
+ if (preferences & installer_util::MASTER_PROFILE_ALT_SHORTCUT_TXT ||
+ cmd_line.HasSwitch(installer_util::switches::kAltDesktopShortcut))
+ options |= installer_util::ALT_DESKTOP_SHORTCUT;
- if (cmd_line.HasSwitch(installer_util::switches::kAltDesktopShortcut))
- installer_util::SetDistroBooleanPreference(
- prefs, installer_util::master_preferences::kAltShortcutText, true);
-
- return prefs;
+ return options;
}
-// Copy master 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(bool system_level,
- const CommandLine& cmd_line) {
- std::wstring prefs_source_path = cmd_line.GetSwitchValue(
- installer_util::switches::kInstallerData);
- std::wstring prefs_dest_path(
- installer::GetChromeInstallPath(system_level));
- 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";
+// 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";
+ }
}
bool CheckPreInstallConditions(const installer::Version* installed_version,
- bool system_install,
+ int options,
installer_util::InstallStatus& status) {
+ bool system_install = (options & installer_util::SYSTEM_LEVEL) != 0;
+
// Check to avoid simultaneous per-user and per-machine installs.
scoped_ptr<installer::Version>
chrome_version(InstallUtil::GetChromeVersion(!system_install));
@@ -297,14 +308,12 @@ bool CheckPreInstallConditions(const installer::Version* installed_version,
}
installer_util::InstallStatus InstallChrome(const CommandLine& cmd_line,
- const installer::Version* installed_version, const DictionaryValue* prefs) {
- bool system_level = installer_util::GetDistroBooleanPreference(prefs,
- installer_util::master_preferences::kSystemLevel);
+ const installer::Version* installed_version, int options) {
installer_util::InstallStatus install_status = installer_util::UNKNOWN_STATUS;
- if (!CheckPreInstallConditions(installed_version,
- system_level, install_status))
+ if (!CheckPreInstallConditions(installed_version, options, install_status))
return install_status;
+ 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());
@@ -323,7 +332,7 @@ installer_util::InstallStatus InstallChrome(const CommandLine& cmd_line,
if (!file_util::CreateNewTempDirectory(std::wstring(L"chrome_"),
&temp_path)) {
LOG(ERROR) << "Could not create temporary path.";
- InstallUtil::WriteInstallerResult(system_level,
+ InstallUtil::WriteInstallerResult(system_install,
installer_util::TEMP_DIR_FAILED,
IDS_INSTALL_TEMP_DIR_FAILED_BASE,
NULL);
@@ -336,10 +345,10 @@ installer_util::InstallStatus InstallChrome(const CommandLine& cmd_line,
file_util::AppendToPath(&unpack_path,
std::wstring(installer::kInstallSourceDir));
bool incremental_install = false;
- if (UnPackArchive(archive, system_level, installed_version,
+ if (UnPackArchive(archive, system_install, installed_version,
temp_path, unpack_path, incremental_install)) {
install_status = installer_util::UNCOMPRESSION_FAILED;
- InstallUtil::WriteInstallerResult(system_level, install_status,
+ InstallUtil::WriteInstallerResult(system_install, install_status,
IDS_INSTALL_UNCOMPRESSION_FAILED_BASE,
NULL);
} else {
@@ -352,7 +361,7 @@ installer_util::InstallStatus InstallChrome(const CommandLine& cmd_line,
if (!installer_version.get()) {
LOG(ERROR) << "Did not find any valid version in installer.";
install_status = installer_util::INVALID_ARCHIVE;
- InstallUtil::WriteInstallerResult(system_level, install_status,
+ InstallUtil::WriteInstallerResult(system_install, install_status,
IDS_INSTALL_INVALID_ARCHIVE_BASE, NULL);
} else {
LOG(INFO) << "version to install: " << installer_version->GetString();
@@ -360,7 +369,7 @@ installer_util::InstallStatus InstallChrome(const CommandLine& cmd_line,
installed_version->IsHigherThan(installer_version.get())) {
LOG(ERROR) << "Higher version is already installed.";
install_status = installer_util::HIGHER_VERSION_EXISTS;
- InstallUtil::WriteInstallerResult(system_level, install_status,
+ InstallUtil::WriteInstallerResult(system_install, install_status,
IDS_INSTALL_HIGHER_VERSION_BASE,
NULL);
} else {
@@ -370,13 +379,13 @@ 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, prefs,
+ cmd_line.program(), archive_to_copy, temp_path, options,
*installer_version, installed_version);
int install_msg_base = IDS_INSTALL_FAILED_BASE;
std::wstring chrome_exe;
if (install_status != installer_util::INSTALL_FAILED) {
- chrome_exe = installer::GetChromeInstallPath(system_level);
+ chrome_exe = installer::GetChromeInstallPath(system_install);
if (chrome_exe.empty()) {
// If we failed to construct install path, it means the OS call to
// get %ProgramFiles% or %AppData% failed. Report this as failure.
@@ -388,15 +397,15 @@ installer_util::InstallStatus InstallChrome(const CommandLine& cmd_line,
install_msg_base = 0;
}
}
- InstallUtil::WriteInstallerResult(system_level, install_status,
+ InstallUtil::WriteInstallerResult(system_install, install_status,
install_msg_base, &chrome_exe);
if (install_status == installer_util::FIRST_INSTALL_SUCCESS) {
LOG(INFO) << "First install successful.";
- CopyPreferenceFileForFirstRun(system_level, cmd_line);
+ CopyPreferenceFileForFirstRun(options, cmd_line);
// We never want to launch Chrome in system level install mode.
- if (!system_level && !installer_util::GetDistroBooleanPreference(prefs,
- installer_util::master_preferences::kDoNotLaunchChrome))
- installer::LaunchChrome(system_level);
+ if (!(options & installer_util::DO_NOT_LAUNCH_CHROME) &&
+ !(options & installer_util::SYSTEM_LEVEL))
+ installer::LaunchChrome(system_install);
}
}
}
@@ -405,7 +414,7 @@ installer_util::InstallStatus InstallChrome(const CommandLine& cmd_line,
// the case we would not do that directly at this point but in another
// instance of setup.exe
dist->LaunchUserExperiment(install_status, *installer_version,
- system_level);
+ system_install, options);
}
// Delete temporary files. These include install temporary directory
@@ -413,14 +422,14 @@ installer_util::InstallStatus InstallChrome(const CommandLine& cmd_line,
scoped_ptr<WorkItemList> cleanup_list(WorkItem::CreateWorkItemList());
LOG(INFO) << "Deleting temporary directory " << temp_path;
cleanup_list->AddDeleteTreeWorkItem(temp_path, std::wstring());
- if (cmd_line.HasSwitch(installer_util::switches::kInstallerData)) {
+ 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();
- dist->UpdateDiffInstallStatus(system_level, incremental_install,
+ dist->UpdateDiffInstallStatus(system_install, incremental_install,
install_status);
return install_status;
}
@@ -611,13 +620,11 @@ int WINAPI wWinMain(HINSTANCE instance, HINSTANCE prev_instance,
CommandLine::Init(0, NULL);
const CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess();
installer::InitInstallerLogging(parsed_command_line);
- scoped_ptr<DictionaryValue> prefs(GetInstallPreferences(parsed_command_line));
- if (installer_util::GetDistroBooleanPreference(prefs.get(),
- installer_util::master_preferences::kVerboseLogging))
+ int options = GetInstallOptions(parsed_command_line);
+ if (options & installer_util::VERBOSE_LOGGING)
logging::SetMinLogLevel(logging::LOG_INFO);
- bool system_install = installer_util::GetDistroBooleanPreference(prefs.get(),
- installer_util::master_preferences::kSystemLevel);
+ 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
@@ -684,7 +691,7 @@ int WINAPI wWinMain(HINSTANCE instance, HINSTANCE prev_instance,
} else {
install_status = InstallChrome(parsed_command_line,
installed_version.get(),
- prefs.get());
+ options);
}
CoUninitialize();
diff --git a/chrome/installer/util/browser_distribution.cc b/chrome/installer/util/browser_distribution.cc
index 25555ac..ad31cba 100644
--- a/chrome/installer/util/browser_distribution.cc
+++ b/chrome/installer/util/browser_distribution.cc
@@ -88,7 +88,7 @@ void BrowserDistribution::UpdateDiffInstallStatus(bool system_install,
void BrowserDistribution::LaunchUserExperiment(
installer_util::InstallStatus status, const installer::Version& version,
- bool system_install) {
+ bool system_install, int options) {
}
diff --git a/chrome/installer/util/browser_distribution.h b/chrome/installer/util/browser_distribution.h
index 452b8a2..26f9b3b 100644
--- a/chrome/installer/util/browser_distribution.h
+++ b/chrome/installer/util/browser_distribution.h
@@ -58,7 +58,7 @@ class BrowserDistribution {
// sets the wheels in motion or in simple cases does the experiment itself.
virtual void LaunchUserExperiment(installer_util::InstallStatus status,
const installer::Version& version,
- bool system_install);
+ bool system_install, int options);
// The user has qualified for the inactive user toast experiment and this
// function just performs it.
diff --git a/chrome/installer/util/google_chrome_distribution.cc b/chrome/installer/util/google_chrome_distribution.cc
index 3c60e06..9f8995e 100644
--- a/chrome/installer/util/google_chrome_distribution.cc
+++ b/chrome/installer/util/google_chrome_distribution.cc
@@ -407,7 +407,7 @@ void GoogleChromeDistribution::UpdateDiffInstallStatus(bool system_install,
// applies for users doing upgrades and non-systemwide install.
void GoogleChromeDistribution::LaunchUserExperiment(
installer_util::InstallStatus status, const installer::Version& version,
- bool system_install) {
+ bool system_install, int options) {
if ((installer_util::NEW_VERSION_UPDATED != status) || system_install)
return;
diff --git a/chrome/installer/util/google_chrome_distribution.h b/chrome/installer/util/google_chrome_distribution.h
index aa2c99f..f4b5016 100644
--- a/chrome/installer/util/google_chrome_distribution.h
+++ b/chrome/installer/util/google_chrome_distribution.h
@@ -80,7 +80,7 @@ class GoogleChromeDistribution : public BrowserDistribution {
virtual void LaunchUserExperiment(installer_util::InstallStatus status,
const installer::Version& version,
- bool system_install);
+ bool system_install, int options);
// Assuming that the user qualifies, this function performs the inactive user
// toast experiment. It will use chrome to show the UI and it will record the
diff --git a/chrome/installer/util/google_chrome_distribution_unittest.cc b/chrome/installer/util/google_chrome_distribution_unittest.cc
index f84916b..c404061 100644
--- a/chrome/installer/util/google_chrome_distribution_unittest.cc
+++ b/chrome/installer/util/google_chrome_distribution_unittest.cc
@@ -256,8 +256,8 @@ TEST(BrowserDistribution, AlternateAndNormalShortcutName) {
}
TEST(MasterPreferences, ParseDistroParams) {
- std::wstring prefs_file;
- ASSERT_TRUE(file_util::CreateTemporaryFileName(&prefs_file));
+ std::wstring prefs;
+ ASSERT_TRUE(file_util::CreateTemporaryFileName(&prefs));
const char text[] =
"{ \n"
" \"distribution\": { \n"
@@ -281,49 +281,31 @@ TEST(MasterPreferences, ParseDistroParams) {
" }\n"
"} \n";
- EXPECT_TRUE(file_util::WriteFile(prefs_file, text, sizeof(text)));
- scoped_ptr<DictionaryValue> prefs(
- installer_util::ParseDistributionPreferences(
- FilePath::FromWStringHack(prefs_file)));
- EXPECT_TRUE(prefs.get() != NULL);
- EXPECT_TRUE(installer_util::GetDistroBooleanPreference(prefs.get(),
- installer_util::master_preferences::kDistroSkipFirstRunPref));
- EXPECT_TRUE(installer_util::GetDistroBooleanPreference(prefs.get(),
- installer_util::master_preferences::kDistroShowWelcomePage));
-
- EXPECT_TRUE(installer_util::GetDistroBooleanPreference(prefs.get(),
- installer_util::master_preferences::kDistroImportSearchPref));
- EXPECT_TRUE(installer_util::GetDistroBooleanPreference(prefs.get(),
- installer_util::master_preferences::kDistroImportHistoryPref));
- EXPECT_TRUE(installer_util::GetDistroBooleanPreference(prefs.get(),
- installer_util::master_preferences::kDistroImportBookmarksPref));
- EXPECT_TRUE(installer_util::GetDistroBooleanPreference(prefs.get(),
- installer_util::master_preferences::kDistroImportHomePagePref));
-
- EXPECT_TRUE(installer_util::GetDistroBooleanPreference(prefs.get(),
- installer_util::master_preferences::kCreateAllShortcuts));
- EXPECT_TRUE(installer_util::GetDistroBooleanPreference(prefs.get(),
- installer_util::master_preferences::kDoNotLaunchChrome));
- EXPECT_TRUE(installer_util::GetDistroBooleanPreference(prefs.get(),
- installer_util::master_preferences::kMakeChromeDefault));
- EXPECT_TRUE(installer_util::GetDistroBooleanPreference(prefs.get(),
- installer_util::master_preferences::kMakeChromeDefaultForUser));
-
- EXPECT_TRUE(installer_util::GetDistroBooleanPreference(prefs.get(),
- installer_util::master_preferences::kSystemLevel));
- EXPECT_TRUE(installer_util::GetDistroBooleanPreference(prefs.get(),
- installer_util::master_preferences::kVerboseLogging));
- EXPECT_TRUE(installer_util::GetDistroBooleanPreference(prefs.get(),
- installer_util::master_preferences::kRequireEula));
- EXPECT_TRUE(installer_util::GetDistroBooleanPreference(prefs.get(),
- installer_util::master_preferences::kAltShortcutText));
-
- EXPECT_TRUE(file_util::Delete(prefs_file, false));
+ EXPECT_TRUE(file_util::WriteFile(prefs, text, sizeof(text)));
+ int result = installer_util::ParseDistributionPreferences(prefs);
+ EXPECT_FALSE(result & installer_util::MASTER_PROFILE_NOT_FOUND);
+ EXPECT_FALSE(result & installer_util::MASTER_PROFILE_ERROR);
+ EXPECT_TRUE(result & installer_util::MASTER_PROFILE_NO_FIRST_RUN_UI);
+ EXPECT_TRUE(result & installer_util::MASTER_PROFILE_SHOW_WELCOME);
+ EXPECT_TRUE(result & installer_util::MASTER_PROFILE_IMPORT_SEARCH_ENGINE);
+ EXPECT_TRUE(result & installer_util::MASTER_PROFILE_IMPORT_HISTORY);
+ EXPECT_TRUE(result & installer_util::MASTER_PROFILE_IMPORT_BOOKMARKS);
+ EXPECT_TRUE(result & installer_util::MASTER_PROFILE_IMPORT_HOME_PAGE);
+ EXPECT_TRUE(result & installer_util::MASTER_PROFILE_CREATE_ALL_SHORTCUTS);
+ EXPECT_TRUE(result & installer_util::MASTER_PROFILE_DO_NOT_LAUNCH_CHROME);
+ EXPECT_TRUE(result & installer_util::MASTER_PROFILE_MAKE_CHROME_DEFAULT);
+ EXPECT_TRUE(result &
+ installer_util::MASTER_PROFILE_MAKE_CHROME_DEFAULT_FOR_USER);
+ EXPECT_TRUE(result & installer_util::MASTER_PROFILE_SYSTEM_LEVEL);
+ EXPECT_TRUE(result & installer_util::MASTER_PROFILE_VERBOSE_LOGGING);
+ EXPECT_TRUE(result & installer_util::MASTER_PROFILE_REQUIRE_EULA);
+ EXPECT_TRUE(result & installer_util::MASTER_PROFILE_ALT_SHORTCUT_TXT);
+ EXPECT_TRUE(file_util::Delete(prefs, false));
}
TEST(MasterPreferences, FirstRunTabs) {
- std::wstring prefs_file;
- ASSERT_TRUE(file_util::CreateTemporaryFileName(&prefs_file));
+ std::wstring prefs;
+ ASSERT_TRUE(file_util::CreateTemporaryFileName(&prefs));
const char text[] =
"{ \n"
" \"distribution\": { \n"
@@ -336,17 +318,12 @@ TEST(MasterPreferences, FirstRunTabs) {
" ]\n"
"} \n";
- EXPECT_TRUE(file_util::WriteFile(prefs_file, text, sizeof(text)));
- scoped_ptr<DictionaryValue> prefs(
- installer_util::ParseDistributionPreferences(
- FilePath::FromWStringHack(prefs_file)));
- EXPECT_TRUE(prefs.get() != NULL);
-
+ EXPECT_TRUE(file_util::WriteFile(prefs, text, sizeof(text)));
typedef std::vector<std::wstring> TabsVector;
- TabsVector tabs = installer_util::GetFirstRunTabs(prefs.get());
+ TabsVector tabs = installer_util::ParseFirstRunTabs(prefs);
ASSERT_EQ(3, tabs.size());
EXPECT_EQ(L"http://google.com/f1", tabs[0]);
EXPECT_EQ(L"https://google.com/f2", tabs[1]);
EXPECT_EQ(L"new_tab_page", tabs[2]);
- EXPECT_TRUE(file_util::Delete(prefs_file, false));
+ EXPECT_TRUE(file_util::Delete(prefs, false));
}
diff --git a/chrome/installer/util/master_preferences.cc b/chrome/installer/util/master_preferences.cc
index f8c8018..8a7c637 100644
--- a/chrome/installer/util/master_preferences.cc
+++ b/chrome/installer/util/master_preferences.cc
@@ -11,92 +11,154 @@
namespace {
-const wchar_t* kDistroDict = L"distribution";
-
-DictionaryValue* GetPrefsFromFile(const FilePath& master_prefs_path) {
- std::string json_data;
- if (!file_util::ReadFileToString(master_prefs_path, &json_data))
- return NULL;
-
- JSONStringValueSerializer json(json_data);
+DictionaryValue* ReadJSONPrefs(const std::string& data) {
+ JSONStringValueSerializer json(data);
scoped_ptr<Value> root(json.Deserialize(NULL));
-
if (!root.get())
return NULL;
-
if (!root->IsType(Value::TYPE_DICTIONARY))
return NULL;
return static_cast<DictionaryValue*>(root.release());
}
+
+DictionaryValue* GetPrefsFromFile(const std::wstring& master_prefs_path) {
+ std::string json_data;
+ if (!file_util::ReadFileToString(master_prefs_path, &json_data))
+ return NULL;
+ return ReadJSONPrefs(json_data);
+}
+
+bool GetBooleanPref(const DictionaryValue* prefs, const std::wstring& name) {
+ bool value = false;
+ prefs->GetBoolean(name, &value);
+ return value;
+}
+
} // namespace
namespace installer_util {
-namespace master_preferences {
-const wchar_t kAltFirstRunBubble[] = L"oem_bubble";
-const wchar_t kAltShortcutText[] = L"alternate_shortcut_text";
-const wchar_t kCreateAllShortcuts[] = L"create_all_shortcuts";
-const wchar_t kDistroImportBookmarksPref[] = L"import_bookmarks";
-const wchar_t kDistroImportHistoryPref[] = L"import_history";
-const wchar_t kDistroImportHomePagePref[] = L"import_home_page";
+// All the preferences below are expected to be inside the JSON "distribution"
+// block. See master_preferences.h for an example.
+
+// Boolean pref that triggers skipping the first run dialogs.
+const wchar_t kDistroSkipFirstRunPref[] = L"skip_first_run_ui";
+// Boolean pref that triggers loading the welcome page.
+const wchar_t kDistroShowWelcomePage[] = L"show_welcome_page";
+// Boolean pref that triggers silent import of the default search engine.
const wchar_t kDistroImportSearchPref[] = L"import_search_engine";
+// Boolean pref that triggers silent import of the default browser history.
+const wchar_t kDistroImportHistoryPref[] = L"import_history";
+// Boolean pref that triggers silent import of the default browser bookmarks.
+const wchar_t kDistroImportBookmarksPref[] = L"import_bookmarks";
+// RLZ ping delay in seconds
const wchar_t kDistroPingDelay[] = L"ping_delay";
-const wchar_t kDistroShowWelcomePage[] = L"show_welcome_page";
-const wchar_t kDistroSkipFirstRunPref[] = L"skip_first_run_ui";
+// Register Chrome as default browser for the current user.
+const wchar_t kMakeChromeDefaultForUser[] = L"make_chrome_default_for_user";
+// 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"create_all_shortcuts";
+// Prevent installer from launching Chrome after a successful first install.
const wchar_t kDoNotLaunchChrome[] = L"do_not_launch_chrome";
+// Register Chrome as default browser on the system.
const wchar_t kMakeChromeDefault[] = L"make_chrome_default";
-const wchar_t kMakeChromeDefaultForUser[] = L"make_chrome_default_for_user";
-const wchar_t kRequireEula[] = L"require_eula";
+// Install Chrome to system wise location.
const wchar_t kSystemLevel[] = L"system_level";
+// Run installer in verbose mode.
const wchar_t kVerboseLogging[] = L"verbose_logging";
-}
-
-bool GetDistroBooleanPreference(const DictionaryValue* prefs,
- const std::wstring& name) {
-
- bool value = false;
- DictionaryValue* distro = NULL;
- if (prefs && prefs->GetDictionary(kDistroDict, &distro) && distro)
- distro->GetBoolean(name, &value);
- return value;
-}
-
-bool GetDistributionPingDelay(const DictionaryValue* prefs,
- int* ping_delay) {
- if (!ping_delay)
- return false;
+// Show EULA dialog and install only if accepted.
+const wchar_t kRequireEula[] = L"require_eula";
+// Use alternate shortcut text for the main shortcut.
+const wchar_t kAltShortcutText[] = L"alternate_shortcut_text";
+// Use alternate smaller first run info bubble.
+const wchar_t kAltFirstRunBubble[] = L"oem_bubble";
+// Boolean pref that triggers silent import of the default browser homepage.
+const wchar_t kDistroImportHomePagePref[] = L"import_home_page";
+bool GetDistributionPingDelay(const FilePath& master_prefs_path,
+ int& delay) {
// 90 seconds is the default that we want to use in case master preferences
// is missing or corrupt.
- *ping_delay = 90;
+ delay = 90;
+ FilePath master_prefs = master_prefs_path;
+ if (master_prefs.empty()) {
+ if (!PathService::Get(base::DIR_EXE, &master_prefs))
+ return false;
+ master_prefs = master_prefs.Append(installer_util::kDefaultMasterPrefs);
+ }
- DictionaryValue* distro = NULL;
- if (!prefs || !prefs->GetDictionary(kDistroDict, &distro) || !distro)
+ if (!file_util::PathExists(master_prefs))
+ return false;
+
+ scoped_ptr<DictionaryValue> json_root(
+ GetPrefsFromFile(master_prefs.ToWStringHack()));
+ if (!json_root.get())
return false;
- if (!distro->GetInteger(master_preferences::kDistroPingDelay, ping_delay))
+ DictionaryValue* distro = NULL;
+ if (!json_root->GetDictionary(L"distribution", &distro) ||
+ !distro->GetInteger(kDistroPingDelay, &delay))
return false;
return true;
}
-DictionaryValue* ParseDistributionPreferences(
- const FilePath& master_prefs_path) {
- if (!file_util::PathExists(master_prefs_path)) {
- LOG(WARNING) << "Master preferences file not found: "
- << master_prefs_path.value();
- return NULL;
- }
+int ParseDistributionPreferences(const std::wstring& master_prefs_path) {
+ if (!file_util::PathExists(master_prefs_path))
+ return MASTER_PROFILE_NOT_FOUND;
+ LOG(INFO) << "master profile found";
- return GetPrefsFromFile(master_prefs_path);
+ scoped_ptr<DictionaryValue> json_root(GetPrefsFromFile(master_prefs_path));
+ if (!json_root.get())
+ return MASTER_PROFILE_ERROR;
+
+ int parse_result = 0;
+ DictionaryValue* distro = NULL;
+ if (json_root->GetDictionary(L"distribution", &distro)) {
+ if (GetBooleanPref(distro, kDistroSkipFirstRunPref))
+ parse_result |= MASTER_PROFILE_NO_FIRST_RUN_UI;
+ if (GetBooleanPref(distro, kDistroShowWelcomePage))
+ parse_result |= MASTER_PROFILE_SHOW_WELCOME;
+ if (GetBooleanPref(distro, kDistroImportSearchPref))
+ parse_result |= MASTER_PROFILE_IMPORT_SEARCH_ENGINE;
+ if (GetBooleanPref(distro, kDistroImportHistoryPref))
+ parse_result |= MASTER_PROFILE_IMPORT_HISTORY;
+ if (GetBooleanPref(distro, kDistroImportBookmarksPref))
+ parse_result |= MASTER_PROFILE_IMPORT_BOOKMARKS;
+ if (GetBooleanPref(distro, kDistroImportHomePagePref))
+ parse_result |= MASTER_PROFILE_IMPORT_HOME_PAGE;
+ if (GetBooleanPref(distro, kMakeChromeDefaultForUser))
+ parse_result |= MASTER_PROFILE_MAKE_CHROME_DEFAULT_FOR_USER;
+ if (GetBooleanPref(distro, kCreateAllShortcuts))
+ parse_result |= MASTER_PROFILE_CREATE_ALL_SHORTCUTS;
+ if (GetBooleanPref(distro, kDoNotLaunchChrome))
+ parse_result |= MASTER_PROFILE_DO_NOT_LAUNCH_CHROME;
+ if (GetBooleanPref(distro, kMakeChromeDefault))
+ parse_result |= MASTER_PROFILE_MAKE_CHROME_DEFAULT;
+ if (GetBooleanPref(distro, kSystemLevel))
+ parse_result |= MASTER_PROFILE_SYSTEM_LEVEL;
+ if (GetBooleanPref(distro, kVerboseLogging))
+ parse_result |= MASTER_PROFILE_VERBOSE_LOGGING;
+ if (GetBooleanPref(distro, kRequireEula))
+ parse_result |= MASTER_PROFILE_REQUIRE_EULA;
+ if (GetBooleanPref(distro, kAltShortcutText))
+ parse_result |= MASTER_PROFILE_ALT_SHORTCUT_TXT;
+ if (GetBooleanPref(distro, kAltFirstRunBubble))
+ parse_result |= MASTER_PROFILE_OEM_FIRST_RUN_BUBBLE;
+ }
+ return parse_result;
}
-std::vector<std::wstring> GetFirstRunTabs(const DictionaryValue* prefs) {
+std::vector<std::wstring> ParseFirstRunTabs(
+ const std::wstring& master_prefs_path) {
std::vector<std::wstring> launch_tabs;
- if (!prefs)
+ scoped_ptr<DictionaryValue> json_root(GetPrefsFromFile(master_prefs_path));
+ if (!json_root.get())
return launch_tabs;
ListValue* tabs_list = NULL;
- if (!prefs->GetList(L"first_run_tabs", &tabs_list))
+ if (!json_root->GetList(L"first_run_tabs", &tabs_list))
return launch_tabs;
for (size_t i = 0; i < tabs_list->GetSize(); ++i) {
Value* entry;
@@ -110,18 +172,4 @@ std::vector<std::wstring> GetFirstRunTabs(const DictionaryValue* prefs) {
return launch_tabs;
}
-bool SetDistroBooleanPreference(DictionaryValue* prefs,
- const std::wstring& name,
- bool value) {
-
- bool ret = false;
- if (prefs && !name.empty()) {
- std::wstring key(kDistroDict);
- key.append(L"." + name);
- if (prefs->SetBoolean(key, value))
- ret = true;
- }
- return ret;
-}
-
} // installer_util
diff --git a/chrome/installer/util/master_preferences.h b/chrome/installer/util/master_preferences.h
index d9efb3d..856d53e 100644
--- a/chrome/installer/util/master_preferences.h
+++ b/chrome/installer/util/master_preferences.h
@@ -8,64 +8,64 @@
#ifndef CHROME_INSTALLER_UTIL_MASTER_PREFERENCES_H_
#define CHROME_INSTALLER_UTIL_MASTER_PREFERENCES_H_
-#include "base/file_path.h"
-#include "base/values.h"
+#include <string>
+#include <vector>
-namespace installer_util {
-
-namespace master_preferences {
-// All the preferences below are expected to be inside the JSON "distribution"
-// block. Some of them also have equivalent command line option. If same option
-// is specified in master preference as well as command line, the commnd line
-// value takes precedence.
+#include "base/file_util.h"
-// Boolean. Use alternate text for the shortcut. Cmd line override present.
-extern const wchar_t kAltShortcutText[];
-// Boolean. Use alternate smaller first run info bubble.
-extern const wchar_t kAltFirstRunBubble[];
-// Boolean. Create Desktop and QuickLaunch shortcuts. Cmd line override present.
-extern const wchar_t kCreateAllShortcuts[];
-// Boolean pref that triggers silent import of the default browser bookmarks.
-extern const wchar_t kDistroImportBookmarksPref[];
-// Boolean pref that triggers silent import of the default browser history.
-extern const wchar_t kDistroImportHistoryPref[];
-// Boolean pref that triggers silent import of the default browser homepage.
-extern const wchar_t kDistroImportHomePagePref[];
-// Boolean pref that triggers silent import of the default search engine.
-extern const wchar_t kDistroImportSearchPref[];
-// Integer. RLZ ping delay in seconds.
-extern const wchar_t kDistroPingDelay[];
-// Boolean pref that triggers loading the welcome page.
-extern const wchar_t kDistroShowWelcomePage[];
-// Boolean pref that triggers skipping the first run dialogs.
-extern const wchar_t kDistroSkipFirstRunPref[];
-// Boolean. Do not launch Chrome after first install. Cmd line override present.
-extern const wchar_t kDoNotLaunchChrome[];
-// Boolean. Register Chrome as default browser. Cmd line override present.
-extern const wchar_t kMakeChromeDefault[];
-// Boolean. Register Chrome as default browser for the current user.
-extern const wchar_t kMakeChromeDefaultForUser[];
-// Boolean. Show EULA dialog before install.
-extern const wchar_t kRequireEula[];
-// Boolean. Install Chrome to system wise location. Cmd line override present.
-extern const wchar_t kSystemLevel[];
-// Boolean. Run installer in verbose mode. Cmd line override present.
-extern const wchar_t kVerboseLogging[];
-}
+namespace installer_util {
// This is the default name for the master preferences file used to pre-set
// values in the user profile at first run.
const wchar_t kDefaultMasterPrefs[] = L"master_preferences";
-// Gets the value of given boolean preference |name| from |prefs| dictionary
-// which is assumed to contain a dictionary named "distribution".
-bool GetDistroBooleanPreference(const DictionaryValue* prefs,
- const std::wstring& name);
+// These are the possible results of calling ParseDistributionPreferences.
+// Some of the results can be combined, so they are bit flags.
+enum MasterPrefResult {
+ MASTER_PROFILE_NOT_FOUND = 0x1,
+ // A critical error processing the master profile.
+ MASTER_PROFILE_ERROR = 0x1 << 1,
+ // Skip first run dialogs.
+ MASTER_PROFILE_NO_FIRST_RUN_UI = 0x1 << 2,
+ // Show welcome page.
+ MASTER_PROFILE_SHOW_WELCOME = 0x1 << 3,
+ // Import search engine setting from the default browser.
+ MASTER_PROFILE_IMPORT_SEARCH_ENGINE = 0x1 << 4,
+ // Import history from the default browser.
+ MASTER_PROFILE_IMPORT_HISTORY = 0x1 << 5,
+ // Import bookmarks from the default browser.
+ MASTER_PROFILE_IMPORT_BOOKMARKS = 0x1 << 6,
+ // Register Chrome as default browser for the current user. This option is
+ // different than MAKE_CHROME_DEFAULT as installer ignores this option and
+ // Chrome on first run makes itself default.
+ MASTER_PROFILE_MAKE_CHROME_DEFAULT_FOR_USER = 0x1 << 7,
+ // 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 << 8,
+ // Prevent installer from launching Chrome after a successful first install.
+ MASTER_PROFILE_DO_NOT_LAUNCH_CHROME = 0x1 << 9,
+ // Register Chrome as default browser on the system.
+ MASTER_PROFILE_MAKE_CHROME_DEFAULT = 0x1 << 10,
+ // Install Chrome to system wise location.
+ MASTER_PROFILE_SYSTEM_LEVEL = 0x1 << 11,
+ // Run installer in verbose mode.
+ MASTER_PROFILE_VERBOSE_LOGGING = 0x1 << 12,
+ // Show the EULA and do not install if not accepted.
+ MASTER_PROFILE_REQUIRE_EULA = 0x1 << 13,
+ // Use an alternate description text for some shortcuts.
+ MASTER_PROFILE_ALT_SHORTCUT_TXT = 0x1 << 14,
+ // Use a smaller OEM info bubble on first run.
+ MASTER_PROFILE_OEM_FIRST_RUN_BUBBLE = 0x1 << 15,
+ // Import home page from the default browser.
+ MASTER_PROFILE_IMPORT_HOME_PAGE = 0x1 << 16
+};
// This function gets ping delay (ping_delay in the sample above) from master
// preferences.
-bool GetDistributionPingDelay(const DictionaryValue* prefs,
- int* ping_delay);
+bool GetDistributionPingDelay(const FilePath& master_prefs_path,
+ int& delay);
// The master preferences is a JSON file with the same entries as the
// 'Default\Preferences' file. This function parses the distribution
@@ -75,22 +75,21 @@ bool GetDistributionPingDelay(const DictionaryValue* prefs,
//
// {
// "distribution": {
-// "alternate_shortcut_text": false,
-// "oem_bubble": false,
-// "create_all_shortcuts": true,
-// "import_bookmarks": false,
+// "skip_first_run_ui": true,
+// "show_welcome_page": true,
+// "import_search_engine": true,
// "import_history": false,
+// "import_bookmarks": false,
// "import_home_page": false,
-// "import_search_engine": true,
-// "ping_delay": 40,
-// "show_welcome_page": true,
-// "skip_first_run_ui": true,
+// "create_all_shortcuts": true,
// "do_not_launch_chrome": false,
// "make_chrome_default": false,
// "make_chrome_default_for_user": true,
-// "require_eula": true,
// "system_level": false,
-// "verbose_logging": true
+// "verbose_logging": true,
+// "require_eula": true,
+// "alternate_shortcut_text": false,
+// "ping_delay": 40
// },
// "browser": {
// "show_home_button": true
@@ -110,8 +109,7 @@ bool GetDistributionPingDelay(const DictionaryValue* prefs,
// installation properties. This entry will be ignored at other times.
// This function parses the 'distribution' entry and returns a combination
// of MasterPrefResult.
-DictionaryValue* ParseDistributionPreferences(
- const FilePath& master_prefs_path);
+int ParseDistributionPreferences(const std::wstring& master_prefs_path);
// As part of the master preferences an optional section indicates the tabs
// to open during first run. An example is the following:
@@ -127,13 +125,8 @@ DictionaryValue* ParseDistributionPreferences(
//
// This function retuns the list as a vector of strings. If the master
// preferences file does not contain such list the vector is empty.
-std::vector<std::wstring> GetFirstRunTabs(const DictionaryValue* prefs);
-
-// Sets the value of given boolean preference |name| in "distribution"
-// dictionary inside |prefs| dictionary.
-bool SetDistroBooleanPreference(DictionaryValue* prefs,
- const std::wstring& name,
- bool value);
+std::vector<std::wstring> ParseFirstRunTabs(
+ const std::wstring& master_prefs_path);
}
#endif // CHROME_INSTALLER_UTIL_MASTER_PREFERENCES_H_
diff --git a/chrome/installer/util/shell_util.cc b/chrome/installer/util/shell_util.cc
index d157f02..1261316 100644
--- a/chrome/installer/util/shell_util.cc
+++ b/chrome/installer/util/shell_util.cc
@@ -334,7 +334,7 @@ bool ElevateAndRegisterChrome(const std::wstring& chrome_exe,
params.append(installer_util::switches::kRegisterChromeBrowser);
params.append(L"=\"" + chrome_exe + L"\"");
if (!suffix.empty()) {
- params.append(L" --");
+ params.append(L"--");
params.append(installer_util::switches::kRegisterChromeBrowserSuffix);
params.append(L"=\"" + suffix + L"\"");
}
diff --git a/chrome/installer/util/util_constants.h b/chrome/installer/util/util_constants.h
index 4e209b2..5256d6a 100644
--- a/chrome/installer/util/util_constants.h
+++ b/chrome/installer/util/util_constants.h
@@ -42,6 +42,31 @@ enum InstallStatus {
INSTALL_DIR_IN_USE // Installation directory is in use by another process
};
+// These are distribution 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,
+ // Run installer in verbose mode.
+ VERBOSE_LOGGING = 0x1 << 6,
+ // Show the EULA dialog.
+ SHOW_EULA_DIALOG = 0x1 << 7,
+ // Use alternate dekstop shortcut text.
+ ALT_DESKTOP_SHORTCUT = 0x1 << 8
+};
+
namespace switches {
extern const wchar_t kCreateAllShortcuts[];
extern const wchar_t kDeleteProfile[];