mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-02-17 04:30:46 +01:00
Windows: Allow the JS dialog message hook to be shared across multiple browser windows (issue #605).
git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@654 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
parent
71773b5bbc
commit
584bd26331
@ -58,6 +58,7 @@ class CefJavaScriptDialog {
|
|||||||
static bool UninstallMessageHook();
|
static bool UninstallMessageHook();
|
||||||
static LRESULT CALLBACK GetMsgProc(int code, WPARAM wparam, LPARAM lparam);
|
static LRESULT CALLBACK GetMsgProc(int code, WPARAM wparam, LPARAM lparam);
|
||||||
static HHOOK msg_hook_;
|
static HHOOK msg_hook_;
|
||||||
|
static int msg_hook_user_count_;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(CefJavaScriptDialog);
|
DISALLOW_COPY_AND_ASSIGN(CefJavaScriptDialog);
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
class CefJavaScriptDialog;
|
class CefJavaScriptDialog;
|
||||||
|
|
||||||
HHOOK CefJavaScriptDialog::msg_hook_ = NULL;
|
HHOOK CefJavaScriptDialog::msg_hook_ = NULL;
|
||||||
|
int CefJavaScriptDialog::msg_hook_user_count_ = 0;
|
||||||
|
|
||||||
INT_PTR CALLBACK CefJavaScriptDialog::DialogProc(HWND dialog, UINT message,
|
INT_PTR CALLBACK CefJavaScriptDialog::DialogProc(HWND dialog, UINT message,
|
||||||
WPARAM wparam,
|
WPARAM wparam,
|
||||||
@ -192,8 +193,12 @@ LRESULT CALLBACK CefJavaScriptDialog::GetMsgProc(int code, WPARAM wparam,
|
|||||||
|
|
||||||
// static
|
// static
|
||||||
bool CefJavaScriptDialog::InstallMessageHook() {
|
bool CefJavaScriptDialog::InstallMessageHook() {
|
||||||
|
msg_hook_user_count_++;
|
||||||
|
|
||||||
// Make sure we only call this once.
|
// Make sure we only call this once.
|
||||||
DCHECK(msg_hook_ == NULL);
|
if (msg_hook_ != NULL)
|
||||||
|
return true;
|
||||||
|
|
||||||
msg_hook_ = ::SetWindowsHookEx(WH_GETMESSAGE,
|
msg_hook_ = ::SetWindowsHookEx(WH_GETMESSAGE,
|
||||||
&CefJavaScriptDialog::GetMsgProc,
|
&CefJavaScriptDialog::GetMsgProc,
|
||||||
NULL,
|
NULL,
|
||||||
@ -204,6 +209,12 @@ bool CefJavaScriptDialog::InstallMessageHook() {
|
|||||||
|
|
||||||
// static
|
// static
|
||||||
bool CefJavaScriptDialog::UninstallMessageHook() {
|
bool CefJavaScriptDialog::UninstallMessageHook() {
|
||||||
|
msg_hook_user_count_--;
|
||||||
|
DCHECK_GE(msg_hook_user_count_, 0);
|
||||||
|
|
||||||
|
if (msg_hook_user_count_ > 0)
|
||||||
|
return true;
|
||||||
|
|
||||||
DCHECK(msg_hook_ != NULL);
|
DCHECK(msg_hook_ != NULL);
|
||||||
BOOL result = ::UnhookWindowsHookEx(msg_hook_);
|
BOOL result = ::UnhookWindowsHookEx(msg_hook_);
|
||||||
DCHECK(result);
|
DCHECK(result);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user