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 #include "base/win/message_window.h" | 5 #include "base/win/message_window.h" |
6 | 6 |
7 #include "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/process/memory.h" | 10 #include "base/win/current_module.h" |
11 #include "base/win/wrapped_window_proc.h" | 11 #include "base/win/wrapped_window_proc.h" |
12 | 12 |
13 const wchar_t kMessageWindowClassName[] = L"Chrome_MessageWindow"; | 13 const wchar_t kMessageWindowClassName[] = L"Chrome_MessageWindow"; |
14 | 14 |
15 namespace base { | 15 namespace base { |
16 namespace win { | 16 namespace win { |
17 | 17 |
18 // Used along with LazyInstance to register a window class for message-only | 18 // Used along with LazyInstance to register a window class for message-only |
19 // windows created by MessageWindow. | 19 // windows created by MessageWindow. |
20 class MessageWindow::WindowClass { | 20 class MessageWindow::WindowClass { |
21 public: | 21 public: |
22 WindowClass(); | 22 WindowClass(); |
23 ~WindowClass(); | 23 ~WindowClass(); |
24 | 24 |
25 ATOM atom() { return atom_; } | 25 ATOM atom() { return atom_; } |
26 HINSTANCE instance() { return instance_; } | 26 HINSTANCE instance() { return instance_; } |
27 | 27 |
28 private: | 28 private: |
29 ATOM atom_; | 29 ATOM atom_; |
30 HINSTANCE instance_; | 30 HINSTANCE instance_; |
31 | 31 |
32 DISALLOW_COPY_AND_ASSIGN(WindowClass); | 32 DISALLOW_COPY_AND_ASSIGN(WindowClass); |
33 }; | 33 }; |
34 | 34 |
35 static LazyInstance<MessageWindow::WindowClass> g_window_class = | 35 static LazyInstance<MessageWindow::WindowClass> g_window_class = |
36 LAZY_INSTANCE_INITIALIZER; | 36 LAZY_INSTANCE_INITIALIZER; |
37 | 37 |
38 MessageWindow::WindowClass::WindowClass() | 38 MessageWindow::WindowClass::WindowClass() |
39 : atom_(0), | 39 : atom_(0), instance_(CURRENT_MODULE()) { |
40 instance_(base::GetModuleFromAddress(&MessageWindow::WindowProc)) { | |
41 WNDCLASSEX window_class; | 40 WNDCLASSEX window_class; |
42 window_class.cbSize = sizeof(window_class); | 41 window_class.cbSize = sizeof(window_class); |
43 window_class.style = 0; | 42 window_class.style = 0; |
44 window_class.lpfnWndProc = &base::win::WrappedWindowProc<WindowProc>; | 43 window_class.lpfnWndProc = &base::win::WrappedWindowProc<WindowProc>; |
45 window_class.cbClsExtra = 0; | 44 window_class.cbClsExtra = 0; |
46 window_class.cbWndExtra = 0; | 45 window_class.cbWndExtra = 0; |
47 window_class.hInstance = instance_; | 46 window_class.hInstance = instance_; |
48 window_class.hIcon = NULL; | 47 window_class.hIcon = NULL; |
49 window_class.hCursor = NULL; | 48 window_class.hCursor = NULL; |
50 window_class.hbrBackground = NULL; | 49 window_class.hbrBackground = NULL; |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 LRESULT message_result; | 156 LRESULT message_result; |
158 if (self->message_callback_.Run(message, wparam, lparam, &message_result)) | 157 if (self->message_callback_.Run(message, wparam, lparam, &message_result)) |
159 return message_result; | 158 return message_result; |
160 } | 159 } |
161 | 160 |
162 return DefWindowProc(hwnd, message, wparam, lparam); | 161 return DefWindowProc(hwnd, message, wparam, lparam); |
163 } | 162 } |
164 | 163 |
165 } // namespace win | 164 } // namespace win |
166 } // namespace base | 165 } // namespace base |
OLD | NEW |