OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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_UI_VIEWS_DOWNLOAD_DOWNLOAD_FEEDBACK_DIALOG_VIEW_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_DOWNLOAD_DOWNLOAD_FEEDBACK_DIALOG_VIEW_H_ |
6 #define CHROME_BROWSER_UI_VIEWS_DOWNLOAD_DOWNLOAD_FEEDBACK_DIALOG_VIEW_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_DOWNLOAD_DOWNLOAD_FEEDBACK_DIALOG_VIEW_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "chrome/common/pref_names.h" | 10 #include "chrome/common/pref_names.h" |
11 #include "ui/views/window/dialog_delegate.h" | 11 #include "ui/views/window/dialog_delegate.h" |
12 | 12 |
13 namespace views { | 13 namespace views { |
14 class MessageBoxView; | 14 class MessageBoxView; |
15 } | 15 } |
16 | 16 |
17 class Profile; | 17 class Profile; |
18 | 18 |
19 // Asks the user whether s/he wants to participate in the Safe Browsing | 19 // Asks the user whether s/he wants to participate in the Safe Browsing |
20 // download feedback program. Shown only for downloads marked DANGEROUS_HOST | 20 // download feedback program. Shown only for downloads marked DANGEROUS_HOST |
21 // or UNCOMMON_DOWNLOAD. The user should only see this dialog once. | 21 // or UNCOMMON_DOWNLOAD. The user should only see this dialog once. |
22 class DownloadFeedbackDialogView : public views::DialogDelegate { | 22 class DownloadFeedbackDialogView : public views::DialogDelegate { |
23 public: | 23 public: |
24 // Possible values for prefs::kSafeBrowsingDownloadReportingEnabled pref. | 24 // Callback with the user's decision. |accepted| is true if the user clicked |
25 enum DownloadReportingStatus { | 25 // Accept(). Otherwise, assume the user cancelled. |
26 kDialogNotYetShown, | 26 typedef base::Callback<void(bool accepted)> UserDecisionCallback; |
27 kDownloadReportingDisabled, // Set by Cancel(). | |
28 kDownloadReportingEnabled, // Set by Accept(). | |
29 kMaxValue | |
30 }; | |
31 | 27 |
32 static void Show( | 28 static void Show( |
33 gfx::NativeWindow parent_window, | 29 gfx::NativeWindow parent_window, |
34 Profile* profile, | 30 Profile* profile, |
35 const base::Callback<void(DownloadReportingStatus)>& callback); | 31 const UserDecisionCallback& callback); |
36 | 32 |
37 private: | 33 private: |
38 DownloadFeedbackDialogView( | 34 DownloadFeedbackDialogView( |
39 Profile* profile, | 35 Profile* profile, |
40 const base::Callback<void(DownloadReportingStatus)>& callback); | 36 const UserDecisionCallback& callback); |
41 virtual ~DownloadFeedbackDialogView(); | 37 virtual ~DownloadFeedbackDialogView(); |
42 | 38 |
43 void ReleaseDialogStatusHold(); | 39 // Handles the user's decision. |
| 40 bool OnButtonClicked(bool accepted); |
44 | 41 |
45 // views::DialogDelegate: | 42 // views::DialogDelegate: |
46 virtual ui::ModalType GetModalType() const OVERRIDE; | 43 virtual ui::ModalType GetModalType() const OVERRIDE; |
47 virtual base::string16 GetWindowTitle() const OVERRIDE; | 44 virtual base::string16 GetWindowTitle() const OVERRIDE; |
48 virtual void DeleteDelegate() OVERRIDE; | 45 virtual void DeleteDelegate() OVERRIDE; |
49 virtual views::Widget* GetWidget() OVERRIDE; | 46 virtual views::Widget* GetWidget() OVERRIDE; |
50 virtual const views::Widget* GetWidget() const OVERRIDE; | 47 virtual const views::Widget* GetWidget() const OVERRIDE; |
51 virtual views::View* GetContentsView() OVERRIDE; | 48 virtual views::View* GetContentsView() OVERRIDE; |
52 virtual int GetDefaultDialogButton() const OVERRIDE; | 49 virtual int GetDefaultDialogButton() const OVERRIDE; |
53 virtual base::string16 GetDialogButtonLabel( | 50 virtual base::string16 GetDialogButtonLabel( |
54 ui::DialogButton button) const OVERRIDE; | 51 ui::DialogButton button) const OVERRIDE; |
55 virtual bool Cancel() OVERRIDE; | 52 virtual bool Cancel() OVERRIDE; |
56 virtual bool Accept() OVERRIDE; | 53 virtual bool Accept() OVERRIDE; |
57 | 54 |
58 Profile* profile_; | 55 Profile* profile_; |
59 const base::Callback<void(DownloadReportingStatus)> callback_; | 56 const UserDecisionCallback callback_; |
60 views::MessageBoxView* explanation_box_view_; | 57 views::MessageBoxView* explanation_box_view_; |
61 base::string16 title_text_; | 58 base::string16 title_text_; |
62 base::string16 ok_button_text_; | 59 base::string16 ok_button_text_; |
63 base::string16 cancel_button_text_; | 60 base::string16 cancel_button_text_; |
64 | 61 |
65 DISALLOW_COPY_AND_ASSIGN(DownloadFeedbackDialogView); | 62 DISALLOW_COPY_AND_ASSIGN(DownloadFeedbackDialogView); |
66 }; | 63 }; |
67 | 64 |
68 #endif // CHROME_BROWSER_UI_VIEWS_DOWNLOAD_DOWNLOAD_FEEDBACK_DIALOG_VIEW_H_ | 65 #endif // CHROME_BROWSER_UI_VIEWS_DOWNLOAD_DOWNLOAD_FEEDBACK_DIALOG_VIEW_H_ |
OLD | NEW |