| 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.h" |
| 7 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
| 8 #include "base/supports_user_data.h" | 9 #include "base/supports_user_data.h" |
| 9 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/browser/ui/views/constrained_window_views.h" | 11 #include "chrome/browser/ui/views/constrained_window_views.h" |
| 11 #include "grit/generated_resources.h" | 12 #include "grit/generated_resources.h" |
| 12 #include "ui/base/l10n/l10n_util.h" | 13 #include "ui/base/l10n/l10n_util.h" |
| 13 #include "ui/views/controls/message_box_view.h" | 14 #include "ui/views/controls/message_box_view.h" |
| 14 #include "ui/views/widget/widget.h" | 15 #include "ui/views/widget/widget.h" |
| 15 | 16 |
| 16 namespace { | 17 namespace { |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 } | 86 } |
| 86 | 87 |
| 87 bool DownloadFeedbackDialogView::OnButtonClicked(bool accepted) { | 88 bool DownloadFeedbackDialogView::OnButtonClicked(bool accepted) { |
| 88 profile_->GetPrefs()->SetBoolean(prefs::kSafeBrowsingDownloadFeedbackEnabled, | 89 profile_->GetPrefs()->SetBoolean(prefs::kSafeBrowsingDownloadFeedbackEnabled, |
| 89 accepted); | 90 accepted); |
| 90 DialogStatusData* data = | 91 DialogStatusData* data = |
| 91 static_cast<DialogStatusData*>(profile_->GetUserData(kDialogStatusKey)); | 92 static_cast<DialogStatusData*>(profile_->GetUserData(kDialogStatusKey)); |
| 92 DCHECK(data); | 93 DCHECK(data); |
| 93 data->set_currently_shown(false); | 94 data->set_currently_shown(false); |
| 94 | 95 |
| 96 UMA_HISTOGRAM_BOOLEAN("Download.FeedbackDialogEnabled", accepted); |
| 97 |
| 95 callback_.Run(accepted); | 98 callback_.Run(accepted); |
| 96 return true; | 99 return true; |
| 97 } | 100 } |
| 98 | 101 |
| 99 bool DownloadFeedbackDialogView::Cancel() { | 102 bool DownloadFeedbackDialogView::Cancel() { |
| 100 return OnButtonClicked(false); | 103 return OnButtonClicked(false); |
| 101 } | 104 } |
| 102 | 105 |
| 103 bool DownloadFeedbackDialogView::Accept() { | 106 bool DownloadFeedbackDialogView::Accept() { |
| 104 return OnButtonClicked(true); | 107 return OnButtonClicked(true); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 120 return explanation_box_view_->GetWidget(); | 123 return explanation_box_view_->GetWidget(); |
| 121 } | 124 } |
| 122 | 125 |
| 123 const views::Widget* DownloadFeedbackDialogView::GetWidget() const { | 126 const views::Widget* DownloadFeedbackDialogView::GetWidget() const { |
| 124 return explanation_box_view_->GetWidget(); | 127 return explanation_box_view_->GetWidget(); |
| 125 } | 128 } |
| 126 | 129 |
| 127 views::View* DownloadFeedbackDialogView::GetContentsView() { | 130 views::View* DownloadFeedbackDialogView::GetContentsView() { |
| 128 return explanation_box_view_; | 131 return explanation_box_view_; |
| 129 } | 132 } |
| OLD | NEW |