Add ICU message format support
[chromium-blink-merge.git] / chrome / browser / download / download_danger_prompt.h
blobe1b5c612c08994378a2e598440e948009d6aef82
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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_DOWNLOAD_DOWNLOAD_DANGER_PROMPT_H_
6 #define CHROME_BROWSER_DOWNLOAD_DOWNLOAD_DANGER_PROMPT_H_
8 #include "base/callback_forward.h"
10 namespace content {
11 class DownloadItem;
12 class WebContents;
15 // 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
17 // 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
19 // to accept a dangerous download from script without user intervention. This
20 // step is necessary to prevent a malicious script form abusing such a
21 // privilege.
22 class DownloadDangerPrompt {
23 public:
24 // Actions resulting from showing the danger prompt.
25 enum Action {
26 ACCEPT,
27 CANCEL,
28 DISMISS,
30 typedef base::Callback<void(Action)> OnDone;
32 // Return a new self-deleting DownloadDangerPrompt. |accepted| or |canceled|
33 // 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
35 // progress, or if the tab corresponding to |web_contents| is
36 // closing. The returned DownloadDangerPrompt* is only used for testing. The
37 // caller does not own the object and receive no guarantees about lifetime.
38 // If |show_context|, then the prompt message will contain some information
39 // about the download and its danger; otherwise it won't.
40 static DownloadDangerPrompt* Create(
41 content::DownloadItem* item,
42 content::WebContents* web_contents,
43 bool show_context,
44 const OnDone& done);
46 // Only to be used by tests. Subclasses must override to manually call the
47 // respective button click handler.
48 virtual void InvokeActionForTesting(Action action) = 0;
51 #endif // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_DANGER_PROMPT_H_