Fullscreen support for Lion.
[chromium-blink-merge.git] / chrome_frame / event_hooker.cc
blob839b3adcd20f4005aa1f6b8c5c5bb27f248cc706
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome_frame/event_hooker.h"
7 #include <crtdbg.h>
8 #include "chrome_frame/bho_loader.h"
10 EXTERN_C IMAGE_DOS_HEADER __ImageBase;
12 EventHooker::EventHooker()
13 : window_creation_hook_(NULL) {}
15 EventHooker::~EventHooker() {
16 StopHook();
19 bool EventHooker::StartHook() {
20 if ((NULL != window_creation_hook_)) {
21 return false;
24 window_creation_hook_ = SetWinEventHook(EVENT_OBJECT_CREATE,
25 EVENT_OBJECT_CREATE,
26 reinterpret_cast<HMODULE>(
27 &__ImageBase),
28 WindowCreationHookProc,
31 WINEVENT_INCONTEXT);
32 if (NULL == window_creation_hook_) {
33 return false;
35 return true;
38 void EventHooker::StopHook() {
39 if (NULL != window_creation_hook_) {
40 UnhookWinEvent(window_creation_hook_);
41 window_creation_hook_ = NULL;
45 VOID CALLBACK EventHooker::WindowCreationHookProc(HWINEVENTHOOK hook,
46 DWORD event,
47 HWND window,
48 LONG object_id,
49 LONG child_id,
50 DWORD event_tid,
51 DWORD event_time) {
52 _ASSERTE((EVENT_OBJECT_CREATE == event) ||
53 (EVENT_OBJECT_PARENTCHANGE == event));
54 if (OBJID_WINDOW == object_id) {
55 BHOLoader::GetInstance()->OnHookEvent(event, window);