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

Unified 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, 2 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 side-by-side diff with in-line comments
Download patch
Index: remoting/host/chromeos/message_box.cc
diff --git a/remoting/host/chromeos/message_box.cc b/remoting/host/chromeos/message_box.cc
new file mode 100644
index 0000000000000000000000000000000000000000..de439bcab1d763a35ab743be99eed6d4f02aa211
--- /dev/null
+++ b/remoting/host/chromeos/message_box.cc
@@ -0,0 +1,80 @@
+// 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 "remoting/host/chromeos/message_box.h"
+
+#include "base/callback_helpers.h"
+#include "ui/base/l10n/l10n_util.h"
+#include "ui/views/widget/widget.h"
+
+namespace remoting {
+
+MessageBox::MessageBox(const base::string16& message_label,
+ const base::string16& ok_label,
+ const base::string16& cancel_label,
+ ResultCallback result_callback)
+ : message_label_(message_label),
+ ok_label_(ok_label),
+ cancel_label_(cancel_label),
+ result_callback_(result_callback) {
+}
+
+MessageBox::~MessageBox() {
+}
+
+void MessageBox::Show() {
+ // The widget is owned by the NativeWidget. See class comments for ownership.
+ views::Widget* widget =
+ CreateDialogWidget(this, /* delegate */
+ nullptr /* parent window*/, nullptr /* parent view */);
+
+ if (widget) {
+ AddRef();
+ widget->Show();
+ }
+}
+
+void MessageBox::Hide() {
+ if (GetWidget()) {
+ GetWidget()->Close();
+ }
+}
+
+bool MessageBox::Accept() {
+ DCHECK(!result_callback_.is_null());
+ base::ResetAndReturn(&result_callback_).Run(OK);
+ return true /* close the window*/;
+}
+
+bool MessageBox::Cancel() {
+ if (result_callback_.is_null()) {
+ return false;
+ }
+ base::ResetAndReturn(&result_callback_).Run(CANCEL);
+ return true /* close the window*/;
+}
+
+ui::ModalType MessageBox::GetModalType() const {
+ return ui::MODAL_TYPE_SYSTEM;
+}
+
+base::string16 MessageBox::GetWindowTitle() const {
+ return message_label_;
+}
+
+base::string16 MessageBox::GetDialogButtonLabel(ui::DialogButton button) const {
+ 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.
+ return ok_label_;
+ } else if (button == ui::DIALOG_BUTTON_CANCEL) {
+ return cancel_label_;
+ }
+ NOTREACHED();
+ return base::string16();
+}
+
+void MessageBox::DeleteDelegate() {
+ Release();
+}
+
+} // namespace remoting

Powered by Google App Engine
This is Rietveld 408576698