OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 UI_BASE_WIN_HWND_SUBCLASS_H_ | 5 #ifndef UI_BASE_WIN_HWND_SUBCLASS_H_ |
6 #define UI_BASE_WIN_HWND_SUBCLASS_H_ | 6 #define UI_BASE_WIN_HWND_SUBCLASS_H_ |
7 | 7 |
| 8 #include <windows.h> |
8 #include <vector> | 9 #include <vector> |
9 #include <windows.h> | |
10 | 10 |
11 #include "base/gtest_prod_util.h" | 11 #include "base/gtest_prod_util.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "ui/base/ui_export.h" | 13 #include "ui/base/ui_base_export.h" |
14 #include "ui/base/view_prop.h" | 14 #include "ui/base/view_prop.h" |
15 | 15 |
16 namespace ui { | 16 namespace ui { |
17 | 17 |
18 // Classes implementing this interface get the opportunity to handle and consume | 18 // Classes implementing this interface get the opportunity to handle and consume |
19 // messages before they are sent to their target HWND. | 19 // messages before they are sent to their target HWND. |
20 class UI_EXPORT HWNDMessageFilter { | 20 class UI_BASE_EXPORT HWNDMessageFilter { |
21 public: | 21 public: |
22 virtual ~HWNDMessageFilter(); | 22 virtual ~HWNDMessageFilter(); |
23 | 23 |
24 // A derived class overrides this method to perform filtering of the messages. | 24 // A derived class overrides this method to perform filtering of the messages. |
25 // Return true to prevent other HWNDMessageFilter's of the target HWND and the | 25 // Return true to prevent other HWNDMessageFilter's of the target HWND and the |
26 // system message handler |original_wnd_proc_| from receiving the message. | 26 // system message handler |original_wnd_proc_| from receiving the message. |
27 // Return false to propagate the message further to other HWNDMessageFilters | 27 // Return false to propagate the message further to other HWNDMessageFilters |
28 // and eventually to |original_wnd_proc|. | 28 // and eventually to |original_wnd_proc|. |
29 // The order in which HWNDMessageFilters are added in HWNDSubclass::AddFilter | 29 // The order in which HWNDMessageFilters are added in HWNDSubclass::AddFilter |
30 // determines which filter gets to see the message first (a filter added first | 30 // determines which filter gets to see the message first (a filter added first |
31 // will see the message first). | 31 // will see the message first). |
32 virtual bool FilterMessage(HWND hwnd, | 32 virtual bool FilterMessage(HWND hwnd, |
33 UINT message, | 33 UINT message, |
34 WPARAM w_param, | 34 WPARAM w_param, |
35 LPARAM l_param, | 35 LPARAM l_param, |
36 LRESULT* l_result) = 0; | 36 LRESULT* l_result) = 0; |
37 }; | 37 }; |
38 | 38 |
39 // An object that instance-subclasses a window. If the window has already been | 39 // An object that instance-subclasses a window. If the window has already been |
40 // instance-subclassed, that subclassing is lost. | 40 // instance-subclassed, that subclassing is lost. |
41 class UI_EXPORT HWNDSubclass { | 41 class UI_BASE_EXPORT HWNDSubclass { |
42 public: | 42 public: |
43 ~HWNDSubclass(); | 43 ~HWNDSubclass(); |
44 | 44 |
45 // Adds |filter| to the HWNDSubclass of |target|. Caller retains ownership of | 45 // Adds |filter| to the HWNDSubclass of |target|. Caller retains ownership of |
46 // |filter|. See the comment about the order in which filters are added in | 46 // |filter|. See the comment about the order in which filters are added in |
47 // HWNDMessageFilter::FilterMessage. | 47 // HWNDMessageFilter::FilterMessage. |
48 static void AddFilterToTarget(HWND target, HWNDMessageFilter* filter); | 48 static void AddFilterToTarget(HWND target, HWNDMessageFilter* filter); |
49 | 49 |
50 // Removes |filter| from any HWNDSubclass that has it. | 50 // Removes |filter| from any HWNDSubclass that has it. |
51 static void RemoveFilterFromAllTargets(HWNDMessageFilter* filter); | 51 static void RemoveFilterFromAllTargets(HWNDMessageFilter* filter); |
(...skipping 22 matching lines...) Expand all Loading... |
74 std::vector<HWNDMessageFilter*> filters_; | 74 std::vector<HWNDMessageFilter*> filters_; |
75 WNDPROC original_wnd_proc_; | 75 WNDPROC original_wnd_proc_; |
76 ui::ViewProp prop_; | 76 ui::ViewProp prop_; |
77 | 77 |
78 DISALLOW_COPY_AND_ASSIGN(HWNDSubclass); | 78 DISALLOW_COPY_AND_ASSIGN(HWNDSubclass); |
79 }; | 79 }; |
80 | 80 |
81 } // namespace ui | 81 } // namespace ui |
82 | 82 |
83 #endif // UI_BASE_WIN_HWND_SUBCLASS_H_ | 83 #endif // UI_BASE_WIN_HWND_SUBCLASS_H_ |
OLD | NEW |