Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(111)

Side by Side Diff: chrome/browser/ui/views/download/download_feedback_dialog_view.cc

Issue 147593002: Implement new dangerous download reporting dialog for UNCOMMON_DOWNLOAD, in Views (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove logging statement Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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 #include "chrome/browser/ui/views/download/download_feedback_dialog_view.h"
6
7 #include "chrome/browser/prefs/pref_service_syncable.h"
8 #include "chrome/browser/profiles/profile.h"
9 #include "chrome/browser/ui/views/constrained_window_views.h"
10 #include "grit/generated_resources.h"
11 #include "ui/base/l10n/l10n_util.h"
12 #include "ui/views/controls/message_box_view.h"
13 #include "ui/views/widget/widget.h"
14
15 // static
16 void DownloadFeedbackDialogView::Show(
17 gfx::NativeWindow parent_window,
18 Profile* profile,
19 const base::Callback<void(DownloadReportingStatus)>& callback) {
20 // This dialog should only be shown if it hasn't been shown before.
21 DCHECK(profile->GetPrefs()->GetInteger(
22 prefs::kSafeBrowsingDownloadReportingEnabled) == kDialogNotYetShown);
23 DownloadFeedbackDialogView* window =
24 new DownloadFeedbackDialogView(profile, callback);
25 CreateBrowserModalDialogViews(window, parent_window)->Show();
26 }
27
28 DownloadFeedbackDialogView::DownloadFeedbackDialogView(
29 Profile* profile,
30 const base::Callback<void(DownloadReportingStatus)>& callback)
31 : profile_(profile),
32 callback_(callback),
33 explanation_box_view_(new views::MessageBoxView(
34 views::MessageBoxView::InitParams(l10n_util::GetStringUTF16(
35 IDS_FEEDBACK_SERVICE_DIALOG_EXPLANATION)))),
36 title_text_(l10n_util::GetStringUTF16(IDS_FEEDBACK_SERVICE_DIALOG_TITLE)),
37 ok_button_text_(l10n_util::GetStringUTF16(
38 IDS_FEEDBACK_SERVICE_DIALOG_OK_BUTTON_LABEL)),
39 cancel_button_text_(l10n_util::GetStringUTF16(
40 IDS_FEEDBACK_SERVICE_DIALOG_CANCEL_BUTTON_LABEL)) {
41 }
42
43 DownloadFeedbackDialogView::~DownloadFeedbackDialogView() {}
44
45 int DownloadFeedbackDialogView::GetDefaultDialogButton() const {
46 return ui::DIALOG_BUTTON_CANCEL;
47 }
48
49 base::string16 DownloadFeedbackDialogView::GetDialogButtonLabel(
50 ui::DialogButton button) const {
51 return (button == ui::DIALOG_BUTTON_OK) ?
52 ok_button_text_ : cancel_button_text_;
53 }
54
55 bool DownloadFeedbackDialogView::Cancel() {
56 profile_->GetPrefs()->SetInteger(
57 prefs::kSafeBrowsingDownloadReportingEnabled, kDownloadReportingDisabled);
58 callback_.Run(kDownloadReportingDisabled);
59 return true;
60 }
61
62 bool DownloadFeedbackDialogView::Accept() {
63 profile_->GetPrefs()->SetInteger(
64 prefs::kSafeBrowsingDownloadReportingEnabled, kDownloadReportingEnabled);
65 callback_.Run(kDownloadReportingEnabled);
66 return true;
67 }
68
69 ui::ModalType DownloadFeedbackDialogView::GetModalType() const {
70 return ui::MODAL_TYPE_WINDOW;
71 }
72
73 base::string16 DownloadFeedbackDialogView::GetWindowTitle() const {
74 return title_text_;
75 }
76
77 void DownloadFeedbackDialogView::DeleteDelegate() {
78 delete this;
79 }
80
81 views::Widget* DownloadFeedbackDialogView::GetWidget() {
82 return explanation_box_view_->GetWidget();
83 }
84
85 const views::Widget* DownloadFeedbackDialogView::GetWidget() const {
86 return explanation_box_view_->GetWidget();
87 }
88
89 views::View* DownloadFeedbackDialogView::GetContentsView() {
90 return explanation_box_view_;
91 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698