| 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 #include "ui/base/win/hwnd_subclass.h" | 5 #include "ui/base/win/hwnd_subclass.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/memory/scoped_vector.h" | 10 #include "base/memory/scoped_vector.h" |
| 11 #include "base/memory/singleton.h" | 11 #include "base/memory/singleton.h" |
| 12 #include "base/stl_util.h" |
| 12 #include "ui/gfx/win/dpi.h" | 13 #include "ui/gfx/win/dpi.h" |
| 13 #include "ui/gfx/win/hwnd_util.h" | 14 #include "ui/gfx/win/hwnd_util.h" |
| 14 | 15 |
| 15 namespace { | 16 namespace { |
| 16 const char kHWNDSubclassKey[] = "__UI_BASE_WIN_HWND_SUBCLASS_PROC__"; | 17 const char kHWNDSubclassKey[] = "__UI_BASE_WIN_HWND_SUBCLASS_PROC__"; |
| 17 | 18 |
| 18 LRESULT CALLBACK WndProc(HWND hwnd, | 19 LRESULT CALLBACK WndProc(HWND hwnd, |
| 19 UINT message, | 20 UINT message, |
| 20 WPARAM w_param, | 21 WPARAM w_param, |
| 21 LPARAM l_param) { | 22 LPARAM l_param) { |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 (*it)->RemoveFilter(filter); | 103 (*it)->RemoveFilter(filter); |
| 103 } | 104 } |
| 104 | 105 |
| 105 // static | 106 // static |
| 106 HWNDSubclass* HWNDSubclass::GetHwndSubclassForTarget(HWND target) { | 107 HWNDSubclass* HWNDSubclass::GetHwndSubclassForTarget(HWND target) { |
| 107 return HWNDSubclassFactory::GetInstance()->GetHwndSubclassForTarget(target); | 108 return HWNDSubclassFactory::GetInstance()->GetHwndSubclassForTarget(target); |
| 108 } | 109 } |
| 109 | 110 |
| 110 void HWNDSubclass::AddFilter(HWNDMessageFilter* filter) { | 111 void HWNDSubclass::AddFilter(HWNDMessageFilter* filter) { |
| 111 DCHECK(filter); | 112 DCHECK(filter); |
| 112 if (std::find(filters_.begin(), filters_.end(), filter) == filters_.end()) | 113 if (!ContainsValue(filters_, filter)) |
| 113 filters_.push_back(filter); | 114 filters_.push_back(filter); |
| 114 } | 115 } |
| 115 | 116 |
| 116 void HWNDSubclass::RemoveFilter(HWNDMessageFilter* filter) { | 117 void HWNDSubclass::RemoveFilter(HWNDMessageFilter* filter) { |
| 117 std::vector<HWNDMessageFilter*>::iterator it = | 118 std::vector<HWNDMessageFilter*>::iterator it = |
| 118 std::find(filters_.begin(), filters_.end(), filter); | 119 std::find(filters_.begin(), filters_.end(), filter); |
| 119 if (it != filters_.end()) | 120 if (it != filters_.end()) |
| 120 filters_.erase(it); | 121 filters_.erase(it); |
| 121 } | 122 } |
| 122 | 123 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 // In most cases, |original_wnd_proc_| will take care of calling | 163 // In most cases, |original_wnd_proc_| will take care of calling |
| 163 // DefWindowProc. | 164 // DefWindowProc. |
| 164 return CallWindowProc(original_wnd_proc_, hwnd, message, w_param, l_param); | 165 return CallWindowProc(original_wnd_proc_, hwnd, message, w_param, l_param); |
| 165 } | 166 } |
| 166 | 167 |
| 167 HWNDMessageFilter::~HWNDMessageFilter() { | 168 HWNDMessageFilter::~HWNDMessageFilter() { |
| 168 HWNDSubclass::RemoveFilterFromAllTargets(this); | 169 HWNDSubclass::RemoveFilterFromAllTargets(this); |
| 169 } | 170 } |
| 170 | 171 |
| 171 } // namespace ui | 172 } // namespace ui |
| OLD | NEW |