Index: chrome_frame/chrome_frame_activex_base.h |
=================================================================== |
--- chrome_frame/chrome_frame_activex_base.h (revision 29999) |
+++ chrome_frame/chrome_frame_activex_base.h (working copy) |
@@ -201,6 +201,7 @@ |
BEGIN_MSG_MAP(ChromeFrameActivexBase) |
MESSAGE_HANDLER(WM_CREATE, OnCreate) |
+ MESSAGE_HANDLER(WM_DESTROY, OnDestroy) |
CHAIN_MSG_MAP(ChromeFramePlugin<T>) |
CHAIN_MSG_MAP(CComControl<T>) |
CHAIN_MSG_MAP(TaskMarshaller) |
@@ -238,12 +239,6 @@ |
IE_8, |
IE_8 + 1); |
} |
- |
- base::Thread::Options options; |
- options.message_loop_type = MessageLoop::TYPE_UI; |
- worker_thread_.StartWithOptions(options); |
- worker_thread_.message_loop()->PostTask( |
- FROM_HERE, NewRunnableMethod(this, &Base::OnWorkerStart)); |
return S_OK; |
} |
@@ -324,13 +319,6 @@ |
return true; |
} |
- virtual void OnFinalMessage(HWND) { |
- ChromeFramePlugin<T>::Uninitialize(); |
- worker_thread_.message_loop()->PostTask( |
- FROM_HERE, NewRunnableMethod(this, &Base::OnWorkerStop)); |
- worker_thread_.Stop(); |
- } |
- |
protected: |
virtual void OnTabbedOut(int tab_handle, bool reverse) { |
DCHECK(m_bInPlaceActive); |
@@ -432,6 +420,16 @@ |
virtual void OnRequestStart(int tab_handle, int request_id, |
const IPC::AutomationURLRequest& request_info) { |
+ // The worker thread may have been stopped. This could happen if the |
+ // ActiveX instance was reused. |
+ if (!worker_thread_.message_loop()) { |
+ base::Thread::Options options; |
+ options.message_loop_type = MessageLoop::TYPE_UI; |
+ worker_thread_.StartWithOptions(options); |
+ worker_thread_.message_loop()->PostTask( |
+ FROM_HERE, NewRunnableMethod(this, &Base::OnWorkerStart)); |
+ } |
+ |
scoped_refptr<CComObject<UrlmonUrlRequest> > request; |
if (base_url_request_.get() && |
GURL(base_url_request_->url()) == GURL(request_info.url)) { |
@@ -505,6 +503,16 @@ |
return 0; |
} |
+ LRESULT OnDestroy(UINT message, WPARAM wparam, LPARAM lparam, |
+ BOOL& handled) { // NO_LINT |
+ worker_thread_.message_loop()->PostTask( |
+ FROM_HERE, NewRunnableMethod(this, &Base::OnWorkerStop)); |
+ if (automation_client_.get()) |
+ automation_client_->CleanupRequests(); |
+ worker_thread_.Stop(); |
+ return 0; |
+ } |
+ |
// ChromeFrameDelegate override |
virtual void OnAutomationServerReady() { |
ChromeFramePlugin<T>::OnAutomationServerReady(); |