| OLD | NEW |
| 1 // Copyright (c) 2011 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 "chrome_frame/test/win_event_receiver.h" | 5 #include "chrome_frame/test/win_event_receiver.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| 11 #include "base/win/object_watcher.h" | 11 #include "base/win/object_watcher.h" |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 DCHECK(hook_ == NULL); | 51 DCHECK(hook_ == NULL); |
| 52 DCHECK(hook_stub_ == NULL); | 52 DCHECK(hook_stub_ == NULL); |
| 53 hook_stub_ = FunctionStub::Create(reinterpret_cast<uintptr_t>(this), | 53 hook_stub_ = FunctionStub::Create(reinterpret_cast<uintptr_t>(this), |
| 54 WinEventHook); | 54 WinEventHook); |
| 55 // Don't use WINEVENT_SKIPOWNPROCESS here because we fake generate an event | 55 // Don't use WINEVENT_SKIPOWNPROCESS here because we fake generate an event |
| 56 // in the mock IE event sink (IA2_EVENT_DOCUMENT_LOAD_COMPLETE) that we want | 56 // in the mock IE event sink (IA2_EVENT_DOCUMENT_LOAD_COMPLETE) that we want |
| 57 // to catch. | 57 // to catch. |
| 58 hook_ = SetWinEventHook(event_min, event_max, NULL, | 58 hook_ = SetWinEventHook(event_min, event_max, NULL, |
| 59 reinterpret_cast<WINEVENTPROC>(hook_stub_->code()), 0, | 59 reinterpret_cast<WINEVENTPROC>(hook_stub_->code()), 0, |
| 60 0, WINEVENT_OUTOFCONTEXT); | 60 0, WINEVENT_OUTOFCONTEXT); |
| 61 DLOG_IF(ERROR, hook_ == NULL) << "Unable to SetWinEvent hook"; | 61 LOG_IF(ERROR, hook_ == NULL) << "Unable to SetWinEvent hook"; |
| 62 return hook_ != NULL; | 62 return hook_ != NULL; |
| 63 } | 63 } |
| 64 | 64 |
| 65 // static | 65 // static |
| 66 void WinEventReceiver::WinEventHook(WinEventReceiver* me, HWINEVENTHOOK hook, | 66 void WinEventReceiver::WinEventHook(WinEventReceiver* me, HWINEVENTHOOK hook, |
| 67 DWORD event, HWND hwnd, LONG object_id, | 67 DWORD event, HWND hwnd, LONG object_id, |
| 68 LONG child_id, DWORD event_thread_id, | 68 LONG child_id, DWORD event_thread_id, |
| 69 DWORD event_time) { | 69 DWORD event_time) { |
| 70 DCHECK(me->listener_ != NULL); | 70 DCHECK(me->listener_ != NULL); |
| 71 me->listener_->OnEventReceived(event, hwnd, object_id, child_id); | 71 me->listener_->OnEventReceived(event, hwnd, object_id, child_id); |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 HandleOnOpen(hwnd); | 266 HandleOnOpen(hwnd); |
| 267 } else { | 267 } else { |
| 268 DCHECK(event == EVENT_OBJECT_DESTROY || event == EVENT_OBJECT_HIDE); | 268 DCHECK(event == EVENT_OBJECT_DESTROY || event == EVENT_OBJECT_HIDE); |
| 269 HandleOnClose(hwnd); | 269 HandleOnClose(hwnd); |
| 270 } | 270 } |
| 271 } | 271 } |
| 272 | 272 |
| 273 void WindowWatchdog::OnHwndProcessExited(HWND hwnd) { | 273 void WindowWatchdog::OnHwndProcessExited(HWND hwnd) { |
| 274 HandleOnClose(hwnd); | 274 HandleOnClose(hwnd); |
| 275 } | 275 } |
| OLD | NEW |