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 #include "chrome/installer/setup/install.h" | 5 #include "chrome/installer/setup/install.h" |
6 | 6 |
7 #include <shlobj.h> | 7 #include <shlobj.h> |
8 #include <time.h> | 8 #include <time.h> |
9 #include <winuser.h> | 9 #include <winuser.h> |
10 | 10 |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
287 | 287 |
288 start_menu_folder_path = start_menu_folder_path.Append(product_name); | 288 start_menu_folder_path = start_menu_folder_path.Append(product_name); |
289 | 289 |
290 // Create/update Chrome link (points to chrome.exe) & Uninstall Chrome link | 290 // Create/update Chrome link (points to chrome.exe) & Uninstall Chrome link |
291 // (which points to setup.exe) under |start_menu_folder_path|. | 291 // (which points to setup.exe) under |start_menu_folder_path|. |
292 | 292 |
293 // Chrome link (launches Chrome) | 293 // Chrome link (launches Chrome) |
294 FilePath chrome_link(start_menu_folder_path.Append(product_name + L".lnk")); | 294 FilePath chrome_link(start_menu_folder_path.Append(product_name + L".lnk")); |
295 | 295 |
296 if (create_always && !file_util::PathExists(start_menu_folder_path)) | 296 if (create_always && !file_util::PathExists(start_menu_folder_path)) |
297 file_util::CreateDirectoryW(start_menu_folder_path); | 297 file_util::CreateDirectoryW(start_menu_folder_path); |
298 | 298 |
299 VLOG(1) << operation << " shortcut to " << chrome_exe.value() << " at " | 299 VLOG(1) << operation << " shortcut to " << chrome_exe.value() << " at " |
300 << chrome_link.value(); | 300 << chrome_link.value(); |
301 if (!ShellUtil::UpdateChromeShortcut(browser_dist, chrome_exe.value(), | 301 if (!ShellUtil::UpdateChromeShortcut(browser_dist, chrome_exe.value(), |
302 chrome_link.value(), string16(), product_desc, chrome_exe.value(), | 302 chrome_link.value(), string16(), product_desc, chrome_exe.value(), |
303 browser_dist->GetIconIndex(), options)) { | 303 browser_dist->GetIconIndex(), options)) { |
304 LOG(WARNING) << operation << " shortcut at " << chrome_link.value() | 304 LOG(WARNING) << operation << " shortcut at " << chrome_link.value() |
305 << " failed."; | 305 << " failed."; |
306 } else if (create_always && | 306 } else if (create_always && |
307 base::win::GetVersion() >= base::win::VERSION_WIN7) { | 307 base::win::GetVersion() >= base::win::VERSION_WIN7) { |
308 // If the Start Menu shortcut was successfully created and |create_always|, | 308 // If the Start Menu shortcut was successfully created and |create_always|, |
309 // proceed to pin the Start Menu shortcut to the taskbar on Win7+. | 309 // proceed to pin the Start Menu shortcut to the taskbar on Win7+. |
310 VLOG(1) << "Pinning new shortcut at " << chrome_link.value() | 310 VLOG(1) << "Pinning new shortcut at " << chrome_link.value() |
311 << " to taskbar"; | 311 << " to taskbar"; |
312 if (!file_util::TaskbarPinShortcutLink(chrome_link.value().c_str())) { | 312 if (!file_util::TaskbarPinShortcutLink(chrome_link.value().c_str())) { |
313 LOG(ERROR) << "Failed to pin shortcut to taskbar: " | 313 LOG(ERROR) << "Failed to pin shortcut to taskbar: " |
314 << chrome_link.value(); | 314 << chrome_link.value(); |
315 } | 315 } |
316 } | 316 } |
317 | 317 |
318 if (create_always && installer_state.system_install()) | |
319 ForceCreateUserLevelStartMenuShortcut(installer_state, product); | |
320 | |
318 // Create/update uninstall link if we are not an MSI install. MSI | 321 // Create/update uninstall link if we are not an MSI install. MSI |
319 // installations are, for the time being, managed only through the | 322 // installations are, for the time being, managed only through the |
320 // Add/Remove Programs dialog. | 323 // Add/Remove Programs dialog. |
321 // TODO(robertshield): We could add a shortcut to msiexec /X {GUID} here. | 324 // TODO(robertshield): We could add a shortcut to msiexec /X {GUID} here. |
322 if (!installer_state.is_msi()) { | 325 if (!installer_state.is_msi()) { |
323 // Uninstall Chrome link | 326 // Uninstall Chrome link |
324 FilePath uninstall_link(start_menu_folder_path.Append( | 327 FilePath uninstall_link(start_menu_folder_path.Append( |
325 browser_dist->GetUninstallLinkName() + L".lnk")); | 328 browser_dist->GetUninstallLinkName() + L".lnk")); |
326 | 329 |
327 CommandLine arguments(CommandLine::NO_PROGRAM); | 330 CommandLine arguments(CommandLine::NO_PROGRAM); |
328 AppendUninstallCommandLineFlags(installer_state, product, &arguments); | 331 AppendUninstallCommandLineFlags(installer_state, product, &arguments); |
329 VLOG(1) << operation << " uninstall link at " << uninstall_link.value(); | 332 VLOG(1) << operation << " uninstall link at " << uninstall_link.value(); |
330 if (!file_util::CreateOrUpdateShortcutLink(setup_exe.value().c_str(), | 333 if (!file_util::CreateOrUpdateShortcutLink(setup_exe.value().c_str(), |
331 uninstall_link.value().c_str(), NULL, | 334 uninstall_link.value().c_str(), NULL, |
332 arguments.GetCommandLineString().c_str(), NULL, | 335 arguments.GetCommandLineString().c_str(), NULL, |
333 setup_exe.value().c_str(), 0, NULL, | 336 setup_exe.value().c_str(), 0, NULL, |
334 create_always ? file_util::SHORTCUT_CREATE_ALWAYS : | 337 create_always ? file_util::SHORTCUT_CREATE_ALWAYS : |
335 file_util::SHORTCUT_NO_OPTIONS)) { | 338 file_util::SHORTCUT_NO_OPTIONS)) { |
336 LOG(WARNING) << operation << " uninstall link at " | 339 LOG(WARNING) << operation << " uninstall link at " |
337 << uninstall_link.value() << " failed."; | 340 << uninstall_link.value() << " failed."; |
338 } | 341 } |
339 } | 342 } |
340 } | 343 } |
341 | 344 |
345 // TODO(gab): This is a hack that is temporarily required for the Start Menu | |
346 // (now Start Screen) shortcut to show up on Win8. This will be removed when I'm | |
347 // done refactoring ShellUtil as part of http://goo.gl/Az889. | |
348 void ForceCreateUserLevelStartMenuShortcut( | |
349 const InstallerState& installer_state, | |
350 const Product& product) { | |
351 BrowserDistribution* browser_dist = product.distribution(); | |
grt (UTC plus 2)
2012/09/02 14:18:19
to protect against someone accidentally calling th
gab
2012/09/02 16:15:12
Done.
| |
352 const string16 product_name(browser_dist->GetAppShortCutName()); | |
353 const string16 product_desc(browser_dist->GetAppDescription()); | |
354 const FilePath chrome_exe( | |
355 installer_state.target_path().Append(installer::kChromeExe)); | |
356 | |
357 FilePath user_start_menu; | |
358 if (!PathService::Get(base::DIR_START_MENU, &user_start_menu)) { | |
359 LOG(DFATAL) << "Failed to get user-level start menu path."; | |
360 return; | |
361 } | |
362 user_start_menu = user_start_menu.Append(product_name); | |
363 // Make sure the directory exists (no need to handle the return value here | |
364 // as we still want to try to create the shortcut; if the directory is truly | |
grt (UTC plus 2)
2012/09/02 14:18:19
i find the "...as we still want to try..." part mi
gab
2012/09/02 16:15:12
Ended up deciding to wrap it in the if below. What
| |
365 // not present the shortcut creation will fail anyways). | |
366 file_util::CreateDirectory(user_start_menu); | |
367 | |
368 const FilePath chrome_link( | |
369 user_start_menu.Append(product_name + L".lnk")); | |
370 | |
371 const uint32 options = (ShellUtil::SHORTCUT_CREATE_ALWAYS | | |
372 ShellUtil::SHORTCUT_DUAL_MODE); | |
373 | |
374 VLOG(1) << "Creating shortcut to " << chrome_exe.value() << " at " | |
375 << chrome_link.value(); | |
376 if (!ShellUtil::UpdateChromeShortcut(browser_dist, chrome_exe.value(), | |
377 chrome_link.value(), string16(), product_desc, chrome_exe.value(), | |
378 browser_dist->GetIconIndex(), options)) { | |
379 LOG(ERROR) << "Creating shortcut at " << chrome_link.value() << " failed."; | |
380 } | |
381 } | |
382 | |
342 void CreateOrUpdateDesktopAndQuickLaunchShortcuts( | 383 void CreateOrUpdateDesktopAndQuickLaunchShortcuts( |
343 const InstallerState& installer_state, | 384 const InstallerState& installer_state, |
344 const Product& product, | 385 const Product& product, |
345 uint32 options) { | 386 uint32 options) { |
346 // TODO(tommi): Change this function to use WorkItemList. | 387 // TODO(tommi): Change this function to use WorkItemList. |
347 DCHECK(product.is_chrome()); | 388 DCHECK(product.is_chrome()); |
348 | 389 |
349 // Information used for all shortcut types | 390 // Information used for all shortcut types |
350 BrowserDistribution* browser_dist = product.distribution(); | 391 BrowserDistribution* browser_dist = product.distribution(); |
351 const string16 product_name(browser_dist->GetAppShortCutName()); | 392 const string16 product_name(browser_dist->GetAppShortCutName()); |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
546 installer_state.RemoveOldVersionDirectories( | 587 installer_state.RemoveOldVersionDirectories( |
547 new_version, | 588 new_version, |
548 existing_version.get(), | 589 existing_version.get(), |
549 install_temp_path); | 590 install_temp_path); |
550 } | 591 } |
551 | 592 |
552 return result; | 593 return result; |
553 } | 594 } |
554 | 595 |
555 } // namespace installer | 596 } // namespace installer |
OLD | NEW |