diff options
author | ananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-17 21:47:16 +0000 |
---|---|---|
committer | ananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-17 21:47:16 +0000 |
commit | d9d8f0c234ea70e6c5121c038c3c6ab33699f903 (patch) | |
tree | b755aee455afacf4bb88950ab74e6876ad85dd39 /chrome_frame/utils.cc | |
parent | 1b8a1b648148a058b2c03d89398a65038992732f (diff) | |
download | chromium_src-d9d8f0c234ea70e6c5121c038c3c6ab33699f903.zip chromium_src-d9d8f0c234ea70e6c5121c038c3c6ab33699f903.tar.gz chromium_src-d9d8f0c234ea70e6c5121c038c3c6ab33699f903.tar.bz2 |
Added full support for invoking before unload and unload handlers on ChromeFrame rendered
pages. This allows a webpage to put up a confirmation dialog in its beforeunload handler
and potentially cancel the operation. We only support invoking unload handlers on the page
for IE full tab mode. To achieve this the active document handles the OLECMDID_ONUNLOAD
exec command which is passed by the DOCHOST to the object which allows us to potentially
cancel the operation.
Thanks to Stoyan for his help in authoring parts of this CL.
The AutomationMsg_RunUnloadHandlers message which is used only by ChromeFrame is now a sync
message which returns back a bool indicating whether the unload operation can be continued
or not. The ExternalTabContainer now implements the BeforeUnloadFired method in the
TabContentsDelegate and aborts the unload operation if the user chose to not proceed with
the unload.
Fixes bug http://code.google.com/p/chromium/issues/detail?id=33200
Bug=33200
Test=Covered by existing unload event test. Will add a test which validates whether a page
can cancel the unload operation in a subsequent CL.
Review URL: http://codereview.chromium.org/3450014
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@59854 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome_frame/utils.cc')
-rw-r--r-- | chrome_frame/utils.cc | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/chrome_frame/utils.cc b/chrome_frame/utils.cc index 35fbc83..80095428 100644 --- a/chrome_frame/utils.cc +++ b/chrome_frame/utils.cc @@ -1453,3 +1453,37 @@ void PinModule() { } } } + +void WaitWithMessageLoop(HANDLE* handles, int count, DWORD timeout) { + base::Time now = base::Time::Now(); + base::Time wait_until = now + base::TimeDelta::FromMilliseconds(timeout); + + while (wait_until >= now) { + base::TimeDelta wait_time = wait_until - now; + DWORD wait = MsgWaitForMultipleObjects( + count, handles, FALSE, static_cast<DWORD>(wait_time.InMilliseconds()), + QS_ALLINPUT); + switch (wait) { + case WAIT_OBJECT_0: + case WAIT_TIMEOUT: + return; + + case WAIT_OBJECT_0 + 1: { + MSG msg = {0}; + while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { + TranslateMessage(&msg); + DispatchMessage(&msg); + } + break; + } + + default: { + NOTREACHED() << "Unexpected return from MsgWaitForMultipleObjects :" + << wait; + return; + } + } + now = base::Time::Now(); + } +} + |