summaryrefslogtreecommitdiffstats
path: root/chrome/installer
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/installer')
-rw-r--r--chrome/installer/setup/install.cc27
-rw-r--r--chrome/installer/setup/setup_main.cc29
-rw-r--r--chrome/installer/setup/setup_util_unittest.cc36
-rw-r--r--chrome/installer/util/master_preferences.cc20
-rw-r--r--chrome/installer/util/master_preferences.h10
-rw-r--r--chrome/installer/util/master_preferences_unittest.cc77
6 files changed, 129 insertions, 70 deletions
diff --git a/chrome/installer/setup/install.cc b/chrome/installer/setup/install.cc
index 1d3bd7d..c7862b4 100644
--- a/chrome/installer/setup/install.cc
+++ b/chrome/installer/setup/install.cc
@@ -577,8 +577,9 @@ installer_util::InstallStatus installer::InstallOrUpdateChrome(
const std::wstring& install_temp_path, const std::wstring& prefs_path,
const DictionaryValue* prefs, const Version& new_version,
const Version* installed_version) {
- bool system_install = installer_util::GetDistroBooleanPreference(prefs,
- installer_util::master_preferences::kSystemLevel);
+ bool system_install = false;
+ installer_util::GetDistroBooleanPreference(prefs,
+ installer_util::master_preferences::kSystemLevel, &system_install);
std::wstring install_path(GetChromeInstallPath(system_install));
if (install_path.empty()) {
LOG(ERROR) << "Could not get installation destination path.";
@@ -621,20 +622,28 @@ installer_util::InstallStatus installer::InstallOrUpdateChrome(
result = installer_util::NEW_VERSION_UPDATED;
}
+ bool value = false;
if (!installer_util::GetDistroBooleanPreference(prefs,
- installer_util::master_preferences::kDoNotCreateShortcuts)) {
- 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);
+ installer_util::master_preferences::kDoNotCreateShortcuts, &value) ||
+ !value) {
+ bool create_all_shortcut = false;
+ installer_util::GetDistroBooleanPreference(prefs,
+ installer_util::master_preferences::kCreateAllShortcuts,
+ &create_all_shortcut);
+ bool alt_shortcut = false;
+ installer_util::GetDistroBooleanPreference(prefs,
+ installer_util::master_preferences::kAltShortcutText,
+ &alt_shortcut);
if (!CreateOrUpdateChromeShortcuts(exe_path, install_path,
new_version.GetString(), result,
system_install, create_all_shortcut,
alt_shortcut))
LOG(WARNING) << "Failed to create/update start menu shortcut.";
- bool make_chrome_default = installer_util::GetDistroBooleanPreference(
- prefs, installer_util::master_preferences::kMakeChromeDefault);
+ bool make_chrome_default = false;
+ installer_util::GetDistroBooleanPreference(prefs,
+ installer_util::master_preferences::kMakeChromeDefault,
+ &make_chrome_default);
RegisterChromeOnMachine(install_path, system_install,
make_chrome_default);
}
diff --git a/chrome/installer/setup/setup_main.cc b/chrome/installer/setup/setup_main.cc
index f20e307..11f2c6d 100644
--- a/chrome/installer/setup/setup_main.cc
+++ b/chrome/installer/setup/setup_main.cc
@@ -181,8 +181,9 @@ 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);
+ bool system_level = false;
+ installer_util::GetDistroBooleanPreference(prefs,
+ installer_util::master_preferences::kSystemLevel, &system_level);
installer_util::InstallStatus install_status = installer_util::UNKNOWN_STATUS;
if (!CheckPreInstallConditions(installed_version,
system_level, install_status))
@@ -274,9 +275,11 @@ installer_util::InstallStatus InstallChrome(const CommandLine& cmd_line,
}
}
- bool write_chrome_launch_string =
- !installer_util::GetDistroBooleanPreference(prefs,
- installer_util::master_preferences::kDoNotRegisterForUpdateLaunch);
+ bool value = false;
+ installer_util::GetDistroBooleanPreference(prefs,
+ installer_util::master_preferences::kDoNotRegisterForUpdateLaunch,
+ &value);
+ bool write_chrome_launch_string = !value;
InstallUtil::WriteInstallerResult(system_level, install_status,
install_msg_base, write_chrome_launch_string ? &chrome_exe : NULL);
@@ -284,8 +287,11 @@ installer_util::InstallStatus InstallChrome(const CommandLine& cmd_line,
if (install_status == installer_util::FIRST_INSTALL_SUCCESS) {
LOG(INFO) << "First install successful.";
// We never want to launch Chrome in system level install mode.
- if (!system_level && !installer_util::GetDistroBooleanPreference(
- prefs, installer_util::master_preferences::kDoNotLaunchChrome))
+ bool do_not_launch_chrome = false;
+ installer_util::GetDistroBooleanPreference(prefs,
+ installer_util::master_preferences::kDoNotLaunchChrome,
+ &do_not_launch_chrome);
+ if (!system_level && !do_not_launch_chrome)
installer::LaunchChrome(system_level);
} else if (install_status == installer_util::NEW_VERSION_UPDATED) {
installer_setup::RemoveLegacyRegistryKeys();
@@ -512,12 +518,15 @@ int WINAPI wWinMain(HINSTANCE instance, HINSTANCE prev_instance,
installer::InitInstallerLogging(parsed_command_line);
scoped_ptr<DictionaryValue> prefs(setup_util::GetInstallPreferences(
parsed_command_line));
+ bool value = false;
if (installer_util::GetDistroBooleanPreference(prefs.get(),
- installer_util::master_preferences::kVerboseLogging))
+ installer_util::master_preferences::kVerboseLogging, &value) &&
+ value)
logging::SetMinLogLevel(logging::LOG_INFO);
- bool system_install = installer_util::GetDistroBooleanPreference(prefs.get(),
- installer_util::master_preferences::kSystemLevel);
+ bool system_install = false;
+ installer_util::GetDistroBooleanPreference(prefs.get(),
+ installer_util::master_preferences::kSystemLevel, &system_install);
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_util_unittest.cc b/chrome/installer/setup/setup_util_unittest.cc
index 34a26fe..44af7fc 100644
--- a/chrome/installer/setup/setup_util_unittest.cc
+++ b/chrome/installer/setup/setup_util_unittest.cc
@@ -93,22 +93,29 @@ TEST_F(SetupUtilTest, GetInstallPreferencesTest) {
EXPECT_TRUE(prefs.get() != NULL);
// Check prefs that do not have any equivalent command line option.
+ bool value = false;
EXPECT_TRUE(installer_util::GetDistroBooleanPreference(prefs.get(),
- installer_util::master_preferences::kDistroSkipFirstRunPref));
+ installer_util::master_preferences::kDistroSkipFirstRunPref, &value) &&
+ value);
EXPECT_FALSE(installer_util::GetDistroBooleanPreference(prefs.get(),
- installer_util::master_preferences::kDistroShowWelcomePage));
+ installer_util::master_preferences::kDistroShowWelcomePage, &value));
// Now check that prefs got merged correctly.
EXPECT_TRUE(installer_util::GetDistroBooleanPreference(prefs.get(),
- installer_util::master_preferences::kCreateAllShortcuts));
+ installer_util::master_preferences::kCreateAllShortcuts, &value) &&
+ value);
EXPECT_TRUE(installer_util::GetDistroBooleanPreference(prefs.get(),
- installer_util::master_preferences::kDoNotLaunchChrome));
+ installer_util::master_preferences::kDoNotLaunchChrome, &value) &&
+ value);
EXPECT_TRUE(installer_util::GetDistroBooleanPreference(prefs.get(),
- installer_util::master_preferences::kAltShortcutText));
+ installer_util::master_preferences::kAltShortcutText, &value) &&
+ value);
EXPECT_TRUE(installer_util::GetDistroBooleanPreference(prefs.get(),
- installer_util::master_preferences::kSystemLevel));
- EXPECT_FALSE(installer_util::GetDistroBooleanPreference(prefs.get(),
- installer_util::master_preferences::kVerboseLogging));
+ installer_util::master_preferences::kSystemLevel, &value) &&
+ value);
+ EXPECT_TRUE(installer_util::GetDistroBooleanPreference(prefs.get(),
+ installer_util::master_preferences::kVerboseLogging, &value));
+ EXPECT_FALSE(value);
// Delete temporary prefs file.
EXPECT_TRUE(file_util::Delete(prefs_file, false));
@@ -121,15 +128,18 @@ TEST_F(SetupUtilTest, GetInstallPreferencesTest) {
prefs.reset(setup_util::GetInstallPreferences(cmd_line));
EXPECT_TRUE(prefs.get() != NULL);
EXPECT_TRUE(installer_util::GetDistroBooleanPreference(prefs.get(),
- installer_util::master_preferences::kCreateAllShortcuts));
+ installer_util::master_preferences::kCreateAllShortcuts, &value) &&
+ value);
EXPECT_TRUE(installer_util::GetDistroBooleanPreference(prefs.get(),
- installer_util::master_preferences::kDoNotLaunchChrome));
+ installer_util::master_preferences::kDoNotLaunchChrome, &value) &&
+ value);
EXPECT_TRUE(installer_util::GetDistroBooleanPreference(prefs.get(),
- installer_util::master_preferences::kAltShortcutText));
+ installer_util::master_preferences::kAltShortcutText, &value) &&
+ value);
EXPECT_FALSE(installer_util::GetDistroBooleanPreference(prefs.get(),
- installer_util::master_preferences::kSystemLevel));
+ installer_util::master_preferences::kSystemLevel, &value));
EXPECT_FALSE(installer_util::GetDistroBooleanPreference(prefs.get(),
- installer_util::master_preferences::kVerboseLogging));
+ installer_util::master_preferences::kVerboseLogging, &value));
}
// Test that we are parsing Chrome version correctly.
diff --git a/chrome/installer/util/master_preferences.cc b/chrome/installer/util/master_preferences.cc
index 98f5ba8..8eb3ad1 100644
--- a/chrome/installer/util/master_preferences.cc
+++ b/chrome/installer/util/master_preferences.cc
@@ -40,23 +40,29 @@ const wchar_t kVerboseLogging[] = L"verbose_logging";
}
bool GetDistroBooleanPreference(const DictionaryValue* prefs,
- const std::wstring& name) {
+ const std::wstring& name,
+ bool* value) {
+ if (!prefs || !value)
+ return false;
- bool value = false;
DictionaryValue* distro = NULL;
- if (prefs && prefs->GetDictionary(kDistroDict, &distro) && distro)
- distro->GetBoolean(name, &value);
- return value;
+ if (!prefs->GetDictionary(kDistroDict, &distro) || !distro)
+ return false;
+
+ if (!distro->GetBoolean(name, value))
+ return false;
+
+ return true;
}
bool GetDistroIntegerPreference(const DictionaryValue* prefs,
const std::wstring& name,
int* value) {
- if (!value)
+ if (!prefs || !value)
return false;
DictionaryValue* distro = NULL;
- if (!prefs || !prefs->GetDictionary(kDistroDict, &distro) || !distro)
+ if (!prefs->GetDictionary(kDistroDict, &distro) || !distro)
return false;
if (!distro->GetInteger(name, value))
diff --git a/chrome/installer/util/master_preferences.h b/chrome/installer/util/master_preferences.h
index 335a4ad..a809c97 100644
--- a/chrome/installer/util/master_preferences.h
+++ b/chrome/installer/util/master_preferences.h
@@ -65,12 +65,14 @@ extern const wchar_t kVerboseLogging[];
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".
+// which is assumed to contain a dictionary named "distribution". Returns
+// true if the value is read successfully, otherwise false.
bool GetDistroBooleanPreference(const DictionaryValue* prefs,
- const std::wstring& name);
+ const std::wstring& name,
+ bool* value);
-// This function gets ping delay (ping_delay in the sample above) from master
-// preferences.
+// This function gets value of an integer preference from master
+// preferences. Returns true if the value is read successfully, otherwise false.
bool GetDistroIntegerPreference(const DictionaryValue* prefs,
const std::wstring& name,
int* value);
diff --git a/chrome/installer/util/master_preferences_unittest.cc b/chrome/installer/util/master_preferences_unittest.cc
index 18f3a6b..ad827eb 100644
--- a/chrome/installer/util/master_preferences_unittest.cc
+++ b/chrome/installer/util/master_preferences_unittest.cc
@@ -56,40 +56,56 @@ TEST(MasterPreferencesTest, ParseDistroParams) {
scoped_ptr<DictionaryValue> prefs(
installer_util::ParseDistributionPreferences(prefs_file));
EXPECT_TRUE(prefs.get() != NULL);
+ bool value = true;
EXPECT_TRUE(installer_util::GetDistroBooleanPreference(prefs.get(),
- installer_util::master_preferences::kDistroSkipFirstRunPref));
+ installer_util::master_preferences::kDistroSkipFirstRunPref, &value) &&
+ value);
EXPECT_TRUE(installer_util::GetDistroBooleanPreference(prefs.get(),
- installer_util::master_preferences::kDistroShowWelcomePage));
+ installer_util::master_preferences::kDistroShowWelcomePage, &value) &&
+ value);
EXPECT_TRUE(installer_util::GetDistroBooleanPreference(prefs.get(),
- installer_util::master_preferences::kDistroImportSearchPref));
+ installer_util::master_preferences::kDistroImportSearchPref, &value) &&
+ value);
EXPECT_TRUE(installer_util::GetDistroBooleanPreference(prefs.get(),
- installer_util::master_preferences::kDistroImportHistoryPref));
+ installer_util::master_preferences::kDistroImportHistoryPref, &value) &&
+ value);
EXPECT_TRUE(installer_util::GetDistroBooleanPreference(prefs.get(),
- installer_util::master_preferences::kDistroImportBookmarksPref));
+ installer_util::master_preferences::kDistroImportBookmarksPref, &value) &&
+ value);
EXPECT_TRUE(installer_util::GetDistroBooleanPreference(prefs.get(),
- installer_util::master_preferences::kDistroImportHomePagePref));
+ installer_util::master_preferences::kDistroImportHomePagePref, &value) &&
+ value);
EXPECT_TRUE(installer_util::GetDistroBooleanPreference(prefs.get(),
- installer_util::master_preferences::kCreateAllShortcuts));
+ installer_util::master_preferences::kCreateAllShortcuts, &value) &&
+ value);
EXPECT_TRUE(installer_util::GetDistroBooleanPreference(prefs.get(),
- installer_util::master_preferences::kDoNotLaunchChrome));
+ installer_util::master_preferences::kDoNotLaunchChrome, &value) &&
+ value);
EXPECT_TRUE(installer_util::GetDistroBooleanPreference(prefs.get(),
- installer_util::master_preferences::kMakeChromeDefault));
+ installer_util::master_preferences::kMakeChromeDefault, &value) &&
+ value);
EXPECT_TRUE(installer_util::GetDistroBooleanPreference(prefs.get(),
- installer_util::master_preferences::kMakeChromeDefaultForUser));
+ installer_util::master_preferences::kMakeChromeDefaultForUser, &value) &&
+ value);
EXPECT_TRUE(installer_util::GetDistroBooleanPreference(prefs.get(),
- installer_util::master_preferences::kSystemLevel));
+ installer_util::master_preferences::kSystemLevel, &value) &&
+ value);
EXPECT_TRUE(installer_util::GetDistroBooleanPreference(prefs.get(),
- installer_util::master_preferences::kVerboseLogging));
+ installer_util::master_preferences::kVerboseLogging, &value) &&
+ value);
EXPECT_TRUE(installer_util::GetDistroBooleanPreference(prefs.get(),
- installer_util::master_preferences::kRequireEula));
+ installer_util::master_preferences::kRequireEula, &value) &&
+ value);
EXPECT_TRUE(installer_util::GetDistroBooleanPreference(prefs.get(),
- installer_util::master_preferences::kAltShortcutText));
+ installer_util::master_preferences::kAltShortcutText, &value) &&
+ value);
EXPECT_TRUE(installer_util::GetDistroBooleanPreference(prefs.get(),
- installer_util::master_preferences::kAltFirstRunBubble));
+ installer_util::master_preferences::kAltFirstRunBubble, &value) &&
+ value);
int icon_index = 0;
EXPECT_TRUE(installer_util::GetDistroIntegerPreference(prefs.get(),
installer_util::master_preferences::kChromeShortcutIconIndex,
@@ -121,30 +137,37 @@ TEST(MasterPreferencesTest, ParseMissingDistroParams) {
scoped_ptr<DictionaryValue> prefs(
installer_util::ParseDistributionPreferences(prefs_file));
EXPECT_TRUE(prefs.get() != NULL);
+ bool value = false;
EXPECT_TRUE(installer_util::GetDistroBooleanPreference(prefs.get(),
- installer_util::master_preferences::kDistroSkipFirstRunPref));
+ installer_util::master_preferences::kDistroSkipFirstRunPref, &value) &&
+ value);
EXPECT_FALSE(installer_util::GetDistroBooleanPreference(prefs.get(),
- installer_util::master_preferences::kDistroShowWelcomePage));
+ installer_util::master_preferences::kDistroShowWelcomePage, &value));
EXPECT_TRUE(installer_util::GetDistroBooleanPreference(prefs.get(),
- installer_util::master_preferences::kDistroImportSearchPref));
+ installer_util::master_preferences::kDistroImportSearchPref, &value) &&
+ value);
EXPECT_FALSE(installer_util::GetDistroBooleanPreference(prefs.get(),
- installer_util::master_preferences::kDistroImportHistoryPref));
- EXPECT_FALSE(installer_util::GetDistroBooleanPreference(prefs.get(),
- installer_util::master_preferences::kDistroImportBookmarksPref));
+ installer_util::master_preferences::kDistroImportHistoryPref, &value));
+ EXPECT_TRUE(installer_util::GetDistroBooleanPreference(prefs.get(),
+ installer_util::master_preferences::kDistroImportBookmarksPref, &value));
+ EXPECT_FALSE(value);
EXPECT_FALSE(installer_util::GetDistroBooleanPreference(prefs.get(),
- installer_util::master_preferences::kDistroImportHomePagePref));
+ installer_util::master_preferences::kDistroImportHomePagePref, &value));
EXPECT_TRUE(installer_util::GetDistroBooleanPreference(prefs.get(),
- installer_util::master_preferences::kCreateAllShortcuts));
+ installer_util::master_preferences::kCreateAllShortcuts, &value) &&
+ value);
EXPECT_TRUE(installer_util::GetDistroBooleanPreference(prefs.get(),
- installer_util::master_preferences::kDoNotLaunchChrome));
+ installer_util::master_preferences::kDoNotLaunchChrome, &value) &&
+ value);
EXPECT_FALSE(installer_util::GetDistroBooleanPreference(prefs.get(),
- installer_util::master_preferences::kDoNotRegisterForUpdateLaunch));
+ installer_util::master_preferences::kDoNotRegisterForUpdateLaunch,
+ &value));
EXPECT_FALSE(installer_util::GetDistroBooleanPreference(prefs.get(),
- installer_util::master_preferences::kMakeChromeDefault));
+ installer_util::master_preferences::kMakeChromeDefault, &value));
EXPECT_FALSE(installer_util::GetDistroBooleanPreference(prefs.get(),
- installer_util::master_preferences::kMakeChromeDefaultForUser));
+ installer_util::master_preferences::kMakeChromeDefaultForUser, &value));
int icon_index = 0;
EXPECT_FALSE(installer_util::GetDistroIntegerPreference(prefs.get(),