Chromium Code Reviews| 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 <windows.h> | 7 #include <windows.h> |
| 8 #include <shlobj.h> | 8 #include <shlobj.h> |
| 9 #include <time.h> | 9 #include <time.h> |
| 10 #include <winuser.h> | 10 #include <winuser.h> |
| (...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 367 << " to " << src_path.value(); | 367 << " to " << src_path.value(); |
| 368 return true; | 368 return true; |
| 369 } else { | 369 } else { |
| 370 PLOG(ERROR) << "Error writing " << installer::kVisualElementsManifest | 370 PLOG(ERROR) << "Error writing " << installer::kVisualElementsManifest |
| 371 << " to " << src_path.value(); | 371 << " to " << src_path.value(); |
| 372 return false; | 372 return false; |
| 373 } | 373 } |
| 374 } | 374 } |
| 375 } | 375 } |
| 376 | 376 |
| 377 // TODO(tommi): Change this function to use WorkItemList. | 377 // TODO(tommi): Change this function to use WorkItemList. |
|
robertshield
2012/12/10 20:58:28
since we don't generally roll back on failure, you
gab
2012/12/10 21:50:32
Done.
| |
| 378 void CreateOrUpdateShortcuts( | 378 void CreateOrUpdateShortcuts( |
| 379 const FilePath& target, | 379 const FilePath& target, |
| 380 const Product& product, | 380 const Product& product, |
| 381 const MasterPreferences& prefs, | 381 const MasterPreferences& prefs, |
| 382 InstallShortcutLevel install_level, | 382 InstallShortcutLevel install_level, |
| 383 InstallShortcutOperation install_operation) { | 383 InstallShortcutOperation install_operation) { |
| 384 // Extract shortcut preferences from |prefs|. | 384 // Extract shortcut preferences from |prefs|. |
| 385 bool do_not_create_desktop_shortcut = false; | 385 bool do_not_create_desktop_shortcut = false; |
| 386 bool do_not_create_quick_launch_shortcut = false; | 386 bool do_not_create_quick_launch_shortcut = false; |
| 387 bool alternate_desktop_shortcut = false; | 387 bool alternate_desktop_shortcut = false; |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 435 shortcut_operation == ShellUtil::SHELL_SHORTCUT_REPLACE_EXISTING) { | 435 shortcut_operation == ShellUtil::SHELL_SHORTCUT_REPLACE_EXISTING) { |
| 436 desktop_properties.set_shortcut_name(dist->GetAlternateApplicationName()); | 436 desktop_properties.set_shortcut_name(dist->GetAlternateApplicationName()); |
| 437 ExecuteAndLogShortcutOperation( | 437 ExecuteAndLogShortcutOperation( |
| 438 ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist, desktop_properties, | 438 ShellUtil::SHORTCUT_LOCATION_DESKTOP, dist, desktop_properties, |
| 439 shortcut_operation); | 439 shortcut_operation); |
| 440 } | 440 } |
| 441 } | 441 } |
| 442 | 442 |
| 443 if (!do_not_create_quick_launch_shortcut || | 443 if (!do_not_create_quick_launch_shortcut || |
| 444 shortcut_operation == ShellUtil::SHELL_SHORTCUT_REPLACE_EXISTING) { | 444 shortcut_operation == ShellUtil::SHELL_SHORTCUT_REPLACE_EXISTING) { |
| 445 // There is no such thing as an all-users Quick Launch shortcut, always | |
| 446 // install the per-user shortcut. | |
| 447 ShellUtil::ShortcutProperties quick_launch_properties(base_properties); | |
| 448 quick_launch_properties.level = ShellUtil::CURRENT_USER; | |
| 445 ExecuteAndLogShortcutOperation( | 449 ExecuteAndLogShortcutOperation( |
| 446 ShellUtil::SHORTCUT_LOCATION_QUICK_LAUNCH, dist, base_properties, | 450 ShellUtil::SHORTCUT_LOCATION_QUICK_LAUNCH, dist, |
| 447 shortcut_operation); | 451 quick_launch_properties, shortcut_operation); |
| 448 } | 452 } |
| 449 | 453 |
| 450 ShellUtil::ShortcutProperties start_menu_properties(base_properties); | 454 ShellUtil::ShortcutProperties start_menu_properties(base_properties); |
| 451 // IMPORTANT: Only the default (no arguments and default browserappid) browser | 455 // IMPORTANT: Only the default (no arguments and default browserappid) browser |
| 452 // shortcut in the Start menu (Start screen on Win8+) should be made dual | 456 // shortcut in the Start menu (Start screen on Win8+) should be made dual |
| 453 // mode. | 457 // mode. |
| 454 start_menu_properties.set_dual_mode(true); | 458 start_menu_properties.set_dual_mode(true); |
| 455 if (shortcut_operation == ShellUtil::SHELL_SHORTCUT_CREATE_ALWAYS || | 459 if (shortcut_operation == ShellUtil::SHELL_SHORTCUT_CREATE_ALWAYS || |
| 456 shortcut_operation == | 460 shortcut_operation == |
| 457 ShellUtil::SHELL_SHORTCUT_CREATE_IF_NO_SYSTEM_LEVEL) { | 461 ShellUtil::SHELL_SHORTCUT_CREATE_IF_NO_SYSTEM_LEVEL) { |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 564 | 568 |
| 565 const Product* chrome_product = | 569 const Product* chrome_product = |
| 566 installer_state.FindProduct(BrowserDistribution::CHROME_BROWSER); | 570 installer_state.FindProduct(BrowserDistribution::CHROME_BROWSER); |
| 567 // Creates shortcuts for Chrome. | 571 // Creates shortcuts for Chrome. |
| 568 if (chrome_product) { | 572 if (chrome_product) { |
| 569 BrowserDistribution* dist = chrome_product->distribution(); | 573 BrowserDistribution* dist = chrome_product->distribution(); |
| 570 const FilePath chrome_exe( | 574 const FilePath chrome_exe( |
| 571 installer_state.target_path().Append(kChromeExe)); | 575 installer_state.target_path().Append(kChromeExe)); |
| 572 CleanupLegacyShortcuts(installer_state, dist, chrome_exe); | 576 CleanupLegacyShortcuts(installer_state, dist, chrome_exe); |
| 573 | 577 |
| 578 // Install per-user shortcuts on user-level installs and all-users | |
| 579 // shortcuts on system-level installs. Note that Active Setup will take | |
| 580 // care of installing missing per-user shortcuts on system-level install | |
| 581 // (i.e., quick launch, taskbar pin, and possibly deleted all-users | |
| 582 // shortcuts). | |
| 583 InstallShortcutLevel install_level = installer_state.system_install() ? | |
| 584 ALL_USERS : CURRENT_USER; | |
| 585 | |
| 574 InstallShortcutOperation install_operation = | 586 InstallShortcutOperation install_operation = |
| 575 INSTALL_SHORTCUT_REPLACE_EXISTING; | 587 INSTALL_SHORTCUT_REPLACE_EXISTING; |
| 576 if (result == installer::FIRST_INSTALL_SUCCESS || | 588 if (result == installer::FIRST_INSTALL_SUCCESS || |
| 577 result == installer::INSTALL_REPAIRED) { | 589 result == installer::INSTALL_REPAIRED) { |
| 578 install_operation = INSTALL_SHORTCUT_CREATE_ALL; | 590 install_operation = INSTALL_SHORTCUT_CREATE_ALL; |
| 579 } | 591 } |
| 580 | 592 |
| 581 if (installer_state.system_install()) { | 593 CreateOrUpdateShortcuts(chrome_exe, *chrome_product, prefs, install_level, |
| 582 // Update existing all-users shortcuts for legacy installs. | |
| 583 CreateOrUpdateShortcuts(chrome_exe, *chrome_product, prefs, ALL_USERS, | |
| 584 INSTALL_SHORTCUT_REPLACE_EXISTING); | |
| 585 } | |
| 586 // Always install per-user shortcuts (even on system-level installs where | |
| 587 // we do so for the installing user instead of waiting for Active Setup). | |
| 588 CreateOrUpdateShortcuts(chrome_exe, *chrome_product, prefs, CURRENT_USER, | |
| 589 install_operation); | 594 install_operation); |
| 590 } | 595 } |
| 591 | 596 |
| 592 if (chrome_product) { | 597 if (chrome_product) { |
| 593 // Register Chrome and, if requested, make Chrome the default browser. | 598 // Register Chrome and, if requested, make Chrome the default browser. |
| 594 installer_state.UpdateStage(installer::REGISTERING_CHROME); | 599 installer_state.UpdateStage(installer::REGISTERING_CHROME); |
| 595 | 600 |
| 596 bool make_chrome_default = false; | 601 bool make_chrome_default = false; |
| 597 prefs.GetBool(master_preferences::kMakeChromeDefault, | 602 prefs.GetBool(master_preferences::kMakeChromeDefault, |
| 598 &make_chrome_default); | 603 &make_chrome_default); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 645 // Upon upgrading to Windows 8, we need to fix Chrome shortcuts and register | 650 // Upon upgrading to Windows 8, we need to fix Chrome shortcuts and register |
| 646 // Chrome, so that Metro Chrome would work if Chrome is the default browser. | 651 // Chrome, so that Metro Chrome would work if Chrome is the default browser. |
| 647 if (base::win::GetVersion() >= base::win::VERSION_WIN8) { | 652 if (base::win::GetVersion() >= base::win::VERSION_WIN8) { |
| 648 VLOG(1) << "Updating and registering shortcuts."; | 653 VLOG(1) << "Updating and registering shortcuts."; |
| 649 // Read master_preferences copied beside chrome.exe at install. | 654 // Read master_preferences copied beside chrome.exe at install. |
| 650 MasterPreferences prefs( | 655 MasterPreferences prefs( |
| 651 installer_state.target_path().AppendASCII(kDefaultMasterPrefs)); | 656 installer_state.target_path().AppendASCII(kDefaultMasterPrefs)); |
| 652 | 657 |
| 653 // Unfortunately, if this is a system-level install, we can't update the | 658 // Unfortunately, if this is a system-level install, we can't update the |
| 654 // shortcuts of each individual user (this only matters if this is an OS | 659 // shortcuts of each individual user (this only matters if this is an OS |
| 655 // upgrade for XP/Vista to Win7+ as some properties are only set on | 660 // upgrade from XP/Vista to Win7+ as some properties are only set on |
| 656 // shortcuts as of Win7). | 661 // shortcuts as of Win7). |
| 657 // At least attempt to update potentially existing all-users shortcuts. | 662 // At least attempt to update potentially existing all-users shortcuts. |
| 658 InstallShortcutLevel level = installer_state.system_install() ? | 663 InstallShortcutLevel level = installer_state.system_install() ? |
| 659 ALL_USERS : CURRENT_USER; | 664 ALL_USERS : CURRENT_USER; |
| 660 FilePath chrome_exe(installer_state.target_path().Append(kChromeExe)); | 665 FilePath chrome_exe(installer_state.target_path().Append(kChromeExe)); |
| 661 CreateOrUpdateShortcuts( | 666 CreateOrUpdateShortcuts( |
| 662 chrome_exe, chrome, prefs, level, INSTALL_SHORTCUT_REPLACE_EXISTING); | 667 chrome_exe, chrome, prefs, level, INSTALL_SHORTCUT_REPLACE_EXISTING); |
| 663 RegisterChromeOnMachine(installer_state, chrome, false); | 668 RegisterChromeOnMachine(installer_state, chrome, false); |
| 664 } | 669 } |
| 665 } | 670 } |
| 666 | 671 |
| 667 // NOTE: Should the work done here, on Active Setup, change: kActiveSetupVersion | 672 // NOTE: Should the work done here, on Active Setup, change: kActiveSetupVersion |
| 668 // in install_worker.cc needs to be increased for Active Setup to invoke this | 673 // in install_worker.cc needs to be increased for Active Setup to invoke this |
| 669 // again for all users of this install. | 674 // again for all users of this install. |
| 670 void HandleActiveSetupForBrowser(const FilePath& installation_root, | 675 void HandleActiveSetupForBrowser(const FilePath& installation_root, |
| 671 const Product& chrome, | 676 const Product& chrome, |
| 672 bool force) { | 677 bool force) { |
| 673 DCHECK(chrome.is_chrome()); | 678 DCHECK(chrome.is_chrome()); |
| 674 // Only create shortcuts on Active Setup if the first run sentinel is not | 679 // Only create shortcuts on Active Setup if the first run sentinel is not |
| 675 // present for this user (as some shortcuts used to be installed on first | 680 // present for this user (as some shortcuts used to be installed on first |
| 676 // run and this could otherwise re-install shortcuts for users that have | 681 // run and this could otherwise re-install shortcuts for users that have |
| 677 // already deleted them in the past). | 682 // already deleted them in the past). |
| 678 FilePath first_run_sentinel; | 683 FilePath first_run_sentinel; |
| 679 InstallUtil::GetSentinelFilePath( | 684 InstallUtil::GetSentinelFilePath( |
| 680 chrome::kFirstRunSentinel, chrome.distribution(), &first_run_sentinel); | 685 chrome::kFirstRunSentinel, chrome.distribution(), &first_run_sentinel); |
| 686 // Decide whether to create the shortcuts or simply replace existing | |
| 687 // shortcuts; if the decision is to create them, only shortcuts whose matching | |
| 688 // all-users shortcut isn't present on the system will be created. | |
| 681 InstallShortcutOperation install_operation = | 689 InstallShortcutOperation install_operation = |
| 682 (!force && file_util::PathExists(first_run_sentinel) ? | 690 (!force && file_util::PathExists(first_run_sentinel) ? |
| 683 INSTALL_SHORTCUT_REPLACE_EXISTING : | 691 INSTALL_SHORTCUT_REPLACE_EXISTING : |
| 684 INSTALL_SHORTCUT_CREATE_EACH_IF_NO_SYSTEM_LEVEL); | 692 INSTALL_SHORTCUT_CREATE_EACH_IF_NO_SYSTEM_LEVEL); |
| 685 | 693 |
| 686 // Read master_preferences copied beside chrome.exe at install. | 694 // Read master_preferences copied beside chrome.exe at install. |
| 687 MasterPreferences prefs(installation_root.AppendASCII(kDefaultMasterPrefs)); | 695 MasterPreferences prefs(installation_root.AppendASCII(kDefaultMasterPrefs)); |
| 688 FilePath chrome_exe(installation_root.Append(kChromeExe)); | 696 FilePath chrome_exe(installation_root.Append(kChromeExe)); |
| 689 CreateOrUpdateShortcuts( | 697 CreateOrUpdateShortcuts( |
| 690 chrome_exe, chrome, prefs, CURRENT_USER, install_operation); | 698 chrome_exe, chrome, prefs, CURRENT_USER, install_operation); |
| 691 } | 699 } |
| 692 | 700 |
| 693 } // namespace installer | 701 } // namespace installer |
| OLD | NEW |