Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(118)

Side by Side Diff: chrome/browser/views/confirm_message_box_dialog.cc

Issue 155291: Adding a message box to confirm if the user really wants to delete all stored... (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 11 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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/confirm_message_box_dialog.h"
6
7 #include "app/l10n_util.h"
8 #include "app/message_box_flags.h"
9 #include "base/message_loop.h"
10 #include "grit/generated_resources.h"
11 #include "views/controls/message_box_view.h"
12 #include "views/widget/widget.h"
13 #include "views/window/window.h"
14
15 // static
16 bool ConfirmMessageBoxDialog::Run(gfx::NativeWindow parent,
17 const std::wstring& message_text,
18 const std::wstring& window_title) {
19 ConfirmMessageBoxDialog* dialog = new ConfirmMessageBoxDialog(parent,
20 message_text, window_title);
21 MessageLoopForUI::current()->Run(dialog);
22 return dialog->accepted();
23 }
24
25 ConfirmMessageBoxDialog::ConfirmMessageBoxDialog(gfx::NativeWindow parent,
26 const std::wstring& message_text,
27 const std::wstring& window_title)
28 : message_text_(message_text),
29 window_title_(window_title),
30 accepted_(false),
31 is_blocking_(true) {
32 message_box_view_ = new MessageBoxView(MessageBoxFlags::kIsConfirmMessageBox,
33 message_text_, window_title_);
34 views::Window::CreateChromeWindow(parent, gfx::Rect(), this)->Show();
35 }
36
37 ConfirmMessageBoxDialog::~ConfirmMessageBoxDialog() {
38 }
39
40 void ConfirmMessageBoxDialog::DeleteDelegate() {
41 delete this;
42 }
43
44 int ConfirmMessageBoxDialog::GetDialogButtons() const {
45 return MessageBoxFlags::DIALOGBUTTON_OK |
46 MessageBoxFlags::DIALOGBUTTON_CANCEL;
47 }
48
49 std::wstring ConfirmMessageBoxDialog::GetWindowTitle() const {
50 return window_title_;
51 }
52
53 std::wstring ConfirmMessageBoxDialog::GetDialogButtonLabel(
54 MessageBoxFlags::DialogButton button) const {
55 if (button == MessageBoxFlags::DIALOGBUTTON_OK) {
56 return l10n_util::GetString(IDS_CONFIRM_MESSAGEBOX_YES_BUTTON_LABEL);
57 }
58 if (button == MessageBoxFlags::DIALOGBUTTON_CANCEL)
59 return l10n_util::GetString(IDS_CONFIRM_MESSAGEBOX_NO_BUTTON_LABEL);
60 return DialogDelegate::GetDialogButtonLabel(button);
61 }
62
63 views::View* ConfirmMessageBoxDialog::GetContentsView() {
64 return message_box_view_;
65 }
66
67 bool ConfirmMessageBoxDialog::Accept() {
68 is_blocking_ = false;
69 accepted_ = true;
70 return true;
71 }
72
73 bool ConfirmMessageBoxDialog::Cancel() {
74 is_blocking_ = false;
75 accepted_ = false;
76 return true;
77 }
78
79 bool ConfirmMessageBoxDialog::Dispatch(const MSG& msg) {
80 TranslateMessage(&msg);
81 DispatchMessage(&msg);
82 return is_blocking_;
83 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698