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

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

Issue 2418813002: [Reland] Refactoring of SBER preference usage (Closed)
Patch Set: Sync Created 4 years, 2 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
« no previous file with comments | « chrome/browser/ui/BUILD.gn ('k') | chrome/browser/ui/views/download/download_item_view.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_macros.h" 7 #include "base/metrics/histogram_macros.h"
8 #include "base/supports_user_data.h" 8 #include "base/supports_user_data.h"
9 #include "chrome/browser/platform_util.h" 9 #include "chrome/browser/platform_util.h"
10 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
11 #include "chrome/common/pref_names.h" 11 #include "chrome/common/pref_names.h"
12 #include "chrome/grit/chromium_strings.h" 12 #include "chrome/grit/chromium_strings.h"
13 #include "chrome/grit/generated_resources.h" 13 #include "chrome/grit/generated_resources.h"
14 #include "components/constrained_window/constrained_window_views.h" 14 #include "components/constrained_window/constrained_window_views.h"
15 #include "components/prefs/pref_service.h" 15 #include "components/prefs/pref_service.h"
16 #include "components/safe_browsing_db/safe_browsing_prefs.h"
16 #include "components/strings/grit/components_strings.h" 17 #include "components/strings/grit/components_strings.h"
17 #include "content/public/browser/page_navigator.h" 18 #include "content/public/browser/page_navigator.h"
18 #include "ui/base/l10n/l10n_util.h" 19 #include "ui/base/l10n/l10n_util.h"
19 #include "ui/views/controls/link.h" 20 #include "ui/views/controls/link.h"
20 #include "ui/views/controls/message_box_view.h" 21 #include "ui/views/controls/message_box_view.h"
21 #include "ui/views/widget/widget.h" 22 #include "ui/views/widget/widget.h"
22 23
23 using content::OpenURLParams; 24 using content::OpenURLParams;
24 25
25 namespace { 26 namespace {
(...skipping 13 matching lines...) Expand all
39 } // namespace 40 } // namespace
40 41
41 // static 42 // static
42 void DownloadFeedbackDialogView::Show( 43 void DownloadFeedbackDialogView::Show(
43 gfx::NativeWindow parent_window, 44 gfx::NativeWindow parent_window,
44 Profile* profile, 45 Profile* profile,
45 content::PageNavigator* navigator, 46 content::PageNavigator* navigator,
46 const UserDecisionCallback& callback) { 47 const UserDecisionCallback& callback) {
47 // This dialog should only be shown if it hasn't been shown before. 48 // This dialog should only be shown if it hasn't been shown before.
48 DCHECK(!profile->GetPrefs()->HasPrefPath( 49 DCHECK(!profile->GetPrefs()->HasPrefPath(
49 prefs::kSafeBrowsingExtendedReportingEnabled)); 50 safe_browsing::GetExtendedReportingPrefName()));
50 51
51 // Only one dialog should be shown at a time, so check to see if another one 52 // Only one dialog should be shown at a time, so check to see if another one
52 // is open. If another one is open, treat this parallel call as if reporting 53 // is open. If another one is open, treat this parallel call as if reporting
53 // is disabled (to be conservative). 54 // is disabled (to be conservative).
54 DialogStatusData* data = 55 DialogStatusData* data =
55 static_cast<DialogStatusData*>(profile->GetUserData(kDialogStatusKey)); 56 static_cast<DialogStatusData*>(profile->GetUserData(kDialogStatusKey));
56 if (data == NULL) { 57 if (data == NULL) {
57 data = new DialogStatusData(); 58 data = new DialogStatusData();
58 profile->SetUserData(kDialogStatusKey, data); 59 profile->SetUserData(kDialogStatusKey, data);
59 } 60 }
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 return ui::DIALOG_BUTTON_CANCEL; 95 return ui::DIALOG_BUTTON_CANCEL;
95 } 96 }
96 97
97 base::string16 DownloadFeedbackDialogView::GetDialogButtonLabel( 98 base::string16 DownloadFeedbackDialogView::GetDialogButtonLabel(
98 ui::DialogButton button) const { 99 ui::DialogButton button) const {
99 return (button == ui::DIALOG_BUTTON_OK) ? 100 return (button == ui::DIALOG_BUTTON_OK) ?
100 ok_button_text_ : cancel_button_text_; 101 ok_button_text_ : cancel_button_text_;
101 } 102 }
102 103
103 bool DownloadFeedbackDialogView::OnButtonClicked(bool accepted) { 104 bool DownloadFeedbackDialogView::OnButtonClicked(bool accepted) {
104 profile_->GetPrefs()->SetBoolean(prefs::kSafeBrowsingExtendedReportingEnabled, 105 profile_->GetPrefs()->SetBoolean(
105 accepted); 106 safe_browsing::GetExtendedReportingPrefName(), accepted);
106 DialogStatusData* data = 107 DialogStatusData* data =
107 static_cast<DialogStatusData*>(profile_->GetUserData(kDialogStatusKey)); 108 static_cast<DialogStatusData*>(profile_->GetUserData(kDialogStatusKey));
108 DCHECK(data); 109 DCHECK(data);
109 data->set_currently_shown(false); 110 data->set_currently_shown(false);
110 111
111 UMA_HISTOGRAM_BOOLEAN("Download.FeedbackDialogEnabled", accepted); 112 UMA_HISTOGRAM_BOOLEAN("Download.FeedbackDialogEnabled", accepted);
112 113
113 callback_.Run(accepted); 114 callback_.Run(accepted);
114 return true; 115 return true;
115 } 116 }
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 WindowOpenDisposition disposition = 156 WindowOpenDisposition disposition =
156 ui::DispositionFromEventFlags(event_flags); 157 ui::DispositionFromEventFlags(event_flags);
157 content::OpenURLParams params( 158 content::OpenURLParams params(
158 GURL(l10n_util::GetStringUTF8(IDS_SAFE_BROWSING_PRIVACY_POLICY_URL)), 159 GURL(l10n_util::GetStringUTF8(IDS_SAFE_BROWSING_PRIVACY_POLICY_URL)),
159 content::Referrer(), disposition == WindowOpenDisposition::CURRENT_TAB 160 content::Referrer(), disposition == WindowOpenDisposition::CURRENT_TAB
160 ? WindowOpenDisposition::NEW_FOREGROUND_TAB 161 ? WindowOpenDisposition::NEW_FOREGROUND_TAB
161 : disposition, 162 : disposition,
162 ui::PAGE_TRANSITION_LINK, false); 163 ui::PAGE_TRANSITION_LINK, false);
163 navigator_->OpenURL(params); 164 navigator_->OpenURL(params);
164 } 165 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/BUILD.gn ('k') | chrome/browser/ui/views/download/download_item_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698