Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(524)

Side by Side Diff: chrome/installer/util/shell_util.cc

Issue 10836247: Refactor ShellUtil shortcut code -- single multi-purpose methods as opposed to many slighlty diffe… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix some comments Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 // 4 //
5 // This file defines functions that integrate Chrome in Windows shell. These 5 // This file defines functions that integrate Chrome in Windows shell. These
6 // functions can be used by Chrome as well as Chrome installer. All of the 6 // functions can be used by Chrome as well as Chrome installer. All of the
7 // work is done by the local functions defined in anonymous namespace in 7 // work is done by the local functions defined in anonymous namespace in
8 // this class. 8 // this class.
9 9
10 #include "chrome/installer/util/shell_util.h" 10 #include "chrome/installer/util/shell_util.h"
(...skipping 953 matching lines...) Expand 10 before | Expand all | Expand 10 after
964 const wchar_t* ShellUtil::kRegDelegateExecute = L"DelegateExecute"; 964 const wchar_t* ShellUtil::kRegDelegateExecute = L"DelegateExecute";
965 const wchar_t* ShellUtil::kRegOpenWithProgids = L"OpenWithProgids"; 965 const wchar_t* ShellUtil::kRegOpenWithProgids = L"OpenWithProgids";
966 966
967 bool ShellUtil::QuickIsChromeRegisteredInHKLM(BrowserDistribution* dist, 967 bool ShellUtil::QuickIsChromeRegisteredInHKLM(BrowserDistribution* dist,
968 const string16& chrome_exe, 968 const string16& chrome_exe,
969 const string16& suffix) { 969 const string16& suffix) {
970 return QuickIsChromeRegistered(dist, chrome_exe, suffix, 970 return QuickIsChromeRegistered(dist, chrome_exe, suffix,
971 CONFIRM_SHELL_REGISTRATION_IN_HKLM); 971 CONFIRM_SHELL_REGISTRATION_IN_HKLM);
972 } 972 }
973 973
974 bool ShellUtil::CreateChromeDesktopShortcut(BrowserDistribution* dist, 974 bool ShellUtil::GetShortcutPath(ShellUtil::ShortcutLocation location,
975 const string16& chrome_exe, 975 bool system_level,
976 const string16& description, 976 FilePath* path) {
977 const string16& appended_name, 977 switch (location) {
978 const string16& arguments, 978 case ShellUtil::SHORTCUT_DESKTOP: {
979 const string16& icon_path, 979 wchar_t desktop[MAX_PATH];
980 int icon_index, 980 int dir = system_level ? CSIDL_COMMON_DESKTOPDIRECTORY :
981 ShellChange shell_change, 981 CSIDL_DESKTOPDIRECTORY;
982 uint32 options) { 982 if (FAILED(SHGetFolderPath(NULL, dir, NULL, SHGFP_TYPE_CURRENT, desktop)))
983 string16 shortcut_name; 983 return false;
984 bool alternate = (options & ShellUtil::SHORTCUT_ALTERNATE) != 0; 984 *path = FilePath(desktop);
985 if (!ShellUtil::GetChromeShortcutName(dist, alternate, appended_name, 985 break;
986 &shortcut_name)) 986 }
987 return false; 987 case ShellUtil::SHORTCUT_QUICK_LAUNCH: {
988 988 if (system_level) {
989 bool ret = false; 989 wchar_t qlaunch[MAX_PATH];
990 if (shell_change == ShellUtil::CURRENT_USER) { 990 // We are accessing GetDefaultUserProfileDirectory this way so that we
991 FilePath shortcut_path; 991 // do not have to declare dependency to Userenv.lib for chrome.exe
992 // We do not want to create a desktop shortcut to Chrome in the current 992 typedef BOOL (WINAPI *PROFILE_FUNC)(LPWSTR, LPDWORD);
993 // user's desktop folder if there is already one in the "All Users" 993 HMODULE module = LoadLibrary(L"Userenv.dll");
994 // desktop folder. 994 PROFILE_FUNC p = reinterpret_cast<PROFILE_FUNC>(GetProcAddress(module,
995 bool got_system_desktop = ShellUtil::GetDesktopPath(true, &shortcut_path); 995 "GetDefaultUserProfileDirectoryW"));
996 FilePath shortcut = shortcut_path.Append(shortcut_name); 996 DWORD size = _countof(qlaunch);
997 if (!got_system_desktop || !file_util::PathExists(shortcut)) { 997 if ((p == NULL) || ((p)(qlaunch, &size) != TRUE))
998 // Either we couldn't query the "All Users" Desktop folder or there's 998 return false;
999 // nothing in it, so let's continue. 999 *path = FilePath(qlaunch);
1000 if (ShellUtil::GetDesktopPath(false, &shortcut_path)) { 1000 if (base::win::GetVersion() >= base::win::VERSION_VISTA) {
1001 shortcut = shortcut_path.Append(shortcut_name); 1001 *path = path->AppendASCII("AppData");
1002 ret = ShellUtil::UpdateChromeShortcut(dist, 1002 *path = path->AppendASCII("Roaming");
1003 chrome_exe, 1003 } else {
1004 shortcut.value(), 1004 *path = path->AppendASCII("Application Data");
1005 arguments, 1005 }
1006 description, 1006 } else {
1007 icon_path, 1007 if (!PathService::Get(base::DIR_APP_DATA, path)) {
1008 icon_index, 1008 return false;
1009 options); 1009 }
1010 } 1010 }
1011 *path = path->AppendASCII("Microsoft");
1012 *path = path->AppendASCII("Internet Explorer");
1013 *path = path->AppendASCII("Quick Launch");
1014 break;
1011 } 1015 }
1012 } else if (shell_change == ShellUtil::SYSTEM_LEVEL) { 1016 case ShellUtil::SHORTCUT_START_MENU:
1013 FilePath shortcut_path; 1017 case ShellUtil::SHORTCUT_START_MENU_UNINSTALL: {
1014 if (ShellUtil::GetDesktopPath(true, &shortcut_path)) { 1018 int dir = system_level ? base::DIR_COMMON_START_MENU :
1015 FilePath shortcut = shortcut_path.Append(shortcut_name); 1019 base::DIR_START_MENU;
1016 ret = ShellUtil::UpdateChromeShortcut(dist, 1020 if (!PathService::Get(dir, path))
1017 chrome_exe, 1021 return false;
1018 shortcut.value(), 1022 BrowserDistribution* dist = BrowserDistribution::GetDistribution();
1019 arguments, 1023 *path = path->Append(dist->GetAppShortCutName());
1020 description, 1024 break;
1021 icon_path,
1022 icon_index,
1023 options);
1024 } 1025 }
1025 } else { 1026 default: {
1026 NOTREACHED(); 1027 NOTREACHED();
1028 return false;
1029 }
1027 } 1030 }
1028 return ret; 1031 return true;
1029 } 1032 }
1030 1033
1031 bool ShellUtil::CreateChromeQuickLaunchShortcut(BrowserDistribution* dist, 1034 bool ShellUtil::CreateOrUpdateChromeShortcut(
1032 const string16& chrome_exe, 1035 ShellUtil::ShortcutLocation location,
1033 int shell_change, 1036 BrowserDistribution* dist,
1034 uint32 options) { 1037 const string16& exe_path,
1038 const string16& description,
1039 const string16& appended_name,
1040 const string16& arguments,
1041 const string16& icon_path,
1042 int icon_index,
1043 uint32 options) {
1035 string16 shortcut_name; 1044 string16 shortcut_name;
1036 if (!ShellUtil::GetChromeShortcutName(dist, false, L"", &shortcut_name)) 1045 const bool alternate = ((options & ShellUtil::SHORTCUT_ALTERNATE) != 0 &&
1046 location == SHORTCUT_DESKTOP);
1047 if (!ShellUtil::GetChromeShortcutName(location, dist, alternate,
1048 appended_name, &shortcut_name)) {
1037 return false; 1049 return false;
1050 }
1038 1051
1039 bool ret = true; 1052 FilePath user_shortcut_path;
1040 // First create shortcut for the current user. 1053 FilePath system_shortcut_path;
1041 if (shell_change & ShellUtil::CURRENT_USER) { 1054 const bool got_system_desktop =
1042 FilePath user_ql_path; 1055 GetShortcutPath(location, true, &system_shortcut_path);
1043 if (ShellUtil::GetQuickLaunchPath(false, &user_ql_path)) { 1056 if (got_system_desktop)
1044 user_ql_path = user_ql_path.Append(shortcut_name); 1057 system_shortcut_path = system_shortcut_path.Append(shortcut_name);
1045 ret = ShellUtil::UpdateChromeShortcut(dist, chrome_exe, 1058
1046 user_ql_path.value(), 1059 FilePath* chosen_path = NULL;
1047 L"", L"", chrome_exe, 1060 if (options & ShellUtil::SHORTCUT_SYSTEM_LEVEL) {
1048 dist->GetIconIndex(), 1061 // Install the system-level shortcut if requested.
1049 options); 1062 if (got_system_desktop) {
1050 } else { 1063 chosen_path = &system_shortcut_path;
1051 ret = false; 1064 }
1065 } else if (!got_system_desktop ||
1066 !file_util::PathExists(system_shortcut_path)){
1067 // Otherwise install the user-level shortcut, but do so iff no system-level
1068 // shortcut is present (or we couldn't get the system shortcut's path).
1069 if (GetShortcutPath(location, false, &user_shortcut_path)) {
1070 user_shortcut_path = user_shortcut_path.Append(shortcut_name);
1071 chosen_path = &user_shortcut_path;
1052 } 1072 }
1053 } 1073 }
1054 1074
1055 // Add a shortcut to Default User's profile so that all new user profiles 1075 // Make sure we have a path and its parent directories exist.
1056 // get it. 1076 if (!chosen_path || ((options & SHORTCUT_CREATE_ALWAYS) &&
1057 if (shell_change & ShellUtil::SYSTEM_LEVEL) { 1077 !file_util::CreateDirectory(chosen_path->DirName()))) {
1058 FilePath default_ql_path; 1078 NOTREACHED();
1059 if (ShellUtil::GetQuickLaunchPath(true, &default_ql_path)) { 1079 return false;
1060 default_ql_path = default_ql_path.Append(shortcut_name); 1080 }
1061 ret = ShellUtil::UpdateChromeShortcut(dist, chrome_exe, 1081
1062 default_ql_path.value(), 1082 string16 app_id;
1063 L"", L"", chrome_exe, 1083 FilePath exe_dir(FilePath(exe_path).DirName());
1064 dist->GetIconIndex(), 1084 // Set the |app_id| and |icon_index| correctly if this is a shortcut to
1065 options) && ret; 1085 // chrome.exe.
1066 } else { 1086 if (exe_path.find(installer::kChromeExe) != string16::npos) {
1067 ret = false; 1087 app_id.assign(GetBrowserModelId(dist, exe_path));
1088
1089 installer::MasterPreferences prefs(
1090 exe_dir.AppendASCII(installer::kDefaultMasterPrefs));
1091 if (InstallUtil::ProgramCompare(FilePath(exe_path)).Evaluate(icon_path)) {
1092 prefs.GetInt(installer::master_preferences::kChromeShortcutIconIndex,
1093 &icon_index);
1068 } 1094 }
1069 } 1095 }
1070 1096
1097 bool ret = file_util::CreateOrUpdateShortcutLink(
1098 exe_path.c_str(), chosen_path->value().c_str(),
1099 exe_dir.value().c_str(), arguments.c_str(), description.c_str(),
1100 icon_path.c_str(), icon_index, app_id.c_str(),
1101 ConvertShellUtilShortcutOptionsToFileUtil(options));
1102
1103 if (ret && (options & SHORTCUT_PIN_TO_TASKBAR) &&
1104 (options & SHORTCUT_CREATE_ALWAYS) &&
1105 base::win::GetVersion() >= base::win::VERSION_WIN7) {
1106 ret = file_util::TaskbarPinShortcutLink(chosen_path->value().c_str());
1107 }
1108
1071 return ret; 1109 return ret;
1072 } 1110 }
1073 1111
1074 string16 ShellUtil::GetChromeIcon(BrowserDistribution* dist, 1112 string16 ShellUtil::GetChromeIcon(BrowserDistribution* dist,
1075 const string16& chrome_exe) { 1113 const string16& chrome_exe) {
1076 string16 chrome_icon(chrome_exe); 1114 string16 chrome_icon(chrome_exe);
1077 chrome_icon.append(L","); 1115 chrome_icon.append(L",");
1078 chrome_icon.append(base::IntToString16(dist->GetIconIndex())); 1116 chrome_icon.append(base::IntToString16(dist->GetIconIndex()));
1079 return chrome_icon; 1117 return chrome_icon;
1080 } 1118 }
1081 1119
1082 string16 ShellUtil::GetChromeShellOpenCmd(const string16& chrome_exe) { 1120 string16 ShellUtil::GetChromeShellOpenCmd(const string16& chrome_exe) {
1083 return L"\"" + chrome_exe + L"\" -- \"%1\""; 1121 return L"\"" + chrome_exe + L"\" -- \"%1\"";
1084 } 1122 }
1085 1123
1086 string16 ShellUtil::GetChromeDelegateCommand(const string16& chrome_exe) { 1124 string16 ShellUtil::GetChromeDelegateCommand(const string16& chrome_exe) {
1087 return L"\"" + chrome_exe + L"\" -- %*"; 1125 return L"\"" + chrome_exe + L"\" -- %*";
1088 } 1126 }
1089 1127
1090 bool ShellUtil::GetChromeShortcutName(BrowserDistribution* dist, 1128 bool ShellUtil::GetChromeShortcutName(ShellUtil::ShortcutLocation location,
1129 BrowserDistribution* dist,
1091 bool alternate, 1130 bool alternate,
1092 const string16& appended_name, 1131 const string16& appended_name,
1093 string16* shortcut) { 1132 string16* shortcut) {
1094 shortcut->assign(alternate ? dist->GetAlternateApplicationName() : 1133 // Only the Desktop shortcut can use the alternate name.
1095 dist->GetAppShortCutName()); 1134 DCHECK(!alternate || location == SHORTCUT_DESKTOP);
1135
1136 switch (location) {
1137 case SHORTCUT_DESKTOP:
1138 shortcut->assign(alternate ? dist->GetAlternateApplicationName() :
1139 dist->GetAppShortCutName());
1140 break;
1141 case SHORTCUT_QUICK_LAUNCH:
1142 case SHORTCUT_START_MENU:
1143 shortcut->assign(dist->GetAppShortCutName());
1144 break;
1145 case SHORTCUT_START_MENU_UNINSTALL:
1146 shortcut->assign(dist->GetUninstallLinkName());
1147 break;
1148 default:
1149 NOTREACHED();
1150 shortcut->clear();
1151 return false;
1152 }
1153
1096 if (!appended_name.empty()) { 1154 if (!appended_name.empty()) {
1097 shortcut->append(L" ("); 1155 shortcut->append(L" (");
1098 shortcut->append(appended_name); 1156 shortcut->append(appended_name);
1099 shortcut->append(L")"); 1157 shortcut->append(L")");
1100 } 1158 }
1101 shortcut->append(L".lnk"); 1159 shortcut->append(L".lnk");
1102 return true; 1160 return true;
1103 } 1161 }
1104 1162
1105 bool ShellUtil::GetDesktopPath(bool system_level, FilePath* path) {
1106 wchar_t desktop[MAX_PATH];
1107 int dir = system_level ? CSIDL_COMMON_DESKTOPDIRECTORY :
1108 CSIDL_DESKTOPDIRECTORY;
1109 if (FAILED(SHGetFolderPath(NULL, dir, NULL, SHGFP_TYPE_CURRENT, desktop)))
1110 return false;
1111 *path = FilePath(desktop);
1112 return true;
1113 }
1114
1115 bool ShellUtil::GetQuickLaunchPath(bool system_level, FilePath* path) {
1116 if (system_level) {
1117 wchar_t qlaunch[MAX_PATH];
1118 // We are accessing GetDefaultUserProfileDirectory this way so that we do
1119 // not have to declare dependency to Userenv.lib for chrome.exe
1120 typedef BOOL (WINAPI *PROFILE_FUNC)(LPWSTR, LPDWORD);
1121 HMODULE module = LoadLibrary(L"Userenv.dll");
1122 PROFILE_FUNC p = reinterpret_cast<PROFILE_FUNC>(GetProcAddress(module,
1123 "GetDefaultUserProfileDirectoryW"));
1124 DWORD size = _countof(qlaunch);
1125 if ((p == NULL) || ((p)(qlaunch, &size) != TRUE))
1126 return false;
1127 *path = FilePath(qlaunch);
1128 if (base::win::GetVersion() >= base::win::VERSION_VISTA) {
1129 *path = path->AppendASCII("AppData");
1130 *path = path->AppendASCII("Roaming");
1131 } else {
1132 *path = path->AppendASCII("Application Data");
1133 }
1134 } else {
1135 if (!PathService::Get(base::DIR_APP_DATA, path)) {
1136 return false;
1137 }
1138 }
1139 *path = path->AppendASCII("Microsoft");
1140 *path = path->AppendASCII("Internet Explorer");
1141 *path = path->AppendASCII("Quick Launch");
1142 return true;
1143 }
1144
1145 void ShellUtil::GetRegisteredBrowsers( 1163 void ShellUtil::GetRegisteredBrowsers(
1146 BrowserDistribution* dist, 1164 BrowserDistribution* dist,
1147 std::map<string16, string16>* browsers) { 1165 std::map<string16, string16>* browsers) {
1148 DCHECK(dist); 1166 DCHECK(dist);
1149 DCHECK(browsers); 1167 DCHECK(browsers);
1150 1168
1151 const string16 base_key(ShellUtil::kRegStartMenuInternet); 1169 const string16 base_key(ShellUtil::kRegStartMenuInternet);
1152 string16 client_path; 1170 string16 client_path;
1153 RegKey key; 1171 RegKey key;
1154 string16 name; 1172 string16 name;
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after
1535 } else if (elevate_if_not_admin && 1553 } else if (elevate_if_not_admin &&
1536 base::win::GetVersion() >= base::win::VERSION_VISTA) { 1554 base::win::GetVersion() >= base::win::VERSION_VISTA) {
1537 // Elevate to do the whole job 1555 // Elevate to do the whole job
1538 return ElevateAndRegisterChrome(dist, chrome_exe, suffix, protocol); 1556 return ElevateAndRegisterChrome(dist, chrome_exe, suffix, protocol);
1539 } else { 1557 } else {
1540 // Admin rights are required to register capabilities before Windows 8. 1558 // Admin rights are required to register capabilities before Windows 8.
1541 return false; 1559 return false;
1542 } 1560 }
1543 } 1561 }
1544 1562
1545 bool ShellUtil::RemoveChromeDesktopShortcut(BrowserDistribution* dist, 1563 bool ShellUtil::RemoveChromeShortcut(ShellUtil::ShortcutLocation location,
1546 int shell_change, uint32 options) { 1564 BrowserDistribution* dist,
1547 // Only SHORTCUT_ALTERNATE is a valid option for this function. 1565 uint32 options) {
1548 DCHECK(!options || options == ShellUtil::SHORTCUT_ALTERNATE);
1549
1550 string16 shortcut_name; 1566 string16 shortcut_name;
1551 bool alternate = (options & ShellUtil::SHORTCUT_ALTERNATE) != 0; 1567 bool alternate = (options & ShellUtil::SHORTCUT_ALTERNATE) != 0 &&
1552 if (!ShellUtil::GetChromeShortcutName(dist, alternate, L"", 1568 location == SHORTCUT_DESKTOP;
1569 if (!ShellUtil::GetChromeShortcutName(location, dist, alternate, string16(),
1553 &shortcut_name)) 1570 &shortcut_name))
1554 return false; 1571 return false;
1555 1572
1556 bool ret = true; 1573 bool ret = true;
1557 if (shell_change & ShellUtil::CURRENT_USER) { 1574
1558 FilePath shortcut_path; 1575 // Always delete the user-level shortcut.
1559 if (ShellUtil::GetDesktopPath(false, &shortcut_path)) { 1576 FilePath user_shortcut_path;
1560 FilePath shortcut = shortcut_path.Append(shortcut_name); 1577 if (GetShortcutPath(location, false, &user_shortcut_path)) {
1561 ret = file_util::Delete(shortcut, false); 1578 user_shortcut_path = user_shortcut_path.Append(shortcut_name);
1579 ret = file_util::Delete(user_shortcut_path, false);
1580 } else {
1581 ret = false;
1582 }
1583
1584 // Delete the system-level shortcut if requested.
1585 if (options & ShellUtil::SHORTCUT_SYSTEM_LEVEL) {
1586 FilePath system_shortcut_path;
1587 if (GetShortcutPath(location, true, &system_shortcut_path)) {
1588 system_shortcut_path = system_shortcut_path.Append(shortcut_name);
1589 ret = ret && file_util::Delete(system_shortcut_path, false);
1562 } else { 1590 } else {
1563 ret = false; 1591 ret = false;
1564 } 1592 }
1565 }
1566
1567 if (shell_change & ShellUtil::SYSTEM_LEVEL) {
1568 FilePath shortcut_path;
1569 if (ShellUtil::GetDesktopPath(true, &shortcut_path)) {
1570 FilePath shortcut = shortcut_path.Append(shortcut_name);
1571 ret = file_util::Delete(shortcut, false) && ret;
1572 } else {
1573 ret = false;
1574 }
1575 } 1593 }
1576 return ret; 1594 return ret;
1577 } 1595 }
1578 1596
1579 bool ShellUtil::RemoveChromeDesktopShortcutsWithAppendedNames( 1597 bool ShellUtil::RemoveChromeDesktopShortcutsWithAppendedNames(
1580 const std::vector<string16>& appended_names) { 1598 const std::vector<string16>& appended_names) {
1581 FilePath shortcut_path; 1599 FilePath shortcut_path;
1582 bool ret = true; 1600 bool ret = true;
1583 if (ShellUtil::GetDesktopPath(false, &shortcut_path)) { 1601 if (GetShortcutPath(ShellUtil::SHORTCUT_DESKTOP, false, &shortcut_path)) {
1584 for (std::vector<string16>::const_iterator it = 1602 for (std::vector<string16>::const_iterator it = appended_names.begin();
1585 appended_names.begin(); 1603 it != appended_names.end(); ++it) {
1586 it != appended_names.end();
1587 ++it) {
1588 FilePath delete_shortcut = shortcut_path.Append(*it); 1604 FilePath delete_shortcut = shortcut_path.Append(*it);
1589 ret = ret && file_util::Delete(delete_shortcut, false); 1605 ret = ret && file_util::Delete(delete_shortcut, false);
1590 } 1606 }
1591 } else { 1607 } else {
1592 ret = false; 1608 ret = false;
1593 } 1609 }
1594 return ret; 1610 return ret;
1595 } 1611 }
1596 1612
1597 bool ShellUtil::RemoveChromeQuickLaunchShortcut(BrowserDistribution* dist,
1598 int shell_change) {
1599 string16 shortcut_name;
1600 if (!ShellUtil::GetChromeShortcutName(dist, false, L"", &shortcut_name))
1601 return false;
1602
1603 bool ret = true;
1604 // First remove shortcut for the current user.
1605 if (shell_change & ShellUtil::CURRENT_USER) {
1606 FilePath user_ql_path;
1607 if (ShellUtil::GetQuickLaunchPath(false, &user_ql_path)) {
1608 user_ql_path = user_ql_path.Append(shortcut_name);
1609 ret = file_util::Delete(user_ql_path, false);
1610 } else {
1611 ret = false;
1612 }
1613 }
1614
1615 // Delete shortcut in Default User's profile
1616 if (shell_change & ShellUtil::SYSTEM_LEVEL) {
1617 FilePath default_ql_path;
1618 if (ShellUtil::GetQuickLaunchPath(true, &default_ql_path)) {
1619 default_ql_path = default_ql_path.Append(shortcut_name);
1620 ret = file_util::Delete(default_ql_path, false) && ret;
1621 } else {
1622 ret = false;
1623 }
1624 }
1625
1626 return ret;
1627 }
1628
1629 bool ShellUtil::UpdateChromeShortcut(BrowserDistribution* dist,
1630 const string16& chrome_exe,
1631 const string16& shortcut,
1632 const string16& arguments,
1633 const string16& description,
1634 const string16& icon_path,
1635 int icon_index,
1636 uint32 options) {
1637 const FilePath chrome_path(FilePath(chrome_exe).DirName());
1638
1639 installer::MasterPreferences prefs(
1640 chrome_path.AppendASCII(installer::kDefaultMasterPrefs));
1641 if (FilePath::CompareEqualIgnoreCase(icon_path, chrome_exe)) {
1642 prefs.GetInt(installer::master_preferences::kChromeShortcutIconIndex,
1643 &icon_index);
1644 }
1645
1646 const string16 app_id(GetBrowserModelId(dist, chrome_exe));
1647
1648 return file_util::CreateOrUpdateShortcutLink(
1649 chrome_exe.c_str(),
1650 shortcut.c_str(),
1651 chrome_path.value().c_str(),
1652 arguments.c_str(),
1653 description.c_str(),
1654 icon_path.c_str(),
1655 icon_index,
1656 app_id.c_str(),
1657 ConvertShellUtilShortcutOptionsToFileUtil(options));
1658 }
1659
1660 ShellUtil::VerifyShortcutStatus ShellUtil::VerifyChromeShortcut( 1613 ShellUtil::VerifyShortcutStatus ShellUtil::VerifyChromeShortcut(
1661 const string16& exe_path, const string16& shortcut, 1614 const string16& exe_path, const string16& shortcut,
1662 const string16& description, int icon_index) { 1615 const string16& description, int icon_index) {
1663 base::win::ScopedComPtr<IShellLink> i_shell_link; 1616 base::win::ScopedComPtr<IShellLink> i_shell_link;
1664 base::win::ScopedComPtr<IPersistFile> i_persist_file; 1617 base::win::ScopedComPtr<IPersistFile> i_persist_file;
1665 wchar_t long_path[MAX_PATH] = {0}; 1618 wchar_t long_path[MAX_PATH] = {0};
1666 wchar_t short_path[MAX_PATH] = {0}; 1619 wchar_t short_path[MAX_PATH] = {0};
1667 wchar_t file_path[MAX_PATH] = {0}; 1620 wchar_t file_path[MAX_PATH] = {0};
1668 wchar_t icon_path[MAX_PATH] = {0}; 1621 wchar_t icon_path[MAX_PATH] = {0};
1669 wchar_t desc[MAX_PATH] = {0}; 1622 wchar_t desc[MAX_PATH] = {0};
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
1756 // are any left...). 1709 // are any left...).
1757 if (free_bits >= 8 && next_byte_index < size) { 1710 if (free_bits >= 8 && next_byte_index < size) {
1758 free_bits -= 8; 1711 free_bits -= 8;
1759 bit_stream += bytes[next_byte_index++] << free_bits; 1712 bit_stream += bytes[next_byte_index++] << free_bits;
1760 } 1713 }
1761 } 1714 }
1762 1715
1763 DCHECK_EQ(ret.length(), encoded_length); 1716 DCHECK_EQ(ret.length(), encoded_length);
1764 return ret; 1717 return ret;
1765 } 1718 }
OLDNEW
« chrome/installer/util/shell_util.h ('K') | « chrome/installer/util/shell_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698