OLD | NEW |
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 1080 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1091 if (!appended_name.empty()) { | 1091 if (!appended_name.empty()) { |
1092 shortcut->append(L" ("); | 1092 shortcut->append(L" ("); |
1093 shortcut->append(appended_name); | 1093 shortcut->append(appended_name); |
1094 shortcut->append(L")"); | 1094 shortcut->append(L")"); |
1095 } | 1095 } |
1096 shortcut->append(L".lnk"); | 1096 shortcut->append(L".lnk"); |
1097 return true; | 1097 return true; |
1098 } | 1098 } |
1099 | 1099 |
1100 bool ShellUtil::GetDesktopPath(bool system_level, FilePath* path) { | 1100 bool ShellUtil::GetDesktopPath(bool system_level, FilePath* path) { |
1101 int dir_key = system_level ? base::DIR_COMMON_DESKTOP : | 1101 wchar_t desktop[MAX_PATH]; |
1102 base::DIR_USER_DESKTOP; | 1102 int dir = system_level ? CSIDL_COMMON_DESKTOPDIRECTORY : |
1103 return PathService::Get(dir_key, path); | 1103 CSIDL_DESKTOPDIRECTORY; |
| 1104 if (FAILED(SHGetFolderPath(NULL, dir, NULL, SHGFP_TYPE_CURRENT, desktop))) |
| 1105 return false; |
| 1106 *path = FilePath(desktop); |
| 1107 return true; |
1104 } | 1108 } |
1105 | 1109 |
1106 bool ShellUtil::GetQuickLaunchPath(bool system_level, FilePath* path) { | 1110 bool ShellUtil::GetQuickLaunchPath(bool system_level, FilePath* path) { |
1107 int dir_key = system_level ? base::DIR_DEFAULT_USER_QUICK_LAUNCH : | 1111 if (system_level) { |
1108 base::DIR_USER_QUICK_LAUNCH; | 1112 wchar_t qlaunch[MAX_PATH]; |
1109 return PathService::Get(dir_key, path); | 1113 // We are accessing GetDefaultUserProfileDirectory this way so that we do |
| 1114 // not have to declare dependency to Userenv.lib for chrome.exe |
| 1115 typedef BOOL (WINAPI *PROFILE_FUNC)(LPWSTR, LPDWORD); |
| 1116 HMODULE module = LoadLibrary(L"Userenv.dll"); |
| 1117 PROFILE_FUNC p = reinterpret_cast<PROFILE_FUNC>(GetProcAddress(module, |
| 1118 "GetDefaultUserProfileDirectoryW")); |
| 1119 DWORD size = _countof(qlaunch); |
| 1120 if ((p == NULL) || ((p)(qlaunch, &size) != TRUE)) |
| 1121 return false; |
| 1122 *path = FilePath(qlaunch); |
| 1123 if (base::win::GetVersion() >= base::win::VERSION_VISTA) { |
| 1124 *path = path->AppendASCII("AppData"); |
| 1125 *path = path->AppendASCII("Roaming"); |
| 1126 } else { |
| 1127 *path = path->AppendASCII("Application Data"); |
| 1128 } |
| 1129 } else { |
| 1130 if (!PathService::Get(base::DIR_APP_DATA, path)) { |
| 1131 return false; |
| 1132 } |
| 1133 } |
| 1134 *path = path->AppendASCII("Microsoft"); |
| 1135 *path = path->AppendASCII("Internet Explorer"); |
| 1136 *path = path->AppendASCII("Quick Launch"); |
| 1137 return true; |
1110 } | 1138 } |
1111 | 1139 |
1112 void ShellUtil::GetRegisteredBrowsers( | 1140 void ShellUtil::GetRegisteredBrowsers( |
1113 BrowserDistribution* dist, | 1141 BrowserDistribution* dist, |
1114 std::map<string16, string16>* browsers) { | 1142 std::map<string16, string16>* browsers) { |
1115 DCHECK(dist); | 1143 DCHECK(dist); |
1116 DCHECK(browsers); | 1144 DCHECK(browsers); |
1117 | 1145 |
1118 const string16 base_key(ShellUtil::kRegStartMenuInternet); | 1146 const string16 base_key(ShellUtil::kRegStartMenuInternet); |
1119 string16 client_path; | 1147 string16 client_path; |
(...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1716 // are any left...). | 1744 // are any left...). |
1717 if (free_bits >= 8 && next_byte_index < size) { | 1745 if (free_bits >= 8 && next_byte_index < size) { |
1718 free_bits -= 8; | 1746 free_bits -= 8; |
1719 bit_stream += bytes[next_byte_index++] << free_bits; | 1747 bit_stream += bytes[next_byte_index++] << free_bits; |
1720 } | 1748 } |
1721 } | 1749 } |
1722 | 1750 |
1723 DCHECK_EQ(ret.length(), encoded_length); | 1751 DCHECK_EQ(ret.length(), encoded_length); |
1724 return ret; | 1752 return ret; |
1725 } | 1753 } |
OLD | NEW |