Chromium Code Reviews| Index: chrome/installer/setup/install.cc |
| diff --git a/chrome/installer/setup/install.cc b/chrome/installer/setup/install.cc |
| index b17e0db4cb3679aa5fbbdf0e113961fa0b0b6a56..bfb1eb09e26bd808ad41a5723cbf69efae0d0f11 100644 |
| --- a/chrome/installer/setup/install.cc |
| +++ b/chrome/installer/setup/install.cc |
| @@ -21,11 +21,9 @@ |
| #include "base/strings/stringprintf.h" |
| #include "base/strings/utf_string_conversions.h" |
| #include "base/win/shortcut.h" |
| -#include "base/win/windows_version.h" |
| -#include "chrome/common/chrome_constants.h" |
| -#include "chrome/common/chrome_switches.h" |
| #include "chrome/installer/setup/install_worker.h" |
| #include "chrome/installer/setup/installer_crash_reporting.h" |
| +#include "chrome/installer/setup/installer_state.h" |
| #include "chrome/installer/setup/setup_constants.h" |
| #include "chrome/installer/setup/setup_util.h" |
| #include "chrome/installer/setup/update_active_setup_version_work_item.h" |
| @@ -34,12 +32,10 @@ |
| #include "chrome/installer/util/create_reg_key_work_item.h" |
| #include "chrome/installer/util/delete_after_reboot_helper.h" |
| #include "chrome/installer/util/delete_old_versions.h" |
| -#include "chrome/installer/util/google_update_constants.h" |
| -#include "chrome/installer/util/helper.h" |
| #include "chrome/installer/util/install_util.h" |
| +#include "chrome/installer/util/installation_state.h" |
| #include "chrome/installer/util/master_preferences.h" |
| #include "chrome/installer/util/master_preferences_constants.h" |
| -#include "chrome/installer/util/set_reg_value_work_item.h" |
| #include "chrome/installer/util/util_constants.h" |
| #include "chrome/installer/util/work_item.h" |
| #include "chrome/installer/util/work_item_list.h" |
| @@ -103,10 +99,8 @@ void LogShortcutOperation(ShellUtil::ShortcutLocation location, |
| if (properties.has_arguments()) |
| message.append(base::UTF16ToUTF8(properties.arguments)); |
| - if (properties.pin_to_taskbar && |
| - base::win::GetVersion() >= base::win::VERSION_WIN7) { |
| + if (properties.pin_to_taskbar && base::win::CanPinShortcutToTaskbar()) |
| message.append(" and pinning to the taskbar"); |
| - } |
| message.push_back('.'); |
| @@ -223,10 +217,6 @@ installer::InstallStatus InstallNewVersion( |
| return result; |
| } |
| - installer_state.SetStage(installer::REFRESHING_POLICY); |
| - |
| - installer::RefreshElevationPolicy(); |
|
gab
2016/12/22 19:05:10
This is Chrome Frame stuff, separate CL?
|
| - |
| if (!current_version->get()) { |
| VLOG(1) << "First install of version " << new_version; |
| return installer::FIRST_INSTALL_SUCCESS; |
| @@ -265,7 +255,7 @@ installer::InstallStatus InstallNewVersion( |
| return installer::INSTALL_FAILED; |
| } |
| -} // end namespace |
| +} // namespace |
| namespace installer { |
| @@ -442,8 +432,6 @@ void RegisterChromeOnMachine(const installer::InstallerState& installer_state, |
| const installer::Product& product, |
| bool make_chrome_default, |
| const base::Version& version) { |
| - DCHECK(product.is_chrome()); |
|
gab
2016/12/22 19:05:10
I don't see a change to product.h in this CL? Leav
grt (UTC plus 2)
2017/01/02 10:45:03
While the change to product.h is in https://codere
gab
2017/01/05 22:08:01
I think we should leave the DCHECK while Product h
grt (UTC plus 2)
2017/01/06 10:25:53
Done.
|
| - |
| // Try to add Chrome to Media Player shim inclusion list. We don't do any |
| // error checking here because this operation will fail if user doesn't |
| // have admin rights and we want to ignore the error. |
| @@ -480,8 +468,6 @@ InstallStatus InstallOrUpdateProduct( |
| const base::FilePath& prefs_path, |
| const MasterPreferences& prefs, |
| const base::Version& new_version) { |
| - DCHECK(!installer_state.products().empty()); |
| - |
| // TODO(robertshield): Removing the pending on-reboot moves should be done |
| // elsewhere. |
| // Remove any scheduled MOVEFILE_DELAY_UNTIL_REBOOT entries in the target of |
| @@ -507,8 +493,9 @@ InstallStatus InstallOrUpdateProduct( |
| if (!InstallUtil::GetInstallReturnCode(result)) { |
| installer_state.SetStage(UPDATING_CHANNELS); |
| - // Update the modifiers on the channel values for the product(s) being |
| - // installed and for the binaries in case of multi-install. |
| + // Strip evidence of multi-install from the "ap" value. |
| + // TODO(grt): Consider doing this earlier, prior to any other work, so that |
| + // failed updates benefit from the stripping. |
| installer_state.UpdateChannels(); |
| installer_state.SetStage(COPYING_PREFERENCES_FILE); |
| @@ -518,66 +505,59 @@ InstallStatus InstallOrUpdateProduct( |
| installer_state.SetStage(CREATING_SHORTCUTS); |
| - const installer::Product* chrome_product = |
| - installer_state.FindProduct(BrowserDistribution::CHROME_BROWSER); |
| // Creates shortcuts for Chrome. |
| - if (chrome_product) { |
| - BrowserDistribution* chrome_dist = chrome_product->distribution(); |
| - const base::FilePath chrome_exe( |
| - installer_state.target_path().Append(kChromeExe)); |
| - |
| - // Install per-user shortcuts on user-level installs and all-users |
| - // shortcuts on system-level installs. Note that Active Setup will take |
| - // care of installing missing per-user shortcuts on system-level install |
| - // (i.e., quick launch, taskbar pin, and possibly deleted all-users |
| - // shortcuts). |
| - InstallShortcutLevel install_level = installer_state.system_install() ? |
| - ALL_USERS : CURRENT_USER; |
| - |
| - InstallShortcutOperation install_operation = |
| - INSTALL_SHORTCUT_REPLACE_EXISTING; |
| - if (result == installer::FIRST_INSTALL_SUCCESS || |
| - result == installer::INSTALL_REPAIRED || |
| - !original_state.GetProductState(installer_state.system_install(), |
| - chrome_dist->GetType())) { |
| - // Always create the shortcuts on a new install, a repair install, and |
| - // when the Chrome product is being added to the current install. |
| - install_operation = INSTALL_SHORTCUT_CREATE_ALL; |
| - } |
| - |
| - CreateOrUpdateShortcuts(chrome_exe, *chrome_product, prefs, install_level, |
| - install_operation); |
| + const Product& chrome_product = installer_state.product(); |
|
gab
2016/12/22 19:05:10
I presume InstallerState and Product will eventual
grt (UTC plus 2)
2017/01/02 10:45:03
Yeah, there will be opportunities for further simp
|
| + BrowserDistribution* chrome_dist = chrome_product.distribution(); |
| + const base::FilePath chrome_exe( |
| + installer_state.target_path().Append(kChromeExe)); |
| + |
| + // Install per-user shortcuts on user-level installs and all-users shortcuts |
| + // on system-level installs. Note that Active Setup will take care of |
| + // installing missing per-user shortcuts on system-level install (i.e., |
| + // quick launch, taskbar pin, and possibly deleted all-users shortcuts). |
| + InstallShortcutLevel install_level = |
| + installer_state.system_install() ? ALL_USERS : CURRENT_USER; |
| + |
| + InstallShortcutOperation install_operation = |
| + INSTALL_SHORTCUT_REPLACE_EXISTING; |
| + if (result == installer::FIRST_INSTALL_SUCCESS || |
| + result == installer::INSTALL_REPAIRED || |
| + !original_state.GetProductState(installer_state.system_install(), |
| + chrome_dist->GetType())) { |
| + // Always create the shortcuts on a new install, a repair install, and |
| + // when the Chrome product is being added to the current install. |
| + install_operation = INSTALL_SHORTCUT_CREATE_ALL; |
| } |
| - if (chrome_product) { |
|
gab
2016/12/22 19:05:10
Nice, we had two if (chrome_product) {} blocks in
grt (UTC plus 2)
2017/01/02 10:45:03
Indeed! I laughed at that one, too.
|
| - // Register Chrome and, if requested, make Chrome the default browser. |
| - installer_state.SetStage(REGISTERING_CHROME); |
| - |
| - bool make_chrome_default = false; |
| - prefs.GetBool(master_preferences::kMakeChromeDefault, |
| - &make_chrome_default); |
| - |
| - // If this is not the user's first Chrome install, but they have chosen |
| - // Chrome to become their default browser on the download page, we must |
| - // force it here because the master_preferences file will not get copied |
| - // into the build. |
| - bool force_chrome_default_for_user = false; |
| - if (result == NEW_VERSION_UPDATED || result == INSTALL_REPAIRED || |
| - result == OLD_VERSION_DOWNGRADE || result == IN_USE_DOWNGRADE) { |
| - prefs.GetBool(master_preferences::kMakeChromeDefaultForUser, |
| - &force_chrome_default_for_user); |
| - } |
| - |
| - RegisterChromeOnMachine( |
| - installer_state, *chrome_product, |
| - make_chrome_default || force_chrome_default_for_user, new_version); |
| - |
| - if (!installer_state.system_install()) { |
| - DCHECK_EQ(chrome_product->distribution(), |
| - BrowserDistribution::GetDistribution()); |
| - UpdateDefaultBrowserBeaconForPath( |
| - installer_state.target_path().Append(installer::kChromeExe)); |
| - } |
| + CreateOrUpdateShortcuts(chrome_exe, chrome_product, prefs, install_level, |
| + install_operation); |
| + |
| + // Register Chrome and, if requested, make Chrome the default browser. |
| + installer_state.SetStage(REGISTERING_CHROME); |
| + |
| + bool make_chrome_default = false; |
| + prefs.GetBool(master_preferences::kMakeChromeDefault, &make_chrome_default); |
| + |
| + // If this is not the user's first Chrome install, but they have chosen |
| + // Chrome to become their default browser on the download page, we must |
| + // force it here because the master_preferences file will not get copied |
| + // into the build. |
| + bool force_chrome_default_for_user = false; |
| + if (result == NEW_VERSION_UPDATED || result == INSTALL_REPAIRED || |
| + result == OLD_VERSION_DOWNGRADE || result == IN_USE_DOWNGRADE) { |
| + prefs.GetBool(master_preferences::kMakeChromeDefaultForUser, |
| + &force_chrome_default_for_user); |
| + } |
| + |
| + RegisterChromeOnMachine( |
| + installer_state, chrome_product, |
| + make_chrome_default || force_chrome_default_for_user, new_version); |
| + |
| + if (!installer_state.system_install()) { |
| + DCHECK_EQ(chrome_product.distribution(), |
| + BrowserDistribution::GetDistribution()); |
| + UpdateDefaultBrowserBeaconForPath( |
| + installer_state.target_path().Append(installer::kChromeExe)); |
| } |
| // Delete files that belong to old versions of Chrome. If that fails during |
| @@ -600,17 +580,8 @@ InstallStatus InstallOrUpdateProduct( |
| void LaunchDeleteOldVersionsProcess(const base::FilePath& setup_path, |
| const InstallerState& installer_state) { |
| - // Deleting old versions is relevant if multi-install binaries are being |
| - // updated or if single-install Chrome is. |
| - const Product* product = |
| - installer_state.FindProduct(BrowserDistribution::CHROME_BINARIES); |
| - if (!product) |
| - product = installer_state.FindProduct(BrowserDistribution::CHROME_BROWSER); |
| - if (!product) |
| - return; |
| - |
| base::CommandLine command_line(setup_path); |
| - product->AppendProductFlags(&command_line); |
| + installer_state.product().AppendProductFlags(&command_line); |
| command_line.AppendSwitch(switches::kDeleteOldVersions); |
| if (installer_state.system_install()) |
| @@ -636,8 +607,6 @@ void LaunchDeleteOldVersionsProcess(const base::FilePath& setup_path, |
| void HandleOsUpgradeForBrowser(const installer::InstallerState& installer_state, |
| const installer::Product& chrome, |
| const base::Version& installed_version) { |
| - DCHECK(chrome.is_chrome()); |
| - |
| VLOG(1) << "Updating and registering shortcuts for --on-os-upgrade."; |
| // Read master_preferences copied beside chrome.exe at install. |
| @@ -700,8 +669,6 @@ void HandleOsUpgradeForBrowser(const installer::InstallerState& installer_state, |
| void HandleActiveSetupForBrowser(const base::FilePath& installation_root, |
| const installer::Product& chrome, |
| bool force) { |
| - DCHECK(chrome.is_chrome()); |
| - |
| std::unique_ptr<WorkItemList> cleanup_list(WorkItem::CreateWorkItemList()); |
| cleanup_list->set_log_message("Cleanup deprecated per-user registrations"); |
| cleanup_list->set_rollback_enabled(false); |