OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "remoting/host/continue_window.h" | 5 #include "remoting/host/continue_window.h" |
6 | 6 |
7 #include <gtk/gtk.h> | 7 #include <gtk/gtk.h> |
8 | 8 |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
12 #include "remoting/host/chromoting_host.h" | 12 #include "remoting/host/chromoting_host.h" |
13 #include "remoting/host/ui_strings.h" | 13 #include "remoting/host/ui_strings.h" |
14 #include "ui/base/gtk/gtk_signal.h" | 14 #include "ui/base/gtk/gtk_signal.h" |
15 | 15 |
16 namespace remoting { | 16 namespace remoting { |
17 | 17 |
18 class ContinueWindowLinux : public remoting::ContinueWindow { | 18 class ContinueWindowLinux : public remoting::ContinueWindow { |
19 public: | 19 public: |
20 ContinueWindowLinux(); | 20 ContinueWindowLinux(); |
21 virtual ~ContinueWindowLinux(); | 21 virtual ~ContinueWindowLinux(); |
22 | 22 |
23 virtual void Show(remoting::ChromotingHost* host) OVERRIDE; | 23 virtual void Show(remoting::ChromotingHost* host, |
| 24 const ContinueSessionCallback& callback) OVERRIDE; |
24 virtual void Hide() OVERRIDE; | 25 virtual void Hide() OVERRIDE; |
25 | 26 |
26 private: | 27 private: |
27 CHROMEGTK_CALLBACK_1(ContinueWindowLinux, void, OnResponse, int); | 28 CHROMEGTK_CALLBACK_1(ContinueWindowLinux, void, OnResponse, int); |
28 | 29 |
29 void CreateWindow(const UiStrings& ui_strings); | 30 void CreateWindow(const UiStrings& ui_strings); |
30 | 31 |
31 ChromotingHost* host_; | 32 ChromotingHost* host_; |
| 33 ContinueSessionCallback callback_; |
32 GtkWidget* continue_window_; | 34 GtkWidget* continue_window_; |
33 | 35 |
34 DISALLOW_COPY_AND_ASSIGN(ContinueWindowLinux); | 36 DISALLOW_COPY_AND_ASSIGN(ContinueWindowLinux); |
35 }; | 37 }; |
36 | 38 |
37 ContinueWindowLinux::ContinueWindowLinux() | 39 ContinueWindowLinux::ContinueWindowLinux() |
38 : host_(NULL), | 40 : host_(NULL), |
39 continue_window_(NULL) { | 41 continue_window_(NULL) { |
40 } | 42 } |
41 | 43 |
(...skipping 30 matching lines...) Expand all Loading... |
72 GtkWidget* text_label = | 74 GtkWidget* text_label = |
73 gtk_label_new(UTF16ToUTF8(ui_strings.continue_prompt).c_str()); | 75 gtk_label_new(UTF16ToUTF8(ui_strings.continue_prompt).c_str()); |
74 gtk_label_set_line_wrap(GTK_LABEL(text_label), TRUE); | 76 gtk_label_set_line_wrap(GTK_LABEL(text_label), TRUE); |
75 // TODO(lambroslambrou): Fix magic numbers, as in disconnect_window_linux.cc. | 77 // TODO(lambroslambrou): Fix magic numbers, as in disconnect_window_linux.cc. |
76 gtk_misc_set_padding(GTK_MISC(text_label), 12, 12); | 78 gtk_misc_set_padding(GTK_MISC(text_label), 12, 12); |
77 gtk_container_add(GTK_CONTAINER(content_area), text_label); | 79 gtk_container_add(GTK_CONTAINER(content_area), text_label); |
78 | 80 |
79 gtk_widget_show_all(content_area); | 81 gtk_widget_show_all(content_area); |
80 } | 82 } |
81 | 83 |
82 void ContinueWindowLinux::Show(remoting::ChromotingHost* host) { | 84 void ContinueWindowLinux::Show(remoting::ChromotingHost* host, |
| 85 const ContinueSessionCallback& callback) { |
83 host_ = host; | 86 host_ = host; |
| 87 callback_ = callback; |
84 CreateWindow(host->ui_strings()); | 88 CreateWindow(host->ui_strings()); |
85 gtk_window_set_urgency_hint(GTK_WINDOW(continue_window_), TRUE); | 89 gtk_window_set_urgency_hint(GTK_WINDOW(continue_window_), TRUE); |
86 gtk_window_present(GTK_WINDOW(continue_window_)); | 90 gtk_window_present(GTK_WINDOW(continue_window_)); |
87 } | 91 } |
88 | 92 |
89 void ContinueWindowLinux::Hide() { | 93 void ContinueWindowLinux::Hide() { |
90 if (continue_window_) { | 94 if (continue_window_) { |
91 gtk_widget_destroy(continue_window_); | 95 gtk_widget_destroy(continue_window_); |
92 continue_window_ = NULL; | 96 continue_window_ = NULL; |
93 } | 97 } |
94 } | 98 } |
95 | 99 |
96 void ContinueWindowLinux::OnResponse(GtkWidget* dialog, int response_id) { | 100 void ContinueWindowLinux::OnResponse(GtkWidget* dialog, int response_id) { |
97 if (response_id == GTK_RESPONSE_OK) { | 101 callback_.Run(response_id == GTK_RESPONSE_OK); |
98 host_->PauseSession(false); | |
99 } else { | |
100 host_->Shutdown(base::Closure()); | |
101 } | |
102 Hide(); | 102 Hide(); |
103 } | 103 } |
104 | 104 |
105 ContinueWindow* ContinueWindow::Create() { | 105 ContinueWindow* ContinueWindow::Create() { |
106 return new ContinueWindowLinux(); | 106 return new ContinueWindowLinux(); |
107 } | 107 } |
108 | 108 |
109 } // namespace remoting | 109 } // namespace remoting |
OLD | NEW |