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" |
11 | 11 |
12 #include <shlobj.h> | 12 #include <shlobj.h> |
13 #include <windows.h> | 13 #include <windows.h> |
14 | 14 |
15 #include <limits> | 15 #include <limits> |
16 #include <string> | 16 #include <string> |
17 | 17 |
| 18 #include "base/base_paths.h" |
| 19 #include "base/base_paths_win.h" |
18 #include "base/command_line.h" | 20 #include "base/command_line.h" |
19 #include "base/file_path.h" | 21 #include "base/file_path.h" |
20 #include "base/file_util.h" | 22 #include "base/file_util.h" |
21 #include "base/lazy_instance.h" | 23 #include "base/lazy_instance.h" |
22 #include "base/logging.h" | 24 #include "base/logging.h" |
23 #include "base/md5.h" | 25 #include "base/md5.h" |
24 #include "base/memory/scoped_ptr.h" | 26 #include "base/memory/scoped_ptr.h" |
25 #include "base/memory/scoped_vector.h" | 27 #include "base/memory/scoped_vector.h" |
26 #include "base/path_service.h" | 28 #include "base/path_service.h" |
27 #include "base/string16.h" | 29 #include "base/string16.h" |
(...skipping 1063 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1091 if (!appended_name.empty()) { | 1093 if (!appended_name.empty()) { |
1092 shortcut->append(L" ("); | 1094 shortcut->append(L" ("); |
1093 shortcut->append(appended_name); | 1095 shortcut->append(appended_name); |
1094 shortcut->append(L")"); | 1096 shortcut->append(L")"); |
1095 } | 1097 } |
1096 shortcut->append(L".lnk"); | 1098 shortcut->append(L".lnk"); |
1097 return true; | 1099 return true; |
1098 } | 1100 } |
1099 | 1101 |
1100 bool ShellUtil::GetDesktopPath(bool system_level, FilePath* path) { | 1102 bool ShellUtil::GetDesktopPath(bool system_level, FilePath* path) { |
1101 wchar_t desktop[MAX_PATH]; | 1103 int dir_enum = system_level ? base::DIR_COMMON_DESKTOP : |
1102 int dir = system_level ? CSIDL_COMMON_DESKTOPDIRECTORY : | 1104 base::DIR_USER_DESKTOP; |
1103 CSIDL_DESKTOPDIRECTORY; | 1105 return PathService::Get(dir_enum, path); |
1104 if (FAILED(SHGetFolderPath(NULL, dir, NULL, SHGFP_TYPE_CURRENT, desktop))) | |
1105 return false; | |
1106 *path = FilePath(desktop); | |
1107 return true; | |
1108 } | 1106 } |
1109 | 1107 |
1110 bool ShellUtil::GetQuickLaunchPath(bool system_level, FilePath* path) { | 1108 bool ShellUtil::GetQuickLaunchPath(bool system_level, FilePath* path) { |
1111 if (system_level) { | 1109 int dir_enum = system_level ? base::DIR_DEFAULT_USER_QUICK_LAUNCH : |
1112 wchar_t qlaunch[MAX_PATH]; | 1110 base::DIR_USER_QUICK_LAUNCH; |
1113 // We are accessing GetDefaultUserProfileDirectory this way so that we do | 1111 return PathService::Get(dir_enum, path); |
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; | |
1138 } | 1112 } |
1139 | 1113 |
1140 void ShellUtil::GetRegisteredBrowsers( | 1114 void ShellUtil::GetRegisteredBrowsers( |
1141 BrowserDistribution* dist, | 1115 BrowserDistribution* dist, |
1142 std::map<string16, string16>* browsers) { | 1116 std::map<string16, string16>* browsers) { |
1143 DCHECK(dist); | 1117 DCHECK(dist); |
1144 DCHECK(browsers); | 1118 DCHECK(browsers); |
1145 | 1119 |
1146 const string16 base_key(ShellUtil::kRegStartMenuInternet); | 1120 const string16 base_key(ShellUtil::kRegStartMenuInternet); |
1147 string16 client_path; | 1121 string16 client_path; |
(...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1744 // are any left...). | 1718 // are any left...). |
1745 if (free_bits >= 8 && next_byte_index < size) { | 1719 if (free_bits >= 8 && next_byte_index < size) { |
1746 free_bits -= 8; | 1720 free_bits -= 8; |
1747 bit_stream += bytes[next_byte_index++] << free_bits; | 1721 bit_stream += bytes[next_byte_index++] << free_bits; |
1748 } | 1722 } |
1749 } | 1723 } |
1750 | 1724 |
1751 DCHECK_EQ(ret.length(), encoded_length); | 1725 DCHECK_EQ(ret.length(), encoded_length); |
1752 return ret; | 1726 return ret; |
1753 } | 1727 } |
OLD | NEW |