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 1141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1152 const base::win::Version windows_version = base::win::GetVersion(); | 1152 const base::win::Version windows_version = base::win::GetVersion(); |
1153 | 1153 |
1154 if (windows_version >= base::win::VERSION_WIN8) | 1154 if (windows_version >= base::win::VERSION_WIN8) |
1155 return ProbeCurrentDefaultHandlers(protocols, num_protocols); | 1155 return ProbeCurrentDefaultHandlers(protocols, num_protocols); |
1156 else if (windows_version >= base::win::VERSION_VISTA) | 1156 else if (windows_version >= base::win::VERSION_VISTA) |
1157 return ProbeAppIsDefaultHandlers(protocols, num_protocols); | 1157 return ProbeAppIsDefaultHandlers(protocols, num_protocols); |
1158 | 1158 |
1159 return ProbeOpenCommandHandlers(protocols, num_protocols); | 1159 return ProbeOpenCommandHandlers(protocols, num_protocols); |
1160 } | 1160 } |
1161 | 1161 |
1162 // Removes shortcut at |shortcut_path| if it is a shortcut that points to | 1162 // (Windows 8+) Returns the folder for app shortcuts, or empty if none found. |
1163 // |target_exe|. If |delete_folder| is true, deletes the parent folder of | 1163 base::FilePath GetAppShortcutsFolder(BrowserDistribution* dist, |
1164 // the shortcut completely. Returns true if either the shortcut was deleted | 1164 const string16& target_exe) { |
1165 // successfully or if the shortcut did not point to |target_exe|. | 1165 if (base::win::GetVersion() < base::win::VERSION_WIN8) |
1166 bool MaybeRemoveShortcutAtPath(const base::FilePath& shortcut_path, | 1166 return base::FilePath(); |
1167 const base::FilePath& target_exe, | 1167 |
1168 bool delete_folder) { | 1168 base::FilePath folder; |
1169 base::FilePath target_path; | 1169 if (!PathService::Get(base::DIR_APP_SHORTCUTS, &folder)) { |
1170 if (!base::win::ResolveShortcut(shortcut_path, &target_path, NULL)) | 1170 LOG(ERROR) << "Could not get application shortcuts location."; |
1171 return base::FilePath(); | |
1172 } | |
1173 | |
1174 folder = folder.Append( | |
1175 ShellUtil::GetBrowserModelId(dist, | |
gab
2013/04/24 21:41:46
nit: wrap |dist| on the line below.
The rule is e
huangs
2013/04/25 16:27:46
Done.
| |
1176 InstallUtil::IsPerUserInstall(target_exe.c_str()))); | |
1177 if (!file_util::DirectoryExists(folder)) { | |
1178 VLOG(1) << "No start screen shortcuts."; | |
1179 return base::FilePath(); | |
1180 } | |
1181 | |
1182 return folder; | |
1183 } | |
1184 | |
1185 const wchar_t kAllFiles[] = L"*"; | |
1186 | |
1187 // Helper to perform common operations to shortcuts in a folder. | |
1188 // Implement the ActOnShortcut() and ActOnFolder() to define operations. | |
1189 class BatchShortcutOperation { | |
gab
2013/04/24 21:41:46
I think it would be nicer, less verbose, and easie
huangs
2013/04/25 16:27:46
I think it's important to group it into a class, b
| |
1190 public: | |
1191 BatchShortcutOperation() {} | |
1192 virtual ~BatchShortcutOperation() {} | |
1193 | |
1194 // Goes through |shortcut_folder| and seeks shortcuts with names that match | |
1195 // |name_filter| (empty = none), and with targets given by |target_exe|. | |
1196 // Calls ActOnShortcut() with each matching shortcuts. Afterwards, calls | |
1197 // ActOnFolder() with |shortcut_folder|. | |
1198 // Returns true iff all operations are successful. | |
1199 bool Run(const base::FilePath& shortcut_folder, | |
1200 const string16& name_filter, | |
1201 const base::FilePath& target_exe); | |
1202 | |
1203 // Wrapper for Run(): first determine shortcut path based on given data. | |
1204 // |name| can specify the name for a single shortcut (without ".lnk" suffix), | |
gab
2013/04/24 21:41:46
s/suffix/extension
gab
2013/04/24 21:41:46
I don't like relying on the extension being presen
huangs
2013/04/25 16:27:46
Done.
huangs
2013/04/25 16:27:46
Done; adding ".lnk" if missing (exception is empty
| |
1205 // or all shortcuts if NULL. | |
1206 bool RunForLocation(ShellUtil::ShortcutLocation location, | |
1207 BrowserDistribution* dist, | |
1208 const base::FilePath& target_exe, | |
1209 ShellUtil::ShellChange level, | |
1210 const string16* name); | |
1211 | |
1212 // Wrapper for Run(): specifying all shortcuts in the taskbar. | |
1213 bool RunForTaskbar(const base::FilePath& target_exe); | |
1214 | |
1215 // Returns: true on success. | |
1216 virtual bool ActOnShortcut(const base::FilePath& shortcut_path) const = 0; | |
1217 | |
1218 // Returns: true on success. | |
1219 virtual bool ActOnFolder(const base::FilePath& shortcut_folder) const = 0; | |
1220 | |
1221 private: | |
1222 DISALLOW_COPY_AND_ASSIGN(BatchShortcutOperation); | |
1223 }; | |
1224 | |
1225 // |name_filter| will have ".lnk" appended. | |
1226 bool BatchShortcutOperation::Run(const base::FilePath& shortcut_folder, | |
1227 const string16& name_filter, | |
1228 const base::FilePath& target_exe) { | |
1229 InstallUtil::ProgramCompare target_compare(target_exe); | |
1230 bool success = true; | |
1231 if (!name_filter.empty()) { | |
1232 string16 pattern = name_filter + installer::kLnkExt; | |
1233 file_util::FileEnumerator enumerator(shortcut_folder, false, | |
1234 file_util::FileEnumerator::FILES, pattern); | |
1235 for (base::FilePath shortcut_path = enumerator.Next(); | |
1236 !shortcut_path.empty(); | |
1237 shortcut_path = enumerator.Next()) { | |
1238 if (shortcut_path.Extension() == installer::kLnkExt) { | |
gab
2013/04/24 21:41:46
You are already only enumerating files with the .l
huangs
2013/04/25 16:27:46
Changed to DCHECK_EQ().
| |
1239 base::FilePath target_path; | |
1240 if (base::win::ResolveShortcut(shortcut_path, &target_path, NULL)) { | |
1241 if (target_compare.EvaluatePath(target_path)) | |
1242 success = ActOnShortcut(shortcut_path) && success; | |
1243 } else { | |
1244 LOG(ERROR) << "Cannot resolve shortcut at " << shortcut_path.value(); | |
1245 success = false; | |
1246 } | |
1247 } | |
1248 } | |
1249 } | |
1250 success = ActOnFolder(shortcut_folder) && success; | |
1251 return success; | |
1252 } | |
1253 | |
1254 bool BatchShortcutOperation::RunForLocation( | |
1255 ShellUtil::ShortcutLocation location, | |
1256 BrowserDistribution* dist, | |
1257 const base::FilePath& target_exe, | |
1258 ShellUtil::ShellChange level, | |
1259 const string16* name) { | |
gab
2013/04/24 21:41:46
If |name| is changed to a pattern (as suggested in
huangs
2013/04/25 16:27:46
I think I'll get rid of the ActOnFolder() stuff; w
| |
1260 base::FilePath shortcut_folder; | |
1261 if (!ShellUtil::GetShortcutPath(location, dist, level, &shortcut_folder) || | |
1262 shortcut_folder.empty()) { | |
1263 NOTREACHED(); | |
1171 return false; | 1264 return false; |
1172 | 1265 } |
1173 if (InstallUtil::ProgramCompare(target_exe).EvaluatePath(target_path)) { | 1266 |
1174 // Unpin the shortcut if it was ever pinned by the user or the installer. | 1267 return Run(shortcut_folder, name ? *name : kAllFiles, target_exe); |
1268 } | |
1269 | |
1270 bool BatchShortcutOperation::RunForTaskbar(const base::FilePath& target_exe) { | |
1271 base::FilePath taskbar_pins_path; | |
1272 if (!PathService::Get(base::DIR_TASKBAR_PINS, &taskbar_pins_path) || | |
gab
2013/04/24 21:41:46
Feels like we should augment GetShortcutPath() ins
huangs
2013/04/25 16:27:46
Might be solved by removing ActOnFolder().
| |
1273 !file_util::PathExists(taskbar_pins_path)) { | |
1274 LOG(ERROR) << "Couldn't find path to taskbar pins."; | |
1275 return false; | |
1276 } | |
1277 | |
1278 return Run(taskbar_pins_path, kAllFiles, target_exe); | |
gab
2013/04/24 21:41:46
Taskbar pins are special though, they have to be e
huangs
2013/04/25 16:27:46
Per earlier discussion, having a dedicated unpin o
| |
1279 } | |
1280 | |
1281 // Batch shortcut operation to unpin and/or delete shortcuts in a folder, | |
1282 // and possibly remove the folder itself. | |
1283 class BatchShortcutDelete: public BatchShortcutOperation { | |
1284 public: | |
1285 BatchShortcutDelete(bool unpin, bool delete_file, bool delete_folder); | |
1286 virtual ~BatchShortcutDelete() {} | |
1287 | |
1288 // Unpins and/or removes |shortcut_path|. | |
1289 // Returns true if deletion successful or if no deletion occurs. | |
1290 virtual bool ActOnShortcut(const base::FilePath& shortcut_path) const | |
1291 OVERRIDE; | |
1292 | |
1293 // Removes |shortcut_folder| if |delete_folder_|. | |
1294 // Returns true if deletion successful. | |
1295 virtual bool ActOnFolder(const base::FilePath& shortcut_folder) const | |
1296 OVERRIDE; | |
1297 | |
1298 private: | |
1299 bool unpin_; | |
1300 bool delete_file_; | |
1301 bool delete_folder_; | |
1302 | |
1303 DISALLOW_COPY_AND_ASSIGN(BatchShortcutDelete); | |
1304 }; | |
1305 | |
1306 BatchShortcutDelete::BatchShortcutDelete(bool unpin, | |
1307 bool delete_file, | |
1308 bool delete_folder) | |
gab
2013/04/24 21:41:46
(bool, bool, bool, bool, bool, bool, bool) interfa
huangs
2013/04/25 16:27:46
Adding accessors to explicitly set flags. But thi
| |
1309 : unpin_(unpin), | |
1310 delete_file_(delete_file), | |
1311 delete_folder_(delete_folder) { | |
1312 } | |
1313 | |
1314 bool BatchShortcutDelete::ActOnShortcut(const base::FilePath& shortcut_path) | |
1315 const { | |
1316 if (unpin_) { | |
1175 VLOG(1) << "Trying to unpin " << shortcut_path.value(); | 1317 VLOG(1) << "Trying to unpin " << shortcut_path.value(); |
1176 if (!base::win::TaskbarUnpinShortcutLink(shortcut_path.value().c_str())) { | 1318 if (!base::win::TaskbarUnpinShortcutLink(shortcut_path.value().c_str())) { |
gab
2013/04/24 21:41:46
Did you check who uses RemoveShortcut(), is it sti
huangs
2013/04/25 16:27:46
There a routine that avoids calling this BECAUSE o
| |
1177 VLOG(1) << shortcut_path.value() | 1319 VLOG(1) << shortcut_path.value() |
1178 << " wasn't pinned (or the unpin failed)."; | 1320 << " wasn't pinned (or the unpin failed)."; |
1321 // Not an error condition, since shortcut might not be pinned. | |
1179 } | 1322 } |
1180 if (delete_folder) | 1323 } |
1181 return file_util::Delete(shortcut_path.DirName(), true); | 1324 return delete_file_ ? file_util::Delete(shortcut_path, false) : true; |
1182 else | 1325 } |
1183 return file_util::Delete(shortcut_path, false); | 1326 |
1184 } | 1327 bool BatchShortcutDelete::ActOnFolder(const base::FilePath& shortcut_folder) |
1185 | 1328 const { |
1186 // The shortcut at |shortcut_path| doesn't point to |target_exe|, act as if | 1329 return delete_folder_ ? file_util::Delete(shortcut_folder, true) : true; |
1187 // our shortcut had been deleted. | 1330 } |
1331 | |
1332 // Batch shortcut operation to set target. | |
1333 class BatchShortcutSetTarget: public BatchShortcutOperation { | |
1334 public: | |
1335 explicit BatchShortcutSetTarget(const base::FilePath& target); | |
1336 virtual ~BatchShortcutSetTarget() {} | |
1337 | |
1338 // Sets the target of |shortcut_path| to |target_|. | |
1339 // Returns true on success. | |
1340 virtual bool ActOnShortcut(const base::FilePath& shortcut_path) const | |
1341 OVERRIDE; | |
1342 | |
1343 // No-op; returns true. | |
1344 virtual bool ActOnFolder(const base::FilePath& shortcut_path) const OVERRIDE; | |
1345 | |
1346 private: | |
1347 base::FilePath target_; | |
1348 | |
1349 DISALLOW_COPY_AND_ASSIGN(BatchShortcutSetTarget); | |
1350 }; | |
1351 | |
1352 BatchShortcutSetTarget::BatchShortcutSetTarget( | |
1353 const base::FilePath& target) | |
1354 : target_(target) { | |
1355 } | |
1356 | |
1357 bool BatchShortcutSetTarget::ActOnShortcut(const base::FilePath& shortcut_path) | |
1358 const { | |
1359 base::win::ShortcutProperties shortcut_properties; | |
1360 shortcut_properties.set_target(target_); | |
1361 shortcut_properties.set_working_dir(target_.DirName()); | |
1362 return base::win::CreateOrUpdateShortcutLink( | |
1363 shortcut_path, shortcut_properties, base::win::SHORTCUT_UPDATE_EXISTING); | |
1364 } | |
1365 | |
1366 bool BatchShortcutSetTarget::ActOnFolder(const base::FilePath& shortcut_path) | |
1367 const { | |
1188 return true; | 1368 return true; |
1189 } | 1369 } |
1190 | 1370 |
1191 } // namespace | 1371 } // namespace |
1192 | 1372 |
1193 const wchar_t* ShellUtil::kRegDefaultIcon = L"\\DefaultIcon"; | 1373 const wchar_t* ShellUtil::kRegDefaultIcon = L"\\DefaultIcon"; |
1194 const wchar_t* ShellUtil::kRegShellPath = L"\\shell"; | 1374 const wchar_t* ShellUtil::kRegShellPath = L"\\shell"; |
1195 const wchar_t* ShellUtil::kRegShellOpen = L"\\shell\\open\\command"; | 1375 const wchar_t* ShellUtil::kRegShellOpen = L"\\shell\\open\\command"; |
1196 const wchar_t* ShellUtil::kRegStartMenuInternet = | 1376 const wchar_t* ShellUtil::kRegStartMenuInternet = |
1197 L"Software\\Clients\\StartMenuInternet"; | 1377 L"Software\\Clients\\StartMenuInternet"; |
(...skipping 653 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1851 } else if (elevate_if_not_admin && | 2031 } else if (elevate_if_not_admin && |
1852 base::win::GetVersion() >= base::win::VERSION_VISTA) { | 2032 base::win::GetVersion() >= base::win::VERSION_VISTA) { |
1853 // Elevate to do the whole job | 2033 // Elevate to do the whole job |
1854 return ElevateAndRegisterChrome(dist, chrome_exe, suffix, protocol); | 2034 return ElevateAndRegisterChrome(dist, chrome_exe, suffix, protocol); |
1855 } else { | 2035 } else { |
1856 // Admin rights are required to register capabilities before Windows 8. | 2036 // Admin rights are required to register capabilities before Windows 8. |
1857 return false; | 2037 return false; |
1858 } | 2038 } |
1859 } | 2039 } |
1860 | 2040 |
2041 // static | |
1861 bool ShellUtil::RemoveShortcut(ShellUtil::ShortcutLocation location, | 2042 bool ShellUtil::RemoveShortcut(ShellUtil::ShortcutLocation location, |
1862 BrowserDistribution* dist, | 2043 BrowserDistribution* dist, |
1863 const base::FilePath& target_exe, | 2044 const base::FilePath& target_exe, |
1864 ShellChange level, | 2045 ShellChange level, |
1865 const string16* shortcut_name) { | 2046 const string16* shortcut_name) { |
1866 const bool delete_folder = (location == SHORTCUT_LOCATION_START_MENU); | 2047 bool delete_folder = (location == SHORTCUT_LOCATION_START_MENU); |
1867 | 2048 BatchShortcutDelete op(true, true, delete_folder); // Unpon and delete-file. |
gab
2013/04/24 21:41:46
nit: Unpon :)
huangs
2013/04/25 16:27:46
Done. :)
| |
1868 base::FilePath shortcut_folder; | 2049 return op.RunForLocation(location, dist, target_exe, level, shortcut_name); |
1869 if (!GetShortcutPath(location, dist, level, &shortcut_folder) || | |
1870 shortcut_folder.empty()) { | |
1871 NOTREACHED(); | |
1872 return false; | |
1873 } | |
1874 | |
1875 if (!delete_folder && !shortcut_name) { | |
1876 file_util::FileEnumerator enumerator(shortcut_folder, false, | |
1877 file_util::FileEnumerator::FILES); | |
1878 bool had_failures = false; | |
1879 for (base::FilePath path = enumerator.Next(); !path.empty(); | |
1880 path = enumerator.Next()) { | |
1881 if (path.Extension() != installer::kLnkExt) | |
1882 continue; | |
1883 | |
1884 if (!MaybeRemoveShortcutAtPath(path, target_exe, delete_folder)) | |
1885 had_failures = true; | |
1886 } | |
1887 return !had_failures; | |
1888 } | |
1889 | |
1890 const string16 shortcut_base_name( | |
1891 (shortcut_name ? *shortcut_name : dist->GetAppShortCutName()) + | |
1892 installer::kLnkExt); | |
1893 const base::FilePath shortcut_path( | |
1894 shortcut_folder.Append(shortcut_base_name)); | |
1895 if (!file_util::PathExists(shortcut_path)) | |
1896 return true; | |
1897 | |
1898 return MaybeRemoveShortcutAtPath(shortcut_path, target_exe, delete_folder); | |
1899 } | 2050 } |
1900 | 2051 |
2052 // static | |
1901 void ShellUtil::RemoveTaskbarShortcuts(const string16& target_exe) { | 2053 void ShellUtil::RemoveTaskbarShortcuts(const string16& target_exe) { |
1902 if (base::win::GetVersion() < base::win::VERSION_WIN7) | 2054 if (base::win::GetVersion() < base::win::VERSION_WIN7) |
1903 return; | 2055 return; |
1904 | 2056 |
1905 base::FilePath taskbar_pins_path; | 2057 BatchShortcutDelete op(true, false, false); // Unpin only. |
1906 if (!PathService::Get(base::DIR_TASKBAR_PINS, &taskbar_pins_path) || | 2058 op.RunForTaskbar(base::FilePath(target_exe)); |
1907 !file_util::PathExists(taskbar_pins_path)) { | |
1908 LOG(ERROR) << "Couldn't find path to taskbar pins."; | |
1909 return; | |
1910 } | |
1911 | |
1912 file_util::FileEnumerator shortcuts_enum( | |
1913 taskbar_pins_path, false, | |
1914 file_util::FileEnumerator::FILES, FILE_PATH_LITERAL("*.lnk")); | |
1915 | |
1916 base::FilePath target_path(target_exe); | |
1917 InstallUtil::ProgramCompare target_compare(target_path); | |
1918 for (base::FilePath shortcut_path = shortcuts_enum.Next(); | |
1919 !shortcut_path.empty(); | |
1920 shortcut_path = shortcuts_enum.Next()) { | |
1921 base::FilePath read_target; | |
1922 if (!base::win::ResolveShortcut(shortcut_path, &read_target, NULL)) { | |
1923 LOG(ERROR) << "Couldn't resolve shortcut at " << shortcut_path.value(); | |
1924 continue; | |
1925 } | |
1926 if (target_compare.EvaluatePath(read_target)) { | |
1927 // Unpin this shortcut if it points to |target_exe|. | |
1928 base::win::TaskbarUnpinShortcutLink(shortcut_path.value().c_str()); | |
1929 } | |
1930 } | |
1931 } | 2059 } |
1932 | 2060 |
2061 // static | |
1933 void ShellUtil::RemoveStartScreenShortcuts(BrowserDistribution* dist, | 2062 void ShellUtil::RemoveStartScreenShortcuts(BrowserDistribution* dist, |
1934 const string16& target_exe) { | 2063 const string16& target_exe) { |
1935 if (base::win::GetVersion() < base::win::VERSION_WIN8) | 2064 if (base::win::GetVersion() < base::win::VERSION_WIN8) |
1936 return; | 2065 return; |
1937 | 2066 |
1938 base::FilePath app_shortcuts_path; | 2067 base::FilePath folder(GetAppShortcutsFolder(dist, target_exe)); |
gab
2013/04/24 21:41:46
This could probably also go in GetShortcutPath() a
huangs
2013/04/25 16:27:46
Will do this next. Can I remove / redo the messag
| |
1939 if (!PathService::Get(base::DIR_APP_SHORTCUTS, &app_shortcuts_path)) { | 2068 if (folder.empty()) |
1940 LOG(ERROR) << "Could not get application shortcuts location to delete" | |
1941 << " start screen shortcuts."; | |
1942 return; | 2069 return; |
1943 } | |
1944 | 2070 |
1945 app_shortcuts_path = app_shortcuts_path.Append( | 2071 BatchShortcutDelete op(false, false, true); // Delete-folder only. |
1946 GetBrowserModelId(dist, | 2072 VLOG(1) << "Removing start screen shortcuts from " << folder.value(); |
1947 InstallUtil::IsPerUserInstall(target_exe.c_str()))); | 2073 if (!op.Run(folder, L"", base::FilePath())) { |
1948 if (!file_util::DirectoryExists(app_shortcuts_path)) { | |
1949 VLOG(1) << "No start screen shortcuts to delete."; | |
1950 return; | |
1951 } | |
1952 | |
1953 VLOG(1) << "Removing start screen shortcuts from " | |
1954 << app_shortcuts_path.value(); | |
1955 if (!file_util::Delete(app_shortcuts_path, true)) { | |
1956 LOG(ERROR) << "Failed to remove start screen shortcuts from " | 2074 LOG(ERROR) << "Failed to remove start screen shortcuts from " |
1957 << app_shortcuts_path.value(); | 2075 << folder.value(); |
1958 } | 2076 } |
1959 } | 2077 } |
1960 | 2078 |
2079 // static | |
2080 bool ShellUtil::MigrateShortcut(ShellUtil::ShortcutLocation location, | |
2081 BrowserDistribution* dist, | |
2082 const base::FilePath& old_target_exe, | |
2083 const base::FilePath& new_target_exe, | |
2084 ShellChange level, | |
2085 const string16* shortcut_name) { | |
2086 bool delete_folder = (location == SHORTCUT_LOCATION_START_MENU); | |
2087 BatchShortcutSetTarget op(new_target_exe); | |
2088 return op.RunForLocation(location, dist, old_target_exe, level, | |
2089 shortcut_name); | |
2090 } | |
2091 | |
2092 // static | |
2093 void ShellUtil::MigrateTaskbarShortcuts(const string16& old_target_exe, | |
2094 const string16& new_target_exe) { | |
2095 if (base::win::GetVersion() < base::win::VERSION_WIN7) | |
2096 return; | |
2097 | |
2098 base::FilePath new_target_path(new_target_exe); | |
2099 BatchShortcutSetTarget op(new_target_path); | |
2100 op.RunForTaskbar(base::FilePath(old_target_exe)); | |
2101 } | |
2102 | |
2103 // static | |
2104 void ShellUtil::MigrateStartScreenShortcuts(BrowserDistribution* dist, | |
2105 const string16& old_target_exe, | |
2106 const string16& new_target_exe) { | |
2107 if (base::win::GetVersion() < base::win::VERSION_WIN8) | |
2108 return; | |
2109 | |
2110 base::FilePath folder(GetAppShortcutsFolder(dist, old_target_exe)); | |
2111 if (folder.empty()) | |
2112 return; | |
2113 | |
2114 base::FilePath new_target_path(new_target_exe); | |
2115 BatchShortcutSetTarget op(new_target_path); | |
2116 VLOG(1) << "Migrating start screen shortcuts from " << folder.value(); | |
2117 if (!op.Run(folder, kAllFiles, base::FilePath(old_target_exe))) { | |
2118 LOG(ERROR) << "Failed to migrate start screen shortcuts from " | |
2119 << folder.value(); | |
2120 } | |
2121 } | |
2122 | |
1961 bool ShellUtil::GetUserSpecificRegistrySuffix(string16* suffix) { | 2123 bool ShellUtil::GetUserSpecificRegistrySuffix(string16* suffix) { |
1962 // Use a thread-safe cache for the user's suffix. | 2124 // Use a thread-safe cache for the user's suffix. |
1963 static base::LazyInstance<UserSpecificRegistrySuffix>::Leaky suffix_instance = | 2125 static base::LazyInstance<UserSpecificRegistrySuffix>::Leaky suffix_instance = |
1964 LAZY_INSTANCE_INITIALIZER; | 2126 LAZY_INSTANCE_INITIALIZER; |
1965 return suffix_instance.Get().GetSuffix(suffix); | 2127 return suffix_instance.Get().GetSuffix(suffix); |
1966 } | 2128 } |
1967 | 2129 |
1968 bool ShellUtil::GetOldUserSpecificRegistrySuffix(string16* suffix) { | 2130 bool ShellUtil::GetOldUserSpecificRegistrySuffix(string16* suffix) { |
1969 wchar_t user_name[256]; | 2131 wchar_t user_name[256]; |
1970 DWORD size = arraysize(user_name); | 2132 DWORD size = arraysize(user_name); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2018 // are any left...). | 2180 // are any left...). |
2019 if (free_bits >= 8 && next_byte_index < size) { | 2181 if (free_bits >= 8 && next_byte_index < size) { |
2020 free_bits -= 8; | 2182 free_bits -= 8; |
2021 bit_stream += bytes[next_byte_index++] << free_bits; | 2183 bit_stream += bytes[next_byte_index++] << free_bits; |
2022 } | 2184 } |
2023 } | 2185 } |
2024 | 2186 |
2025 DCHECK_EQ(ret.length(), encoded_length); | 2187 DCHECK_EQ(ret.length(), encoded_length); |
2026 return ret; | 2188 return ret; |
2027 } | 2189 } |
OLD | NEW |