blob: 6ccdc7b64a7280de0d35ad518093a181b64b29da [file] [log] [blame]
Avi Drissman4a8573c2022-09-09 19:35:541// Copyright 2012 The Chromium Authors
[email protected]bc38c252011-04-12 21:46:572// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
Daniel Cheng7d9e3d52022-02-26 09:03:245#include "chrome/browser/first_run/upgrade_util_win.h"
[email protected]bc38c252011-04-12 21:46:576
Takuto Ikutac8d6b16f2024-04-15 16:59:197#include <objbase.h>
8
[email protected]770c6d82012-09-06 22:21:329#include <windows.h>
Nico Webereaa08412019-08-14 01:24:3710
[email protected]fdbea98d2014-05-16 19:29:2011#include <psapi.h>
[email protected]770c6d82012-09-06 22:21:3212#include <shellapi.h>
Robert Liaob2bc703d2017-10-17 20:52:3513#include <wrl/client.h>
[email protected]770c6d82012-09-06 22:21:3214
[email protected]bc38c252011-04-12 21:46:5715#include <algorithm>
Greg Thompsona1f95122019-01-31 22:46:4516#include <ios>
[email protected]bc38c252011-04-12 21:46:5717#include <string>
18
19#include "base/base_paths.h"
Etienne Bergeron7a0ef612023-09-15 18:28:0820#include "base/check.h"
[email protected]bc38c252011-04-12 21:46:5721#include "base/command_line.h"
[email protected]57999812013-02-24 05:40:5222#include "base/files/file_path.h"
thestig18dfb7a52014-08-26 10:44:0423#include "base/files/file_util.h"
S. Ganeshcad45032024-07-18 17:43:1124#include "base/functional/bind.h"
[email protected]bc38c252011-04-12 21:46:5725#include "base/logging.h"
S. Ganeshcad45032024-07-18 17:43:1126#include "base/memory/ref_counted.h"
27#include "base/memory/scoped_refptr.h"
S. Ganesh48540862024-08-12 18:09:3928#include "base/metrics/histogram_functions.h"
[email protected]bc38c252011-04-12 21:46:5729#include "base/path_service.h"
[email protected]d09a4ce1c2013-07-24 17:37:0230#include "base/process/launch.h"
31#include "base/process/process_handle.h"
[email protected]3ea1b182013-02-08 22:38:4132#include "base/strings/string_number_conversions.h"
[email protected]d8830562013-06-10 22:01:5433#include "base/strings/string_util.h"
S. Ganeshcad45032024-07-18 17:43:1134#include "base/synchronization/waitable_event.h"
S. Ganeshbb1d4fc2024-08-14 19:16:3235#include "base/system/sys_info.h"
S. Ganeshcad45032024-07-18 17:43:1136#include "base/task/sequenced_task_runner.h"
37#include "base/task/task_traits.h"
38#include "base/task/thread_pool.h"
Gabriel Charette12b58ac2021-09-22 18:08:5539#include "base/time/time.h"
S. Ganesh48540862024-08-12 18:09:3940#include "base/timer/elapsed_timer.h"
Gabriel Charette12b58ac2021-09-22 18:08:5541#include "base/trace_event/trace_event.h"
S. Ganesh48540862024-08-12 18:09:3942#include "base/values.h"
[email protected]bc38c252011-04-12 21:46:5743#include "base/win/registry.h"
[email protected]770c6d82012-09-06 22:21:3244#include "base/win/windows_version.h"
Nico Webereaa08412019-08-14 01:24:3745#include "build/branding_buildflags.h"
ananta069fc882014-09-13 01:22:1246#include "chrome/browser/browser_process.h"
Etienne Bergeron7a0ef612023-09-15 18:28:0847#include "chrome/browser/chrome_process_singleton.h"
Daniel Cheng7d9e3d52022-02-26 09:03:2448#include "chrome/browser/first_run/upgrade_util.h"
[email protected]3f69d6e612012-08-03 18:52:2749#include "chrome/browser/shell_integration.h"
Javier Flores Assad9c26f9b92022-05-21 01:20:4350#include "chrome/browser/win/browser_util.h"
[email protected]80274b92011-07-15 17:20:3851#include "chrome/common/chrome_switches.h"
ananta069fc882014-09-13 01:22:1252#include "chrome/common/pref_names.h"
grt4474dad2017-02-27 21:00:4653#include "chrome/install_static/install_util.h"
S. Ganeshf77e2a52022-11-22 18:40:1954#include "chrome/installer/util/app_command.h"
S. Ganesh48540862024-08-12 18:09:3955#include "chrome/installer/util/per_install_values.h"
[email protected]bc38c252011-04-12 21:46:5756#include "chrome/installer/util/util_constants.h"
brettwb1fc1b82016-02-02 00:19:0857#include "components/prefs/pref_service.h"
S. Ganeshcad45032024-07-18 17:43:1158#include "third_party/abseil-cpp/absl/cleanup/cleanup.h"
ananta069fc882014-09-13 01:22:1259#include "ui/base/ui_base_switches.h"
[email protected]bc38c252011-04-12 21:46:5760
Nico Webereaa08412019-08-14 01:24:3761#if BUILDFLAG(GOOGLE_CHROME_BRANDING)
S. Ganesh6adf04c2023-06-07 19:34:5562#include "chrome/updater/app/server/win/updater_legacy_idl.h"
grt235b3f092015-05-27 21:42:4863#endif
64
[email protected]bc38c252011-04-12 21:46:5765namespace {
66
[email protected]650b2d52013-02-10 03:41:4567bool GetNewerChromeFile(base::FilePath* path) {
Avi Drissman9098f9002018-05-04 00:11:5268 if (!base::PathService::Get(base::DIR_EXE, path))
[email protected]bc38c252011-04-12 21:46:5769 return false;
70 *path = path->Append(installer::kChromeNewExe);
71 return true;
72}
73
S. Ganeshcad45032024-07-18 17:43:11