Index: remoting/host/continue_window_gtk.cc |
diff --git a/remoting/host/continue_window_gtk.cc b/remoting/host/continue_window_gtk.cc |
index 906e50f38ce11d11b011c6146e1023003647dde4..09e36d286574e2e0431109b62353084718cc9576 100644 |
--- a/remoting/host/continue_window_gtk.cc |
+++ b/remoting/host/continue_window_gtk.cc |
@@ -2,59 +2,85 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-#include "remoting/host/continue_window.h" |
- |
#include <gtk/gtk.h> |
#include "base/compiler_specific.h" |
#include "base/logging.h" |
#include "base/utf_string_conversions.h" |
+#include "remoting/host/continue_window.h" |
#include "remoting/host/ui_strings.h" |
#include "ui/base/gtk/gtk_signal.h" |
namespace remoting { |
-class ContinueWindowGtk : public remoting::ContinueWindow { |
+class ContinueWindowGtk : public ContinueWindow { |
public: |
- explicit ContinueWindowGtk(const UiStrings* ui_strings); |
+ explicit ContinueWindowGtk(const UiStrings& ui_strings); |
virtual ~ContinueWindowGtk(); |
- virtual void Show(const ContinueSessionCallback& callback) OVERRIDE; |
- virtual void Hide() OVERRIDE; |
+ protected: |
+ // ContinueWindow overrides. |
+ virtual void ShowUi() OVERRIDE; |
+ virtual void HideUi() OVERRIDE; |
private: |
+ void CreateWindow(); |
+ |
CHROMEGTK_CALLBACK_1(ContinueWindowGtk, void, OnResponse, int); |
- void CreateWindow(); |
+ // Invoked when the user clicks on the Continue button to resume the session, |
+ // or dismisses the window to disconnect the session. |
+ base::Callback<void(bool)> continue_callback_; |
Sergey Ulanov
2013/04/04 21:04:26
This is not used.
alexeypa (please no reviews)
2013/04/06 18:07:56
Done.
|
- ContinueSessionCallback callback_; |
GtkWidget* continue_window_; |
- // Points to the localized strings. |
- const UiStrings* ui_strings_; |
+ // Localized UI strings. |
+ UiStrings ui_strings_; |
DISALLOW_COPY_AND_ASSIGN(ContinueWindowGtk); |
}; |
-ContinueWindowGtk::ContinueWindowGtk(const UiStrings* ui_strings) |
+ContinueWindowGtk::ContinueWindowGtk(const UiStrings& ui_strings) |
: continue_window_(NULL), |
ui_strings_(ui_strings) { |
} |
ContinueWindowGtk::~ContinueWindowGtk() { |
+ if (continue_window_) { |
+ gtk_widget_destroy(continue_window_); |
+ continue_window_ = NULL; |
+ } |
+} |
+ |
+void ContinueWindowGtk::ShowUi() { |
+ DCHECK(CalledOnValidThread()); |
+ DCHECK(!continue_window_); |
+ |
+ CreateWindow(); |
+ gtk_window_set_urgency_hint(GTK_WINDOW(continue_window_), TRUE); |
+ gtk_window_present(GTK_WINDOW(continue_window_)); |
+} |
+ |
+void ContinueWindowGtk::HideUi() { |
+ DCHECK(CalledOnValidThread()); |
+ |
+ if (continue_window_) { |
+ gtk_widget_destroy(continue_window_); |
+ continue_window_ = NULL; |
+ } |
} |
void ContinueWindowGtk::CreateWindow() { |
- if (continue_window_) |
- return; |
+ DCHECK(CalledOnValidThread()); |
+ DCHECK(!continue_window_); |
continue_window_ = gtk_dialog_new_with_buttons( |
- UTF16ToUTF8(ui_strings_->product_name).c_str(), |
+ UTF16ToUTF8(ui_strings_.product_name).c_str(), |
NULL, |
static_cast<GtkDialogFlags>(GTK_DIALOG_MODAL | GTK_DIALOG_NO_SEPARATOR), |
- UTF16ToUTF8(ui_strings_->stop_sharing_button_text).c_str(), |
+ UTF16ToUTF8(ui_strings_.stop_sharing_button_text).c_str(), |
GTK_RESPONSE_CANCEL, |
- UTF16ToUTF8(ui_strings_->continue_button_text).c_str(), |
+ UTF16ToUTF8(ui_strings_.continue_button_text).c_str(), |
GTK_RESPONSE_OK, |
NULL); |
@@ -73,7 +99,7 @@ void ContinueWindowGtk::CreateWindow() { |
gtk_dialog_get_content_area(GTK_DIALOG(continue_window_)); |
GtkWidget* text_label = |
- gtk_label_new(UTF16ToUTF8(ui_strings_->continue_prompt).c_str()); |
+ gtk_label_new(UTF16ToUTF8(ui_strings_.continue_prompt).c_str()); |
gtk_label_set_line_wrap(GTK_LABEL(text_label), TRUE); |
// TODO(lambroslambrou): Fix magic numbers, as in disconnect_window_gtk.cc. |
gtk_misc_set_padding(GTK_MISC(text_label), 12, 12); |
@@ -82,27 +108,22 @@ void ContinueWindowGtk::CreateWindow() { |
gtk_widget_show_all(content_area); |
} |
-void ContinueWindowGtk::Show(const ContinueSessionCallback& callback) { |
- callback_ = callback; |
- CreateWindow(); |
- gtk_window_set_urgency_hint(GTK_WINDOW(continue_window_), TRUE); |
- gtk_window_present(GTK_WINDOW(continue_window_)); |
-} |
+void ContinueWindowGtk::OnResponse(GtkWidget* dialog, int response_id) { |
+ DCHECK(CalledOnValidThread()); |
-void ContinueWindowGtk::Hide() { |
- if (continue_window_) { |
- gtk_widget_destroy(continue_window_); |
- continue_window_ = NULL; |
+ if (response_id == GTK_RESPONSE_OK) { |
+ ContinueSession(); |
+ } else { |
+ DisconnectSession(); |
} |
-} |
-void ContinueWindowGtk::OnResponse(GtkWidget* dialog, int response_id) { |
- callback_.Run(response_id == GTK_RESPONSE_OK); |
- Hide(); |
+ HideUi(); |
} |
-scoped_ptr<ContinueWindow> ContinueWindow::Create(const UiStrings* ui_strings) { |
- return scoped_ptr<ContinueWindow>(new ContinueWindowGtk(ui_strings)); |
+// static |
+scoped_ptr<HostWindow> HostWindow::CreateContinueWindow( |
+ const UiStrings& ui_strings) { |
+ return scoped_ptr<HostWindow>(new ContinueWindowGtk(ui_strings)); |
} |
} // namespace remoting |