1 // Copyright 2014 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_UI_VIEWS_DOWNLOAD_DOWNLOAD_FEEDBACK_DIALOG_VIEW_H_
6 #define CHROME_BROWSER_UI_VIEWS_DOWNLOAD_DOWNLOAD_FEEDBACK_DIALOG_VIEW_H_
8 #include "base/basictypes.h"
9 #include "base/compiler_specific.h"
10 #include "chrome/common/pref_names.h"
11 #include "ui/views/controls/link_listener.h"
12 #include "ui/views/window/dialog_delegate.h"
24 // Asks the user whether s/he wants to participate in the Safe Browsing
25 // download feedback program. Shown only for downloads marked DANGEROUS_HOST
26 // or UNCOMMON_DOWNLOAD. The user should only see this dialog once.
27 class DownloadFeedbackDialogView
: public views::DialogDelegate
,
28 public views::LinkListener
{
30 // Callback with the user's decision. |accepted| is true if the user clicked
31 // Accept(). Otherwise, assume the user cancelled.
32 typedef base::Callback
<void(bool accepted
)> UserDecisionCallback
;
35 gfx::NativeWindow parent_window
,
37 content::PageNavigator
* navigator
,
38 const UserDecisionCallback
& callback
);
41 DownloadFeedbackDialogView(
43 content::PageNavigator
* navigator
,
44 const UserDecisionCallback
& callback
);
45 virtual ~DownloadFeedbackDialogView();
47 // Handles the user's decision.
48 bool OnButtonClicked(bool accepted
);
50 // views::DialogDelegate:
51 virtual ui::ModalType
GetModalType() const override
;
52 virtual base::string16
GetWindowTitle() const override
;
53 virtual void DeleteDelegate() override
;
54 virtual views::Widget
* GetWidget() override
;
55 virtual const views::Widget
* GetWidget() const override
;
56 virtual views::View
* GetContentsView() override
;
57 virtual int GetDefaultDialogButton() const override
;
58 virtual base::string16
GetDialogButtonLabel(
59 ui::DialogButton button
) const override
;
60 virtual bool Cancel() override
;
61 virtual bool Accept() override
;
62 virtual views::View
* CreateExtraView() override
;
64 // views::LinkListener:
65 virtual void LinkClicked(views::Link
* source
, int event_flags
) override
;
68 content::PageNavigator
* navigator_
;
69 const UserDecisionCallback callback_
;
70 views::MessageBoxView
* explanation_box_view_
;
71 views::Link
* link_view_
;
72 base::string16 title_text_
;
73 base::string16 ok_button_text_
;
74 base::string16 cancel_button_text_
;
76 DISALLOW_COPY_AND_ASSIGN(DownloadFeedbackDialogView
);
79 #endif // CHROME_BROWSER_UI_VIEWS_DOWNLOAD_DOWNLOAD_FEEDBACK_DIALOG_VIEW_H_