download_feedback_dialog_view.h revision f8ee788a64d60abd8f2d742a5fdedde054ecd910
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.
4
5#ifndef CHROME_BROWSER_UI_VIEWS_DOWNLOAD_DOWNLOAD_FEEDBACK_DIALOG_VIEW_H_
6#define CHROME_BROWSER_UI_VIEWS_DOWNLOAD_DOWNLOAD_FEEDBACK_DIALOG_VIEW_H_
7
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"
13
14namespace views {
15class MessageBoxView;
16}
17
18namespace content {
19class PageNavigator;
20}
21
22class Profile;
23
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.
27class DownloadFeedbackDialogView : public views::DialogDelegate,
28                                   public views::LinkListener {
29 public:
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;
33
34  static void Show(
35      gfx::NativeWindow parent_window,
36      Profile* profile,
37      content::PageNavigator* navigator,
38      const UserDecisionCallback& callback);
39
40 private:
41  DownloadFeedbackDialogView(
42      Profile* profile,
43      content::PageNavigator* navigator,
44      const UserDecisionCallback& callback);
45  virtual ~DownloadFeedbackDialogView();
46
47  // Handles the user's decision.
48  bool OnButtonClicked(bool accepted);
49
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;
63
64  // views::LinkListener:
65  virtual void LinkClicked(views::Link* source, int event_flags) OVERRIDE;
66
67  Profile* profile_;
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_;
75
76  DISALLOW_COPY_AND_ASSIGN(DownloadFeedbackDialogView);
77};
78
79#endif  // CHROME_BROWSER_UI_VIEWS_DOWNLOAD_DOWNLOAD_FEEDBACK_DIALOG_VIEW_H_
80