download_feedback_dialog_view.h revision 5d1f7b1de12d16ceb2c938c56701a3e8bfa558f7
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/window/dialog_delegate.h" 12 13namespace views { 14class MessageBoxView; 15} 16 17class Profile; 18 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 21// or UNCOMMON_DOWNLOAD. The user should only see this dialog once. 22class DownloadFeedbackDialogView : public views::DialogDelegate { 23 public: 24 // Callback with the user's decision. |accepted| is true if the user clicked 25 // Accept(). Otherwise, assume the user cancelled. 26 typedef base::Callback<void(bool accepted)> UserDecisionCallback; 27 28 static void Show( 29 gfx::NativeWindow parent_window, 30 Profile* profile, 31 const UserDecisionCallback& callback); 32 33 private: 34 DownloadFeedbackDialogView( 35 Profile* profile, 36 const UserDecisionCallback& callback); 37 virtual ~DownloadFeedbackDialogView(); 38 39 // Handles the user's decision. 40 bool OnButtonClicked(bool accepted); 41 42 // views::DialogDelegate: 43 virtual ui::ModalType GetModalType() const OVERRIDE; 44 virtual base::string16 GetWindowTitle() const OVERRIDE; 45 virtual void DeleteDelegate() OVERRIDE; 46 virtual views::Widget* GetWidget() OVERRIDE; 47 virtual const views::Widget* GetWidget() const OVERRIDE; 48 virtual views::View* GetContentsView() OVERRIDE; 49 virtual int GetDefaultDialogButton() const OVERRIDE; 50 virtual base::string16 GetDialogButtonLabel( 51 ui::DialogButton button) const OVERRIDE; 52 virtual bool Cancel() OVERRIDE; 53 virtual bool Accept() OVERRIDE; 54 55 Profile* profile_; 56 const UserDecisionCallback callback_; 57 views::MessageBoxView* explanation_box_view_; 58 base::string16 title_text_; 59 base::string16 ok_button_text_; 60 base::string16 cancel_button_text_; 61 62 DISALLOW_COPY_AND_ASSIGN(DownloadFeedbackDialogView); 63}; 64 65#endif // CHROME_BROWSER_UI_VIEWS_DOWNLOAD_DOWNLOAD_FEEDBACK_DIALOG_VIEW_H_ 66