OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_DOWNLOAD_DOWNLOAD_DANGER_PROMPT_H_ | 5 #ifndef CHROME_BROWSER_DOWNLOAD_DOWNLOAD_DANGER_PROMPT_H_ |
6 #define CHROME_BROWSER_DOWNLOAD_DOWNLOAD_DANGER_PROMPT_H_ | 6 #define CHROME_BROWSER_DOWNLOAD_DOWNLOAD_DANGER_PROMPT_H_ |
7 | 7 |
8 #include "base/callback_forward.h" | 8 #include "base/callback_forward.h" |
9 | 9 |
10 class GURL; | 10 class GURL; |
11 | 11 |
12 namespace content { | 12 namespace content { |
13 class DownloadItem; | 13 class DownloadItem; |
14 class WebContents; | 14 class WebContents; |
15 } | 15 } |
16 | 16 |
17 // Prompts the user for whether to Keep a dangerous DownloadItem using native | 17 // Prompts the user for whether to Keep a dangerous DownloadItem using native |
18 // UI. This prompt is invoked by the DownloadsDOMHandler when the user wants to | 18 // UI. This prompt is invoked by the DownloadsDOMHandler when the user wants to |
19 // accept a dangerous download. Having a native dialog intervene during the this | 19 // accept a dangerous download. Having a native dialog intervene during the this |
20 // workflow means that the chrome://downloads page no longer has the privilege | 20 // workflow means that the chrome://downloads page no longer has the privilege |
21 // to accept a dangerous download from script without user intervention. This | 21 // to accept a dangerous download from script without user intervention. This |
22 // step is necessary to prevent a malicious script form abusing such a | 22 // step is necessary to prevent a malicious script form abusing such a |
23 // privilege. | 23 // privilege. |
24 class DownloadDangerPrompt { | 24 class DownloadDangerPrompt { |
25 public: | 25 public: |
26 // Actions resulting from showing the danger prompt. | 26 // Actions resulting from showing the danger prompt. |
27 enum Action { | 27 enum Action { |
| 28 // The user chose to proceed down the dangerous path. |
28 ACCEPT, | 29 ACCEPT, |
| 30 // The user chose not to proceed down the dangerous path. |
29 CANCEL, | 31 CANCEL, |
| 32 // The user dismissed the dialog without making an explicit choice. |
30 DISMISS, | 33 DISMISS, |
31 }; | 34 }; |
32 typedef base::Callback<void(Action)> OnDone; | 35 typedef base::Callback<void(Action)> OnDone; |
33 | 36 |
34 // Return a new self-deleting DownloadDangerPrompt. |accepted| or |canceled| | 37 // Return a new self-deleting DownloadDangerPrompt. |accepted| or |canceled| |
35 // will be run when the the respective action is invoked. |canceled| may also | 38 // will be run when the the respective action is invoked. |canceled| may also |
36 // be called when |item| is either no longer dangerous or no longer in | 39 // be called when |item| is either no longer dangerous or no longer in |
37 // progress, or if the tab corresponding to |web_contents| is | 40 // progress, or if the tab corresponding to |web_contents| is |
38 // closing. The returned DownloadDangerPrompt* is only used for testing. The | 41 // closing. The returned DownloadDangerPrompt* is only used for testing. The |
39 // caller does not own the object and receive no guarantees about lifetime. | 42 // caller does not own the object and receive no guarantees about lifetime. |
(...skipping 18 matching lines...) Expand all Loading... |
58 static void SendSafeBrowsingDownloadRecoveryReport( | 61 static void SendSafeBrowsingDownloadRecoveryReport( |
59 bool did_proceed, | 62 bool did_proceed, |
60 const content::DownloadItem& download); | 63 const content::DownloadItem& download); |
61 | 64 |
62 // Records UMA stats for a download danger prompt event. | 65 // Records UMA stats for a download danger prompt event. |
63 static void RecordDownloadDangerPrompt(bool did_proceed, | 66 static void RecordDownloadDangerPrompt(bool did_proceed, |
64 const content::DownloadItem& download); | 67 const content::DownloadItem& download); |
65 }; | 68 }; |
66 | 69 |
67 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_DANGER_PROMPT_H_ | 70 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_DANGER_PROMPT_H_ |
OLD | NEW |