| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #ifndef REMOTING_HOST_WIN_MESSAGE_WINDOW_H_ | 5 #ifndef BASE_WIN_MESSAGE_WINDOW_H_ |
| 6 #define REMOTING_HOST_WIN_MESSAGE_WINDOW_H_ | 6 #define BASE_WIN_MESSAGE_WINDOW_H_ |
| 7 | 7 |
| 8 #include <windows.h> | 8 #include <windows.h> |
| 9 | 9 |
| 10 #include <string> | 10 #include "base/base_export.h" |
| 11 | |
| 12 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 13 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 14 #include "base/threading/non_thread_safe.h" | 13 #include "base/threading/non_thread_safe.h" |
| 15 | 14 |
| 16 namespace remoting { | 15 namespace base { |
| 17 namespace win { | 16 namespace win { |
| 18 | 17 |
| 19 // Implements a message-only window. | 18 // Implements a message-only window. |
| 20 class MessageWindow : base::NonThreadSafe { | 19 class BASE_EXPORT MessageWindow : public base::NonThreadSafe { |
| 21 public: | 20 public: |
| 22 // Handles incoming window messages. | 21 // Handles incoming window messages. |
| 23 class Delegate { | 22 class BASE_EXPORT Delegate { |
| 24 public: | 23 public: |
| 25 virtual ~Delegate() {} | 24 virtual ~Delegate() {} |
| 26 | 25 |
| 27 virtual bool HandleMessage(HWND hwnd, | 26 virtual bool HandleMessage(HWND hwnd, |
| 28 UINT message, | 27 UINT message, |
| 29 WPARAM wparam, | 28 WPARAM wparam, |
| 30 LPARAM lparam, | 29 LPARAM lparam, |
| 31 LRESULT* result) = 0; | 30 LRESULT* result) = 0; |
| 32 }; | 31 }; |
| 33 | 32 |
| 34 MessageWindow(); | 33 MessageWindow(); |
| 35 MessageWindow(const std::string& class_name, HINSTANCE instance); | |
| 36 ~MessageWindow(); | 34 ~MessageWindow(); |
| 37 | 35 |
| 38 // Registers the window class and creates the window. The incoming messages | 36 // Registers the window class and creates the window. The incoming messages |
| 39 // will be handled by |delegate|. |delegate| must outlive |this|. | 37 // will be handled by |delegate|. |delegate| must outlive |this|. |
| 40 bool Create(Delegate* delegate); | 38 bool Create(Delegate* delegate); |
| 41 | 39 |
| 42 HWND hwnd() const { return window_; } | 40 HWND hwnd() const { return window_; } |
| 43 | 41 |
| 44 private: | 42 private: |
| 45 // Invoked by the OS to process incoming window messages. | 43 // Invoked by the OS to process incoming window messages. |
| 46 static LRESULT CALLBACK WindowProc(HWND hwnd, UINT message, WPARAM wparam, | 44 static LRESULT CALLBACK WindowProc(HWND hwnd, UINT message, WPARAM wparam, |
| 47 LPARAM lparam); | 45 LPARAM lparam); |
| 48 | 46 |
| 49 // Atom representing the registered window class. | 47 // Atom representing the registered window class. |
| 50 ATOM atom_; | 48 ATOM atom_; |
| 51 | 49 |
| 52 // MessageWindow class name. | |
| 53 std::string class_name_; | |
| 54 | |
| 55 // Instance of the module containing the window procedure. | |
| 56 HINSTANCE instance_; | |
| 57 | |
| 58 // Handle of the input window. | 50 // Handle of the input window. |
| 59 HWND window_; | 51 HWND window_; |
| 60 | 52 |
| 61 DISALLOW_COPY_AND_ASSIGN(MessageWindow); | 53 DISALLOW_COPY_AND_ASSIGN(MessageWindow); |
| 62 }; | 54 }; |
| 63 | 55 |
| 64 } // namespace win | 56 } // namespace win |
| 65 } // namespace remoting | 57 } // namespace base |
| 66 | 58 |
| 67 #endif // REMOTING_HOST_WIN_MESSAGE_WINDOW_H_ | 59 #endif // BASE_WIN_MESSAGE_WINDOW_H_ |
| OLD | NEW |