Chromium Code Reviews| 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 <string> | |
| 9 | |
| 8 #include "base/callback_forward.h" | 10 #include "base/callback_forward.h" |
| 11 #include "url/gurl.h" | |
| 9 | 12 |
| 10 namespace content { | 13 namespace content { |
| 11 class DownloadItem; | 14 class DownloadItem; |
| 12 class WebContents; | 15 class WebContents; |
| 13 } | 16 } |
| 14 | 17 |
| 15 // Prompts the user for whether to Keep a dangerous DownloadItem using native | 18 // Prompts the user for whether to Keep a dangerous DownloadItem using native |
| 16 // UI. This prompt is invoked by the DownloadsDOMHandler when the user wants to | 19 // UI. This prompt is invoked by the DownloadsDOMHandler when the user wants to |
| 17 // accept a dangerous download. Having a native dialog intervene during the this | 20 // accept a dangerous download. Having a native dialog intervene during the this |
| 18 // workflow means that the chrome://downloads page no longer has the privilege | 21 // workflow means that the chrome://downloads page no longer has the privilege |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 30 typedef base::Callback<void(Action)> OnDone; | 33 typedef base::Callback<void(Action)> OnDone; |
| 31 | 34 |
| 32 // Return a new self-deleting DownloadDangerPrompt. |accepted| or |canceled| | 35 // Return a new self-deleting DownloadDangerPrompt. |accepted| or |canceled| |
| 33 // will be run when the the respective action is invoked. |canceled| may also | 36 // will be run when the the respective action is invoked. |canceled| may also |
| 34 // be called when |item| is either no longer dangerous or no longer in | 37 // be called when |item| is either no longer dangerous or no longer in |
| 35 // progress, or if the tab corresponding to |web_contents| is | 38 // progress, or if the tab corresponding to |web_contents| is |
| 36 // closing. The returned DownloadDangerPrompt* is only used for testing. The | 39 // closing. The returned DownloadDangerPrompt* is only used for testing. The |
| 37 // caller does not own the object and receive no guarantees about lifetime. | 40 // caller does not own the object and receive no guarantees about lifetime. |
| 38 // If |show_context|, then the prompt message will contain some information | 41 // If |show_context|, then the prompt message will contain some information |
| 39 // about the download and its danger; otherwise it won't. | 42 // about the download and its danger; otherwise it won't. |
| 40 static DownloadDangerPrompt* Create( | 43 static DownloadDangerPrompt* Create(content::DownloadItem* item, |
| 41 content::DownloadItem* item, | 44 content::WebContents* web_contents, |
| 42 content::WebContents* web_contents, | 45 bool show_context, |
| 43 bool show_context, | 46 const OnDone& done); |
| 44 const OnDone& done); | |
| 45 | 47 |
| 46 // Only to be used by tests. Subclasses must override to manually call the | 48 // Helper function only used by tests. This function returns a serialized |
| 47 // respective button click handler. | 49 // ClientSafeBrowsingReportRequest proto or an empty string. Subclasses must |
| 48 virtual void InvokeActionForTesting(Action action) = 0; | 50 // override to manually call the respective button click handler. |
| 51 virtual std::string InvokeActionForTesting(Action action, | |
| 52 const GURL& url) = 0; | |
| 53 | |
| 54 protected: | |
| 55 // Return a serialized ClientSafeBrowsingReportRequest proto. | |
| 56 std::string CreateSafeBrowsingDownloadRecoveryReport(bool did_proceed, | |
| 57 const GURL& url); | |
| 58 | |
| 59 // Sends threat details to safe browsing backend. | |
| 60 // Since this reporting is not gated by extended_reporting, it only records | |
|
Nathan Parker
2015/11/14 01:04:27
I'd swap the two phrases: Since it only records u
Jialiu Lin
2015/11/16 19:30:14
Done.
| |
| 61 // download url and user's action (click through or not). We should not put | |
| 62 // any other extra information in this report. | |
| 63 void SendSerializedReport(const std::string& report); | |
| 49 }; | 64 }; |
| 50 | 65 |
| 51 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_DANGER_PROMPT_H_ | 66 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_DANGER_PROMPT_H_ |
| OLD | NEW |