Avi Drissman | 4a8573c | 2022-09-09 19:35:54 | [diff] [blame] | 1 | // Copyright 2021 The Chromium Authors |
Min Qin | 42484d7 | 2021-08-27 14:52:05 | [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 | #ifndef CHROME_BROWSER_DOWNLOAD_ANDROID_DOWNLOAD_DIALOG_UTILS_H_ |
| 6 | #define CHROME_BROWSER_DOWNLOAD_ANDROID_DOWNLOAD_DIALOG_UTILS_H_ |
| 7 | |
| 8 | #include <string> |
| 9 | #include <vector> |
| 10 | |
| 11 | #include "base/files/file_path.h" |
Ali Hijazi | e63cbaf6 | 2023-12-20 19:29:35 | [diff] [blame^] | 12 | #include "base/memory/raw_ptr.h" |
Min Qin | 42484d7 | 2021-08-27 14:52:05 | [diff] [blame] | 13 | #include "chrome/browser/download/download_target_determiner_delegate.h" |
| 14 | #include "components/download/public/common/download_item.h" |
| 15 | #include "url/gurl.h" |
| 16 | |
| 17 | // Helper class for download dialogs. |
| 18 | class DownloadDialogUtils { |
| 19 | public: |
| 20 | // Helper method to find a download from a list of downloads based on its |
| 21 | // GUID, and remove it from the list. |
| 22 | static download::DownloadItem* FindAndRemoveDownload( |
Ali Hijazi | e63cbaf6 | 2023-12-20 19:29:35 | [diff] [blame^] | 23 | std::vector<raw_ptr<download::DownloadItem, VectorExperimental>>* |
| 24 | downloads, |
Min Qin | 42484d7 | 2021-08-27 14:52:05 | [diff] [blame] | 25 | const std::string& download_guid); |
| 26 | |
| 27 | // Called when a new file was created and inform |callback| about |
| 28 | // the result and the new path. |
| 29 | static void CreateNewFileDone( |
| 30 | DownloadTargetDeterminerDelegate::ConfirmationCallback callback, |
| 31 | download::PathValidationResult result, |
| 32 | const base::FilePath& target_path); |
| 33 | |
| 34 | // Called to get an elided URL for a page URL, so that it can be displayed |
| 35 | // on duplicate inforbar or dialog. |
| 36 | static std::string GetDisplayURLForPageURL(const GURL& page_url); |
| 37 | }; |
| 38 | |
| 39 | #endif // CHROME_BROWSER_DOWNLOAD_ANDROID_DOWNLOAD_DIALOG_UTILS_H_ |