Avi Drissman | 4a8573c | 2022-09-09 19:35:54 | [diff] [blame] | 1 | // Copyright 2012 The Chromium Authors |
[email protected] | bc38c25 | 2011-04-12 21:46:57 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
3 | // found in the LICENSE file. | ||||
4 | |||||
Daniel Cheng | 7d9e3d5 | 2022-02-26 09:03:24 | [diff] [blame] | 5 | #include "chrome/browser/first_run/upgrade_util_win.h" |
[email protected] | bc38c25 | 2011-04-12 21:46:57 | [diff] [blame] | 6 | |
Takuto Ikuta | c8d6b16f | 2024-04-15 16:59:19 | [diff] [blame] | 7 | #include <objbase.h> |
8 | |||||
[email protected] | 770c6d8 | 2012-09-06 22:21:32 | [diff] [blame] | 9 | #include <windows.h> |
Nico Weber | eaa0841 | 2019-08-14 01:24:37 | [diff] [blame] | 10 | |
[email protected] | fdbea98d | 2014-05-16 19:29:20 | [diff] [blame] | 11 | #include <psapi.h> |
[email protected] | 770c6d8 | 2012-09-06 22:21:32 | [diff] [blame] | 12 | #include <shellapi.h> |
Robert Liao | b2bc703d | 2017-10-17 20:52:35 | [diff] [blame] | 13 | #include <wrl/client.h> |
[email protected] | 770c6d8 | 2012-09-06 22:21:32 | [diff] [blame] | 14 | |
[email protected] | bc38c25 | 2011-04-12 21:46:57 | [diff] [blame] | 15 | #include <algorithm> |
Greg Thompson | a1f9512 | 2019-01-31 22:46:45 | [diff] [blame] | 16 | #include <ios> |
[email protected] | bc38c25 | 2011-04-12 21:46:57 | [diff] [blame] | 17 | #include <string> |
18 | |||||
19 | #include "base/base_paths.h" | ||||
Etienne Bergeron | 7a0ef61 | 2023-09-15 18:28:08 | [diff] [blame] | 20 | #include "base/check.h" |
[email protected] | bc38c25 | 2011-04-12 21:46:57 | [diff] [blame] | 21 | #include "base/command_line.h" |
[email protected] | 5799981 | 2013-02-24 05:40:52 | [diff] [blame] | 22 | #include "base/files/file_path.h" |
thestig | 18dfb7a5 | 2014-08-26 10:44:04 | [diff] [blame] | 23 | #include "base/files/file_util.h" |
S. Ganesh | cad4503 | 2024-07-18 17:43:11 | [diff] [blame] | 24 | #include "base/functional/bind.h" |
[email protected] | bc38c25 | 2011-04-12 21:46:57 | [diff] [blame] | 25 | #include "base/logging.h" |
S. Ganesh | cad4503 | 2024-07-18 17:43:11 | [diff] [blame] | 26 | #include "base/memory/ref_counted.h" |
27 | #include "base/memory/scoped_refptr.h" | ||||
S. Ganesh | 4854086 | 2024-08-12 18:09:39 | [diff] [blame] | 28 | #include "base/metrics/histogram_functions.h" |
[email protected] | bc38c25 | 2011-04-12 21:46:57 | [diff] [blame] | 29 | #include "base/path_service.h" |
[email protected] | d09a4ce1c | 2013-07-24 17:37:02 | [diff] [blame] | 30 | #include "base/process/launch.h" |
31 | #include "base/process/process_handle.h" | ||||
[email protected] | 3ea1b18 | 2013-02-08 22:38:41 | [diff] [blame] | 32 | #include "base/strings/string_number_conversions.h" |
[email protected] | d883056 | 2013-06-10 22:01:54 | [diff] [blame] | 33 | #include "base/strings/string_util.h" |
S. Ganesh | cad4503 | 2024-07-18 17:43:11 | [diff] [blame] | 34 | #include "base/synchronization/waitable_event.h" |
S. Ganesh | bb1d4fc | 2024-08-14 19:16:32 | [diff] [blame] | 35 | #include "base/system/sys_info.h" |
S. Ganesh | cad4503 | 2024-07-18 17:43:11 | [diff] [blame] | 36 | #include "base/task/sequenced_task_runner.h" |
37 | #include "base/task/task_traits.h" | ||||
38 | #include "base/task/thread_pool.h" | ||||
Gabriel Charette | 12b58ac | 2021-09-22 18:08:55 | [diff] [blame] | 39 | #include "base/time/time.h" |
S. Ganesh | 4854086 | 2024-08-12 18:09:39 | [diff] [blame] | 40 | #include "base/timer/elapsed_timer.h" |
Gabriel Charette | 12b58ac | 2021-09-22 18:08:55 | [diff] [blame] | 41 | #include "base/trace_event/trace_event.h" |
S. Ganesh | 4854086 | 2024-08-12 18:09:39 | [diff] [blame] | 42 | #include "base/values.h" |
[email protected] | bc38c25 | 2011-04-12 21:46:57 | [diff] [blame] | 43 | #include "base/win/registry.h" |
[email protected] | 770c6d8 | 2012-09-06 22:21:32 | [diff] [blame] | 44 | #include "base/win/windows_version.h" |
Nico Weber | eaa0841 | 2019-08-14 01:24:37 | [diff] [blame] | 45 | #include "build/branding_buildflags.h" |
ananta | 069fc88 | 2014-09-13 01:22:12 | [diff] [blame] | 46 | #include "chrome/browser/browser_process.h" |
Etienne Bergeron | 7a0ef61 | 2023-09-15 18:28:08 | [diff] [blame] | 47 | #include "chrome/browser/chrome_process_singleton.h" |
Daniel Cheng | 7d9e3d5 | 2022-02-26 09:03:24 | [diff] [blame] | 48 | #include "chrome/browser/first_run/upgrade_util.h" |
[email protected] | 3f69d6e61 | 2012-08-03 18:52:27 | [diff] [blame] | 49 | #include "chrome/browser/shell_integration.h" |
Javier Flores Assad | 9c26f9b9 | 2022-05-21 01:20:43 | [diff] [blame] | 50 | #include "chrome/browser/win/browser_util.h" |
[email protected] | 80274b9 | 2011-07-15 17:20:38 | [diff] [blame] | 51 | #include "chrome/common/chrome_switches.h" |
ananta | 069fc88 | 2014-09-13 01:22:12 | [diff] [blame] | 52 | #include "chrome/common/pref_names.h" |
grt | 4474dad | 2017-02-27 21:00:46 | [diff] [blame] | 53 | #include "chrome/install_static/install_util.h" |
S. Ganesh | f77e2a5 | 2022-11-22 18:40:19 | [diff] [blame] | 54 | #include "chrome/installer/util/app_command.h" |
S. Ganesh | 4854086 | 2024-08-12 18:09:39 | [diff] [blame] | 55 | #include "chrome/installer/util/per_install_values.h" |
[email protected] | bc38c25 | 2011-04-12 21:46:57 | [diff] [blame] | 56 | #include "chrome/installer/util/util_constants.h" |
brettw | b1fc1b8 | 2016-02-02 00:19:08 | [diff] [blame] | 57 | #include "components/prefs/pref_service.h" |
S. Ganesh | cad4503 | 2024-07-18 17:43:11 | [diff] [blame] | 58 | #include "third_party/abseil-cpp/absl/cleanup/cleanup.h" |
ananta | 069fc88 | 2014-09-13 01:22:12 | [diff] [blame] | 59 | #include "ui/base/ui_base_switches.h" |
[email protected] | bc38c25 | 2011-04-12 21:46:57 | [diff] [blame] | 60 | |
Nico Weber | eaa0841 | 2019-08-14 01:24:37 | [diff] [blame] | 61 | #if BUILDFLAG(GOOGLE_CHROME_BRANDING) |
S. Ganesh | 6adf04c | 2023-06-07 19:34:55 | [diff] [blame] | 62 | #include "chrome/updater/app/server/win/updater_legacy_idl.h" |
grt | 235b3f09 | 2015-05-27 21:42:48 | [diff] [blame] | 63 | #endif |
64 | |||||
[email protected] | bc38c25 | 2011-04-12 21:46:57 | [diff] [blame] | 65 | namespace { |
66 | |||||
[email protected] | 650b2d5 | 2013-02-10 03:41:45 | [diff] [blame] | 67 | bool GetNewerChromeFile(base::FilePath* path) { |
Avi Drissman | 9098f900 | 2018-05-04 00:11:52 | [diff] [blame] | 68 | if (!base::PathService::Get(base::DIR_EXE, path)) |
[email protected] | bc38c25 | 2011-04-12 21:46:57 | [diff] [blame] | 69 | return false; |
70 | *path = path->Append(installer::kChromeNewExe); | ||||
71 | return true; | ||||
72 | } | ||||
73 | |||||
S. Ganesh | cad4503 | 2024-07-18 17:43:11 | [diff] [ |