summaryrefslogtreecommitdiffstats
path: root/chrome/installer
diff options
context:
space:
mode:
authorstevet@chromium.org <stevet@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-06 03:46:22 +0000
committerstevet@chromium.org <stevet@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-06 03:46:22 +0000
commit4b7a2aa9bec6d0930a964880aec6d1fa3e044272 (patch)
treea53220dc95be462855e904a4f74205dc37f465b3 /chrome/installer
parent87a58d935007a0077082ea113bbd996375a07fa3 (diff)
downloadchromium_src-4b7a2aa9bec6d0930a964880aec6d1fa3e044272.zip
chromium_src-4b7a2aa9bec6d0930a964880aec6d1fa3e044272.tar.gz
chromium_src-4b7a2aa9bec6d0930a964880aec6d1fa3e044272.tar.bz2
Badge Windows profile shortcuts with multi-user avatar.
BUG=105110 TEST=Ensure that when Chrome on Windows creates a desktop icon for a new Profile, the icon image has the user avatar in it. Ensure that changing the Avatar changes the image in the icon. TBR=rsesek Review URL: http://codereview.chromium.org/8785006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@113104 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/installer')
-rw-r--r--chrome/installer/setup/install.cc37
-rw-r--r--chrome/installer/util/shell_util.cc27
-rw-r--r--chrome/installer/util/shell_util.h12
-rw-r--r--chrome/installer/util/shell_util_unittest.cc22
4 files changed, 68 insertions, 30 deletions
diff --git a/chrome/installer/setup/install.cc b/chrome/installer/setup/install.cc
index 36c24ca..0fa8859 100644
--- a/chrome/installer/setup/install.cc
+++ b/chrome/installer/setup/install.cc
@@ -131,12 +131,14 @@ bool CreateOrUpdateChromeShortcuts(const InstallerState& installer_state,
VLOG(1) << "Creating shortcut to " << chrome_exe.value() << " at "
<< chrome_link.value();
ret = ShellUtil::UpdateChromeShortcut(browser_dist, chrome_exe.value(),
- chrome_link.value(), L"", product_desc, true);
+ chrome_link.value(), L"", product_desc, chrome_exe.value(),
+ browser_dist->GetIconIndex(), true);
} else if (file_util::PathExists(chrome_link)) {
VLOG(1) << "Updating shortcut at " << chrome_link.value()
<< " to point to " << chrome_exe.value();
ret = ShellUtil::UpdateChromeShortcut(browser_dist, chrome_exe.value(),
- chrome_link.value(), L"", product_desc, false);
+ chrome_link.value(), L"", product_desc, chrome_exe.value(),
+ browser_dist->GetIconIndex(), false);
} else {
VLOG(1)
<< "not first or repaired install, link file doesn't exist. status: "
@@ -179,25 +181,20 @@ bool CreateOrUpdateChromeShortcuts(const InstallerState& installer_state,
// is specified we want to create them, otherwise we update them only if
// they exist.
if (ret) {
+ ShellUtil::ShellChange desktop_level = ShellUtil::CURRENT_USER;
+ int quick_launch_levels = ShellUtil::CURRENT_USER;
if (installer_state.system_install()) {
- ret = ShellUtil::CreateChromeDesktopShortcut(product.distribution(),
- chrome_exe.value(), product_desc, L"", L"", ShellUtil::SYSTEM_LEVEL,
- alt_shortcut, create_all_shortcut);
- if (ret) {
- ret = ShellUtil::CreateChromeQuickLaunchShortcut(
- product.distribution(), chrome_exe.value(),
- ShellUtil::CURRENT_USER | ShellUtil::SYSTEM_LEVEL,
- create_all_shortcut);
- }
- } else {
- ret = ShellUtil::CreateChromeDesktopShortcut(product.distribution(),
- chrome_exe.value(), product_desc, L"", L"", ShellUtil::CURRENT_USER,
- alt_shortcut, create_all_shortcut);
- if (ret) {
- ret = ShellUtil::CreateChromeQuickLaunchShortcut(
- product.distribution(), chrome_exe.value(), ShellUtil::CURRENT_USER,
- create_all_shortcut);
- }
+ desktop_level = ShellUtil::SYSTEM_LEVEL;
+ quick_launch_levels |= ShellUtil::SYSTEM_LEVEL;
+ }
+ ret = ShellUtil::CreateChromeDesktopShortcut(browser_dist,
+ chrome_exe.value(), product_desc, L"", L"", chrome_exe.value(),
+ browser_dist->GetIconIndex(), desktop_level, alt_shortcut,
+ create_all_shortcut);
+ if (ret) {
+ ret = ShellUtil::CreateChromeQuickLaunchShortcut(
+ browser_dist, chrome_exe.value(), quick_launch_levels,
+ create_all_shortcut);
}
}
diff --git a/chrome/installer/util/shell_util.cc b/chrome/installer/util/shell_util.cc
index ab6622d..3e453f64 100644
--- a/chrome/installer/util/shell_util.cc
+++ b/chrome/installer/util/shell_util.cc
@@ -547,6 +547,8 @@ bool ShellUtil::CreateChromeDesktopShortcut(BrowserDistribution* dist,
const std::wstring& description,
const std::wstring& appended_name,
const std::wstring& arguments,
+ const std::wstring& icon_path,
+ int icon_index,
ShellChange shell_change,
bool alternate,
bool create_new) {
@@ -573,6 +575,8 @@ bool ShellUtil::CreateChromeDesktopShortcut(BrowserDistribution* dist,
shortcut.value(),
arguments,
description,
+ icon_path,
+ icon_index,
create_new);
}
}
@@ -585,6 +589,8 @@ bool ShellUtil::CreateChromeDesktopShortcut(BrowserDistribution* dist,
shortcut.value(),
arguments,
description,
+ icon_path,
+ icon_index,
create_new);
}
} else {
@@ -608,7 +614,9 @@ bool ShellUtil::CreateChromeQuickLaunchShortcut(BrowserDistribution* dist,
if (ShellUtil::GetQuickLaunchPath(false, &user_ql_path)) {
file_util::AppendToPath(&user_ql_path, shortcut_name);
ret = ShellUtil::UpdateChromeShortcut(dist, chrome_exe, user_ql_path,
- L"", L"", create_new);
+ L"", L"", chrome_exe,
+ dist->GetIconIndex(),
+ create_new);
} else {
ret = false;
}
@@ -621,7 +629,9 @@ bool ShellUtil::CreateChromeQuickLaunchShortcut(BrowserDistribution* dist,
if (ShellUtil::GetQuickLaunchPath(true, &default_ql_path)) {
file_util::AppendToPath(&default_ql_path, shortcut_name);
ret = ShellUtil::UpdateChromeShortcut(dist, chrome_exe, default_ql_path,
- L"", L"", create_new) && ret;
+ L"", L"", chrome_exe,
+ dist->GetIconIndex(),
+ create_new) && ret;
} else {
ret = false;
}
@@ -1052,15 +1062,18 @@ bool ShellUtil::UpdateChromeShortcut(BrowserDistribution* dist,
const std::wstring& shortcut,
const std::wstring& arguments,
const std::wstring& description,
+ const std::wstring& icon_path,
+ int icon_index,
bool create_new) {
std::wstring chrome_path = FilePath(chrome_exe).DirName().value();
FilePath prefs_path(chrome_path);
prefs_path = prefs_path.AppendASCII(installer::kDefaultMasterPrefs);
installer::MasterPreferences prefs(prefs_path);
- int icon_index = dist->GetIconIndex();
- prefs.GetInt(installer::master_preferences::kChromeShortcutIconIndex,
- &icon_index);
+ if (FilePath::CompareEqualIgnoreCase(icon_path, chrome_exe)) {
+ prefs.GetInt(installer::master_preferences::kChromeShortcutIconIndex,
+ &icon_index);
+ }
if (create_new) {
return file_util::CreateShortcutLink(
chrome_exe.c_str(), // target
@@ -1068,7 +1081,7 @@ bool ShellUtil::UpdateChromeShortcut(BrowserDistribution* dist,
chrome_path.c_str(), // working dir
arguments.c_str(), // arguments
description.c_str(), // description
- chrome_exe.c_str(), // icon file
+ icon_path.c_str(), // icon file
icon_index, // icon index
dist->GetBrowserAppId().c_str()); // app id
} else {
@@ -1078,7 +1091,7 @@ bool ShellUtil::UpdateChromeShortcut(BrowserDistribution* dist,
chrome_path.c_str(), // working dir
arguments.c_str(), // arguments
description.c_str(), // description
- chrome_exe.c_str(), // icon file
+ icon_path.c_str(), // icon file
icon_index, // icon index
dist->GetBrowserAppId().c_str()); // app id
}
diff --git a/chrome/installer/util/shell_util.h b/chrome/installer/util/shell_util.h
index 9b0524a..fb96771 100644
--- a/chrome/installer/util/shell_util.h
+++ b/chrome/installer/util/shell_util.h
@@ -98,6 +98,8 @@ class ShellUtil {
// |appended_name| provides a string to be appended to the distribution name,
// and can be the empty string.
// |arguments| gives a set of arguments to be passed to the executable.
+ // |icon_path| provides the path to the icon file to use.
+ // |icon_index| provides the index of the icon within the provided icon file.
// If |shell_change| is CURRENT_USER, the shortcut is created in the
// Desktop folder of current user's profile.
// If |shell_change| is SYSTEM_LEVEL, the shortcut is created in the
@@ -111,6 +113,8 @@ class ShellUtil {
const std::wstring& description,
const std::wstring& appended_name,
const std::wstring& arguments,
+ const std::wstring& icon_path,
+ int icon_index,
ShellChange shell_change,
bool alternate,
bool create_new);
@@ -284,14 +288,16 @@ class ShellUtil {
// Updates shortcut (or creates a new shortcut) at destination given by
// shortcut to a target given by chrome_exe. The arguments are given by
- // |arguments| for the target and icon is set as icon at index 0 from exe.
- // If create_new is set to true, the function will create a new shortcut if
- // if doesn't exist.
+ // |arguments| for the target and icon is set based on |icon_path| and
+ // |icon_index|. If create_new is set to true, the function will create a new
+ // shortcut if it doesn't exist.
static bool UpdateChromeShortcut(BrowserDistribution* dist,
const std::wstring& chrome_exe,
const std::wstring& shortcut,
const std::wstring& arguments,
const std::wstring& description,
+ const std::wstring& icon_path,
+ int icon_index,
bool create_new);
private:
diff --git a/chrome/installer/util/shell_util_unittest.cc b/chrome/installer/util/shell_util_unittest.cc
index 625010e..4df10aa 100644
--- a/chrome/installer/util/shell_util_unittest.cc
+++ b/chrome/installer/util/shell_util_unittest.cc
@@ -114,6 +114,8 @@ TEST_F(ShellUtilTest, UpdateChromeShortcutTest) {
shortcut_path.value(),
L"",
description,
+ exe_path.value(),
+ dist->GetIconIndex(),
true));
EXPECT_TRUE(VerifyChromeShortcut(exe_path.value(),
shortcut_path.value(),
@@ -138,6 +140,8 @@ TEST_F(ShellUtilTest, UpdateChromeShortcutTest) {
shortcut_path.value(),
L"",
description,
+ exe_path.value(),
+ dist->GetIconIndex(),
true));
EXPECT_TRUE(VerifyChromeShortcut(exe_path.value(),
shortcut_path.value(),
@@ -151,6 +155,8 @@ TEST_F(ShellUtilTest, UpdateChromeShortcutTest) {
shortcut_path.value(),
L"",
description2,
+ exe_path.value(),
+ dist->GetIconIndex(),
false));
EXPECT_TRUE(VerifyChromeShortcut(exe_path.value(),
shortcut_path.value(),
@@ -210,6 +216,8 @@ TEST_F(ShellUtilTest, CreateChromeDesktopShortcutTest) {
description,
L"",
L"",
+ exe_path.value(),
+ dist->GetIconIndex(),
ShellUtil::CURRENT_USER,
false,
true));
@@ -227,6 +235,8 @@ TEST_F(ShellUtilTest, CreateChromeDesktopShortcutTest) {
description,
L"",
L"",
+ exe_path.value(),
+ dist->GetIconIndex(),
ShellUtil::SYSTEM_LEVEL,
false,
true));
@@ -245,6 +255,8 @@ TEST_F(ShellUtilTest, CreateChromeDesktopShortcutTest) {
description,
L"",
L"",
+ exe_path.value(),
+ dist->GetIconIndex(),
ShellUtil::SYSTEM_LEVEL,
false,
true));
@@ -253,6 +265,8 @@ TEST_F(ShellUtilTest, CreateChromeDesktopShortcutTest) {
description,
L"",
L"",
+ exe_path.value(),
+ dist->GetIconIndex(),
ShellUtil::CURRENT_USER,
false,
true));
@@ -272,6 +286,8 @@ TEST_F(ShellUtilTest, CreateChromeDesktopShortcutTest) {
description,
L"",
L"",
+ exe_path.value(),
+ dist->GetIconIndex(),
ShellUtil::CURRENT_USER,
false,
true));
@@ -280,6 +296,8 @@ TEST_F(ShellUtilTest, CreateChromeDesktopShortcutTest) {
description,
L"",
L"",
+ exe_path.value(),
+ dist->GetIconIndex(),
ShellUtil::SYSTEM_LEVEL,
false,
true));
@@ -306,6 +324,8 @@ TEST_F(ShellUtilTest, CreateChromeDesktopShortcutTest) {
description,
default_profile_user_name,
L"--profile-directory=\"Default\"",
+ exe_path.value(),
+ dist->GetIconIndex(),
ShellUtil::CURRENT_USER,
false,
true));
@@ -319,6 +339,8 @@ TEST_F(ShellUtilTest, CreateChromeDesktopShortcutTest) {
description,
second_profile_user_name,
L"--profile-directory=\"Profile 1\"",
+ exe_path.value(),
+ dist->GetIconIndex(),
ShellUtil::CURRENT_USER,
false,
true));