| 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 // This is only meant to be called for system-level installs. |
| 352 if (!installer_state.system_install()) { |
| 353 NOTREACHED(); |
| 354 return; |
| 355 } |
| 356 BrowserDistribution* browser_dist = product.distribution(); |
| 357 const string16 product_name(browser_dist->GetAppShortCutName()); |
| 358 const string16 product_desc(browser_dist->GetAppDescription()); |
| 359 const FilePath chrome_exe( |
| 360 installer_state.target_path().Append(installer::kChromeExe)); |
| 361 |
| 362 FilePath user_start_menu; |
| 363 if (!PathService::Get(base::DIR_START_MENU, &user_start_menu)) { |
| 364 LOG(DFATAL) << "Failed to get user-level start menu path."; |
| 365 return; |
| 366 } |
| 367 user_start_menu = user_start_menu.Append(product_name); |
| 368 |
| 369 const FilePath chrome_link( |
| 370 user_start_menu.Append(product_name + L".lnk")); |
| 371 |
| 372 const uint32 options = (ShellUtil::SHORTCUT_CREATE_ALWAYS | |
| 373 ShellUtil::SHORTCUT_DUAL_MODE); |
| 374 |
| 375 VLOG(1) << "Creating shortcut to " << chrome_exe.value() << " at " |
| 376 << chrome_link.value(); |
| 377 if (!file_util::CreateDirectory(user_start_menu) || |
| 378 !ShellUtil::UpdateChromeShortcut(browser_dist, chrome_exe.value(), |
| 379 chrome_link.value(), string16(), product_desc, chrome_exe.value(), |
| 380 browser_dist->GetIconIndex(), options)) { |
| 381 LOG(ERROR) << "Creating shortcut at " << chrome_link.value() << " failed."; |
| 382 } |
| 383 } |
| 384 |
| 342 void CreateOrUpdateDesktopAndQuickLaunchShortcuts( | 385 void CreateOrUpdateDesktopAndQuickLaunchShortcuts( |
| 343 const InstallerState& installer_state, | 386 const InstallerState& installer_state, |
| 344 const Product& product, | 387 const Product& product, |
| 345 uint32 options) { | 388 uint32 options) { |
| 346 // TODO(tommi): Change this function to use WorkItemList. | 389 // TODO(tommi): Change this function to use WorkItemList. |
| 347 DCHECK(product.is_chrome()); | 390 DCHECK(product.is_chrome()); |
| 348 | 391 |
| 349 // Information used for all shortcut types | 392 // Information used for all shortcut types |
| 350 BrowserDistribution* browser_dist = product.distribution(); | 393 BrowserDistribution* browser_dist = product.distribution(); |
| 351 const string16 product_name(browser_dist->GetAppShortCutName()); | 394 const string16 product_name(browser_dist->GetAppShortCutName()); |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 563 uint32 shortcut_options = ShellUtil::SHORTCUT_DUAL_MODE; | 606 uint32 shortcut_options = ShellUtil::SHORTCUT_DUAL_MODE; |
| 564 CreateOrUpdateDesktopAndQuickLaunchShortcuts( | 607 CreateOrUpdateDesktopAndQuickLaunchShortcuts( |
| 565 installer_state, chrome, shortcut_options); | 608 installer_state, chrome, shortcut_options); |
| 566 CreateOrUpdateStartMenuAndTaskbarShortcuts( | 609 CreateOrUpdateStartMenuAndTaskbarShortcuts( |
| 567 installer_state, setup_exe, chrome, shortcut_options); | 610 installer_state, setup_exe, chrome, shortcut_options); |
| 568 RegisterChromeOnMachine(installer_state, chrome, false); | 611 RegisterChromeOnMachine(installer_state, chrome, false); |
| 569 } | 612 } |
| 570 } | 613 } |
| 571 | 614 |
| 572 } // namespace installer | 615 } // namespace installer |
| OLD | NEW |