| Index: chrome/browser/ui/views/download/download_feedback_dialog_view.cc
|
| diff --git a/chrome/browser/ui/views/download/download_feedback_dialog_view.cc b/chrome/browser/ui/views/download/download_feedback_dialog_view.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..58dc7d76e757a32a01dc82ef6cec5ecb058b1e02
|
| --- /dev/null
|
| +++ b/chrome/browser/ui/views/download/download_feedback_dialog_view.cc
|
| @@ -0,0 +1,91 @@
|
| +// Copyright 2014 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "chrome/browser/ui/views/download/download_feedback_dialog_view.h"
|
| +
|
| +#include "chrome/browser/prefs/pref_service_syncable.h"
|
| +#include "chrome/browser/profiles/profile.h"
|
| +#include "chrome/browser/ui/views/constrained_window_views.h"
|
| +#include "grit/generated_resources.h"
|
| +#include "ui/base/l10n/l10n_util.h"
|
| +#include "ui/views/controls/message_box_view.h"
|
| +#include "ui/views/widget/widget.h"
|
| +
|
| +// static
|
| +void DownloadFeedbackDialogView::Show(
|
| + gfx::NativeWindow parent_window,
|
| + Profile* profile,
|
| + const base::Callback<void(DownloadReportingStatus)>& callback) {
|
| + // This dialog should only be shown if it hasn't been shown before.
|
| + DCHECK(profile->GetPrefs()->GetInteger(
|
| + prefs::kSafeBrowsingDownloadReportingEnabled) == kDialogNotYetShown);
|
| + DownloadFeedbackDialogView* window =
|
| + new DownloadFeedbackDialogView(profile, callback);
|
| + CreateBrowserModalDialogViews(window, parent_window)->Show();
|
| +}
|
| +
|
| +DownloadFeedbackDialogView::DownloadFeedbackDialogView(
|
| + Profile* profile,
|
| + const base::Callback<void(DownloadReportingStatus)>& callback)
|
| + : profile_(profile),
|
| + callback_(callback),
|
| + explanation_box_view_(new views::MessageBoxView(
|
| + views::MessageBoxView::InitParams(l10n_util::GetStringUTF16(
|
| + IDS_FEEDBACK_SERVICE_DIALOG_EXPLANATION)))),
|
| + title_text_(l10n_util::GetStringUTF16(IDS_FEEDBACK_SERVICE_DIALOG_TITLE)),
|
| + ok_button_text_(l10n_util::GetStringUTF16(
|
| + IDS_FEEDBACK_SERVICE_DIALOG_OK_BUTTON_LABEL)),
|
| + cancel_button_text_(l10n_util::GetStringUTF16(
|
| + IDS_FEEDBACK_SERVICE_DIALOG_CANCEL_BUTTON_LABEL)) {
|
| +}
|
| +
|
| +DownloadFeedbackDialogView::~DownloadFeedbackDialogView() {}
|
| +
|
| +int DownloadFeedbackDialogView::GetDefaultDialogButton() const {
|
| + return ui::DIALOG_BUTTON_CANCEL;
|
| +}
|
| +
|
| +base::string16 DownloadFeedbackDialogView::GetDialogButtonLabel(
|
| + ui::DialogButton button) const {
|
| + return (button == ui::DIALOG_BUTTON_OK) ?
|
| + ok_button_text_ : cancel_button_text_;
|
| +}
|
| +
|
| +bool DownloadFeedbackDialogView::Cancel() {
|
| + profile_->GetPrefs()->SetInteger(
|
| + prefs::kSafeBrowsingDownloadReportingEnabled, kDownloadReportingDisabled);
|
| + callback_.Run(kDownloadReportingDisabled);
|
| + return true;
|
| +}
|
| +
|
| +bool DownloadFeedbackDialogView::Accept() {
|
| + profile_->GetPrefs()->SetInteger(
|
| + prefs::kSafeBrowsingDownloadReportingEnabled, kDownloadReportingEnabled);
|
| + callback_.Run(kDownloadReportingEnabled);
|
| + return true;
|
| +}
|
| +
|
| +ui::ModalType DownloadFeedbackDialogView::GetModalType() const {
|
| + return ui::MODAL_TYPE_WINDOW;
|
| +}
|
| +
|
| +base::string16 DownloadFeedbackDialogView::GetWindowTitle() const {
|
| + return title_text_;
|
| +}
|
| +
|
| +void DownloadFeedbackDialogView::DeleteDelegate() {
|
| + delete this;
|
| +}
|
| +
|
| +views::Widget* DownloadFeedbackDialogView::GetWidget() {
|
| + return explanation_box_view_->GetWidget();
|
| +}
|
| +
|
| +const views::Widget* DownloadFeedbackDialogView::GetWidget() const {
|
| + return explanation_box_view_->GetWidget();
|
| +}
|
| +
|
| +views::View* DownloadFeedbackDialogView::GetContentsView() {
|
| + return explanation_box_view_;
|
| +}
|
|
|