summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorkuchhal@chromium.org <kuchhal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-31 21:58:41 +0000
committerkuchhal@chromium.org <kuchhal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-31 21:58:41 +0000
commitd1572f4a4eddfb0a94e6548c8987aa76f75a2863 (patch)
tree493ec32f3a3bb7484c06e6db34c28024e73b9c62 /chrome
parent7086d56e3fde7f710347d7f58ee998a901754744 (diff)
downloadchromium_src-d1572f4a4eddfb0a94e6548c8987aa76f75a2863.zip
chromium_src-d1572f4a4eddfb0a94e6548c8987aa76f75a2863.tar.gz
chromium_src-d1572f4a4eddfb0a94e6548c8987aa76f75a2863.tar.bz2
cleanup
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@22200 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/first_run.h2
-rw-r--r--chrome/browser/first_run_win.cc20
-rw-r--r--chrome/installer/setup/install.cc14
-rw-r--r--chrome/installer/setup/setup_main.cc10
-rw-r--r--chrome/installer/util/master_preferences.cc81
-rw-r--r--chrome/installer/util/master_preferences.h86
6 files changed, 93 insertions, 120 deletions
diff --git a/chrome/browser/first_run.h b/chrome/browser/first_run.h
index 3bf1ce3..0914e9f 100644
--- a/chrome/browser/first_run.h
+++ b/chrome/browser/first_run.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2009 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.
diff --git a/chrome/browser/first_run_win.cc b/chrome/browser/first_run_win.cc
index f14a3ea..c0ffb6fe 100644
--- a/chrome/browser/first_run_win.cc
+++ b/chrome/browser/first_run_win.cc
@@ -185,11 +185,11 @@ bool FirstRun::ProcessMasterPreferences(const FilePath& user_data_dir,
return true;
if (new_tabs)
- *new_tabs = installer_util::ParseFirstRunTabs(prefs.get());
+ *new_tabs = installer_util::GetFirstRunTabs(prefs.get());
if (ping_delay)
installer_util::GetDistributionPingDelay(prefs.get(), ping_delay);
- if (installer_util::GetBooleanPreference(prefs.get(),
+ if (installer_util::GetDistroBooleanPreference(prefs.get(),
installer_util::master_preferences::kRequireEula)) {
// 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
@@ -216,7 +216,7 @@ bool FirstRun::ProcessMasterPreferences(const FilePath& user_data_dir,
}
}
- if (installer_util::GetBooleanPreference(prefs.get(),
+ if (installer_util::GetDistroBooleanPreference(prefs.get(),
installer_util::master_preferences::kAltFirstRunBubble))
FirstRun::SetOEMFirstRunBubblePref();
@@ -229,7 +229,7 @@ bool FirstRun::ProcessMasterPreferences(const FilePath& user_data_dir,
if (!file_util::CopyFile(master_prefs, user_prefs))
return true;
- if (!installer_util::GetBooleanPreference(prefs.get(),
+ if (!installer_util::GetDistroBooleanPreference(prefs.get(),
installer_util::master_preferences::kDistroSkipFirstRunPref))
return true;
@@ -243,21 +243,21 @@ bool FirstRun::ProcessMasterPreferences(const FilePath& user_data_dir,
if (!FirstRun::CreateSentinel())
return false;
- if (installer_util::GetBooleanPreference(prefs.get(),
+ if (installer_util::GetDistroBooleanPreference(prefs.get(),
installer_util::master_preferences::kDistroShowWelcomePage))
FirstRun::SetShowWelcomePagePref();
int import_items = 0;
- if (installer_util::GetBooleanPreference(prefs.get(),
+ if (installer_util::GetDistroBooleanPreference(prefs.get(),
installer_util::master_preferences::kDistroImportSearchPref))
import_items += SEARCH_ENGINES;
- if (installer_util::GetBooleanPreference(prefs.get(),
+ if (installer_util::GetDistroBooleanPreference(prefs.get(),
installer_util::master_preferences::kDistroImportHistoryPref))
import_items += HISTORY;
- if (installer_util::GetBooleanPreference(prefs.get(),
+ if (installer_util::GetDistroBooleanPreference(prefs.get(),
installer_util::master_preferences::kDistroImportBookmarksPref))
import_items += FAVORITES;
- if (installer_util::GetBooleanPreference(prefs.get(),
+ if (installer_util::GetDistroBooleanPreference(prefs.get(),
installer_util::master_preferences::kDistroImportHomePagePref))
import_items += HOME_PAGE;
@@ -272,7 +272,7 @@ bool FirstRun::ProcessMasterPreferences(const FilePath& user_data_dir,
}
}
- if (installer_util::GetBooleanPreference(prefs.get(),
+ if (installer_util::GetDistroBooleanPreference(prefs.get(),
installer_util::master_preferences::kMakeChromeDefaultForUser))
ShellIntegration::SetAsDefaultBrowser();
diff --git a/chrome/installer/setup/install.cc b/chrome/installer/setup/install.cc
index 8d6a4db..ba62f0c 100644
--- a/chrome/installer/setup/install.cc
+++ b/chrome/installer/setup/install.cc
@@ -7,13 +7,11 @@
#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"
@@ -24,8 +22,6 @@
#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.
@@ -486,7 +482,7 @@ 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 Version& new_version, const Version* installed_version) {
- bool system_install = installer_util::GetBooleanPreference(prefs,
+ bool system_install = installer_util::GetDistroBooleanPreference(prefs,
installer_util::master_preferences::kSystemLevel);
std::wstring install_path(GetChromeInstallPath(system_install));
if (install_path.empty()) {
@@ -528,9 +524,9 @@ installer_util::InstallStatus installer::InstallOrUpdateChrome(
result = installer_util::NEW_VERSION_UPDATED;
}
- bool create_all_shortcut = installer_util::GetBooleanPreference(prefs,
+ bool create_all_shortcut = installer_util::GetDistroBooleanPreference(prefs,
installer_util::master_preferences::kCreateAllShortcuts);
- bool alt_shortcut = installer_util::GetBooleanPreference(prefs,
+ bool alt_shortcut = installer_util::GetDistroBooleanPreference(prefs,
installer_util::master_preferences::kAltShortcutText);
if (!CreateOrUpdateChromeShortcuts(exe_path, install_path,
new_version.GetString(), result,
@@ -540,7 +536,7 @@ installer_util::InstallStatus installer::InstallOrUpdateChrome(
RemoveOldVersionDirs(install_path, new_version.GetString());
- bool make_chrome_default = installer_util::GetBooleanPreference(prefs,
+ bool make_chrome_default = installer_util::GetDistroBooleanPreference(prefs,
installer_util::master_preferences::kMakeChromeDefault);
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 0f0d41a..daae996 100644
--- a/chrome/installer/setup/setup_main.cc
+++ b/chrome/installer/setup/setup_main.cc
@@ -301,7 +301,7 @@ 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::GetBooleanPreference(prefs,
+ bool system_level = installer_util::GetDistroBooleanPreference(prefs,
installer_util::master_preferences::kSystemLevel);
installer_util::InstallStatus install_status = installer_util::UNKNOWN_STATUS;
if (!CheckPreInstallConditions(installed_version,
@@ -395,11 +395,11 @@ installer_util::InstallStatus InstallChrome(const CommandLine& cmd_line,
install_msg_base, &chrome_exe);
if (install_status == installer_util::FIRST_INSTALL_SUCCESS) {
LOG(INFO) << "First install successful.";
- if (installer_util::GetBooleanPreference(prefs,
+ if (installer_util::GetDistroBooleanPreference(prefs,
installer_util::master_preferences::kMasterPreferencesValid))
CopyPreferenceFileForFirstRun(system_level, cmd_line);
// We never want to launch Chrome in system level install mode.
- if (!system_level && !installer_util::GetBooleanPreference(prefs,
+ if (!system_level && !installer_util::GetDistroBooleanPreference(prefs,
installer_util::master_preferences::kDoNotLaunchChrome))
installer::LaunchChrome(system_level);
}
@@ -617,11 +617,11 @@ int WINAPI wWinMain(HINSTANCE instance, HINSTANCE prev_instance,
const CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess();
installer::InitInstallerLogging(parsed_command_line);
scoped_ptr<DictionaryValue> prefs(GetInstallPreferences(parsed_command_line));
- if (installer_util::GetBooleanPreference(prefs.get(),
+ if (installer_util::GetDistroBooleanPreference(prefs.get(),
installer_util::master_preferences::kVerboseLogging))
logging::SetMinLogLevel(logging::LOG_INFO);
- bool system_install = installer_util::GetBooleanPreference(prefs.get(),
+ bool system_install = installer_util::GetDistroBooleanPreference(prefs.get(),
installer_util::master_preferences::kSystemLevel);
LOG(INFO) << "system install is " << system_install;
diff --git a/chrome/installer/util/master_preferences.cc b/chrome/installer/util/master_preferences.cc
index eb62aa5..47123b8 100644
--- a/chrome/installer/util/master_preferences.cc
+++ b/chrome/installer/util/master_preferences.cc
@@ -10,6 +10,9 @@
#include "chrome/common/json_value_serializer.h"
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))
@@ -30,62 +33,49 @@ DictionaryValue* GetPrefsFromFile(const FilePath& master_prefs_path) {
namespace installer_util {
namespace master_preferences {
-// 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 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";
-// RLZ ping delay in seconds
+const wchar_t kDistroImportHistoryPref[] = L"import_history";
+const wchar_t kDistroImportHomePagePref[] = L"import_home_page";
+const wchar_t kDistroImportSearchPref[] = L"import_search_engine";
const wchar_t kDistroPingDelay[] = L"ping_delay";
-// 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 kDistroShowWelcomePage[] = L"show_welcome_page";
+const wchar_t kDistroSkipFirstRunPref[] = L"skip_first_run_ui";
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";
-// Install Chrome to system wise location.
+const wchar_t kMakeChromeDefaultForUser[] = L"make_chrome_default_for_user";
+const wchar_t kMasterPreferencesValid[] = L"master_preferencs_valid";
+const wchar_t kRequireEula[] = L"require_eula";
const wchar_t kSystemLevel[] = L"system_level";
-// Run installer in verbose mode.
const wchar_t kVerboseLogging[] = L"verbose_logging";
-// 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";
-
-const wchar_t kMasterPreferencesValid[] = L"master_preferencs_valid";
}
-bool GetBooleanPreference(const DictionaryValue* prefs,
- const std::wstring& name) {
+bool GetDistroBooleanPreference(const DictionaryValue* prefs,
+ const std::wstring& name) {
+
bool value = false;
- if (!prefs || !prefs->GetBoolean(name, &value))
- return 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 (!prefs || !ping_delay)
+ if (!ping_delay)
return false;
// 90 seconds is the default that we want to use in case master preferences
// is missing or corrupt.
*ping_delay = 90;
- if (!prefs->GetInteger(master_preferences::kDistroPingDelay, ping_delay))
+
+ DictionaryValue* distro = NULL;
+ if (!prefs || !prefs->GetDictionary(kDistroDict, &distro) || !distro)
+ return false;
+
+ if (!distro->GetInteger(master_preferences::kDistroPingDelay, ping_delay))
return false;
return true;
@@ -99,23 +89,10 @@ DictionaryValue* ParseDistributionPreferences(
return NULL;
}
- scoped_ptr<DictionaryValue> json_root(GetPrefsFromFile(master_prefs_path));
- if (!json_root.get()) {
- LOG(WARNING) << "Failed to parse preferences file: "
- << master_prefs_path.value();
- return NULL;
- }
-
- DictionaryValue* distro = NULL;
- if (!json_root->GetDictionary(L"distribution", &distro)) {
- LOG(WARNING) << "Failed to get distriubtion params: "
- << master_prefs_path.value();
- return NULL;
- }
- return distro;
+ return GetPrefsFromFile(master_prefs_path);
}
-std::vector<std::wstring> ParseFirstRunTabs(const DictionaryValue* prefs) {
+std::vector<std::wstring> GetFirstRunTabs(const DictionaryValue* prefs) {
std::vector<std::wstring> launch_tabs;
if (!prefs)
return launch_tabs;
diff --git a/chrome/installer/util/master_preferences.h b/chrome/installer/util/master_preferences.h
index 103605a..44d099c 100644
--- a/chrome/installer/util/master_preferences.h
+++ b/chrome/installer/util/master_preferences.h
@@ -15,53 +15,52 @@ namespace installer_util {
namespace master_preferences {
// All the preferences below are expected to be inside the JSON "distribution"
-// block.
+// 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.
-// Boolean pref that triggers skipping the first run dialogs.
-extern const wchar_t kDistroSkipFirstRunPref[];
-// Boolean pref that triggers loading the welcome page.
-extern const wchar_t kDistroShowWelcomePage[];
-// Boolean pref that triggers silent import of the default search engine.
-extern const wchar_t kDistroImportSearchPref[];
-// Boolean pref that triggers silent import of the default browser history.
-extern const wchar_t kDistroImportHistoryPref[];
+// 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[];
-// RLZ ping delay in seconds
+// 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[];
-// Register Chrome as default browser for the current user.
-extern const wchar_t kMakeChromeDefaultForUser[];
-// 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.
-extern const wchar_t kCreateAllShortcuts[];
-// Prevent installer from launching Chrome after a successful first install.
+// 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[];
-// Register Chrome as default browser on the system.
+// Boolean. Register Chrome as default browser. Cmd line override present.
extern const wchar_t kMakeChromeDefault[];
-// Install Chrome to system wise location.
+// Boolean. Register Chrome as default browser for the current user.
+extern const wchar_t kMakeChromeDefaultForUser[];
+// Boolean but only meant to be used for internal purposes.
+extern const wchar_t kMasterPreferencesValid[];
+// 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[];
-// Run installer in verbose mode.
+// Boolean. Run installer in verbose mode. Cmd line override present.
extern const wchar_t kVerboseLogging[];
-// Show EULA dialog and install only if accepted.
-extern const wchar_t kRequireEula[];
-// Use alternate shortcut text for the main shortcut.
-extern const wchar_t kAltShortcutText[];
-// Use alternate smaller first run info bubble.
-extern const wchar_t kAltFirstRunBubble[];
-// Boolean pref that triggers silent import of the default browser homepage.
-extern const wchar_t kDistroImportHomePagePref[];
-
-extern const wchar_t kMasterPreferencesValid[];
}
// 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";
-bool GetBooleanPreference(const DictionaryValue* prefs,
- const std::wstring& name);
+bool GetDistroBooleanPreference(const DictionaryValue* prefs,
+ const std::wstring& name);
// This function gets ping delay (ping_delay in the sample above) from master
// preferences.
@@ -76,21 +75,22 @@ bool GetDistributionPingDelay(const DictionaryValue* prefs,
//
// {
// "distribution": {
-// "skip_first_run_ui": true,
-// "show_welcome_page": true,
-// "import_search_engine": true,
-// "import_history": false,
+// "alternate_shortcut_text": false,
+// "oem_bubble": false,
+// "create_all_shortcuts": true,
// "import_bookmarks": false,
+// "import_history": false,
// "import_home_page": false,
-// "create_all_shortcuts": true,
+// "import_search_engine": true,
+// "ping_delay": 40,
+// "show_welcome_page": true,
+// "skip_first_run_ui": true,
// "do_not_launch_chrome": false,
// "make_chrome_default": false,
// "make_chrome_default_for_user": true,
-// "system_level": false,
-// "verbose_logging": true,
// "require_eula": true,
-// "alternate_shortcut_text": false,
-// "ping_delay": 40
+// "system_level": false,
+// "verbose_logging": true
// },
// "browser": {
// "show_home_button": true
@@ -127,7 +127,7 @@ 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> ParseFirstRunTabs(const DictionaryValue* prefs);
+std::vector<std::wstring> GetFirstRunTabs(const DictionaryValue* prefs);
}
#endif // CHROME_INSTALLER_UTIL_MASTER_PREFERENCES_H_