| 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/controls/link_listener.h" |
| 11 #include "ui/views/window/dialog_delegate.h" | 12 #include "ui/views/window/dialog_delegate.h" |
| 12 | 13 |
| 13 namespace views { | 14 namespace views { |
| 14 class MessageBoxView; | 15 class MessageBoxView; |
| 15 } | 16 } |
| 16 | 17 |
| 18 namespace content { |
| 19 class PageNavigator; |
| 20 } |
| 21 |
| 17 class Profile; | 22 class Profile; |
| 18 | 23 |
| 19 // Asks the user whether s/he wants to participate in the Safe Browsing | 24 // Asks the user whether s/he wants to participate in the Safe Browsing |
| 20 // download feedback program. Shown only for downloads marked DANGEROUS_HOST | 25 // download feedback program. Shown only for downloads marked DANGEROUS_HOST |
| 21 // or UNCOMMON_DOWNLOAD. The user should only see this dialog once. | 26 // or UNCOMMON_DOWNLOAD. The user should only see this dialog once. |
| 22 class DownloadFeedbackDialogView : public views::DialogDelegate { | 27 class DownloadFeedbackDialogView : public views::DialogDelegate, |
| 28 public views::LinkListener { |
| 23 public: | 29 public: |
| 24 // Callback with the user's decision. |accepted| is true if the user clicked | 30 // Callback with the user's decision. |accepted| is true if the user clicked |
| 25 // Accept(). Otherwise, assume the user cancelled. | 31 // Accept(). Otherwise, assume the user cancelled. |
| 26 typedef base::Callback<void(bool accepted)> UserDecisionCallback; | 32 typedef base::Callback<void(bool accepted)> UserDecisionCallback; |
| 27 | 33 |
| 28 static void Show( | 34 static void Show( |
| 29 gfx::NativeWindow parent_window, | 35 gfx::NativeWindow parent_window, |
| 30 Profile* profile, | 36 Profile* profile, |
| 37 content::PageNavigator* navigator, |
| 31 const UserDecisionCallback& callback); | 38 const UserDecisionCallback& callback); |
| 32 | 39 |
| 33 private: | 40 private: |
| 34 DownloadFeedbackDialogView( | 41 DownloadFeedbackDialogView( |
| 35 Profile* profile, | 42 Profile* profile, |
| 43 content::PageNavigator* navigator, |
| 36 const UserDecisionCallback& callback); | 44 const UserDecisionCallback& callback); |
| 37 virtual ~DownloadFeedbackDialogView(); | 45 virtual ~DownloadFeedbackDialogView(); |
| 38 | 46 |
| 39 // Handles the user's decision. | 47 // Handles the user's decision. |
| 40 bool OnButtonClicked(bool accepted); | 48 bool OnButtonClicked(bool accepted); |
| 41 | 49 |
| 42 // views::DialogDelegate: | 50 // views::DialogDelegate: |
| 43 virtual ui::ModalType GetModalType() const OVERRIDE; | 51 virtual ui::ModalType GetModalType() const OVERRIDE; |
| 44 virtual base::string16 GetWindowTitle() const OVERRIDE; | 52 virtual base::string16 GetWindowTitle() const OVERRIDE; |
| 45 virtual void DeleteDelegate() OVERRIDE; | 53 virtual void DeleteDelegate() OVERRIDE; |
| 46 virtual views::Widget* GetWidget() OVERRIDE; | 54 virtual views::Widget* GetWidget() OVERRIDE; |
| 47 virtual const views::Widget* GetWidget() const OVERRIDE; | 55 virtual const views::Widget* GetWidget() const OVERRIDE; |
| 48 virtual views::View* GetContentsView() OVERRIDE; | 56 virtual views::View* GetContentsView() OVERRIDE; |
| 49 virtual int GetDefaultDialogButton() const OVERRIDE; | 57 virtual int GetDefaultDialogButton() const OVERRIDE; |
| 50 virtual base::string16 GetDialogButtonLabel( | 58 virtual base::string16 GetDialogButtonLabel( |
| 51 ui::DialogButton button) const OVERRIDE; | 59 ui::DialogButton button) const OVERRIDE; |
| 52 virtual bool Cancel() OVERRIDE; | 60 virtual bool Cancel() OVERRIDE; |
| 53 virtual bool Accept() 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; |
| 54 | 66 |
| 55 Profile* profile_; | 67 Profile* profile_; |
| 68 content::PageNavigator* navigator_; |
| 56 const UserDecisionCallback callback_; | 69 const UserDecisionCallback callback_; |
| 57 views::MessageBoxView* explanation_box_view_; | 70 views::MessageBoxView* explanation_box_view_; |
| 71 views::Link* link_view_; |
| 58 base::string16 title_text_; | 72 base::string16 title_text_; |
| 59 base::string16 ok_button_text_; | 73 base::string16 ok_button_text_; |
| 60 base::string16 cancel_button_text_; | 74 base::string16 cancel_button_text_; |
| 61 | 75 |
| 62 DISALLOW_COPY_AND_ASSIGN(DownloadFeedbackDialogView); | 76 DISALLOW_COPY_AND_ASSIGN(DownloadFeedbackDialogView); |
| 63 }; | 77 }; |
| 64 | 78 |
| 65 #endif // CHROME_BROWSER_UI_VIEWS_DOWNLOAD_DOWNLOAD_FEEDBACK_DIALOG_VIEW_H_ | 79 #endif // CHROME_BROWSER_UI_VIEWS_DOWNLOAD_DOWNLOAD_FEEDBACK_DIALOG_VIEW_H_ |
| OLD | NEW |