summaryrefslogtreecommitdiffstats
path: root/chrome_frame/chrome_frame_activex_base.h
diff options
context:
space:
mode:
Diffstat (limited to 'chrome_frame/chrome_frame_activex_base.h')
-rw-r--r--chrome_frame/chrome_frame_activex_base.h37
1 files changed, 37 insertions, 0 deletions
diff --git a/chrome_frame/chrome_frame_activex_base.h b/chrome_frame/chrome_frame_activex_base.h
index dc0a955..be8553a 100644
--- a/chrome_frame/chrome_frame_activex_base.h
+++ b/chrome_frame/chrome_frame_activex_base.h
@@ -361,6 +361,43 @@ END_MSG_MAP()
return true;
}
+ // IOleInPlaceObject overrides.
+ STDMETHOD(InPlaceDeactivate)(void) {
+ static UINT onload_handlers_done_msg =
+ RegisterWindowMessage(L"ChromeFrame_OnloadHandlersDone");
+
+ if (m_bInPlaceActive && IsWindow() && IsValid()) {
+ static const int kChromeFrameUnloadEventTimerId = 0xdeadbeef;
+ static const int kChromeFrameUnloadEventTimeout = 1000;
+
+ // To prevent us from indefinitely waiting for an acknowledgement from
+ // Chrome indicating that unload handlers have been run, we set a 1
+ // second timer and exit the loop when it fires.
+ ::SetTimer(m_hWnd, kChromeFrameUnloadEventTimerId,
+ kChromeFrameUnloadEventTimeout, NULL);
+
+ automation_client_->RunUnloadHandlers(m_hWnd, onload_handlers_done_msg);
+
+ MSG msg = {0};
+ while (GetMessage(&msg, NULL, 0, 0)) {
+ if (msg.message == onload_handlers_done_msg &&
+ msg.hwnd == m_hWnd) {
+ break;
+ }
+
+ if (msg.message == WM_TIMER &&
+ msg.wParam == kChromeFrameUnloadEventTimerId) {
+ break;
+ }
+ TranslateMessage(&msg);
+ DispatchMessage(&msg);
+ }
+
+ ::KillTimer(m_hWnd, kChromeFrameUnloadEventTimerId);
+ }
+ return IOleInPlaceObjectWindowlessImpl<T>::InPlaceDeactivate();
+ }
+
protected:
virtual void GetProfilePath(const std::wstring& profile_name,
FilePath* profile_path) {