Left: | ||
Right: |
OLD | NEW |
---|---|
1 #include "PluginStdAfx.h" | 1 #include "PluginStdAfx.h" |
2 | 2 |
3 #include "PluginClass.h" | 3 #include "PluginClass.h" |
4 #include "PluginSettings.h" | 4 #include "PluginSettings.h" |
5 #include "PluginSystem.h" | 5 #include "PluginSystem.h" |
6 #include "PluginFilter.h" | 6 #include "PluginFilter.h" |
7 #include "PluginMimeFilterClient.h" | 7 #include "PluginMimeFilterClient.h" |
8 #include "PluginClient.h" | 8 #include "PluginClient.h" |
9 #include "PluginClientFactory.h" | 9 #include "PluginClientFactory.h" |
10 #include "PluginMutex.h" | 10 #include "PluginMutex.h" |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
68 return right - left; | 68 return right - left; |
69 } | 69 } |
70 }; | 70 }; |
71 } | 71 } |
72 | 72 |
73 CPluginClass::CPluginClass() | 73 CPluginClass::CPluginClass() |
74 { | 74 { |
75 //Use this line to debug memory leaks | 75 //Use this line to debug memory leaks |
76 // _CrtDumpMemoryLeaks(); | 76 // _CrtDumpMemoryLeaks(); |
77 | 77 |
78 m_isAdviced = false; | 78 m_isAdvised = false; |
79 m_nConnectionID = 0; | |
80 m_hTabWnd = NULL; | 79 m_hTabWnd = NULL; |
81 m_hStatusBarWnd = NULL; | 80 m_hStatusBarWnd = NULL; |
82 m_hPaneWnd = NULL; | 81 m_hPaneWnd = NULL; |
83 m_nPaneWidth = 0; | 82 m_nPaneWidth = 0; |
84 m_pWndProcStatus = NULL; | 83 m_pWndProcStatus = NULL; |
85 m_hTheme = NULL; | 84 m_hTheme = NULL; |
86 m_isInitializedOk = false; | 85 m_isInitializedOk = false; |
87 | 86 |
88 | 87 |
89 m_tab = new CPluginTab(this); | 88 m_tab = new CPluginTab(this); |
(...skipping 17 matching lines...) Expand all Loading... | |
107 | 106 |
108 void CPluginClass::FinalRelease() | 107 void CPluginClass::FinalRelease() |
109 { | 108 { |
110 s_criticalSectionBrowser.Lock(); | 109 s_criticalSectionBrowser.Lock(); |
111 { | 110 { |
112 m_webBrowser2.Release(); | 111 m_webBrowser2.Release(); |
113 } | 112 } |
114 s_criticalSectionBrowser.Unlock(); | 113 s_criticalSectionBrowser.Unlock(); |
115 } | 114 } |
116 | 115 |
117 | |
118 // This method tries to get a 'connection point' from the stored browser, which can be | |
119 // used to attach or detach from the stream of browser events | |
120 CComPtr<IConnectionPoint> CPluginClass::GetConnectionPoint() | |
121 { | |
122 CComQIPtr<IConnectionPointContainer, &IID_IConnectionPointContainer> pContaine r(GetBrowser()); | |
123 if (!pContainer) | |
124 { | |
125 return NULL; | |
126 } | |
127 | |
128 CComPtr<IConnectionPoint> pPoint; | |
129 HRESULT hr = pContainer->FindConnectionPoint(DIID_DWebBrowserEvents2, &pPoint) ; | |
130 if (FAILED(hr)) | |
131 { | |
132 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_SET_SITE, PLUGIN_ERROR_SET_SITE_FIND_CONNEC TION_POINT, "Class::GetConnectionPoint - FindConnectionPoint") | |
133 return NULL; | |
134 } | |
135 | |
136 return pPoint; | |
137 } | |
138 | |
139 HWND CPluginClass::GetBrowserHWND() const | 116 HWND CPluginClass::GetBrowserHWND() const |
140 { | 117 { |
141 SHANDLE_PTR hBrowserWndHandle = NULL; | 118 SHANDLE_PTR hBrowserWndHandle = NULL; |
142 | 119 |
143 CComQIPtr<IWebBrowser2> browser = GetBrowser(); | 120 CComQIPtr<IWebBrowser2> browser = GetBrowser(); |
144 if (browser) | 121 if (browser) |
145 { | 122 { |
146 HRESULT hr = browser->get_HWND(&hBrowserWndHandle); | 123 HRESULT hr = browser->get_HWND(&hBrowserWndHandle); |
147 if (FAILED(hr)) | 124 if (FAILED(hr)) |
148 { | 125 { |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
203 | 180 |
204 return url; | 181 return url; |
205 } | 182 } |
206 | 183 |
207 DWORD WINAPI CPluginClass::StartInitObject(LPVOID thisPtr) | 184 DWORD WINAPI CPluginClass::StartInitObject(LPVOID thisPtr) |
208 { | 185 { |
209 if (thisPtr == NULL) | 186 if (thisPtr == NULL) |
210 return 0; | 187 return 0; |
211 if (!((CPluginClass*)thisPtr)->InitObject(true)) | 188 if (!((CPluginClass*)thisPtr)->InitObject(true)) |
212 { | 189 { |
213 ((CPluginClass*)thisPtr)->Unadvice(); | 190 ((CPluginClass*)thisPtr)->Unadvise(); |
214 } | 191 } |
215 | 192 |
216 return 0; | 193 return 0; |
217 } | 194 } |
218 | 195 |
219 | 196 |
220 | 197 |
221 // This gets called when a new browser window is created (which also triggers th e | 198 // This gets called when a new browser window is created (which also triggers th e |
222 // creation of this object). The pointer passed in should be to a IWebBrowser2 | 199 // creation of this object). The pointer passed in should be to a IWebBrowser2 |
223 // interface that represents the browser for the window. | 200 // interface that represents the browser for the window. |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
255 // Always register on startup, then check if we need to unregister in a se parate thread | 232 // Always register on startup, then check if we need to unregister in a se parate thread |
256 s_mimeFilter = CPluginClientFactory::GetMimeFilterClientInstance(); | 233 s_mimeFilter = CPluginClientFactory::GetMimeFilterClientInstance(); |
257 s_asyncWebBrowser2 = unknownSite; | 234 s_asyncWebBrowser2 = unknownSite; |
258 s_instances.insert(this); | 235 s_instances.insert(this); |
259 } | 236 } |
260 s_criticalSectionLocal.Unlock(); | 237 s_criticalSectionLocal.Unlock(); |
261 | 238 |
262 try | 239 try |
263 { | 240 { |
264 // Check if loaded as BHO | 241 // Check if loaded as BHO |
265 if (GetBrowser()) | 242 auto webBrowser = GetBrowser(); |
243 if (webBrowser) | |
266 { | 244 { |
267 DEBUG_GENERAL("Loaded as BHO"); | 245 DEBUG_GENERAL("Loaded as BHO"); |
268 CComPtr<IConnectionPoint> pPoint = GetConnectionPoint(); | 246 HRESULT hr = DispEventAdvise(webBrowser); |
269 if (pPoint) | 247 if (SUCCEEDED(hr)) |
270 { | 248 { |
271 HRESULT hr = pPoint->Advise((IDispatch*)this, &m_nConnectionID); | 249 m_isAdvised = true; |
272 if (SUCCEEDED(hr)) | 250 try |
273 { | 251 { |
274 m_isAdviced = true; | 252 std::thread startInitObjectThread(StartInitObject, this); |
275 | 253 startInitObjectThread.detach(); // TODO: but actually we should wait for the thread in the dtr. |
276 try | |
277 { | |
278 std::thread startInitObjectThread(StartInitObject, this); | |
279 startInitObjectThread.detach(); // TODO: but actually we should wa it for the thread in the dtr. | |
280 } | |
281 catch (const std::system_error& ex) | |
282 { | |
283 auto errDescription = std::string("Class::Thread - Failed to creat e StartInitObject thread, ") + | |
284 ex.code().message() + ex.what(); | |
285 DEBUG_ERROR_LOG(ex.code().value(), PLUGIN_ERROR_THREAD, PLUGIN_ERR OR_MAIN_THREAD_CREATE_PROCESS, errDescription.c_str()); | |
286 } | |
287 } | 254 } |
288 else | 255 catch (const std::system_error& ex) |
289 { | 256 { |
290 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_SET_SITE, PLUGIN_ERROR_SET_SITE_ADV ICE, "Class::SetSite - Advice"); | 257 auto errDescription = std::string("Class::Thread - Failed to create StartInitObject thread, ") + |
258 ex.code().message() + ex.what(); | |
259 DEBUG_ERROR_LOG(ex.code().value(), PLUGIN_ERROR_THREAD, PLUGIN_ERROR _MAIN_THREAD_CREATE_PROCESS, errDescription.c_str()); | |
291 } | 260 } |
292 } | 261 } |
262 else | |
263 { | |
264 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_SET_SITE, PLUGIN_ERROR_SET_SITE_ADVIC E, "Class::SetSite - Advice"); | |
265 } | |
293 } | 266 } |
294 else // Check if loaded as toolbar handler | 267 else // Check if loaded as toolbar handler |
295 { | 268 { |
296 DEBUG_GENERAL("Loaded as toolbar handler"); | 269 DEBUG_GENERAL("Loaded as toolbar handler"); |
297 CComPtr<IServiceProvider> pServiceProvider; | 270 CComPtr<IServiceProvider> pServiceProvider; |
298 | 271 |
299 HRESULT hr = unknownSite->QueryInterface(&pServiceProvider); | 272 HRESULT hr = unknownSite->QueryInterface(&pServiceProvider); |
300 if (SUCCEEDED(hr)) | 273 if (SUCCEEDED(hr)) |
301 { | 274 { |
302 if (pServiceProvider) | 275 if (pServiceProvider) |
(...skipping 18 matching lines...) Expand all Loading... | |
321 } | 294 } |
322 else | 295 else |
323 { | 296 { |
324 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_SET_SITE, PLUGIN_ERROR_SET_SITE_QUERY _SERVICE_PROVIDER, "Class::SetSite - QueryInterface (service provider)"); | 297 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_SET_SITE, PLUGIN_ERROR_SET_SITE_QUERY _SERVICE_PROVIDER, "Class::SetSite - QueryInterface (service provider)"); |
325 } | 298 } |
326 } | 299 } |
327 } | 300 } |
328 catch (std::runtime_error e) | 301 catch (std::runtime_error e) |
329 { | 302 { |
330 DEBUG_ERROR(e.what()); | 303 DEBUG_ERROR(e.what()); |
331 Unadvice(); | 304 Unadvise(); |
332 } | 305 } |
333 } | 306 } |
334 else | 307 else |
335 { | 308 { |
336 // Unadvice | 309 Unadvise(); |
337 Unadvice(); | |
338 | 310 |
339 // Destroy window | 311 // Destroy window |
340 if (m_pWndProcStatus) | 312 if (m_pWndProcStatus) |
341 { | 313 { |
342 ::SetWindowLongPtr(m_hStatusBarWnd, GWLP_WNDPROC, (LPARAM)(WNDPROC)m_pWndP rocStatus); | 314 ::SetWindowLongPtr(m_hStatusBarWnd, GWLP_WNDPROC, (LPARAM)(WNDPROC)m_pWndP rocStatus); |
343 | 315 |
344 m_pWndProcStatus = NULL; | 316 m_pWndProcStatus = NULL; |
345 } | 317 } |
346 | 318 |
347 if (m_hPaneWnd) | 319 if (m_hPaneWnd) |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
495 } | 467 } |
496 } | 468 } |
497 else | 469 else |
498 { | 470 { |
499 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_UI, PLUGIN_ERROR_UI_GET_STATUSBAR, "Class ::Get statusbar state"); | 471 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_UI, PLUGIN_ERROR_UI_GET_STATUSBAR, "Class ::Get statusbar state"); |
500 } | 472 } |
501 } | 473 } |
502 DEBUG_GENERAL("ShowStatusBar end"); | 474 DEBUG_GENERAL("ShowStatusBar end"); |
503 } | 475 } |
504 | 476 |
505 /* | 477 void STDMETHODCALLTYPE CPluginClass::OnBeforeNavigate2( |
506 * #1163 This class is the implementation for method DISPID_BEFORENAVIGATE2 in C PluginClass::Invoke. | 478 /* [in] */ IDispatch* frameBrowserDisp, |
507 * - It validates and convertes its own arguments, rather than unifying them in the Invoke body. | 479 /* [in] */ VARIANT* urlVariant, |
508 * - It's declared void and not HRESULT, so DISPID_BEFORENAVIGATE2 can only retu rn S_OK. | 480 /* [in] */ VARIANT* /*Flags*/, |
509 */ | 481 /* [in] */ VARIANT* /*TargetFrameName*/, |
510 void CPluginClass::BeforeNavigate2(DISPPARAMS* pDispParams) | 482 /* [in] */ VARIANT* /*PostData*/, |
483 /* [in] */ VARIANT* /*Headers*/, | |
484 /* [in, out] */ VARIANT_BOOL* /*Cancel*/) | |
511 { | 485 { |
512 | 486 ATL::CComQIPtr<IWebBrowser2> webBrowser = frameBrowserDisp; |
513 if (pDispParams->cArgs < 7) | 487 if (!webBrowser) |
514 { | 488 { |
515 return; | 489 return; |
516 } | 490 } |
491 | |
492 if (!urlVariant || urlVariant->vt != VT_BSTR) | |
493 { | |
494 return; | |
495 } | |
496 std::wstring url(urlVariant->bstrVal, SysStringLen(urlVariant->bstrVal)); | |
497 UnescapeUrl(url); | |
498 | |
517 //Register a mime filter if it's not registered yet | 499 //Register a mime filter if it's not registered yet |
518 if (s_mimeFilter == NULL) | 500 if (s_mimeFilter == NULL) |
519 { | 501 { |
520 s_mimeFilter = CPluginClientFactory::GetMimeFilterClientInstance(); | 502 s_mimeFilter = CPluginClientFactory::GetMimeFilterClientInstance(); |
521 } | 503 } |
522 | 504 |
523 // Get the IWebBrowser2 interface | 505 CString urlCString = ToCString(url); |
524 CComQIPtr<IWebBrowser2, &IID_IWebBrowser2> WebBrowser2Ptr; | |
525 VARTYPE vt = pDispParams->rgvarg[6].vt; | |
526 if (vt == VT_DISPATCH) | |
527 { | |
528 WebBrowser2Ptr = pDispParams->rgvarg[6].pdispVal; | |
529 } | |
530 else | |
531 { | |
532 // Wrong type, return. | |
533 return; | |
534 } | |
535 | |
536 // Get the URL | |
537 CString url; | |
538 vt = pDispParams->rgvarg[5].vt; | |
539 if (vt == VT_BYREF + VT_VARIANT) | |
540 { | |
541 url = pDispParams->rgvarg[5].pvarVal->bstrVal; | |
542 | |
543 CPluginClient::UnescapeUrl(url); | |
544 } | |
545 else | |
546 { | |
547 // Wrong type, return. | |
548 return; | |
549 } | |
550 | 506 |
551 // If webbrowser2 is equal to top level browser (as set in SetSite), we are na vigating new page | 507 // If webbrowser2 is equal to top level browser (as set in SetSite), we are na vigating new page |
552 CPluginClient* client = CPluginClient::GetInstance(); | 508 CPluginClient* client = CPluginClient::GetInstance(); |
553 | 509 |
554 if (url.Find(L"javascript") == 0) | 510 if (urlCString.Find(L"javascript") == 0) |
555 { | 511 { |
556 } | 512 } |
557 else if (GetBrowser().IsEqualObject(WebBrowser2Ptr)) | 513 else if (GetBrowser().IsEqualObject(webBrowser)) |
558 { | 514 { |
559 m_tab->OnNavigate(url); | 515 m_tab->OnNavigate(urlCString); |
560 | 516 |
561 DEBUG_GENERAL(L"============================================================ ====================\nBegin main navigation url:" + url + "\n=================== =============================================================") | 517 DEBUG_GENERAL(L"============================================================ ====================\nBegin main navigation url:" + urlCString + "\n============ ====================================================================") |
562 | 518 |
563 #ifdef ENABLE_DEBUG_RESULT | 519 #ifdef ENABLE_DEBUG_RESULT |
564 CPluginDebug::DebugResultDomain(url); | 520 CPluginDebug::DebugResultDomain(urlCString); |
565 #endif | 521 #endif |
566 | 522 |
567 UpdateStatusBar(); | 523 UpdateStatusBar(); |
568 } | 524 } |
569 else | 525 else |
570 { | 526 { |
571 DEBUG_NAVI(L"Navi::Begin navigation url:" + url) | 527 DEBUG_NAVI(L"Navi::Begin navigation url:" + urlCString) |
572 m_tab->CacheFrame(url); | 528 m_tab->CacheFrame(urlCString); |
573 } | 529 } |
574 } | 530 } |
575 | 531 |
576 /* | 532 void STDMETHODCALLTYPE CPluginClass::OnDownloadBegin() |
577 * #1163 implements behavior for method DISPID_WINDOWSTATECHANGED in CPluginClas s::Invoke | 533 { |
578 * - should validate and convert arguments in Invoke, not here | 534 DEBUG_NAVI("Navi::Download Begin") |
579 * - does not validate number of arguments before indexing into 'rgvarg' | 535 } |
580 * - does not validate type of argument before using its value | 536 |
581 */ | 537 void STDMETHODCALLTYPE CPluginClass::OnDownloadComplete() |
582 STDMETHODIMP CPluginClass::OnTabChanged(DISPPARAMS* pDispParams, WORD wFlags) | 538 { |
539 DEBUG_NAVI("Navi::Download Complete") | |
540 ATL::CComPtr<IWebBrowser2> browser = GetBrowser(); | |
541 if (browser) | |
542 { | |
543 m_tab->OnDownloadComplete(browser); | |
544 } | |
545 } | |
546 | |
547 void STDMETHODCALLTYPE CPluginClass::OnDocumentComplete(IDispatch* frameBrowserD isp, VARIANT* /*urlOrPidl*/) | |
548 { | |
549 ATL::CComQIPtr<IWebBrowser2> webBrowser2 = frameBrowserDisp; | |
550 if (!webBrowser2) | |
551 { | |
552 return; | |
553 } | |
554 ATL::CString frameSrc; | |
555 ATL::CComBSTR locationUrl; | |
556 if (FAILED(webBrowser2->get_LocationURL(&locationUrl)) && !!locationUrl) | |
557 { | |
558 return; | |
559 } | |
560 frameSrc = locationUrl; | |
561 CPluginClient::UnescapeUrl(frameSrc); | |
562 bool isRootPageBrowser = GetBrowser().IsEqualObject(webBrowser2); | |
563 m_tab->OnDocumentComplete(webBrowser2, frameSrc, isRootPageBrowser); | |
564 } | |
565 | |
566 void STDMETHODCALLTYPE CPluginClass::OnWindowStateChanged(unsigned long flags, u nsigned long validFlagsMask) | |
583 { | 567 { |
584 DEBUG_GENERAL("Tab changed"); | 568 DEBUG_GENERAL("Tab changed"); |
585 bool newtabshown = pDispParams->rgvarg[1].intVal==3; | 569 bool newtabshown = validFlagsMask == (OLECMDIDF_WINDOWSTATE_USERVISIBLE | OLEC MDIDF_WINDOWSTATE_ENABLED) |
570 && flags == (OLECMDIDF_WINDOWSTATE_USERVISIBLE | OLECMDIDF_WIN DOWSTATE_ENABLED); | |
586 if (newtabshown) | 571 if (newtabshown) |
587 { | 572 { |
588 std::map<DWORD,CPluginClass*>::const_iterator it = s_threadInstances.find(Ge tCurrentThreadId()); | 573 std::map<DWORD,CPluginClass*>::const_iterator it = s_threadInstances.find(Ge tCurrentThreadId()); |
589 if (it == s_threadInstances.end()) | 574 if (it == s_threadInstances.end()) |
590 { | 575 { |
591 s_threadInstances[::GetCurrentThreadId()] = this; | 576 s_threadInstances[::GetCurrentThreadId()] = this; |
592 if (!m_isInitializedOk) | 577 if (!m_isInitializedOk) |
593 { | 578 { |
594 m_isInitializedOk = true; | 579 m_isInitializedOk = true; |
595 InitObject(true); | 580 InitObject(true); |
596 UpdateStatusBar(); | 581 UpdateStatusBar(); |
597 } | 582 } |
598 } | 583 } |
599 } | 584 } |
600 notificationMessage.Hide(); | 585 notificationMessage.Hide(); |
601 DEBUG_GENERAL("Tab change end"); | 586 DEBUG_GENERAL("Tab change end"); |
602 return S_OK; | |
603 } | 587 } |
604 | 588 |
605 // This gets called whenever there's a browser event | 589 void STDMETHODCALLTYPE CPluginClass::OnCommandStateChange(long /*command*/, VARI ANT_BOOL /*enable*/) |
606 // ENTRY POINT | |
607 STDMETHODIMP CPluginClass::Invoke(DISPID dispidMember, REFIID riid, LCID lcid, W ORD wFlags, DISPPARAMS* pDispParams, VARIANT* pvarResult, EXCEPINFO* pExcepInfo, UINT* puArgErr) | |
608 { | 590 { |
609 try | 591 if (m_hPaneWnd == NULL) |
610 { | 592 { |
611 WCHAR tmp[256]; | 593 CreateStatusBarPane(); |
612 wsprintf(tmp, L"Invoke: %d\n", dispidMember); | 594 } |
613 DEBUG_GENERAL(tmp); | 595 else |
614 switch (dispidMember) | 596 { |
597 if (AdblockPlus::IE::InstalledMajorVersion() > 6) | |
615 { | 598 { |
616 case DISPID_WINDOWSTATECHANGED: | 599 RECT rect; |
600 BOOL rectRes = GetClientRect(m_hStatusBarWnd, &rect); | |
601 if (rectRes == TRUE) | |
617 { | 602 { |
618 // #1163 should validate and convert arguments here | 603 MoveWindow(m_hPaneWnd, rect.right - 200, 0, m_nPaneWidth, rect.bottom - rect.top, TRUE); |
619 return OnTabChanged(pDispParams, wFlags); | |
620 } | 604 } |
621 | |
622 case DISPID_HTMLDOCUMENTEVENTS2_ONBEFOREUPDATE: | |
623 break; | |
624 | |
625 case DISPID_HTMLDOCUMENTEVENTS2_ONCLICK: | |
626 break; | |
627 | |
628 case DISPID_EVMETH_ONLOAD: | |
629 DEBUG_NAVI("Navi::OnLoad") | |
630 break; | |
631 | |
632 case DISPID_EVMETH_ONCHANGE: | |
633 break; | |
634 | |
635 case DISPID_EVMETH_ONMOUSEDOWN: | |
636 break; | |
637 | |
638 case DISPID_EVMETH_ONMOUSEENTER: | |
639 break; | |
640 | |
641 case DISPID_IHTMLIMGELEMENT_START: | |
642 break; | |
643 | |
644 case STDDISPID_XOBJ_ERRORUPDATE: | |
645 break; | |
646 | |
647 case STDDISPID_XOBJ_ONPROPERTYCHANGE: | |
648 break; | |
649 | |
650 case DISPID_READYSTATECHANGE: | |
651 DEBUG_NAVI("Navi::ReadyStateChange"); | |
652 break; | |
653 | |
654 case DISPID_BEFORENAVIGATE: | |
655 DEBUG_NAVI("Navi::BeforeNavigate"); | |
656 break; | |
657 | |
658 case DISPID_COMMANDSTATECHANGE: | |
659 if (m_hPaneWnd == NULL) | |
660 { | |
661 CreateStatusBarPane(); | |
662 } | |
663 else | |
664 { | |
665 if (AdblockPlus::IE::InstalledMajorVersion() > 6) | |
666 { | |
667 RECT rect; | |
668 BOOL rectRes = GetClientRect(m_hStatusBarWnd, &rect); | |
669 if (rectRes == TRUE) | |
670 { | |
671 MoveWindow(m_hPaneWnd, rect.right - 200, 0, m_nPaneWidth, rect.botto m - rect.top, TRUE); | |
672 } | |
673 } | |
674 } | |
675 break; | |
676 | |
677 case DISPID_STATUSTEXTCHANGE: | |
678 break; | |
679 | |
680 case DISPID_BEFORENAVIGATE2: | |
681 { | |
682 // #1163 should validate and convert parameters here | |
683 BeforeNavigate2(pDispParams); | |
684 } | |
685 break; | |
686 | |
687 case DISPID_DOWNLOADBEGIN: | |
688 { | |
689 DEBUG_NAVI("Navi::Download Begin") | |
690 } | |
691 break; | |
692 | |
693 case DISPID_DOWNLOADCOMPLETE: | |
694 { | |
695 DEBUG_NAVI("Navi::Download Complete"); | |
696 CComQIPtr<IWebBrowser2> browser = GetBrowser(); | |
697 if (browser) | |
698 { | |
699 m_tab->OnDownloadComplete(browser); | |
700 } | |
701 } | |
702 break; | |
703 | |
704 case DISPID_DOCUMENTCOMPLETE: | |
705 { | |
706 DEBUG_NAVI("Navi::Document Complete"); | |
707 CComQIPtr<IWebBrowser2> browser = GetBrowser(); | |
708 if (browser && pDispParams->cArgs >= 2 && pDispParams->rgvarg[1].vt == V T_DISPATCH) | |
709 { | |
710 CComQIPtr<IWebBrowser2> pBrowser = pDispParams->rgvarg[1].pdispVal; | |
711 if (pBrowser) | |
712 { | |
713 CString url; | |
714 CComBSTR bstrUrl; | |
715 if (SUCCEEDED(pBrowser->get_LocationURL(&bstrUrl)) && ::SysStringLen (bstrUrl) > 0) | |
716 { | |
717 url = bstrUrl; | |
718 CPluginClient::UnescapeUrl(url); | |
719 m_tab->OnDocumentComplete(browser, url, browser.IsEqualObject(pBro wser)); | |
720 } | |
721 } | |
722 } | |
723 } | |
724 break; | |
725 | |
726 case DISPID_ONQUIT: | |
727 case DISPID_QUIT: | |
728 { | |
729 Unadvice(); | |
730 } | |
731 break; | |
732 | |
733 default: | |
734 { | |
735 CString did; | |
736 did.Format(L"DispId:%u", dispidMember); | |
737 | |
738 DEBUG_NAVI(L"Navi::Default " + did) | |
739 } | |
740 /* | |
741 * Ordinarily a method not dispatched should return DISP_E_MEMBERNOTFOUND. | |
742 * As a conservative initial change, we leave it behaving as before, | |
743 * which is to do nothing and return S_OK. | |
744 */ | |
745 // do nothing | |
746 break; | |
747 } | 605 } |
748 } | 606 } |
749 catch(...) | |
750 { | |
751 DEBUG_GENERAL( "Caught unknown exception in CPluginClass::Invoke" ); | |
752 return E_FAIL; | |
753 } | |
754 return S_OK; | |
755 } | 607 } |
756 | 608 |
757 bool CPluginClass::InitObject(bool bBHO) | 609 bool CPluginClass::InitObject(bool bBHO) |
758 { | 610 { |
759 DEBUG_GENERAL("InitObject"); | 611 DEBUG_GENERAL("InitObject"); |
760 CPluginSettings* settings = CPluginSettings::GetInstance(); | 612 CPluginSettings* settings = CPluginSettings::GetInstance(); |
761 | 613 |
762 if (!settings->GetPluginEnabled()) | 614 if (!settings->GetPluginEnabled()) |
763 { | 615 { |
764 s_mimeFilter->Unregister(); | 616 s_mimeFilter->Unregister(); |
(...skipping 970 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1735 if (m_hPaneWnd == NULL) | 1587 if (m_hPaneWnd == NULL) |
1736 { | 1588 { |
1737 CreateStatusBarPane(); | 1589 CreateStatusBarPane(); |
1738 } | 1590 } |
1739 if ((m_hPaneWnd != NULL) && !::InvalidateRect(m_hPaneWnd, NULL, FALSE)) | 1591 if ((m_hPaneWnd != NULL) && !::InvalidateRect(m_hPaneWnd, NULL, FALSE)) |
1740 { | 1592 { |
1741 DEBUG_ERROR_LOG(::GetLastError(), PLUGIN_ERROR_UI, PLUGIN_ERROR_UI_INVALID ATE_STATUSBAR, "Class::Invalidate statusbar"); | 1593 DEBUG_ERROR_LOG(::GetLastError(), PLUGIN_ERROR_UI, PLUGIN_ERROR_UI_INVALID ATE_STATUSBAR, "Class::Invalidate statusbar"); |
1742 } | 1594 } |
1743 } | 1595 } |
1744 | 1596 |
1597 void STDMETHODCALLTYPE CPluginClass::OnOnQuit() | |
1598 { | |
1599 Unadvise(); | |
1600 } | |
1745 | 1601 |
1746 void CPluginClass::Unadvice() | 1602 void CPluginClass::Unadvise() |
1747 { | 1603 { |
1748 s_criticalSectionLocal.Lock(); | 1604 s_criticalSectionLocal.Lock(); |
1749 { | 1605 { |
1750 if (m_isAdviced) | 1606 if (m_isAdvised) |
1751 { | 1607 { |
1752 CComPtr<IConnectionPoint> pPoint = GetConnectionPoint(); | 1608 HRESULT hr = DispEventUnadvise(GetBrowser()); |
1753 if (pPoint) | 1609 if (FAILED(hr)) |
1754 { | 1610 { |
1755 HRESULT hr = pPoint->Unadvise(m_nConnectionID); | 1611 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_SET_SITE, PLUGIN_ERROR_SET_SITE_UNADVIS E, "Class::Unadvise - Unadvise"); |
1756 if (FAILED(hr)) | |
1757 { | |
1758 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_SET_SITE, PLUGIN_ERROR_SET_SITE_UNADV ICE, "Class::Unadvice - Unadvise"); | |
1759 } | |
1760 } | 1612 } |
1761 | 1613 m_isAdvised = false; |
Eric
2015/01/13 18:44:30
If the call to DispEventUnadvise() fails, we shoul
sergei
2015/02/27 18:27:37
If it's already unadvised the value of `FAILED(hr)
| |
1762 m_isAdviced = false; | |
1763 } | 1614 } |
1764 } | 1615 } |
1765 s_criticalSectionLocal.Unlock(); | 1616 s_criticalSectionLocal.Unlock(); |
1766 } | 1617 } |
1767 | 1618 |
1768 HICON CPluginClass::GetIcon(int type) | 1619 HICON CPluginClass::GetIcon(int type) |
1769 { | 1620 { |
1770 HICON icon = NULL; | 1621 HICON icon = NULL; |
1771 | 1622 |
1772 s_criticalSectionLocal.Lock(); | 1623 s_criticalSectionLocal.Lock(); |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1854 } | 1705 } |
1855 } | 1706 } |
1856 } | 1707 } |
1857 | 1708 |
1858 hTabWnd = ::GetWindow(hTabWnd, GW_HWNDNEXT); | 1709 hTabWnd = ::GetWindow(hTabWnd, GW_HWNDNEXT); |
1859 } | 1710 } |
1860 | 1711 |
1861 return hTabWnd; | 1712 return hTabWnd; |
1862 | 1713 |
1863 } | 1714 } |
OLD | NEW |