OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_FRAME_CHROME_FRAME_ACTIVEX_BASE_H_ | 5 #ifndef CHROME_FRAME_CHROME_FRAME_ACTIVEX_BASE_H_ |
6 #define CHROME_FRAME_CHROME_FRAME_ACTIVEX_BASE_H_ | 6 #define CHROME_FRAME_CHROME_FRAME_ACTIVEX_BASE_H_ |
7 | 7 |
8 #include <atlbase.h> | 8 #include <atlbase.h> |
9 #include <atlcom.h> | 9 #include <atlcom.h> |
10 #include <atlctl.h> | 10 #include <atlctl.h> |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 COM_INTERFACE_ENTRY_FUNC_BLIND(0, InterfaceNotSupported) | 194 COM_INTERFACE_ENTRY_FUNC_BLIND(0, InterfaceNotSupported) |
195 END_COM_MAP() | 195 END_COM_MAP() |
196 | 196 |
197 BEGIN_CONNECTION_POINT_MAP(T) | 197 BEGIN_CONNECTION_POINT_MAP(T) |
198 CONNECTION_POINT_ENTRY(IID_IPropertyNotifySink) | 198 CONNECTION_POINT_ENTRY(IID_IPropertyNotifySink) |
199 CONNECTION_POINT_ENTRY(DIID_DIChromeFrameEvents) | 199 CONNECTION_POINT_ENTRY(DIID_DIChromeFrameEvents) |
200 END_CONNECTION_POINT_MAP() | 200 END_CONNECTION_POINT_MAP() |
201 | 201 |
202 BEGIN_MSG_MAP(ChromeFrameActivexBase) | 202 BEGIN_MSG_MAP(ChromeFrameActivexBase) |
203 MESSAGE_HANDLER(WM_CREATE, OnCreate) | 203 MESSAGE_HANDLER(WM_CREATE, OnCreate) |
| 204 MESSAGE_HANDLER(WM_DESTROY, OnDestroy) |
204 CHAIN_MSG_MAP(ChromeFramePlugin<T>) | 205 CHAIN_MSG_MAP(ChromeFramePlugin<T>) |
205 CHAIN_MSG_MAP(CComControl<T>) | 206 CHAIN_MSG_MAP(CComControl<T>) |
206 CHAIN_MSG_MAP(TaskMarshaller) | 207 CHAIN_MSG_MAP(TaskMarshaller) |
207 DEFAULT_REFLECTION_HANDLER() | 208 DEFAULT_REFLECTION_HANDLER() |
208 END_MSG_MAP() | 209 END_MSG_MAP() |
209 | 210 |
210 // IViewObjectEx | 211 // IViewObjectEx |
211 DECLARE_VIEW_STATUS(VIEWSTATUS_SOLIDBKGND | VIEWSTATUS_OPAQUE) | 212 DECLARE_VIEW_STATUS(VIEWSTATUS_SOLIDBKGND | VIEWSTATUS_OPAQUE) |
212 | 213 |
213 inline HRESULT IViewObject_Draw(DWORD draw_aspect, LONG index, | 214 inline HRESULT IViewObject_Draw(DWORD draw_aspect, LONG index, |
(...skipping 17 matching lines...) Expand all Loading... |
231 // Set to true if this is the first launch by this process. | 232 // Set to true if this is the first launch by this process. |
232 // Used to perform one time tasks. | 233 // Used to perform one time tasks. |
233 if (g_first_launch_by_process_) { | 234 if (g_first_launch_by_process_) { |
234 g_first_launch_by_process_ = false; | 235 g_first_launch_by_process_ = false; |
235 UMA_HISTOGRAM_CUSTOM_COUNTS("ChromeFrame.IEVersion", | 236 UMA_HISTOGRAM_CUSTOM_COUNTS("ChromeFrame.IEVersion", |
236 GetIEVersion(), | 237 GetIEVersion(), |
237 IE_INVALID, | 238 IE_INVALID, |
238 IE_8, | 239 IE_8, |
239 IE_8 + 1); | 240 IE_8 + 1); |
240 } | 241 } |
241 | |
242 base::Thread::Options options; | |
243 options.message_loop_type = MessageLoop::TYPE_UI; | |
244 worker_thread_.StartWithOptions(options); | |
245 worker_thread_.message_loop()->PostTask( | |
246 FROM_HERE, NewRunnableMethod(this, &Base::OnWorkerStart)); | |
247 return S_OK; | 242 return S_OK; |
248 } | 243 } |
249 | 244 |
250 void FinalRelease() { | 245 void FinalRelease() { |
251 } | 246 } |
252 | 247 |
253 static HRESULT WINAPI InterfaceNotSupported(void* pv, REFIID riid, void** ppv, | 248 static HRESULT WINAPI InterfaceNotSupported(void* pv, REFIID riid, void** ppv, |
254 DWORD dw) { | 249 DWORD dw) { |
255 #ifndef NDEBUG | 250 #ifndef NDEBUG |
256 wchar_t buffer[64] = {0}; | 251 wchar_t buffer[64] = {0}; |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
317 // scriptable document, return true, else false. | 312 // scriptable document, return true, else false. |
318 bool is_frame_busting_enabled() const { | 313 bool is_frame_busting_enabled() const { |
319 return true; | 314 return true; |
320 } | 315 } |
321 | 316 |
322 // Needed to support PostTask. | 317 // Needed to support PostTask. |
323 static bool ImplementsThreadSafeReferenceCounting() { | 318 static bool ImplementsThreadSafeReferenceCounting() { |
324 return true; | 319 return true; |
325 } | 320 } |
326 | 321 |
327 virtual void OnFinalMessage(HWND) { | |
328 ChromeFramePlugin<T>::Uninitialize(); | |
329 worker_thread_.message_loop()->PostTask( | |
330 FROM_HERE, NewRunnableMethod(this, &Base::OnWorkerStop)); | |
331 worker_thread_.Stop(); | |
332 } | |
333 | |
334 protected: | 322 protected: |
335 virtual void OnTabbedOut(int tab_handle, bool reverse) { | 323 virtual void OnTabbedOut(int tab_handle, bool reverse) { |
336 DCHECK(m_bInPlaceActive); | 324 DCHECK(m_bInPlaceActive); |
337 | 325 |
338 HWND parent = ::GetParent(m_hWnd); | 326 HWND parent = ::GetParent(m_hWnd); |
339 ::SetFocus(parent); | 327 ::SetFocus(parent); |
340 ScopedComPtr<IOleControlSite> control_site; | 328 ScopedComPtr<IOleControlSite> control_site; |
341 control_site.QueryFrom(m_spClientSite); | 329 control_site.QueryFrom(m_spClientSite); |
342 if (control_site) | 330 if (control_site) |
343 control_site->OnFocus(FALSE); | 331 control_site->OnFocus(FALSE); |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
425 http_headers.Set(referrer_header.c_str()); | 413 http_headers.Set(referrer_header.c_str()); |
426 } | 414 } |
427 | 415 |
428 web_browser2->Navigate2(url.AsInput(), &flags, &empty, &empty, | 416 web_browser2->Navigate2(url.AsInput(), &flags, &empty, &empty, |
429 http_headers.AsInput()); | 417 http_headers.AsInput()); |
430 web_browser2->put_Visible(VARIANT_TRUE); | 418 web_browser2->put_Visible(VARIANT_TRUE); |
431 } | 419 } |
432 | 420 |
433 virtual void OnRequestStart(int tab_handle, int request_id, | 421 virtual void OnRequestStart(int tab_handle, int request_id, |
434 const IPC::AutomationURLRequest& request_info) { | 422 const IPC::AutomationURLRequest& request_info) { |
| 423 // The worker thread may have been stopped. This could happen if the |
| 424 // ActiveX instance was reused. |
| 425 if (!worker_thread_.message_loop()) { |
| 426 base::Thread::Options options; |
| 427 options.message_loop_type = MessageLoop::TYPE_UI; |
| 428 worker_thread_.StartWithOptions(options); |
| 429 worker_thread_.message_loop()->PostTask( |
| 430 FROM_HERE, NewRunnableMethod(this, &Base::OnWorkerStart)); |
| 431 } |
| 432 |
435 scoped_refptr<CComObject<UrlmonUrlRequest> > request; | 433 scoped_refptr<CComObject<UrlmonUrlRequest> > request; |
436 if (base_url_request_.get() && | 434 if (base_url_request_.get() && |
437 GURL(base_url_request_->url()) == GURL(request_info.url)) { | 435 GURL(base_url_request_->url()) == GURL(request_info.url)) { |
438 request.swap(base_url_request_); | 436 request.swap(base_url_request_); |
439 } else { | 437 } else { |
440 CComObject<UrlmonUrlRequest>* new_request = NULL; | 438 CComObject<UrlmonUrlRequest>* new_request = NULL; |
441 CComObject<UrlmonUrlRequest>::CreateInstance(&new_request); | 439 CComObject<UrlmonUrlRequest>::CreateInstance(&new_request); |
442 request = new_request; | 440 request = new_request; |
443 } | 441 } |
444 | 442 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
498 ModifyStyle(0, WS_CLIPCHILDREN | WS_CLIPSIBLINGS, 0); | 496 ModifyStyle(0, WS_CLIPCHILDREN | WS_CLIPSIBLINGS, 0); |
499 automation_client_->SetParentWindow(m_hWnd); | 497 automation_client_->SetParentWindow(m_hWnd); |
500 // Only fire the 'interactive' ready state if we aren't there already. | 498 // Only fire the 'interactive' ready state if we aren't there already. |
501 if (ready_state_ < READYSTATE_INTERACTIVE) { | 499 if (ready_state_ < READYSTATE_INTERACTIVE) { |
502 ready_state_ = READYSTATE_INTERACTIVE; | 500 ready_state_ = READYSTATE_INTERACTIVE; |
503 FireOnChanged(DISPID_READYSTATE); | 501 FireOnChanged(DISPID_READYSTATE); |
504 } | 502 } |
505 return 0; | 503 return 0; |
506 } | 504 } |
507 | 505 |
| 506 LRESULT OnDestroy(UINT message, WPARAM wparam, LPARAM lparam, |
| 507 BOOL& handled) { // NO_LINT |
| 508 worker_thread_.message_loop()->PostTask( |
| 509 FROM_HERE, NewRunnableMethod(this, &Base::OnWorkerStop)); |
| 510 if (automation_client_.get()) |
| 511 automation_client_->CleanupRequests(); |
| 512 worker_thread_.Stop(); |
| 513 return 0; |
| 514 } |
| 515 |
508 // ChromeFrameDelegate override | 516 // ChromeFrameDelegate override |
509 virtual void OnAutomationServerReady() { | 517 virtual void OnAutomationServerReady() { |
510 ChromeFramePlugin<T>::OnAutomationServerReady(); | 518 ChromeFramePlugin<T>::OnAutomationServerReady(); |
511 | 519 |
512 ready_state_ = READYSTATE_COMPLETE; | 520 ready_state_ = READYSTATE_COMPLETE; |
513 FireOnChanged(DISPID_READYSTATE); | 521 FireOnChanged(DISPID_READYSTATE); |
514 } | 522 } |
515 | 523 |
516 // ChromeFrameDelegate override | 524 // ChromeFrameDelegate override |
517 virtual void OnAutomationServerLaunchFailed( | 525 virtual void OnAutomationServerLaunchFailed( |
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
997 EventHandlers onprivatemessage_; | 1005 EventHandlers onprivatemessage_; |
998 EventHandlers onextensionready_; | 1006 EventHandlers onextensionready_; |
999 | 1007 |
1000 // The UrlmonUrlRequest instance instantiated for downloading the base URL. | 1008 // The UrlmonUrlRequest instance instantiated for downloading the base URL. |
1001 scoped_refptr<CComObject<UrlmonUrlRequest> > base_url_request_; | 1009 scoped_refptr<CComObject<UrlmonUrlRequest> > base_url_request_; |
1002 | 1010 |
1003 base::Thread worker_thread_; | 1011 base::Thread worker_thread_; |
1004 }; | 1012 }; |
1005 | 1013 |
1006 #endif // CHROME_FRAME_CHROME_FRAME_ACTIVEX_BASE_H_ | 1014 #endif // CHROME_FRAME_CHROME_FRAME_ACTIVEX_BASE_H_ |
OLD | NEW |