OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/views/blacklist_error_dialog.h" |
| 6 |
| 7 #include "app/l10n_util.h" |
| 8 #include "app/message_box_flags.h" |
| 9 #include "base/logging.h" |
| 10 #include "grit/chromium_strings.h" |
| 11 #include "grit/generated_resources.h" |
| 12 #include "views/controls/message_box_view.h" |
| 13 #include "views/widget/widget.h" |
| 14 #include "views/window/window.h" |
| 15 |
| 16 // static |
| 17 bool BlacklistErrorDialog::RunBlacklistErrorDialog() { |
| 18 // When the window closes, it will delete itself. |
| 19 BlacklistErrorDialog* dlg = new BlacklistErrorDialog; |
| 20 MessageLoopForUI::current()->Run(dlg); |
| 21 return dlg->accepted(); |
| 22 } |
| 23 |
| 24 BlacklistErrorDialog::BlacklistErrorDialog() |
| 25 : is_blocking_(true), accepted_(false) { |
| 26 const int kDialogWidth = 400; |
| 27 std::wstring message = l10n_util::GetString(IDS_BLACKLIST_ERROR_LOADING_TEXT); |
| 28 box_view_ = new MessageBoxView(MessageBoxFlags::kIsConfirmMessageBox, |
| 29 message.c_str(), std::wstring(), kDialogWidth); |
| 30 |
| 31 views::Window::CreateChromeWindow(NULL, gfx::Rect(), this)->Show(); |
| 32 } |
| 33 |
| 34 BlacklistErrorDialog::~BlacklistErrorDialog() { |
| 35 } |
| 36 |
| 37 std::wstring BlacklistErrorDialog::GetDialogButtonLabel( |
| 38 MessageBoxFlags::DialogButton button) const { |
| 39 switch (button) { |
| 40 case MessageBoxFlags::DIALOGBUTTON_OK: |
| 41 return l10n_util::GetString(IDS_BLACKLIST_ERROR_LOADING_CONTINUE); |
| 42 case MessageBoxFlags::DIALOGBUTTON_CANCEL: |
| 43 return l10n_util::GetString(IDS_BLACKLIST_ERROR_LOADING_EXIT); |
| 44 } |
| 45 return std::wstring(); |
| 46 } |
| 47 |
| 48 std::wstring BlacklistErrorDialog::GetWindowTitle() const { |
| 49 return l10n_util::GetString(IDS_BLACKLIST_ERROR_LOADING_TITLE); |
| 50 } |
| 51 |
| 52 void BlacklistErrorDialog::DeleteDelegate() { |
| 53 delete this; |
| 54 } |
| 55 |
| 56 bool BlacklistErrorDialog::Accept() { |
| 57 is_blocking_ = false; |
| 58 accepted_ = true; |
| 59 return true; |
| 60 } |
| 61 |
| 62 bool BlacklistErrorDialog::Cancel() { |
| 63 is_blocking_ = false; |
| 64 accepted_ = false; |
| 65 return true; |
| 66 } |
| 67 |
| 68 views::View* BlacklistErrorDialog::GetContentsView() { |
| 69 return box_view_; |
| 70 } |
| 71 |
| 72 bool BlacklistErrorDialog::Dispatch(const MSG& msg) { |
| 73 TranslateMessage(&msg); |
| 74 DispatchMessage(&msg); |
| 75 return is_blocking_; |
| 76 } |
OLD | NEW |