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" |
Micah Morton | 5675f90 | 2017-08-16 22:35:19 | [diff] [blame] | 8 | #include "chrome/browser/safe_browsing/download_protection/download_protection_service.h" |
jialiul | 7f11b74 | 2015-11-26 04:54:49 | [diff] [blame] | 9 | #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
Min Qin | a9f48787 | 2018-02-09 20:43:23 | [diff] [blame] | 10 | #include "components/download/public/common/download_item.h" |
Daniel Rubery | dd3f5a49 | 2020-08-18 19:20:35 | [diff] [blame] | 11 | #include "content/public/browser/download_item_utils.h" |
[email protected] | 33ca232f | 2012-04-10 00:08:45 | [diff] [blame] | 12 | |
Lily Chen | 77e08a1 | 2023-12-14 20:49:47 | [diff] [blame^] | 13 | // static |
Xinghui Lu | 21b5237e | 2022-11-18 03:59:59 | [diff] [blame] | 14 | void DownloadDangerPrompt::RecordDownloadWarningEvent( |
| 15 | Action action, |
| 16 | download::DownloadItem* download) { |
| 17 | DownloadItemWarningData::WarningAction warning_action; |
| 18 | switch (action) { |
| 19 | case Action::ACCEPT: |
Xinghui Lu | b907e8cf | 2022-12-14 22:35:13 | [diff] [blame] | 20 | warning_action = DownloadItemWarningData::WarningAction::PROCEED; |
Xinghui Lu | 21b5237e | 2022-11-18 03:59:59 | [diff] [blame] | 21 | break; |
| 22 | case Action::CANCEL: |
Xinghui Lu | b907e8cf | 2022-12-14 22:35:13 | [diff] [blame] | 23 | warning_action = DownloadItemWarningData::WarningAction::CANCEL; |
Xinghui Lu | 21b5237e | 2022-11-18 03:59:59 | [diff] [blame] | 24 | break; |
| 25 | case Action::DISMISS: |
Xinghui Lu | b907e8cf | 2022-12-14 22:35:13 | [diff] [blame] | 26 | warning_action = DownloadItemWarningData::WarningAction::CLOSE; |
Xinghui Lu | 21b5237e | 2022-11-18 03:59:59 | [diff] [blame] | 27 | break; |
| 28 | } |
| 29 | DownloadItemWarningData::AddWarningActionEvent( |
Xinghui Lu | b907e8cf | 2022-12-14 22:35:13 | [diff] [blame] | 30 | download, DownloadItemWarningData::WarningSurface::DOWNLOAD_PROMPT, |
| 31 | warning_action); |
Xinghui Lu | 21b5237e | 2022-11-18 03:59:59 | [diff] [blame] | 32 | } |