blob: 9c7a73a97addff715dffcdf7107e0ab7cc2b21cc [file] [log] [blame]
Foromo Daniel Soromou67860ff2025-05-05 15:38:331// 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
12class GURL;
13
14namespace base {
15class FilePath;
16}
17
Foromo Daniel Soromoue5104962025-05-16 17:07:2818namespace content {
19class DownloadManager;
20}
21
Foromo Daniel Soromou67860ff2025-05-05 15:38:3322namespace installer_downloader {
23
Foromo Daniel Soromoue5104962025-05-16 17:07:2824using CompletionCallback = base::OnceCallback<void(bool succeeded)>;
Foromo Daniel Soromou3646aa82025-05-22 17:07:2725using EligibilityCheckCallback =
26 base::OnceCallback<void(std::optional<base::FilePath>)>;
Foromo Daniel Soromou67860ff2025-05-05 15:38:3327
28class 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 Soromou3646aa82025-05-22 17:07:2735 virtual void CheckEligibility(EligibilityCheckCallback callback) = 0;
Foromo Daniel Soromou67860ff2025-05-05 15:38:3336
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 Soromoue5104962025-05-16 17:07:2843 content::DownloadManager& download_manager,
Foromo Daniel Soromou67860ff2025-05-05 15:38:3344 CompletionCallback completion_callback) = 0;
Foromo Daniel Soromoubadfb802025-05-05 16:22:0445
Foromo Daniel Soromou06301a12025-06-04 05:36:4946 // Returns true if the infobar can be displayed, false otherwise.
47 virtual bool CanShowInfobar() const = 0;
Foromo Daniel Soromou3646aa82025-05-22 17:07:2748
Foromo Daniel Soromou89f11bf2025-05-22 18:34:0749 // Increments the "show" counter. Called exactly once whenever the
50 // controller actually displays the infobar.
51 virtual void IncrementShowCount() = 0;
52
Foromo Daniel Soromou06301a12025-06-04 05:36:4953 // Set a flag to prevent any future infobar display.
54 virtual void PreventFutureDisplay() = 0;
55
Foromo Daniel Soromou3646aa82025-05-22 17:07:2756 // Returns true if eligibility check should be overridden for manual testing
57 // purpose.
58 virtual bool ShouldByPassEligibilityCheck() const = 0;
Foromo Daniel Soromou67860ff2025-05-05 15:38:3359};
60
61} // namespace installer_downloader
62
63#endif // CHROME_BROWSER_WIN_INSTALLER_DOWNLOADER_INSTALLER_DOWNLOADER_MODEL_H_