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

Side by Side Diff: remoting/host/chromeos/message_box.cc

Issue 690183002: Remote assistance on Chrome OS Part V - It2MeHost Continue Window (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Continue Window Created 6 years, 1 month 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "remoting/host/chromeos/message_box.h"
6
7 #include "base/callback_helpers.h"
8 #include "ui/base/l10n/l10n_util.h"
9 #include "ui/views/widget/widget.h"
10
11 namespace remoting {
12
13 MessageBox::MessageBox(const base::string16& message_label,
14 const base::string16& ok_label,
15 const base::string16& cancel_label,
16 ResultCallback result_callback)
17 : message_label_(message_label),
18 ok_label_(ok_label),
19 cancel_label_(cancel_label),
20 result_callback_(result_callback) {
21 }
22
23 MessageBox::~MessageBox() {
24 }
25
26 void MessageBox::Show() {
27 // The widget is owned by the NativeWidget. See class comments for ownership.
28 views::Widget* widget =
29 CreateDialogWidget(this, /* delegate */
30 nullptr /* parent window*/, nullptr /* parent view */);
31
32 if (widget) {
33 AddRef();
34 widget->Show();
35 }
36 }
37
38 void MessageBox::Hide() {
39 if (GetWidget()) {
40 GetWidget()->Close();
41 }
42 }
43
44 bool MessageBox::Accept() {
45 DCHECK(!result_callback_.is_null());
46 base::ResetAndReturn(&result_callback_).Run(OK);
47 return true /* close the window*/;
48 }
49
50 bool MessageBox::Cancel() {
51 if (result_callback_.is_null()) {
52 return false;
53 }
54 base::ResetAndReturn(&result_callback_).Run(CANCEL);
55 return true /* close the window*/;
56 }
57
58 ui::ModalType MessageBox::GetModalType() const {
59 return ui::MODAL_TYPE_SYSTEM;
60 }
61
62 base::string16 MessageBox::GetWindowTitle() const {
63 return message_label_;
64 }
65
66 base::string16 MessageBox::GetDialogButtonLabel(ui::DialogButton button) const {
67 if (button == ui::DIALOG_BUTTON_OK) {
dcaiafa 2014/10/31 18:05:49 Please use a switch statement here instead.
kelvinp 2014/10/31 21:12:53 Done.
68 return ok_label_;
69 } else if (button == ui::DIALOG_BUTTON_CANCEL) {
70 return cancel_label_;
71 }
72 NOTREACHED();
73 return base::string16();
74 }
75
76 void MessageBox::DeleteDelegate() {
77 Release();
78 }
79
80 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698