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

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

Issue 339073003: Privacy policy links for extended safe browsing reporting (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Bugfix Created 6 years, 6 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 | Annotate | Revision Log
OLDNEW
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 #include "chrome/browser/ui/views/download/download_feedback_dialog_view.h" 5 #include "chrome/browser/ui/views/download/download_feedback_dialog_view.h"
6 6
7 #include "base/metrics/histogram.h" 7 #include "base/metrics/histogram.h"
8 #include "base/prefs/pref_service.h" 8 #include "base/prefs/pref_service.h"
9 #include "base/supports_user_data.h" 9 #include "base/supports_user_data.h"
10 #include "chrome/browser/platform_util.h"
10 #include "chrome/browser/profiles/profile.h" 11 #include "chrome/browser/profiles/profile.h"
11 #include "chrome/browser/ui/views/constrained_window_views.h" 12 #include "chrome/browser/ui/views/constrained_window_views.h"
13 #include "content/public/browser/page_navigator.h"
12 #include "grit/chromium_strings.h" 14 #include "grit/chromium_strings.h"
13 #include "grit/generated_resources.h" 15 #include "grit/generated_resources.h"
14 #include "ui/base/l10n/l10n_util.h" 16 #include "ui/base/l10n/l10n_util.h"
17 #include "ui/views/controls/link.h"
15 #include "ui/views/controls/message_box_view.h" 18 #include "ui/views/controls/message_box_view.h"
16 #include "ui/views/widget/widget.h" 19 #include "ui/views/widget/widget.h"
17 20
21 using content::OpenURLParams;
22
18 namespace { 23 namespace {
19 24
20 const void* kDialogStatusKey = &kDialogStatusKey; 25 const void* kDialogStatusKey = &kDialogStatusKey;
21 26
22 class DialogStatusData : public base::SupportsUserData::Data { 27 class DialogStatusData : public base::SupportsUserData::Data {
23 public: 28 public:
24 DialogStatusData() : currently_shown_(false) {} 29 DialogStatusData() : currently_shown_(false) {}
25 virtual ~DialogStatusData() {} 30 virtual ~DialogStatusData() {}
26 bool currently_shown() const { return currently_shown_; } 31 bool currently_shown() const { return currently_shown_; }
27 void set_currently_shown(bool shown) { currently_shown_ = shown; } 32 void set_currently_shown(bool shown) { currently_shown_ = shown; }
28 private: 33 private:
29 bool currently_shown_; 34 bool currently_shown_;
30 }; 35 };
31 36
32 } // namespace 37 } // namespace
33 38
34 // static 39 // static
35 void DownloadFeedbackDialogView::Show( 40 void DownloadFeedbackDialogView::Show(
36 gfx::NativeWindow parent_window, 41 gfx::NativeWindow parent_window,
37 Profile* profile, 42 Profile* profile,
43 content::PageNavigator* navigator,
38 const UserDecisionCallback& callback) { 44 const UserDecisionCallback& callback) {
39 // This dialog should only be shown if it hasn't been shown before. 45 // This dialog should only be shown if it hasn't been shown before.
40 DCHECK(!profile->GetPrefs()->HasPrefPath( 46 DCHECK(!profile->GetPrefs()->HasPrefPath(
41 prefs::kSafeBrowsingExtendedReportingEnabled)); 47 prefs::kSafeBrowsingExtendedReportingEnabled));
42 48
43 // Only one dialog should be shown at a time, so check to see if another one 49 // Only one dialog should be shown at a time, so check to see if another one
44 // is open. If another one is open, treat this parallel call as if reporting 50 // is open. If another one is open, treat this parallel call as if reporting
45 // is disabled (to be conservative). 51 // is disabled (to be conservative).
46 DialogStatusData* data = 52 DialogStatusData* data =
47 static_cast<DialogStatusData*>(profile->GetUserData(kDialogStatusKey)); 53 static_cast<DialogStatusData*>(profile->GetUserData(kDialogStatusKey));
48 if (data == NULL) { 54 if (data == NULL) {
49 data = new DialogStatusData(); 55 data = new DialogStatusData();
50 profile->SetUserData(kDialogStatusKey, data); 56 profile->SetUserData(kDialogStatusKey, data);
51 } 57 }
52 if (data->currently_shown() == false) { 58 if (data->currently_shown() == false) {
53 data->set_currently_shown(true); 59 data->set_currently_shown(true);
54 DownloadFeedbackDialogView* window = 60 DownloadFeedbackDialogView* window =
55 new DownloadFeedbackDialogView(profile, callback); 61 new DownloadFeedbackDialogView(profile, navigator, callback);
56 CreateBrowserModalDialogViews(window, parent_window)->Show(); 62 CreateBrowserModalDialogViews(window, parent_window)->Show();
57 } else { 63 } else {
58 callback.Run(false); 64 callback.Run(false);
59 } 65 }
60 } 66 }
61 67
62 DownloadFeedbackDialogView::DownloadFeedbackDialogView( 68 DownloadFeedbackDialogView::DownloadFeedbackDialogView(
63 Profile* profile, 69 Profile* profile,
70 content::PageNavigator* navigator,
64 const UserDecisionCallback& callback) 71 const UserDecisionCallback& callback)
65 : profile_(profile), 72 : profile_(profile),
73 navigator_(navigator),
66 callback_(callback), 74 callback_(callback),
67 explanation_box_view_(new views::MessageBoxView( 75 explanation_box_view_(new views::MessageBoxView(
68 views::MessageBoxView::InitParams(l10n_util::GetStringUTF16( 76 views::MessageBoxView::InitParams(l10n_util::GetStringUTF16(
69 IDS_FEEDBACK_SERVICE_DIALOG_EXPLANATION)))), 77 IDS_FEEDBACK_SERVICE_DIALOG_EXPLANATION)))),
78 link_view_(new views::Link(l10n_util::GetStringUTF16(
79 IDS_SAFE_BROWSING_PRIVACY_POLICY_PAGE_V2))),
70 title_text_(l10n_util::GetStringUTF16(IDS_FEEDBACK_SERVICE_DIALOG_TITLE)), 80 title_text_(l10n_util::GetStringUTF16(IDS_FEEDBACK_SERVICE_DIALOG_TITLE)),
71 ok_button_text_(l10n_util::GetStringUTF16( 81 ok_button_text_(l10n_util::GetStringUTF16(
72 IDS_FEEDBACK_SERVICE_DIALOG_OK_BUTTON_LABEL)), 82 IDS_FEEDBACK_SERVICE_DIALOG_OK_BUTTON_LABEL)),
73 cancel_button_text_(l10n_util::GetStringUTF16( 83 cancel_button_text_(l10n_util::GetStringUTF16(
74 IDS_FEEDBACK_SERVICE_DIALOG_CANCEL_BUTTON_LABEL)) { 84 IDS_FEEDBACK_SERVICE_DIALOG_CANCEL_BUTTON_LABEL)) {
85 link_view_->set_listener(this);
75 } 86 }
76 87
77 DownloadFeedbackDialogView::~DownloadFeedbackDialogView() {} 88 DownloadFeedbackDialogView::~DownloadFeedbackDialogView() {}
78 89
79 int DownloadFeedbackDialogView::GetDefaultDialogButton() const { 90 int DownloadFeedbackDialogView::GetDefaultDialogButton() const {
80 return ui::DIALOG_BUTTON_CANCEL; 91 return ui::DIALOG_BUTTON_CANCEL;
81 } 92 }
82 93
83 base::string16 DownloadFeedbackDialogView::GetDialogButtonLabel( 94 base::string16 DownloadFeedbackDialogView::GetDialogButtonLabel(
84 ui::DialogButton button) const { 95 ui::DialogButton button) const {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 return explanation_box_view_->GetWidget(); 135 return explanation_box_view_->GetWidget();
125 } 136 }
126 137
127 const views::Widget* DownloadFeedbackDialogView::GetWidget() const { 138 const views::Widget* DownloadFeedbackDialogView::GetWidget() const {
128 return explanation_box_view_->GetWidget(); 139 return explanation_box_view_->GetWidget();
129 } 140 }
130 141
131 views::View* DownloadFeedbackDialogView::GetContentsView() { 142 views::View* DownloadFeedbackDialogView::GetContentsView() {
132 return explanation_box_view_; 143 return explanation_box_view_;
133 } 144 }
145
146 views::View* DownloadFeedbackDialogView::CreateExtraView() {
147 return link_view_;
148 }
149
150 void DownloadFeedbackDialogView::LinkClicked(
151 views::Link* source, int event_flags) {
152 WindowOpenDisposition disposition =
153 ui::DispositionFromEventFlags(event_flags);
154 content::OpenURLParams params(
155 GURL(l10n_util::GetStringUTF8(IDS_SAFE_BROWSING_PRIVACY_POLICY_URL)),
156 content::Referrer(),
157 disposition == CURRENT_TAB ? NEW_FOREGROUND_TAB : disposition,
158 content::PAGE_TRANSITION_LINK, false);
159 navigator_->OpenURL(params);
sky 2014/06/17 19:11:28 How do you know navigator_ is still valid by the t
felt 2014/06/17 20:27:31 The navigator is from the download shelf, which wo
sky 2014/06/17 23:54:41 DCHECK(navigator_) wouldn't tell if you the object
160 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698