summaryrefslogtreecommitdiffstats
path: root/chrome/browser/views/blacklist_error_dialog.cc
blob: 0aa418a7dce15c4544b5039b944015f1979032e0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
// Copyright (c) 2009 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/views/blacklist_error_dialog.h"

#include "app/l10n_util.h"
#include "app/message_box_flags.h"
#include "base/logging.h"
#include "grit/chromium_strings.h"
#include "grit/generated_resources.h"
#include "views/controls/message_box_view.h"
#include "views/widget/widget.h"
#include "views/window/window.h"

// static
bool BlacklistErrorDialog::RunBlacklistErrorDialog() {
  // When the window closes, it will delete itself.
  BlacklistErrorDialog* dlg = new BlacklistErrorDialog;
  MessageLoopForUI::current()->Run(dlg);
  return dlg->accepted();
}

BlacklistErrorDialog::BlacklistErrorDialog()
    : is_blocking_(true), accepted_(false) {
  const int kDialogWidth = 400;
  std::wstring message = l10n_util::GetString(IDS_BLACKLIST_ERROR_LOADING_TEXT);
  box_view_ = new MessageBoxView(MessageBoxFlags::kIsConfirmMessageBox,
                                 message.c_str(), std::wstring(), kDialogWidth);

  views::Window::CreateChromeWindow(NULL, gfx::Rect(), this)->Show();
}

BlacklistErrorDialog::~BlacklistErrorDialog() {
}

std::wstring BlacklistErrorDialog::GetDialogButtonLabel(
    MessageBoxFlags::DialogButton button) const {
  switch (button) {
    case MessageBoxFlags::DIALOGBUTTON_OK:
      return l10n_util::GetString(IDS_BLACKLIST_ERROR_LOADING_CONTINUE);
    case MessageBoxFlags::DIALOGBUTTON_CANCEL:
      return l10n_util::GetString(IDS_BLACKLIST_ERROR_LOADING_EXIT);
  }
  return std::wstring();
}

std::wstring BlacklistErrorDialog::GetWindowTitle() const {
  return l10n_util::GetString(IDS_BLACKLIST_ERROR_LOADING_TITLE);
}

void BlacklistErrorDialog::DeleteDelegate() {
  delete this;
}

bool BlacklistErrorDialog::Accept() {
  is_blocking_ = false;
  accepted_ = true;
  return true;
}

bool BlacklistErrorDialog::Cancel() {
  is_blocking_ = false;
  accepted_ = false;
  return true;
}

views::View* BlacklistErrorDialog::GetContentsView() {
  return box_view_;
}

bool BlacklistErrorDialog::Dispatch(const MSG& msg) {
  TranslateMessage(&msg);
  DispatchMessage(&msg);
  return is_blocking_;
}