| 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 |
| 11 #include <string> |
| 12 |
| 11 #include "base/command_line.h" | 13 #include "base/command_line.h" |
| 12 #include "base/file_path.h" | 14 #include "base/file_path.h" |
| 13 #include "base/file_util.h" | 15 #include "base/file_util.h" |
| 14 #include "base/logging.h" | 16 #include "base/logging.h" |
| 15 #include "base/memory/scoped_ptr.h" | 17 #include "base/memory/scoped_ptr.h" |
| 16 #include "base/path_service.h" | 18 #include "base/path_service.h" |
| 17 #include "base/string_util.h" | 19 #include "base/string_util.h" |
| 18 #include "base/stringprintf.h" | 20 #include "base/stringprintf.h" |
| 19 #include "base/utf_string_conversions.h" | 21 #include "base/utf_string_conversions.h" |
| 20 #include "base/win/shortcut.h" | 22 #include "base/win/shortcut.h" |
| 21 #include "base/win/windows_version.h" | 23 #include "base/win/windows_version.h" |
| 22 #include "chrome/common/chrome_constants.h" | 24 #include "chrome/common/chrome_constants.h" |
| 23 #include "chrome/installer/setup/setup_constants.h" | 25 #include "chrome/installer/setup/setup_constants.h" |
| 24 #include "chrome/installer/setup/install_worker.h" | 26 #include "chrome/installer/setup/install_worker.h" |
| 25 #include "chrome/installer/util/auto_launch_util.h" | 27 #include "chrome/installer/util/auto_launch_util.h" |
| 26 #include "chrome/installer/util/browser_distribution.h" | 28 #include "chrome/installer/util/browser_distribution.h" |
| 27 #include "chrome/installer/util/create_reg_key_work_item.h" | 29 #include "chrome/installer/util/create_reg_key_work_item.h" |
| 28 #include "chrome/installer/util/delete_after_reboot_helper.h" | 30 #include "chrome/installer/util/delete_after_reboot_helper.h" |
| 29 #include "chrome/installer/util/google_update_constants.h" | 31 #include "chrome/installer/util/google_update_constants.h" |
| 30 #include "chrome/installer/util/helper.h" | 32 #include "chrome/installer/util/helper.h" |
| 31 #include "chrome/installer/util/install_util.h" | 33 #include "chrome/installer/util/install_util.h" |
| 34 #include "chrome/installer/util/master_preferences.h" |
| 32 #include "chrome/installer/util/master_preferences_constants.h" | 35 #include "chrome/installer/util/master_preferences_constants.h" |
| 33 #include "chrome/installer/util/set_reg_value_work_item.h" | 36 #include "chrome/installer/util/set_reg_value_work_item.h" |
| 34 #include "chrome/installer/util/shell_util.h" | 37 #include "chrome/installer/util/shell_util.h" |
| 38 #include "chrome/installer/util/util_constants.h" |
| 35 #include "chrome/installer/util/work_item_list.h" | 39 #include "chrome/installer/util/work_item_list.h" |
| 36 | 40 |
| 37 // Build-time generated include file. | 41 // Build-time generated include file. |
| 38 #include "registered_dlls.h" // NOLINT | 42 #include "registered_dlls.h" // NOLINT |
| 39 | 43 |
| 40 using installer::InstallerState; | 44 using installer::InstallerState; |
| 41 using installer::InstallationState; | 45 using installer::InstallationState; |
| 42 using installer::Product; | 46 using installer::Product; |
| 43 | 47 |
| 44 namespace { | 48 namespace { |
| 45 | 49 |
| 50 void LogShortcutOperation(ShellUtil::ChromeShortcutLocation location, |
| 51 BrowserDistribution* dist, |
| 52 const ShellUtil::ChromeShortcutProperties& properties, |
| 53 ShellUtil::ChromeShortcutOperation operation, |
| 54 bool failed) { |
| 55 // SHORTCUT_UPDATE_EXISTING should not be used at install and thus this method |
| 56 // does not handle logging a message for it. |
| 57 DCHECK(operation != ShellUtil::SHORTCUT_UPDATE_EXISTING); |
| 58 std::string message; |
| 59 if (failed) |
| 60 message.append("Failed: "); |
| 61 message.append(operation == ShellUtil::SHORTCUT_CREATE_ALWAYS ? |
| 62 "Creating " : "Overwriting "); |
| 63 if (failed && operation == ShellUtil::SHORTCUT_REPLACE_EXISTING) |
| 64 message.append("(maybe the shortcut doesn't exist?) "); |
| 65 message.append((properties.level == ShellUtil::CURRENT_USER) ? "per-user " : |
| 66 "all-users "); |
| 67 switch (location) { |
| 68 case ShellUtil::SHORTCUT_DESKTOP: |
| 69 message.append("Desktop "); |
| 70 break; |
| 71 case ShellUtil::SHORTCUT_QUICK_LAUNCH: |
| 72 message.append("Quick Launch "); |
| 73 break; |
| 74 case ShellUtil::SHORTCUT_START_MENU: |
| 75 message.append("Start menu "); |
| 76 break; |
| 77 default: |
| 78 NOTREACHED(); |
| 79 } |
| 80 |
| 81 message.push_back('"'); |
| 82 if (properties.options & |
| 83 ShellUtil::ChromeShortcutProperties::PROPERTIES_SHORTCUT_NAME) { |
| 84 message.append(UTF16ToUTF8(properties.shortcut_name)); |
| 85 } else { |
| 86 message.append(UTF16ToUTF8(dist->GetAppShortCutName())); |
| 87 } |
| 88 message.push_back('"'); |
| 89 |
| 90 message.append(" shortcut to "); |
| 91 message.append(UTF16ToUTF8(properties.chrome_exe.value())); |
| 92 if (properties.options & |
| 93 ShellUtil::ChromeShortcutProperties::PROPERTIES_ARGUMENTS) { |
| 94 message.append(UTF16ToUTF8(properties.arguments)); |
| 95 } |
| 96 |
| 97 if (properties.pin_to_taskbar && |
| 98 base::win::GetVersion() >= base::win::VERSION_WIN7) { |
| 99 message.append(" and pinning to the taskbar."); |
| 100 } else { |
| 101 message.push_back('.'); |
| 102 } |
| 103 |
| 104 if (failed) |
| 105 LOG(WARNING) << message; |
| 106 else |
| 107 VLOG(1) << message; |
| 108 } |
| 109 |
| 110 void ExecuteAndLogShortcutOperation( |
| 111 ShellUtil::ChromeShortcutLocation location, |
| 112 BrowserDistribution* dist, |
| 113 const ShellUtil::ChromeShortcutProperties& properties, |
| 114 ShellUtil::ChromeShortcutOperation operation) { |
| 115 LogShortcutOperation(location, dist, properties, operation, false); |
| 116 if (!ShellUtil::CreateOrUpdateChromeShortcut(location, dist, properties, |
| 117 operation)) { |
| 118 LogShortcutOperation(location, dist, properties, operation, true); |
| 119 } |
| 120 } |
| 121 |
| 46 void AddChromeToMediaPlayerList() { | 122 void AddChromeToMediaPlayerList() { |
| 47 string16 reg_path(installer::kMediaPlayerRegPath); | 123 string16 reg_path(installer::kMediaPlayerRegPath); |
| 48 // registry paths can also be appended like file system path | 124 // registry paths can also be appended like file system path |
| 49 reg_path.push_back(FilePath::kSeparators[0]); | 125 reg_path.push_back(FilePath::kSeparators[0]); |
| 50 reg_path.append(installer::kChromeExe); | 126 reg_path.append(installer::kChromeExe); |
| 51 VLOG(1) << "Adding Chrome to Media player list at " << reg_path; | 127 VLOG(1) << "Adding Chrome to Media player list at " << reg_path; |
| 52 scoped_ptr<WorkItem> work_item(WorkItem::CreateCreateRegKeyWorkItem( | 128 scoped_ptr<WorkItem> work_item(WorkItem::CreateCreateRegKeyWorkItem( |
| 53 HKEY_LOCAL_MACHINE, reg_path)); | 129 HKEY_LOCAL_MACHINE, reg_path)); |
| 54 | 130 |
| 55 // if the operation fails we log the error but still continue | 131 // if the operation fails we log the error but still continue |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 << " to " << src_path.value(); | 326 << " to " << src_path.value(); |
| 251 return true; | 327 return true; |
| 252 } else { | 328 } else { |
| 253 PLOG(ERROR) << "Error writing " << installer::kVisualElementsManifest | 329 PLOG(ERROR) << "Error writing " << installer::kVisualElementsManifest |
| 254 << " to " << src_path.value(); | 330 << " to " << src_path.value(); |
| 255 return false; | 331 return false; |
| 256 } | 332 } |
| 257 } | 333 } |
| 258 } | 334 } |
| 259 | 335 |
| 260 void CreateOrUpdateStartMenuAndTaskbarShortcuts( | 336 void CreateOrUpdateShortcuts(const InstallerState& installer_state, |
| 261 const InstallerState& installer_state, | 337 const FilePath& setup_exe, |
| 262 const FilePath& setup_exe, | 338 const Product& product, |
| 263 const Product& product, | 339 InstallShortcutOperation install_operation, |
| 264 uint32 options) { | 340 bool alternate_desktop_shortcut) { |
| 265 // TODO(tommi): Change this function to use WorkItemList. | 341 // TODO(tommi): Change this function to use WorkItemList. |
| 266 DCHECK(product.is_chrome()); | 342 DCHECK(product.is_chrome()); |
| 267 | 343 |
| 268 // Information used for all shortcut types | 344 BrowserDistribution* dist = product.distribution(); |
| 269 BrowserDistribution* browser_dist = product.distribution(); | 345 const FilePath chrome_exe( |
| 270 const string16 product_name(browser_dist->GetAppShortCutName()); | |
| 271 const string16 product_desc(browser_dist->GetAppDescription()); | |
| 272 // Chrome link target | |
| 273 FilePath chrome_exe( | |
| 274 installer_state.target_path().Append(installer::kChromeExe)); | 346 installer_state.target_path().Append(installer::kChromeExe)); |
| 347 ShellUtil::ShellChange install_level = |
| 348 installer_state.system_install() ? ShellUtil::SYSTEM_LEVEL : |
| 349 ShellUtil::CURRENT_USER; |
| 275 | 350 |
| 276 bool create_always = ((options & ShellUtil::SHORTCUT_CREATE_ALWAYS) != 0); | 351 // The default operation on update is to overwrite shortcuts with the |
| 277 const char* operation = create_always ? "Creating" : "Updating"; | 352 // currently desired properties, but do so only for shortcuts that still |
| 353 // exist. |
| 354 ShellUtil::ChromeShortcutOperation shortcut_operation = |
| 355 ShellUtil::SHORTCUT_REPLACE_EXISTING; |
| 278 | 356 |
| 279 // Create Start Menu shortcuts. | 357 // |base_properties|: The basic properties to set on every shortcut installed |
| 280 // The location of Start->Programs->Google Chrome folder | 358 // (to be refined on a per-shortcut basis). |
| 281 FilePath start_menu_folder_path; | 359 ShellUtil::ChromeShortcutProperties base_properties(install_level); |
| 282 int dir_enum = installer_state.system_install() ? | 360 base_properties.set_chrome_exe(chrome_exe); |
| 283 base::DIR_COMMON_START_MENU : base::DIR_START_MENU; | 361 base_properties.set_dual_mode(true); |
| 284 if (!PathService::Get(dir_enum, &start_menu_folder_path)) { | 362 |
| 285 LOG(ERROR) << "Failed to get start menu path."; | 363 // If |install_operation| is INSTALL_SHORTCUT_CREATE_ALL, create optional |
| 286 return; | 364 // shortcuts (Desktop and Quick Launch) immediately; otherwise delay their |
| 365 // creation until first run. |
| 366 if (install_operation == INSTALL_SHORTCUT_CREATE_ALL) |
| 367 shortcut_operation = ShellUtil::SHORTCUT_CREATE_ALWAYS; |
| 368 |
| 369 ShellUtil::ChromeShortcutProperties desktop_properties(base_properties); |
| 370 if (alternate_desktop_shortcut) |
| 371 desktop_properties.set_shortcut_name(dist->GetAlternateApplicationName()); |
| 372 ExecuteAndLogShortcutOperation( |
| 373 ShellUtil::SHORTCUT_DESKTOP, dist, desktop_properties, |
| 374 shortcut_operation); |
| 375 |
| 376 ExecuteAndLogShortcutOperation( |
| 377 ShellUtil::SHORTCUT_QUICK_LAUNCH, dist, base_properties, |
| 378 shortcut_operation); |
| 379 if (installer_state.system_install() && |
| 380 shortcut_operation == ShellUtil::SHORTCUT_CREATE_ALWAYS) { |
| 381 // On system-level installs, also create the quick launch shortcut for this |
| 382 // user (as the all-users shortcut created is in "Default User" and only |
| 383 // affects new users). |
| 384 ShellUtil::ChromeShortcutProperties user_ql_properties(base_properties); |
| 385 user_ql_properties.level = ShellUtil::CURRENT_USER; |
| 386 ExecuteAndLogShortcutOperation( |
| 387 ShellUtil::SHORTCUT_QUICK_LAUNCH, dist, user_ql_properties, |
| 388 shortcut_operation); |
| 287 } | 389 } |
| 288 | 390 |
| 289 start_menu_folder_path = start_menu_folder_path.Append(product_name); | 391 // Turn on shortcut creation for mandatory shortcuts if requested. |
| 392 if (install_operation == INSTALL_SHORTCUT_CREATE_MANDATORY) |
| 393 shortcut_operation = ShellUtil::SHORTCUT_CREATE_ALWAYS; |
| 290 | 394 |
| 291 // Create/update Chrome link (points to chrome.exe) & Uninstall Chrome link | 395 ShellUtil::ChromeShortcutProperties start_menu_properties(base_properties); |
| 292 // (which points to setup.exe) under |start_menu_folder_path|. | 396 if (shortcut_operation == ShellUtil::SHORTCUT_CREATE_ALWAYS) |
| 397 start_menu_properties.set_pin_to_taskbar(true); |
| 398 ExecuteAndLogShortcutOperation( |
| 399 ShellUtil::SHORTCUT_START_MENU, dist, start_menu_properties, |
| 400 shortcut_operation); |
| 293 | 401 |
| 294 // Chrome link (launches Chrome) | 402 // Create/update uninstall link in the Start menu if we are not an MSI |
| 295 FilePath chrome_link(start_menu_folder_path.Append(product_name + L".lnk")); | 403 // install. MSI installations are, for the time being, managed only through |
| 296 | 404 // the Add/Remove Programs dialog. |
| 297 if (create_always && !file_util::PathExists(start_menu_folder_path)) | |
| 298 file_util::CreateDirectoryW(start_menu_folder_path); | |
| 299 | |
| 300 VLOG(1) << operation << " shortcut to " << chrome_exe.value() << " at " | |
| 301 << chrome_link.value(); | |
| 302 if (!ShellUtil::UpdateChromeShortcut(browser_dist, chrome_exe.value(), | |
| 303 chrome_link.value(), string16(), product_desc, chrome_exe.value(), | |
| 304 browser_dist->GetIconIndex(), options)) { | |
| 305 LOG(WARNING) << operation << " shortcut at " << chrome_link.value() | |
| 306 << " failed."; | |
| 307 } else if (create_always && | |
| 308 base::win::GetVersion() >= base::win::VERSION_WIN7) { | |
| 309 // If the Start Menu shortcut was successfully created and |create_always|, | |
| 310 // proceed to pin the Start Menu shortcut to the taskbar on Win7+. | |
| 311 VLOG(1) << "Pinning new shortcut at " << chrome_link.value() | |
| 312 << " to taskbar"; | |
| 313 if (!base::win::TaskbarPinShortcutLink(chrome_link.value().c_str())) { | |
| 314 LOG(ERROR) << "Failed to pin shortcut to taskbar: " | |
| 315 << chrome_link.value(); | |
| 316 } | |
| 317 } | |
| 318 | |
| 319 // Create/update uninstall link if we are not an MSI install. MSI | |
| 320 // installations are, for the time being, managed only through the | |
| 321 // Add/Remove Programs dialog. | |
| 322 // TODO(robertshield): We could add a shortcut to msiexec /X {GUID} here. | 405 // TODO(robertshield): We could add a shortcut to msiexec /X {GUID} here. |
| 323 if (!installer_state.is_msi()) { | 406 if (!installer_state.is_msi()) { |
| 324 // Uninstall Chrome link | 407 FilePath shortcut_path; |
| 325 FilePath uninstall_link(start_menu_folder_path.Append( | 408 if (!ShellUtil::GetShortcutPath(ShellUtil::SHORTCUT_START_MENU, dist, |
| 326 browser_dist->GetUninstallLinkName() + L".lnk")); | 409 install_level, &shortcut_path)) { |
| 327 | 410 NOTREACHED(); |
| 411 return; |
| 412 } |
| 413 shortcut_path = shortcut_path.Append(dist->GetUninstallLinkName() + |
| 414 kLnkExt); |
| 328 CommandLine arguments(CommandLine::NO_PROGRAM); | 415 CommandLine arguments(CommandLine::NO_PROGRAM); |
| 329 AppendUninstallCommandLineFlags(installer_state, product, &arguments); | 416 AppendUninstallCommandLineFlags(installer_state, product, &arguments); |
| 330 VLOG(1) << operation << " uninstall link at " << uninstall_link.value(); | 417 |
| 331 base::win::ShortcutProperties shortcut_properties; | 418 base::win::ShortcutProperties uninstall_properties; |
| 332 shortcut_properties.set_target(setup_exe); | 419 uninstall_properties.set_target(setup_exe); |
| 333 shortcut_properties.set_arguments(arguments.GetCommandLineString()); | 420 uninstall_properties.set_arguments(arguments.GetCommandLineString()); |
| 334 shortcut_properties.set_icon(setup_exe, 0); | 421 base::win::ShortcutOperation uninstall_operation = |
| 422 (shortcut_operation == ShellUtil::SHORTCUT_CREATE_ALWAYS ? |
| 423 base::win::SHORTCUT_CREATE_ALWAYS : |
| 424 base::win::SHORTCUT_REPLACE_EXISTING); |
| 425 const char* operation_str = |
| 426 (uninstall_operation == base::win::SHORTCUT_CREATE_ALWAYS ? |
| 427 "Creating" : "Updating"); |
| 428 VLOG(1) << operation_str << " uninstall link at " << shortcut_path.value(); |
| 335 if (!base::win::CreateOrUpdateShortcutLink( | 429 if (!base::win::CreateOrUpdateShortcutLink( |
| 336 uninstall_link, shortcut_properties, | 430 shortcut_path, uninstall_properties, uninstall_operation)) { |
| 337 create_always ? base::win::SHORTCUT_CREATE_ALWAYS : | 431 LOG(WARNING) << operation_str << " uninstall link failed."; |
| 338 base::win::SHORTCUT_UPDATE_EXISTING)) { | |
| 339 LOG(WARNING) << operation << " uninstall link at " | |
| 340 << uninstall_link.value() << " failed."; | |
| 341 } | 432 } |
| 342 } | 433 } |
| 343 } | 434 } |
| 344 | 435 |
| 345 void CreateOrUpdateDesktopAndQuickLaunchShortcuts( | |
| 346 const InstallerState& installer_state, | |
| 347 const Product& product, | |
| 348 uint32 options) { | |
| 349 // TODO(tommi): Change this function to use WorkItemList. | |
| 350 DCHECK(product.is_chrome()); | |
| 351 | |
| 352 // Information used for all shortcut types | |
| 353 BrowserDistribution* browser_dist = product.distribution(); | |
| 354 const string16 product_name(browser_dist->GetAppShortCutName()); | |
| 355 const string16 product_desc(browser_dist->GetAppDescription()); | |
| 356 // Chrome link target | |
| 357 FilePath chrome_exe( | |
| 358 installer_state.target_path().Append(installer::kChromeExe)); | |
| 359 | |
| 360 bool create_always = ((options & ShellUtil::SHORTCUT_CREATE_ALWAYS) != 0); | |
| 361 const char* operation = create_always ? "Creating" : "Updating"; | |
| 362 | |
| 363 ShellUtil::ShellChange desktop_level = ShellUtil::CURRENT_USER; | |
| 364 int quick_launch_levels = ShellUtil::CURRENT_USER; | |
| 365 if (installer_state.system_install()) { | |
| 366 desktop_level = ShellUtil::SYSTEM_LEVEL; | |
| 367 quick_launch_levels |= ShellUtil::SYSTEM_LEVEL; | |
| 368 } | |
| 369 | |
| 370 VLOG(1) << operation << " desktop shortcut for " << chrome_exe.value(); | |
| 371 if (!ShellUtil::CreateChromeDesktopShortcut( | |
| 372 browser_dist, chrome_exe.value(), product_desc, string16(), | |
| 373 string16(), chrome_exe.value(), browser_dist->GetIconIndex(), | |
| 374 desktop_level, options)) { | |
| 375 LOG(WARNING) << operation << " desktop shortcut for " << chrome_exe.value() | |
| 376 << " failed."; | |
| 377 } | |
| 378 | |
| 379 VLOG(1) << operation << " quick launch shortcut for " << chrome_exe.value(); | |
| 380 if (!ShellUtil::CreateChromeQuickLaunchShortcut( | |
| 381 browser_dist, chrome_exe.value(), quick_launch_levels, options)) { | |
| 382 LOG(WARNING) << operation << " quick launch shortcut for " | |
| 383 << chrome_exe.value() << " failed."; | |
| 384 } | |
| 385 } | |
| 386 | |
| 387 void RegisterChromeOnMachine(const InstallerState& installer_state, | 436 void RegisterChromeOnMachine(const InstallerState& installer_state, |
| 388 const Product& product, | 437 const Product& product, |
| 389 bool make_chrome_default) { | 438 bool make_chrome_default) { |
| 390 DCHECK(product.is_chrome()); | 439 DCHECK(product.is_chrome()); |
| 391 | 440 |
| 392 // Try to add Chrome to Media Player shim inclusion list. We don't do any | 441 // Try to add Chrome to Media Player shim inclusion list. We don't do any |
| 393 // error checking here because this operation will fail if user doesn't | 442 // error checking here because this operation will fail if user doesn't |
| 394 // have admin rights and we want to ignore the error. | 443 // have admin rights and we want to ignore the error. |
| 395 AddChromeToMediaPlayerList(); | 444 AddChromeToMediaPlayerList(); |
| 396 | 445 |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 472 const Product* chrome_install = | 521 const Product* chrome_install = |
| 473 installer_state.FindProduct(BrowserDistribution::CHROME_BROWSER); | 522 installer_state.FindProduct(BrowserDistribution::CHROME_BROWSER); |
| 474 if (chrome_install) { | 523 if (chrome_install) { |
| 475 installer_state.UpdateStage(installer::CREATING_SHORTCUTS); | 524 installer_state.UpdateStage(installer::CREATING_SHORTCUTS); |
| 476 | 525 |
| 477 bool create_all_shortcuts = false; | 526 bool create_all_shortcuts = false; |
| 478 prefs.GetBool(master_preferences::kCreateAllShortcuts, | 527 prefs.GetBool(master_preferences::kCreateAllShortcuts, |
| 479 &create_all_shortcuts); | 528 &create_all_shortcuts); |
| 480 bool alt_shortcut = false; | 529 bool alt_shortcut = false; |
| 481 prefs.GetBool(master_preferences::kAltShortcutText, &alt_shortcut); | 530 prefs.GetBool(master_preferences::kAltShortcutText, &alt_shortcut); |
| 482 // The DUAL_MODE property is technically only needed on the Start Screen | |
| 483 // shortcut on Win8, but we set it on all shortcuts so that pinning any | |
| 484 // of the shortcuts to the Start Screen results in a shortcut with | |
| 485 // Metro properties. | |
| 486 uint32 shortcut_options = ShellUtil::SHORTCUT_DUAL_MODE; | |
| 487 // Handle Desktop and Quick Launch shortcuts creation. | |
| 488 // If --create-all-shortcuts is specified, create them immediately; | |
| 489 // otherwise delay their creation until first run (if they already exist, | |
| 490 // (i.e. on update) update them). | |
| 491 if (create_all_shortcuts) | |
| 492 shortcut_options |= ShellUtil::SHORTCUT_CREATE_ALWAYS; | |
| 493 // Use the alternate name for the Desktop shortcut if indicated. | |
| 494 if (alt_shortcut) | |
| 495 shortcut_options |= ShellUtil::SHORTCUT_ALTERNATE; | |
| 496 CreateOrUpdateDesktopAndQuickLaunchShortcuts( | |
| 497 installer_state, *chrome_install, shortcut_options); | |
| 498 | 531 |
| 499 if (result == installer::FIRST_INSTALL_SUCCESS || | 532 InstallShortcutOperation install_operation = |
| 500 result == installer::INSTALL_REPAIRED) { | 533 INSTALL_SHORTCUT_REPLACE_EXISTING; |
| 501 // On new installs and repaired installs, always create Start Menu | 534 if (create_all_shortcuts) { |
| 502 // and taskbar shortcuts (i.e. even if they were previously deleted by | 535 install_operation = INSTALL_SHORTCUT_CREATE_ALL; |
| 503 // the user). | 536 } else if (result == installer::FIRST_INSTALL_SUCCESS || |
| 504 shortcut_options |= ShellUtil::SHORTCUT_CREATE_ALWAYS; | 537 result == installer::INSTALL_REPAIRED) { |
| 538 // On new and repaired installs, always create Start Menu, taskbar, and |
| 539 // uninstall shortcuts (i.e. even if they were previously deleted by the |
| 540 // user). |
| 541 install_operation = INSTALL_SHORTCUT_CREATE_MANDATORY; |
| 505 } | 542 } |
| 543 |
| 506 FilePath setup_exe(installer_state.GetInstallerDirectory(new_version) | 544 FilePath setup_exe(installer_state.GetInstallerDirectory(new_version) |
| 507 .Append(setup_path.BaseName())); | 545 .Append(setup_path.BaseName())); |
| 508 CreateOrUpdateStartMenuAndTaskbarShortcuts( | 546 CreateOrUpdateShortcuts(installer_state, setup_exe, *chrome_install, |
| 509 installer_state, setup_exe, *chrome_install, shortcut_options); | 547 install_operation, alt_shortcut); |
| 510 | 548 |
| 511 bool make_chrome_default = false; | 549 bool make_chrome_default = false; |
| 512 prefs.GetBool(master_preferences::kMakeChromeDefault, | 550 prefs.GetBool(master_preferences::kMakeChromeDefault, |
| 513 &make_chrome_default); | 551 &make_chrome_default); |
| 514 | 552 |
| 515 // If this is not the user's first Chrome install, but they have chosen | 553 // If this is not the user's first Chrome install, but they have chosen |
| 516 // Chrome to become their default browser on the download page, we must | 554 // Chrome to become their default browser on the download page, we must |
| 517 // force it here because the master_preferences file will not get copied | 555 // force it here because the master_preferences file will not get copied |
| 518 // into the build. | 556 // into the build. |
| 519 bool force_chrome_default_for_user = false; | 557 bool force_chrome_default_for_user = false; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 556 } | 594 } |
| 557 | 595 |
| 558 void HandleOsUpgradeForBrowser(const InstallerState& installer_state, | 596 void HandleOsUpgradeForBrowser(const InstallerState& installer_state, |
| 559 const Product& chrome, | 597 const Product& chrome, |
| 560 const FilePath& setup_exe) { | 598 const FilePath& setup_exe) { |
| 561 DCHECK(chrome.is_chrome()); | 599 DCHECK(chrome.is_chrome()); |
| 562 // Upon upgrading to Windows 8, we need to fix Chrome shortcuts and register | 600 // Upon upgrading to Windows 8, we need to fix Chrome shortcuts and register |
| 563 // Chrome, so that Metro Chrome would work if Chrome is the default browser. | 601 // Chrome, so that Metro Chrome would work if Chrome is the default browser. |
| 564 if (base::win::GetVersion() >= base::win::VERSION_WIN8) { | 602 if (base::win::GetVersion() >= base::win::VERSION_WIN8) { |
| 565 VLOG(1) << "Updating and registering shortcuts."; | 603 VLOG(1) << "Updating and registering shortcuts."; |
| 566 uint32 shortcut_options = ShellUtil::SHORTCUT_DUAL_MODE; | 604 CreateOrUpdateShortcuts( |
| 567 CreateOrUpdateDesktopAndQuickLaunchShortcuts( | 605 installer_state, setup_exe, chrome, INSTALL_SHORTCUT_REPLACE_EXISTING, |
| 568 installer_state, chrome, shortcut_options); | 606 false); |
| 569 CreateOrUpdateStartMenuAndTaskbarShortcuts( | |
| 570 installer_state, setup_exe, chrome, shortcut_options); | |
| 571 RegisterChromeOnMachine(installer_state, chrome, false); | 607 RegisterChromeOnMachine(installer_state, chrome, false); |
| 572 } | 608 } |
| 573 } | 609 } |
| 574 | 610 |
| 575 } // namespace installer | 611 } // namespace installer |
| OLD | NEW |