Foromo Daniel Soromou | 67860ff | 2025-05-05 15:38:33 | [diff] [blame] | 1 | // Copyright 2025 The Chromium Authors |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef CHROME_BROWSER_WIN_INSTALLER_DOWNLOADER_INSTALLER_DOWNLOADER_MODEL_H_ |
| 6 | #define CHROME_BROWSER_WIN_INSTALLER_DOWNLOADER_INSTALLER_DOWNLOADER_MODEL_H_ |
| 7 | |
| 8 | #include <optional> |
| 9 | |
| 10 | #include "base/functional/callback_forward.h" |
| 11 | |
| 12 | class GURL; |
| 13 | |
| 14 | namespace base { |
| 15 | class FilePath; |
| 16 | } |
| 17 | |
Foromo Daniel Soromou | e510496 | 2025-05-16 17:07:28 | [diff] [blame] | 18 | namespace content { |
| 19 | class DownloadManager; |
| 20 | } |
| 21 | |
Foromo Daniel Soromou | 67860ff | 2025-05-05 15:38:33 | [diff] [blame] | 22 | namespace installer_downloader { |
| 23 | |
Foromo Daniel Soromou | e510496 | 2025-05-16 17:07:28 | [diff] [blame] | 24 | using CompletionCallback = base::OnceCallback<void(bool succeeded)>; |
Foromo Daniel Soromou | 3646aa8 | 2025-05-22 17:07:27 | [diff] [blame] | 25 | using EligibilityCheckCallback = |
| 26 | base::OnceCallback<void(std::optional<base::FilePath>)>; |
Foromo Daniel Soromou | 67860ff | 2025-05-05 15:38:33 | [diff] [blame] | 27 | |
| 28 | class InstallerDownloaderModel { |
| 29 | public: |
| 30 | virtual ~InstallerDownloaderModel() = default; |
| 31 | |
| 32 | // Posts the OS / OneDrive probe to the ThreadPool and returns the installer |
| 33 | // download destination file path asynchronously on the calling sequence. The |
| 34 | // destination file path will be null if the user is not eligible. |
Foromo Daniel Soromou | 3646aa8 | 2025-05-22 17:07:27 | [diff] [blame] | 35 | virtual void CheckEligibility(EligibilityCheckCallback callback) = 0; |
Foromo Daniel Soromou | 67860ff | 2025-05-05 15:38:33 | [diff] [blame] | 36 | |
| 37 | // Kicks off a **transient** download with DownloadManager. Completion is |
| 38 | // reported through `completion_callback`. |
| 39 | // |
| 40 | // TODO(crbug.com/412976021): Download payload. |
| 41 | virtual void StartDownload(const GURL& url, |
| 42 | const base::FilePath& destination, |
Foromo Daniel Soromou | e510496 | 2025-05-16 17:07:28 | [diff] [blame] | 43 | content::DownloadManager& download_manager, |
Foromo Daniel Soromou | 67860ff | 2025-05-05 15:38:33 | [diff] [blame] | 44 | CompletionCallback completion_callback) = 0; |
Foromo Daniel Soromou | badfb80 | 2025-05-05 16:22:04 | [diff] [blame] | 45 | |
Foromo Daniel Soromou | 06301a1 | 2025-06-04 05:36:49 | [diff] [blame] | 46 | // Returns true if the infobar can be displayed, false otherwise. |
| 47 | virtual bool CanShowInfobar() const = 0; |
Foromo Daniel Soromou | 3646aa8 | 2025-05-22 17:07:27 | [diff] [blame] | 48 | |
Foromo Daniel Soromou | 89f11bf | 2025-05-22 18:34:07 | [diff] [blame] | 49 | // Increments the "show" counter. Called exactly once whenever the |
| 50 | // controller actually displays the infobar. |
| 51 | virtual void IncrementShowCount() = 0; |
| 52 | |
Foromo Daniel Soromou | 06301a1 | 2025-06-04 05:36:49 | [diff] [blame] | 53 | // Set a flag to prevent any future infobar display. |
| 54 | virtual void PreventFutureDisplay() = 0; |
| 55 | |
Foromo Daniel Soromou | 3646aa8 | 2025-05-22 17:07:27 | [diff] [blame] | 56 | // Returns true if eligibility check should be overridden for manual testing |
| 57 | // purpose. |
| 58 | virtual bool ShouldByPassEligibilityCheck() const = 0; |
Foromo Daniel Soromou | 67860ff | 2025-05-05 15:38:33 | [diff] [blame] | 59 | }; |
| 60 | |
| 61 | } // namespace installer_downloader |
| 62 | |
| 63 | #endif // CHROME_BROWSER_WIN_INSTALLER_DOWNLOADER_INSTALLER_DOWNLOADER_MODEL_H_ |