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

Unified Diff: remoting/host/continue_window_win.cc

Issue 7219002: Chromoting's ContinueWindow implementation for Windows. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 6 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
« no previous file with comments | « no previous file | remoting/host/disconnect_window_win.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/host/continue_window_win.cc
===================================================================
--- remoting/host/continue_window_win.cc (revision 89904)
+++ remoting/host/continue_window_win.cc (working copy)
@@ -4,31 +4,139 @@
#include "remoting/host/continue_window.h"
+#include <windows.h>
+
#include "base/compiler_specific.h"
#include "base/logging.h"
+#include "remoting/host/chromoting_host.h"
+#include "remoting/host/host_plugin_resource.h"
+// TODO(garykac): Lots of duplicated code in this file and
+// disconnect_window_win.cc. These global floating windows are temporary so
+// they should be deleted soon. If we need to expand this then we should
+// create a class with the shared code.
+
+// HMODULE from DllMain/WinMain. This is needed to find our dialog resource.
+// This is defined in:
+// Plugin: host_plugin.cc
+// SimpleHost: simple_host_process.cc
+extern HMODULE g_hModule;
+
namespace remoting {
-class ContinueWindowWin : public remoting::ContinueWindow {
+class ContinueWindowWin : public ContinueWindow {
public:
- ContinueWindowWin() {}
- virtual ~ContinueWindowWin() {}
+ ContinueWindowWin();
+ virtual ~ContinueWindowWin();
virtual void Show(remoting::ChromotingHost* host) OVERRIDE;
virtual void Hide() OVERRIDE;
private:
+ static BOOL CALLBACK DialogProc(HWND hwmd, UINT msg, WPARAM wParam,
+ LPARAM lParam);
+
+ BOOL OnDialogMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
+
+ void EndDialog();
+
+ remoting::ChromotingHost* host_;
+ HWND hwnd_;
+
+ // A "random" key from the tickcount that is used to validate the WM_USER
+ // message sent to end the dialog. This check is used to help protect
+ // against someone sending (WM_APP,0,0L) to close the dialog.
+ DWORD key_;
Jamie 2011/06/21 23:09:45 What is this designed to protect against? EndDialo
garykac 2011/06/22 00:36:59 Removed. Now that we're on the proper thread, I'm
+
DISALLOW_COPY_AND_ASSIGN(ContinueWindowWin);
};
-void ContinueWindowWin::Show(remoting::ChromotingHost* host) {
- NOTIMPLEMENTED();
+ContinueWindowWin::ContinueWindowWin()
+ : host_(NULL),
+ hwnd_(NULL),
+ key_(0L) {
}
+ContinueWindowWin::~ContinueWindowWin() {
+ EndDialog();
+}
+
+BOOL CALLBACK ContinueWindowWin::DialogProc(HWND hwnd, UINT msg,
+ WPARAM wParam, LPARAM lParam) {
+ ContinueWindowWin* win = NULL;
+ if (msg == WM_INITDIALOG) {
+ win = reinterpret_cast<ContinueWindowWin*>(lParam);
+ CHECK(win);
+ SetWindowLongPtr(hwnd, DWLP_USER, (LONG_PTR)win);
+ } else {
+ LONG_PTR lp = GetWindowLongPtr(hwnd, DWLP_USER);
+ win = reinterpret_cast<ContinueWindowWin*>(lp);
+ }
+ if (win == NULL)
+ return FALSE;
+ return win->OnDialogMessage(hwnd, msg, wParam, lParam);
+}
+
+BOOL ContinueWindowWin::OnDialogMessage(HWND hwnd, UINT msg,
+ WPARAM wParam, LPARAM lParam) {
+ switch (msg) {
+ case WM_INITDIALOG:
+ return TRUE;
+ case WM_CLOSE:
+ // Ignore close messages.
+ return TRUE;
+ case WM_DESTROY:
+ // Ensure we don't try to use the HWND anymore.
+ hwnd_ = NULL;
+ return TRUE;
+ case WM_APP:
Jamie 2011/06/21 23:09:45 I think WM_USER would be more appropriate here.
garykac 2011/06/22 00:36:59 Removed.
+ if (key_ == static_cast<DWORD>(lParam)) {
+ ::EndDialog(hwnd, LOWORD(wParam));
+ hwnd_ = NULL;
+ }
+ return TRUE;
+ case WM_COMMAND:
+ switch (LOWORD(wParam)) {
+ case IDC_CONTINUE:
+ {
+ CHECK(host_);
+ host_->PauseSession(false);
+ ::EndDialog(hwnd, LOWORD(wParam));
+ hwnd_ = NULL;
+ }
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+void ContinueWindowWin::Show(ChromotingHost* host) {
+ host_ = host;
+ // Get a "random" value that we can use to prevent someone from sending a
+ // simple (WM_APP,0,0L) message to our window to close it.
+ key_ = GetTickCount();
+
+ CHECK(!hwnd_);
+ hwnd_ = CreateDialogParam(g_hModule, MAKEINTRESOURCE(IDD_CONTINUE), NULL,
+ (DLGPROC)DialogProc, (LPARAM)this);
+ if (!hwnd_) {
+ LOG(ERROR) << "Unable to create Disconnect dialog for remoting.";
+ return;
+ }
+
+ ShowWindow(hwnd_, SW_SHOW);
+}
+
void ContinueWindowWin::Hide() {
- NOTIMPLEMENTED();
+ EndDialog();
}
+void ContinueWindowWin::EndDialog() {
+ if (hwnd_) {
+ SendMessage(hwnd_, WM_APP, 0, (LPARAM)key_);
+ }
+}
+
ContinueWindow* ContinueWindow::Create() {
return new ContinueWindowWin();
}
« no previous file with comments | « no previous file | remoting/host/disconnect_window_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698