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 #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" |
(...skipping 28 matching lines...) Expand all Loading... |
39 | 39 |
40 } // namespace | 40 } // namespace |
41 | 41 |
42 // static | 42 // static |
43 void DownloadFeedbackDialogView::Show( | 43 void DownloadFeedbackDialogView::Show( |
44 gfx::NativeWindow parent_window, | 44 gfx::NativeWindow parent_window, |
45 Profile* profile, | 45 Profile* profile, |
46 content::PageNavigator* navigator, | 46 content::PageNavigator* navigator, |
47 const UserDecisionCallback& callback) { | 47 const UserDecisionCallback& callback) { |
48 // 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. |
49 DCHECK(!profile->GetPrefs()->HasPrefPath( | 49 DCHECK(!safe_browsing::ExtendedReportingPrefExists(*profile->GetPrefs())); |
50 safe_browsing::GetExtendedReportingPrefName())); | |
51 | 50 |
52 // Only one dialog should be shown at a time, so check to see if another one | 51 // Only one dialog should be shown at a time, so check to see if another one |
53 // is open. If another one is open, treat this parallel call as if reporting | 52 // is open. If another one is open, treat this parallel call as if reporting |
54 // is disabled (to be conservative). | 53 // is disabled (to be conservative). |
55 DialogStatusData* data = | 54 DialogStatusData* data = |
56 static_cast<DialogStatusData*>(profile->GetUserData(kDialogStatusKey)); | 55 static_cast<DialogStatusData*>(profile->GetUserData(kDialogStatusKey)); |
57 if (data == NULL) { | 56 if (data == NULL) { |
58 data = new DialogStatusData(); | 57 data = new DialogStatusData(); |
59 profile->SetUserData(kDialogStatusKey, data); | 58 profile->SetUserData(kDialogStatusKey, data); |
60 } | 59 } |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 return ui::DIALOG_BUTTON_CANCEL; | 94 return ui::DIALOG_BUTTON_CANCEL; |
96 } | 95 } |
97 | 96 |
98 base::string16 DownloadFeedbackDialogView::GetDialogButtonLabel( | 97 base::string16 DownloadFeedbackDialogView::GetDialogButtonLabel( |
99 ui::DialogButton button) const { | 98 ui::DialogButton button) const { |
100 return (button == ui::DIALOG_BUTTON_OK) ? | 99 return (button == ui::DIALOG_BUTTON_OK) ? |
101 ok_button_text_ : cancel_button_text_; | 100 ok_button_text_ : cancel_button_text_; |
102 } | 101 } |
103 | 102 |
104 bool DownloadFeedbackDialogView::OnButtonClicked(bool accepted) { | 103 bool DownloadFeedbackDialogView::OnButtonClicked(bool accepted) { |
105 profile_->GetPrefs()->SetBoolean( | 104 safe_browsing::SetExtendedReportingPref(profile_->GetPrefs(), accepted); |
106 safe_browsing::GetExtendedReportingPrefName(), accepted); | |
107 DialogStatusData* data = | 105 DialogStatusData* data = |
108 static_cast<DialogStatusData*>(profile_->GetUserData(kDialogStatusKey)); | 106 static_cast<DialogStatusData*>(profile_->GetUserData(kDialogStatusKey)); |
109 DCHECK(data); | 107 DCHECK(data); |
110 data->set_currently_shown(false); | 108 data->set_currently_shown(false); |
111 | 109 |
112 UMA_HISTOGRAM_BOOLEAN("Download.FeedbackDialogEnabled", accepted); | 110 UMA_HISTOGRAM_BOOLEAN("Download.FeedbackDialogEnabled", accepted); |
113 | 111 |
114 callback_.Run(accepted); | 112 callback_.Run(accepted); |
115 return true; | 113 return true; |
116 } | 114 } |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 WindowOpenDisposition disposition = | 154 WindowOpenDisposition disposition = |
157 ui::DispositionFromEventFlags(event_flags); | 155 ui::DispositionFromEventFlags(event_flags); |
158 content::OpenURLParams params( | 156 content::OpenURLParams params( |
159 GURL(l10n_util::GetStringUTF8(IDS_SAFE_BROWSING_PRIVACY_POLICY_URL)), | 157 GURL(l10n_util::GetStringUTF8(IDS_SAFE_BROWSING_PRIVACY_POLICY_URL)), |
160 content::Referrer(), disposition == WindowOpenDisposition::CURRENT_TAB | 158 content::Referrer(), disposition == WindowOpenDisposition::CURRENT_TAB |
161 ? WindowOpenDisposition::NEW_FOREGROUND_TAB | 159 ? WindowOpenDisposition::NEW_FOREGROUND_TAB |
162 : disposition, | 160 : disposition, |
163 ui::PAGE_TRANSITION_LINK, false); | 161 ui::PAGE_TRANSITION_LINK, false); |
164 navigator_->OpenURL(params); | 162 navigator_->OpenURL(params); |
165 } | 163 } |
OLD | NEW |