Avi Drissman | 4a8573c | 2022-09-09 19:35:54 | [diff] [blame] | 1 | // Copyright 2012 The Chromium Authors |
[email protected] | 33ca232f | 2012-04-10 00:08:45 | [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/browser/download/download_danger_prompt.h" |
| 6 | |
Xinghui Lu | 21b5237e | 2022-11-18 03:59:59 | [diff] [blame] | 7 | #include "chrome/browser/download/download_item_warning_data.h" |
Byungwoo Lee | 091930a | 2025-03-04 00:39:26 | [diff] [blame] | 8 | #include "components/download/public/common/download_item.h" |
| 9 | #include "components/safe_browsing/buildflags.h" |
| 10 | #include "content/public/browser/download_item_utils.h" |
| 11 | |
| 12 | #if BUILDFLAG(SAFE_BROWSING_AVAILABLE) |
Micah Morton | 5675f90 | 2017-08-16 22:35:19 | [diff] [blame] | 13 | #include "chrome/browser/safe_browsing/download_protection/download_protection_service.h" |
jialiul | 7f11b74 | 2015-11-26 04:54:49 | [diff] [blame] | 14 | #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
Byungwoo Lee | 091930a | 2025-03-04 00:39:26 | [diff] [blame] | 15 | #endif |
[email protected] | 33ca232f | 2012-04-10 00:08:45 | [diff] [blame] | 16 | |
Lily Chen | 77e08a1 | 2023-12-14 20:49:47 | [diff] [blame] | 17 | // static |
Xinghui Lu | 21b5237e | 2022-11-18 03:59:59 | [diff] [blame] | 18 | void DownloadDangerPrompt::RecordDownloadWarningEvent( |
| 19 | Action action, |
| 20 | download::DownloadItem* download) { |
| 21 | DownloadItemWarningData::WarningAction warning_action; |
| 22 | switch (action) { |
| 23 | case Action::ACCEPT: |
Xinghui Lu | b907e8cf | 2022-12-14 22:35:13 | [diff] [blame] | 24 | warning_action = DownloadItemWarningData::WarningAction::PROCEED; |
Xinghui Lu | 21b5237e | 2022-11-18 03:59:59 | [diff] [blame] | 25 | break; |
| 26 | case Action::CANCEL: |
Xinghui Lu | b907e8cf | 2022-12-14 22:35:13 | [diff] [blame] | 27 | warning_action = DownloadItemWarningData::WarningAction::CANCEL; |
Xinghui Lu | 21b5237e | 2022-11-18 03:59:59 | [diff] [blame] | 28 | break; |
| 29 | case Action::DISMISS: |
Xinghui Lu | b907e8cf | 2022-12-14 22:35:13 | [diff] [blame] | 30 | warning_action = DownloadItemWarningData::WarningAction::CLOSE; |
Xinghui Lu | 21b5237e | 2022-11-18 03:59:59 | [diff] [blame] | 31 | break; |
| 32 | } |
| 33 | DownloadItemWarningData::AddWarningActionEvent( |
Xinghui Lu | b907e8cf | 2022-12-14 22:35:13 | [diff] [blame] | 34 | download, DownloadItemWarningData::WarningSurface::DOWNLOAD_PROMPT, |
| 35 | warning_action); |
Xinghui Lu | 21b5237e | 2022-11-18 03:59:59 | [diff] [blame] | 36 | } |