| Avi Drissman | 4a8573c | 2022-09-09 19:35:54 | [diff] [blame] | 1 | // Copyright 2020 The Chromium Authors |
| Joshua Pawlicki | 83d1d823 | 2020-10-23 20:13:31 | [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 | |
| 5 | #include "chrome/updater/update_service_impl_inactive.h" |
| 6 | |
| 7 | #include <string> |
| Joshua Pawlicki | 3208454 | 2021-03-19 18:46:20 | [diff] [blame] | 8 | #include <utility> |
| Xiaoling Bao | a890a31 | 2021-11-30 22:47:16 | [diff] [blame] | 9 | #include <vector> |
| Joshua Pawlicki | 83d1d823 | 2020-10-23 20:13:31 | [diff] [blame] | 10 | |
| Avi Drissman | 69ba0cc | 2023-01-09 20:56:03 | [diff] [blame] | 11 | #include "base/functional/bind.h" |
| 12 | #include "base/functional/callback.h" |
| Joshua Pawlicki | 2c2a0a2 | 2022-06-30 16:00:59 | [diff] [blame] | 13 | #include "base/logging.h" |
| Sorin Jianu | 7bd356a | 2022-10-22 00:59:58 | [diff] [blame] | 14 | #include "base/task/sequenced_task_runner.h" |
| Joshua Pawlicki | 83d1d823 | 2020-10-23 20:13:31 | [diff] [blame] | 15 | #include "base/version.h" |
| 16 | #include "chrome/updater/registration_data.h" |
| 17 | #include "chrome/updater/update_service.h" |
| 18 | |
| 19 | namespace updater { |
| 20 | |
| 21 | namespace { |
| 22 | |
| 23 | class UpdateServiceImplInactive : public UpdateService { |
| 24 | public: |
| 25 | UpdateServiceImplInactive() = default; |
| 26 | |
| 27 | // Overrides for updater::UpdateService. |
| 28 | void GetVersion( |
| Joshua Pawlicki | 0bf0f16f | 2022-02-04 17:50:15 | [diff] [blame] | 29 | base::OnceCallback<void(const base::Version&)> callback) override { |
| Joshua Pawlicki | 2c2a0a2 | 2022-06-30 16:00:59 | [diff] [blame] | 30 | VLOG(1) << __func__ << " (Inactive)"; |
| Sorin Jianu | 7bd356a | 2022-10-22 00:59:58 | [diff] [blame] | 31 | base::SequencedTaskRunner::GetCurrentDefault()->PostTask( |
| Joshua Pawlicki | 83d1d823 | 2020-10-23 20:13:31 | [diff] [blame] | 32 | FROM_HERE, base::BindOnce(std::move(callback), base::Version())); |
| 33 | } |
| 34 | |
| S. Ganesh | f85b7f63 | 2022-09-02 18:07:15 | [diff] [blame] | 35 | void FetchPolicies(base::OnceCallback<void(int)> callback) override { |
| S. Ganesh | 825dfc4d | 2022-08-31 19:41:56 | [diff] [blame] | 36 | VLOG(1) << __func__ << " (Inactive)"; |
| S. Ganesh | f85b7f63 | 2022-09-02 18:07:15 | [diff] [blame] | 37 | std::move(callback).Run(-1); |
| S. Ganesh | 825dfc4d | 2022-08-31 19:41:56 | [diff] [blame] | 38 | } |
| 39 | |
| Sorin Jianu | d91abf4b7 | 2023-03-11 01:48:51 | [diff] [blame] | 40 | void RegisterApp(const RegistrationRequest& /*request*/, |
| Noah Rose Ledesma | 3d874bb9 | 2022-10-04 18:53:10 | [diff] [blame] | 41 | base::OnceCallback<void(int)> callback) override { |
| Joshua Pawlicki | 2c2a0a2 | 2022-06-30 16:00:59 | [diff] [blame] | 42 | VLOG(1) << __func__ << " (Inactive)"; |
| Sorin Jianu | 7bd356a | 2022-10-22 00:59:58 | [diff] [blame] | 43 | base::SequencedTaskRunner::GetCurrentDefault()->PostTask( |
| Noah Rose Ledesma | 3d874bb9 | 2022-10-04 18:53:10 | [diff] [blame] | 44 | FROM_HERE, base::BindOnce(std::move(callback), -1)); |
| Joshua Pawlicki | 83d1d823 | 2020-10-23 20:13:31 | [diff] [blame] | 45 | } |
| 46 | |
| Xiaoling Bao | a890a31 | 2021-11-30 22:47:16 | [diff] [blame] | 47 | void GetAppStates(base::OnceCallback<void(const std::vector<AppState>&)> |
| Sorin Jianu | b4ea8a64 | 2022-02-14 19:17:48 | [diff] [blame] | 48 | callback) override { |
| Joshua Pawlicki | 2c2a0a2 | 2022-06-30 16:00:59 | [diff] [blame] | 49 | VLOG(1) << __func__ << " (Inactive)"; |
| Sorin Jianu | 7bd356a | 2022-10-22 00:59:58 | [diff] [blame] | 50 | base::SequencedTaskRunner::GetCurrentDefault()->PostTask( |
| Xiaoling Bao | a890a31 | 2021-11-30 22:47:16 | [diff] [blame] | 51 | FROM_HERE, |
| 52 | base::BindOnce(std::move(callback), std::vector<AppState>())); |
| 53 | } |
| 54 | |
| Joshua Pawlicki | 3208454 | 2021-03-19 18:46:20 | [diff] [blame] | 55 | void RunPeriodicTasks(base::OnceClosure callback) override { |
| Joshua Pawlicki | 2c2a0a2 | 2022-06-30 16:00:59 | [diff] [blame] | 56 | VLOG(1) << __func__ << " (Inactive)"; |
| Joshua Pawlicki | 3208454 | 2021-03-19 18:46:20 | [diff] [blame] | 57 | std::move(callback).Run(); |
| 58 | } |
| 59 | |
| Sorin Jianu | 92a871e | 2024-08-27 18:06:56 | [diff] [blame] | 60 | void CheckForUpdate( |
| 61 | const std::string& /*app_id*/, |
| 62 | Priority /*priority*/, |
| 63 | PolicySameVersionUpdate /*policy_same_version_update*/, |
| S. Ganesh | 57c3e92 | 2024-12-20 02:16:05 | [diff] [blame^] | 64 | const std::string& /*language*/, |
| Sorin Jianu | 92a871e | 2024-08-27 18:06:56 | [diff] [blame] | 65 | base::RepeatingCallback<void(const UpdateState&)> /*state_update*/, |
| 66 | base::OnceCallback<void(Result)> callback) override { |
| Joshua Pawlicki | 2c2a0a2 | 2022-06-30 16:00:59 | [diff] [blame] | 67 | VLOG(1) << __func__ << " (Inactive)"; |
| Sorin Jianu | 7bd356a | 2022-10-22 00:59:58 | [diff] [blame] | 68 | base::SequencedTaskRunner::GetCurrentDefault()->PostTask( |
| Joshua Pawlicki | 83d1d823 | 2020-10-23 20:13:31 | [diff] [blame] | 69 | FROM_HERE, |
| 70 | base::BindOnce(std::move(callback), UpdateService::Result::kInactive)); |
| 71 | } |
| 72 | |
| Sorin Jianu | 92a871e | 2024-08-27 18:06:56 | [diff] [blame] | 73 | void Update( |
| 74 | const std::string& /*app_id*/, |
| 75 | const std::string& /*install_data_index*/, |
| 76 | Priority /*priority*/, |
| 77 | PolicySameVersionUpdate /*policy_same_version_update*/, |
| S. Ganesh | 57c3e92 | 2024-12-20 02:16:05 | [diff] [blame^] | 78 | const std::string& /*language*/, |
| Sorin Jianu | 92a871e | 2024-08-27 18:06:56 | [diff] [blame] | 79 | base::RepeatingCallback<void(const UpdateState&)> /*state_update*/, |
| 80 | base::OnceCallback<void(Result)> callback) override { |
| Joshua Pawlicki | 2c2a0a2 | 2022-06-30 16:00:59 | [diff] [blame] | 81 | VLOG(1) << __func__ << " (Inactive)"; |
| Sorin Jianu | 7bd356a | 2022-10-22 00:59:58 | [diff] [blame] | 82 | base::SequencedTaskRunner::GetCurrentDefault()->PostTask( |
| Joshua Pawlicki | 83d1d823 | 2020-10-23 20:13:31 | [diff] [blame] | 83 | FROM_HERE, |
| 84 | base::BindOnce(std::move(callback), UpdateService::Result::kInactive)); |
| 85 | } |
| 86 | |
| Sorin Jianu | 92a871e | 2024-08-27 18:06:56 | [diff] [blame] | 87 | void UpdateAll( |
| 88 | base::RepeatingCallback<void(const UpdateState&)> /*state_update*/, |
| 89 | base::OnceCallback<void(Result)> callback) override { |
| Sorin Jianu | d91abf4b7 | 2023-03-11 01:48:51 | [diff] [blame] | 90 | VLOG(1) << __func__ << " (Inactive)"; |
| 91 | base::SequencedTaskRunner::GetCurrentDefault()->PostTask( |
| 92 | FROM_HERE, |
| 93 | base::BindOnce(std::move(callback), UpdateService::Result::kInactive)); |
| 94 | } |
| 95 | |
| Sorin Jianu | 92a871e | 2024-08-27 18:06:56 | [diff] [blame] | 96 | void Install( |
| 97 | const RegistrationRequest& /*registration*/, |
| 98 | const std::string& /*client_install_data*/, |
| 99 | const std::string& /*install_data_index*/, |
| 100 | Priority /*priority*/, |
| S. Ganesh | 57c3e92 | 2024-12-20 02:16:05 | [diff] [blame^] | 101 | const std::string& /*language*/, |
| Sorin Jianu | 92a871e | 2024-08-27 18:06:56 | [diff] [blame] | 102 | base::RepeatingCallback<void(const UpdateState&)> /*state_update*/, |
| 103 | base::OnceCallback<void(Result)> callback) override { |
| Joshua Pawlicki | 0b41491 | 2022-07-07 00:54:14 | [diff] [blame] | 104 | VLOG(1) << __func__ << " (Inactive)"; |
| Sorin Jianu | 7bd356a | 2022-10-22 00:59:58 | [diff] [blame] | 105 | base::SequencedTaskRunner::GetCurrentDefault()->PostTask( |
| Joshua Pawlicki | 0b41491 | 2022-07-07 00:54:14 | [diff] [blame] | 106 | FROM_HERE, |
| 107 | base::BindOnce(std::move(callback), UpdateService::Result::kInactive)); |
| 108 | } |
| 109 | |
| Joshua Pawlicki | 1d63f36 | 2022-07-06 18:04:45 | [diff] [blame] | 110 | void CancelInstalls(const std::string& /*app_id*/) override { |
| 111 | VLOG(1) << __func__ << " (Inactive)"; |
| 112 | } |
| 113 | |
| Sorin Jianu | 92a871e | 2024-08-27 18:06:56 | [diff] [blame] | 114 | void RunInstaller( |
| 115 | const std::string& /*app_id*/, |
| 116 | const base::FilePath& /*installer_path*/, |
| 117 | const std::string& /*install_args*/, |
| 118 | const std::string& /*install_data*/, |
| 119 | const std::string& /*install_settings*/, |
| S. Ganesh | 57c3e92 | 2024-12-20 02:16:05 | [diff] [blame^] | 120 | const std::string& /*language*/, |
| Sorin Jianu | 92a871e | 2024-08-27 18:06:56 | [diff] [blame] | 121 | base::RepeatingCallback<void(const UpdateState&)> /*state_update*/, |
| 122 | base::OnceCallback<void(Result)> callback) override { |
| Joshua Pawlicki | 2c2a0a2 | 2022-06-30 16:00:59 | [diff] [blame] | 123 | VLOG(1) << __func__ << " (Inactive)"; |
| Sorin Jianu | 7bd356a | 2022-10-22 00:59:58 | [diff] [blame] | 124 | base::SequencedTaskRunner::GetCurrentDefault()->PostTask( |
| Xiaoling Bao | b09c406 | 2022-04-12 19:34:29 | [diff] [blame] | 125 | FROM_HERE, |
| 126 | base::BindOnce(std::move(callback), UpdateService::Result::kInactive)); |
| 127 | } |
| 128 | |
| Joshua Pawlicki | 83d1d823 | 2020-10-23 20:13:31 | [diff] [blame] | 129 | private: |
| 130 | ~UpdateServiceImplInactive() override = default; |
| 131 | }; |
| 132 | |
| 133 | } // namespace |
| 134 | |
| 135 | scoped_refptr<UpdateService> MakeInactiveUpdateService() { |
| 136 | return base::MakeRefCounted<UpdateServiceImplInactive>(); |
| 137 | } |
| 138 | |
| 139 | } // namespace updater |