summaryrefslogtreecommitdiffstats
path: root/chrome/installer
diff options
context:
space:
mode:
authorkuchhal@chromium.org <kuchhal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-03 21:42:37 +0000
committerkuchhal@chromium.org <kuchhal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-03 21:42:37 +0000
commit6f2e2824b8143ee4d6c8845b4c17e106acaa04f4 (patch)
treef8f816ceba805db9ed2f05f55f900bf474f4a8e4 /chrome/installer
parent720ce12948a8289f76877927750d9c8f8878b4d1 (diff)
downloadchromium_src-6f2e2824b8143ee4d6c8845b4c17e106acaa04f4.zip
chromium_src-6f2e2824b8143ee4d6c8845b4c17e106acaa04f4.tar.gz
chromium_src-6f2e2824b8143ee4d6c8845b4c17e106acaa04f4.tar.bz2
Use alternate icon for Chrome shortcuts if specified in master preferences.
This change depends on change 159539 that is currently under review and a new chrome2.ico that is yet to be added to the repository. BUG=12701 TEST=Specify an alternate icon in --installerdata file and make sure that icon is used for shortcuts and it not changed later by updates. Review URL: http://codereview.chromium.org/159618 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@22314 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/installer')
-rw-r--r--chrome/installer/setup/install.cc19
-rw-r--r--chrome/installer/setup/install.h5
-rw-r--r--chrome/installer/setup/setup_main.cc22
-rw-r--r--chrome/installer/util/master_preferences.cc43
-rw-r--r--chrome/installer/util/master_preferences.h8
-rw-r--r--chrome/installer/util/shell_util.cc12
6 files changed, 59 insertions, 50 deletions
diff --git a/chrome/installer/setup/install.cc b/chrome/installer/setup/install.cc
index ba62f0c..6b20d68 100644
--- a/chrome/installer/setup/install.cc
+++ b/chrome/installer/setup/install.cc
@@ -142,6 +142,19 @@ void AddUninstallShortcutWorkItems(HKEY reg_root,
}
}
+// 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 std::wstring& prefs_source_path) {
+ 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";
+}
+
// This method creates Chrome shortcuts in Start->Programs for all users or
// only for current user depending on whether it is system wide install or
// user only install.
@@ -480,8 +493,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 Version& new_version, const Version* installed_version) {
+ 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);
std::wstring install_path(GetChromeInstallPath(system_install));
@@ -508,6 +522,7 @@ installer_util::InstallStatus installer::InstallOrUpdateChrome(
if (!installed_version) {
LOG(INFO) << "First install of version " << new_version.GetString();
result = installer_util::FIRST_INSTALL_SUCCESS;
+ CopyPreferenceFileForFirstRun(system_install, prefs_path);
} else if (new_version.GetString() == installed_version->GetString()) {
LOG(INFO) << "Install repaired of version " << new_version.GetString();
result = installer_util::INSTALL_REPAIRED;
diff --git a/chrome/installer/setup/install.h b/chrome/installer/setup/install.h
index de468b3..cd77a3a 100644
--- a/chrome/installer/setup/install.h
+++ b/chrome/installer/setup/install.h
@@ -37,8 +37,9 @@ 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 Version& new_version, const Version* installed_version);
+ const std::wstring& install_temp_path, const std::wstring& prefs_path,
+ const DictionaryValue* prefs, const Version& new_version,
+ const Version* installed_version);
// This function installs a new version of Chrome to the specified location.
// It returns true if install was successful and false in case of an error.
diff --git a/chrome/installer/setup/setup_main.cc b/chrome/installer/setup/setup_main.cc
index eb2e8ba..3c314ff 100644
--- a/chrome/installer/setup/setup_main.cc
+++ b/chrome/installer/setup/setup_main.cc
@@ -245,21 +245,6 @@ DictionaryValue* GetInstallPreferences(const CommandLine& cmd_line) {
return prefs;
}
-// 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";
-}
-
bool CheckPreInstallConditions(const installer::Version* installed_version,
bool system_install,
installer_util::InstallStatus& status) {
@@ -369,9 +354,11 @@ installer_util::InstallStatus InstallChrome(const CommandLine& cmd_line,
std::wstring archive_to_copy(temp_path);
file_util::AppendToPath(&archive_to_copy,
std::wstring(installer::kChromeArchive));
+ std::wstring prefs_source_path = cmd_line.GetSwitchValue(
+ installer_util::switches::kInstallerData);
install_status = installer::InstallOrUpdateChrome(
- cmd_line.program(), archive_to_copy, temp_path, prefs,
- *installer_version, installed_version);
+ cmd_line.program(), archive_to_copy, temp_path, prefs_source_path,
+ prefs, *installer_version, installed_version);
int install_msg_base = IDS_INSTALL_FAILED_BASE;
std::wstring chrome_exe;
@@ -392,7 +379,6 @@ 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.";
- CopyPreferenceFileForFirstRun(system_level, 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))
diff --git a/chrome/installer/util/master_preferences.cc b/chrome/installer/util/master_preferences.cc
index f8c8018..92d57cb 100644
--- a/chrome/installer/util/master_preferences.cc
+++ b/chrome/installer/util/master_preferences.cc
@@ -10,31 +10,16 @@
#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))
- return NULL;
-
- JSONStringValueSerializer json(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());
-}
} // 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 kChromeShortcutIconIndex[] = L"chrome_shortcut_icon_index";
const wchar_t kCreateAllShortcuts[] = L"create_all_shortcuts";
const wchar_t kDistroImportBookmarksPref[] = L"import_bookmarks";
const wchar_t kDistroImportHistoryPref[] = L"import_history";
@@ -61,20 +46,17 @@ bool GetDistroBooleanPreference(const DictionaryValue* prefs,
return value;
}
-bool GetDistributionPingDelay(const DictionaryValue* prefs,
- int* ping_delay) {
- if (!ping_delay)
+bool GetDistroIntegerPreference(const DictionaryValue* prefs,
+ const std::wstring& name,
+ int* value) {
+ if (!value)
return false;
- // 90 seconds is the default that we want to use in case master preferences
- // is missing or corrupt.
- *ping_delay = 90;
-
DictionaryValue* distro = NULL;
if (!prefs || !prefs->GetDictionary(kDistroDict, &distro) || !distro)
return false;
- if (!distro->GetInteger(master_preferences::kDistroPingDelay, ping_delay))
+ if (!distro->GetInteger(name, value))
return false;
return true;
@@ -87,8 +69,19 @@ DictionaryValue* ParseDistributionPreferences(
<< master_prefs_path.value();
return NULL;
}
+ std::string json_data;
+ if (!file_util::ReadFileToString(master_prefs_path, &json_data))
+ return NULL;
+ JSONStringValueSerializer json(json_data);
+ scoped_ptr<Value> root(json.Deserialize(NULL));
- return GetPrefsFromFile(master_prefs_path);
+ if (!root.get())
+ return NULL;
+
+ if (!root->IsType(Value::TYPE_DICTIONARY))
+ return NULL;
+
+ return static_cast<DictionaryValue*>(root.release());
}
std::vector<std::wstring> GetFirstRunTabs(const DictionaryValue* prefs) {
diff --git a/chrome/installer/util/master_preferences.h b/chrome/installer/util/master_preferences.h
index d9efb3d..5284172 100644
--- a/chrome/installer/util/master_preferences.h
+++ b/chrome/installer/util/master_preferences.h
@@ -23,6 +23,8 @@ namespace master_preferences {
extern const wchar_t kAltShortcutText[];
// Boolean. Use alternate smaller first run info bubble.
extern const wchar_t kAltFirstRunBubble[];
+// Integer. Icon index from chrome.exe to use for shortcuts.
+extern const wchar_t kChromeShortcutIconIndex[];
// 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.
@@ -64,8 +66,9 @@ bool GetDistroBooleanPreference(const DictionaryValue* prefs,
// This function gets ping delay (ping_delay in the sample above) from master
// preferences.
-bool GetDistributionPingDelay(const DictionaryValue* prefs,
- int* ping_delay);
+bool GetDistroIntegerPreference(const DictionaryValue* prefs,
+ const std::wstring& name,
+ int* value);
// The master preferences is a JSON file with the same entries as the
// 'Default\Preferences' file. This function parses the distribution
@@ -77,6 +80,7 @@ bool GetDistributionPingDelay(const DictionaryValue* prefs,
// "distribution": {
// "alternate_shortcut_text": false,
// "oem_bubble": false,
+// "chrome_shortcut_icon_index": 0,
// "create_all_shortcuts": true,
// "import_bookmarks": false,
// "import_history": false,
diff --git a/chrome/installer/util/shell_util.cc b/chrome/installer/util/shell_util.cc
index d157f02..10355b6 100644
--- a/chrome/installer/util/shell_util.cc
+++ b/chrome/installer/util/shell_util.cc
@@ -25,6 +25,7 @@
#include "chrome/common/chrome_switches.h"
#include "chrome/installer/util/browser_distribution.h"
#include "chrome/installer/util/install_util.h"
+#include "chrome/installer/util/master_preferences.h"
#include "installer_util_strings.h"
@@ -768,14 +769,23 @@ bool ShellUtil::UpdateChromeShortcut(const std::wstring& chrome_exe,
const std::wstring& description,
bool create_new) {
std::wstring chrome_path = file_util::GetDirectoryFromPath(chrome_exe);
+
if (create_new) {
+ FilePath prefs_path(chrome_path);
+ prefs_path = prefs_path.Append(installer_util::kDefaultMasterPrefs);
+ scoped_ptr<DictionaryValue> prefs(
+ installer_util::ParseDistributionPreferences(prefs_path));
+ int icon_index = 0;
+ installer_util::GetDistroIntegerPreference(prefs.get(),
+ installer_util::master_preferences::kChromeShortcutIconIndex,
+ &icon_index);
return file_util::CreateShortcutLink(chrome_exe.c_str(), // target
shortcut.c_str(), // shortcut
chrome_path.c_str(), // working dir
NULL, // arguments
description.c_str(), // description
chrome_exe.c_str(), // icon file
- 0); // icon index
+ icon_index); // icon index
} else {
return file_util::UpdateShortcutLink(chrome_exe.c_str(), // target
shortcut.c_str(), // shortcut