Left: | ||
Right: |
OLD | NEW |
---|---|
1 /* | 1 /* |
2 * This file is part of Adblock Plus <https://adblockplus.org/>, | 2 * This file is part of Adblock Plus <https://adblockplus.org/>, |
3 * Copyright (C) 2006-2015 Eyeo GmbH | 3 * Copyright (C) 2006-2015 Eyeo GmbH |
4 * | 4 * |
5 * Adblock Plus is free software: you can redistribute it and/or modify | 5 * Adblock Plus is free software: you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License version 3 as | 6 * it under the terms of the GNU General Public License version 3 as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
8 * | 8 * |
9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
85 return right - left; | 85 return right - left; |
86 } | 86 } |
87 }; | 87 }; |
88 } | 88 } |
89 | 89 |
90 CPluginClass::CPluginClass() | 90 CPluginClass::CPluginClass() |
91 { | 91 { |
92 //Use this line to debug memory leaks | 92 //Use this line to debug memory leaks |
93 // _CrtDumpMemoryLeaks(); | 93 // _CrtDumpMemoryLeaks(); |
94 | 94 |
95 m_isAdviced = false; | 95 m_isAdvised = false; |
96 m_nConnectionID = 0; | |
97 m_hTabWnd = NULL; | 96 m_hTabWnd = NULL; |
98 m_hStatusBarWnd = NULL; | 97 m_hStatusBarWnd = NULL; |
99 m_hPaneWnd = NULL; | 98 m_hPaneWnd = NULL; |
100 m_nPaneWidth = 0; | 99 m_nPaneWidth = 0; |
101 m_pWndProcStatus = NULL; | 100 m_pWndProcStatus = NULL; |
102 m_hTheme = NULL; | 101 m_hTheme = NULL; |
103 m_isInitializedOk = false; | 102 m_isInitializedOk = false; |
104 | 103 |
105 | 104 |
106 m_tab = new CPluginTab(this); | 105 m_tab = new CPluginTab(this); |
(...skipping 17 matching lines...) Expand all Loading... | |
124 | 123 |
125 void CPluginClass::FinalRelease() | 124 void CPluginClass::FinalRelease() |
126 { | 125 { |
127 s_criticalSectionBrowser.Lock(); | 126 s_criticalSectionBrowser.Lock(); |
128 { | 127 { |
129 m_webBrowser2.Release(); | 128 m_webBrowser2.Release(); |
130 } | 129 } |
131 s_criticalSectionBrowser.Unlock(); | 130 s_criticalSectionBrowser.Unlock(); |
132 } | 131 } |
133 | 132 |
134 | |
135 // This method tries to get a 'connection point' from the stored browser, which can be | |
136 // used to attach or detach from the stream of browser events | |
137 CComPtr<IConnectionPoint> CPluginClass::GetConnectionPoint() | |
138 { | |
139 CComQIPtr<IConnectionPointContainer, &IID_IConnectionPointContainer> pContaine r(GetBrowser()); | |
140 if (!pContainer) | |
141 { | |
142 return NULL; | |
143 } | |
144 | |
145 CComPtr<IConnectionPoint> pPoint; | |
146 HRESULT hr = pContainer->FindConnectionPoint(DIID_DWebBrowserEvents2, &pPoint) ; | |
147 if (FAILED(hr)) | |
148 { | |
149 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_SET_SITE, PLUGIN_ERROR_SET_SITE_FIND_CONNEC TION_POINT, "Class::GetConnectionPoint - FindConnectionPoint") | |
150 return NULL; | |
151 } | |
152 | |
153 return pPoint; | |
154 } | |
155 | |
156 HWND CPluginClass::GetBrowserHWND() const | 133 HWND CPluginClass::GetBrowserHWND() const |
157 { | 134 { |
158 SHANDLE_PTR hBrowserWndHandle = NULL; | 135 SHANDLE_PTR hBrowserWndHandle = NULL; |
159 | 136 |
160 CComQIPtr<IWebBrowser2> browser = GetBrowser(); | 137 CComQIPtr<IWebBrowser2> browser = GetBrowser(); |
161 if (browser) | 138 if (browser) |
162 { | 139 { |
163 HRESULT hr = browser->get_HWND(&hBrowserWndHandle); | 140 HRESULT hr = browser->get_HWND(&hBrowserWndHandle); |
164 if (FAILED(hr)) | 141 if (FAILED(hr)) |
165 { | 142 { |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
217 } | 194 } |
218 return url; | 195 return url; |
219 } | 196 } |
220 | 197 |
221 DWORD WINAPI CPluginClass::StartInitObject(LPVOID thisPtr) | 198 DWORD WINAPI CPluginClass::StartInitObject(LPVOID thisPtr) |
222 { | 199 { |
223 if (thisPtr == NULL) | 200 if (thisPtr == NULL) |
224 return 0; | 201 return 0; |
225 if (!((CPluginClass*)thisPtr)->InitObject(true)) | 202 if (!((CPluginClass*)thisPtr)->InitObject(true)) |
226 { | 203 { |
227 ((CPluginClass*)thisPtr)->Unadvice(); | 204 ((CPluginClass*)thisPtr)->Unadvise(); |
228 } | 205 } |
229 | 206 |
230 return 0; | 207 return 0; |
231 } | 208 } |
232 | 209 |
233 | |
234 | |
235 // This gets called when a new browser window is created (which also triggers th e | 210 // This gets called when a new browser window is created (which also triggers th e |
236 // creation of this object). The pointer passed in should be to a IWebBrowser2 | 211 // creation of this object). The pointer passed in should be to a IWebBrowser2 |
237 // interface that represents the browser for the window. | 212 // interface that represents the browser for the window. |
238 // it is also called when a tab is closed, this unknownSite will be null | 213 // it is also called when a tab is closed, this unknownSite will be null |
239 // so we should handle that it is called this way several times during a session | 214 // so we should handle that it is called this way several times during a session |
240 STDMETHODIMP CPluginClass::SetSite(IUnknown* unknownSite) | 215 STDMETHODIMP CPluginClass::SetSite(IUnknown* unknownSite) |
241 { | 216 { |
242 CPluginSettings* settings = CPluginSettings::GetInstance(); | 217 CPluginSettings* settings = CPluginSettings::GetInstance(); |
243 | 218 |
244 MULTIPLE_VERSIONS_CHECK(); | 219 MULTIPLE_VERSIONS_CHECK(); |
(...skipping 24 matching lines...) Expand all Loading... | |
269 // Always register on startup, then check if we need to unregister in a se parate thread | 244 // Always register on startup, then check if we need to unregister in a se parate thread |
270 s_mimeFilter = CPluginClientFactory::GetMimeFilterClientInstance(); | 245 s_mimeFilter = CPluginClientFactory::GetMimeFilterClientInstance(); |
271 s_asyncWebBrowser2 = unknownSite; | 246 s_asyncWebBrowser2 = unknownSite; |
272 s_instances.insert(this); | 247 s_instances.insert(this); |
273 } | 248 } |
274 s_criticalSectionLocal.Unlock(); | 249 s_criticalSectionLocal.Unlock(); |
275 | 250 |
276 try | 251 try |
277 { | 252 { |
278 // Check if loaded as BHO | 253 // Check if loaded as BHO |
279 if (GetBrowser()) | 254 auto webBrowser = GetBrowser(); |
255 if (webBrowser) | |
280 { | 256 { |
281 DEBUG_GENERAL("Loaded as BHO"); | 257 DEBUG_GENERAL("Loaded as BHO"); |
282 CComPtr<IConnectionPoint> pPoint = GetConnectionPoint(); | 258 HRESULT hr = DispEventAdvise(webBrowser); |
283 if (pPoint) | 259 if (SUCCEEDED(hr)) |
284 { | 260 { |
285 HRESULT hr = pPoint->Advise((IDispatch*)this, &m_nConnectionID); | 261 m_isAdvised = true; |
286 if (SUCCEEDED(hr)) | 262 try |
287 { | 263 { |
288 m_isAdviced = true; | 264 std::thread startInitObjectThread(StartInitObject, this); |
289 | 265 startInitObjectThread.detach(); // TODO: but actually we should wait for the thread in the dtr. |
290 try | |
291 { | |
292 std::thread startInitObjectThread(StartInitObject, this); | |
293 startInitObjectThread.detach(); // TODO: but actually we should wa it for the thread in the dtr. | |
294 } | |
295 catch (const std::system_error& ex) | |
296 { | |
297 auto errDescription = std::string("Class::Thread - Failed to creat e StartInitObject thread, ") + | |
298 ex.code().message() + ex.what(); | |
299 DEBUG_ERROR_LOG(ex.code().value(), PLUGIN_ERROR_THREAD, PLUGIN_ERR OR_MAIN_THREAD_CREATE_PROCESS, errDescription.c_str()); | |
300 } | |
301 } | 266 } |
302 else | 267 catch (const std::system_error& ex) |
303 { | 268 { |
304 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_SET_SITE, PLUGIN_ERROR_SET_SITE_ADV ICE, "Class::SetSite - Advice"); | 269 auto errDescription = std::string("Class::Thread - Failed to create StartInitObject thread, ") + |
270 ex.code().message() + ex.what(); | |
271 DEBUG_ERROR_LOG(ex.code().value(), PLUGIN_ERROR_THREAD, PLUGIN_ERROR _MAIN_THREAD_CREATE_PROCESS, errDescription.c_str()); | |
305 } | 272 } |
306 } | 273 } |
274 else | |
275 { | |
276 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_SET_SITE, PLUGIN_ERROR_SET_SITE_ADVIC E, "Class::SetSite - Advice"); | |
277 } | |
307 } | 278 } |
308 else // Check if loaded as toolbar handler | 279 else // Check if loaded as toolbar handler |
309 { | 280 { |
310 DEBUG_GENERAL("Loaded as toolbar handler"); | 281 DEBUG_GENERAL("Loaded as toolbar handler"); |
311 CComPtr<IServiceProvider> pServiceProvider; | 282 CComPtr<IServiceProvider> pServiceProvider; |
312 | 283 |
313 HRESULT hr = unknownSite->QueryInterface(&pServiceProvider); | 284 HRESULT hr = unknownSite->QueryInterface(&pServiceProvider); |
314 if (SUCCEEDED(hr)) | 285 if (SUCCEEDED(hr)) |
315 { | 286 { |
316 if (pServiceProvider) | 287 if (pServiceProvider) |
(...skipping 18 matching lines...) Expand all Loading... | |
335 } | 306 } |
336 else | 307 else |
337 { | 308 { |
338 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_SET_SITE, PLUGIN_ERROR_SET_SITE_QUERY _SERVICE_PROVIDER, "Class::SetSite - QueryInterface (service provider)"); | 309 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_SET_SITE, PLUGIN_ERROR_SET_SITE_QUERY _SERVICE_PROVIDER, "Class::SetSite - QueryInterface (service provider)"); |
339 } | 310 } |
340 } | 311 } |
341 } | 312 } |
342 catch (std::runtime_error e) | 313 catch (std::runtime_error e) |
343 { | 314 { |
344 DEBUG_ERROR(e.what()); | 315 DEBUG_ERROR(e.what()); |
345 Unadvice(); | 316 Unadvise(); |
346 } | 317 } |
347 } | 318 } |
348 else | 319 else |
349 { | 320 { |
350 // Unadvice | 321 Unadvise(); |
351 Unadvice(); | |
352 | 322 |
353 // Destroy window | 323 // Destroy window |
354 if (m_pWndProcStatus) | 324 if (m_pWndProcStatus) |
355 { | 325 { |
356 ::SetWindowLongPtr(m_hStatusBarWnd, GWLP_WNDPROC, (LPARAM)(WNDPROC)m_pWndP rocStatus); | 326 ::SetWindowLongPtr(m_hStatusBarWnd, GWLP_WNDPROC, (LPARAM)(WNDPROC)m_pWndP rocStatus); |
357 | 327 |
358 m_pWndProcStatus = NULL; | 328 m_pWndProcStatus = NULL; |
359 } | 329 } |
360 | 330 |
361 if (m_hPaneWnd) | 331 if (m_hPaneWnd) |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
509 } | 479 } |
510 } | 480 } |
511 else | 481 else |
512 { | 482 { |
513 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_UI, PLUGIN_ERROR_UI_GET_STATUSBAR, "Class ::Get statusbar state"); | 483 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_UI, PLUGIN_ERROR_UI_GET_STATUSBAR, "Class ::Get statusbar state"); |
514 } | 484 } |
515 } | 485 } |
516 DEBUG_GENERAL("ShowStatusBar end"); | 486 DEBUG_GENERAL("ShowStatusBar end"); |
517 } | 487 } |
518 | 488 |
519 /* | 489 // Entry point |
520 * #1163 This class is the implementation for method DISPID_BEFORENAVIGATE2 in C PluginClass::Invoke. | 490 void STDMETHODCALLTYPE CPluginClass::OnBeforeNavigate2( |
521 * - It validates and convertes its own arguments, rather than unifying them in the Invoke body. | 491 /* [in] */ IDispatch* frameBrowserDisp, |
Oleksandr
2015/03/12 05:10:57
Since we do have Doxygen set up, how about using
/
Oleksandr
2015/03/13 16:42:03
So how about this comment?
sergei
2015/03/13 17:03:14
I've tested it, neither /* [in] */ nor /**< [in] *
| |
522 * - It's declared void and not HRESULT, so DISPID_BEFORENAVIGATE2 can only retu rn S_OK. | 492 /* [in] */ VARIANT* urlVariant, |
523 */ | 493 /* [in] */ VARIANT* /*Flags*/, |
524 void CPluginClass::BeforeNavigate2(DISPPARAMS* pDispParams) | 494 /* [in] */ VARIANT* /*TargetFrameName*/, |
525 { | 495 /* [in] */ VARIANT* /*PostData*/, |
526 | 496 /* [in] */ VARIANT* /*Headers*/, |
527 if (pDispParams->cArgs < 7) | 497 /* [in, out] */ VARIANT_BOOL* /*Cancel*/) |
528 { | 498 { |
529 return; | 499 try |
530 } | 500 { |
531 //Register a mime filter if it's not registered yet | 501 ATL::CComQIPtr<IWebBrowser2> webBrowser = frameBrowserDisp; |
532 if (s_mimeFilter == NULL) | 502 if (!webBrowser) |
533 { | 503 { |
534 s_mimeFilter = CPluginClientFactory::GetMimeFilterClientInstance(); | 504 return; |
535 } | 505 } |
536 | 506 |
537 // Get the IWebBrowser2 interface | 507 if (!urlVariant || urlVariant->vt != VT_BSTR) |
538 CComQIPtr<IWebBrowser2, &IID_IWebBrowser2> WebBrowser2Ptr; | 508 { |
539 VARTYPE vt = pDispParams->rgvarg[6].vt; | 509 return; |
540 if (vt == VT_DISPATCH) | 510 } |
541 { | 511 std::wstring url(urlVariant->bstrVal, SysStringLen(urlVariant->bstrVal)); |
542 WebBrowser2Ptr = pDispParams->rgvarg[6].pdispVal; | 512 UnescapeUrl(url); |
543 } | 513 |
544 else | 514 //Register a mime filter if it's not registered yet |
545 { | 515 if (s_mimeFilter == nullptr) |
546 // Wrong type, return. | 516 { |
547 return; | 517 s_mimeFilter = CPluginClientFactory::GetMimeFilterClientInstance(); |
548 } | 518 } |
549 | 519 |
550 // Get the URL | 520 // If webbrowser2 is equal to top level browser (as set in SetSite), we are navigating new page |
551 std::wstring url; | 521 CPluginClient* client = CPluginClient::GetInstance(); |
552 const auto& arg = pDispParams->rgvarg[5]; | 522 |
553 vt = arg.vt; | 523 if (url.find(L"javascript") == 0) |
554 if (vt == (VT_BYREF | VT_VARIANT) && arg.pvarVal->vt == VT_BSTR) | 524 { |
555 { | 525 } |
556 BSTR b = arg.pvarVal->bstrVal; | 526 else if (GetBrowser().IsEqualObject(webBrowser)) |
557 if (b) { | 527 { |
558 url = std::wstring(b, SysStringLen(b)); | 528 m_tab->OnNavigate(url); |
559 UnescapeUrl(url); | 529 CString urlLegacy = ToCString(url); |
560 } | 530 DEBUG_GENERAL(L"========================================================== ======================\nBegin main navigation url:" + urlLegacy + "\n=========== =====================================================================") |
561 } | 531 #ifdef ENABLE_DEBUG_RESULT |
562 else | |
563 { | |
564 // Wrong type, return. | |
565 return; | |
566 } | |
567 | |
568 // If webbrowser2 is equal to top level browser (as set in SetSite), we are na vigating new page | |
569 CPluginClient* client = CPluginClient::GetInstance(); | |
570 CString urlLegacy = ToCString(url); | |
571 if (urlLegacy.Find(L"javascript") == 0) | |
572 { | |
573 } | |
574 else if (GetBrowser().IsEqualObject(WebBrowser2Ptr)) | |
575 { | |
576 m_tab->OnNavigate(url); | |
577 | |
578 DEBUG_GENERAL(L"============================================================ ====================\nBegin main navigation url:" + urlLegacy + "\n============= ===================================================================") | |
579 | |
580 #ifdef ENABLE_DEBUG_RESULT | |
581 CPluginDebug::DebugResultDomain(urlLegacy); | 532 CPluginDebug::DebugResultDomain(urlLegacy); |
582 #endif | 533 #endif |
583 | 534 UpdateStatusBar(); |
584 UpdateStatusBar(); | 535 } |
585 } | 536 else |
586 else | 537 { |
587 { | 538 DEBUG_NAVI(L"Navi::Begin navigation url:" + ToCString(url)) |
588 DEBUG_NAVI(L"Navi::Begin navigation url:" + urlLegacy) | 539 m_tab->CacheFrame(url); |
589 m_tab->CacheFrame(url); | 540 } |
590 } | 541 } |
591 } | 542 catch (...) |
592 | 543 { |
593 /* | 544 } |
594 * #1163 implements behavior for method DISPID_WINDOWSTATECHANGED in CPluginClas s::Invoke | 545 } |
595 * - should validate and convert arguments in Invoke, not here | 546 |
596 * - does not validate number of arguments before indexing into 'rgvarg' | 547 // Entry point |
597 * - does not validate type of argument before using its value | 548 void STDMETHODCALLTYPE CPluginClass::OnDownloadComplete() |
598 */ | |
599 STDMETHODIMP CPluginClass::OnTabChanged(DISPPARAMS* pDispParams, WORD wFlags) | |
600 { | |
601 DEBUG_GENERAL("Tab changed"); | |
602 bool newtabshown = pDispParams->rgvarg[1].intVal==3; | |
603 if (newtabshown) | |
604 { | |
605 std::map<DWORD,CPluginClass*>::const_iterator it = s_threadInstances.find(Ge tCurrentThreadId()); | |
606 if (it == s_threadInstances.end()) | |
607 { | |
608 s_threadInstances[::GetCurrentThreadId()] = this; | |
609 if (!m_isInitializedOk) | |
610 { | |
611 m_isInitializedOk = true; | |
612 InitObject(true); | |
613 UpdateStatusBar(); | |
614 } | |
615 } | |
616 } | |
617 notificationMessage.Hide(); | |
618 DEBUG_GENERAL("Tab change end"); | |
619 return S_OK; | |
620 } | |
621 | |
622 // This gets called whenever there's a browser event | |
623 // ENTRY POINT | |
624 STDMETHODIMP CPluginClass::Invoke(DISPID dispidMember, REFIID riid, LCID lcid, W ORD wFlags, DISPPARAMS* pDispParams, VARIANT* pvarResult, EXCEPINFO* pExcepInfo, UINT* puArgErr) | |
625 { | 549 { |
626 try | 550 try |
627 { | 551 { |
628 WCHAR tmp[256]; | 552 DEBUG_NAVI("Navi::Download Complete") |
629 wsprintf(tmp, L"Invoke: %d\n", dispidMember); | 553 ATL::CComPtr<IWebBrowser2> browser = GetBrowser(); |
630 DEBUG_GENERAL(tmp); | 554 if (browser) |
Eric
2015/03/12 22:43:14
FYI. Some of the individual event-handling functio
| |
631 switch (dispidMember) | 555 { |
632 { | 556 m_tab->OnDownloadComplete(browser); |
633 case DISPID_WINDOWSTATECHANGED: | 557 } |
634 { | 558 } |
635 // #1163 should validate and convert arguments here | 559 catch (...) |
636 return OnTabChanged(pDispParams, wFlags); | 560 { |
637 } | 561 } |
638 | 562 } |
639 case DISPID_HTMLDOCUMENTEVENTS2_ONBEFOREUPDATE: | 563 |
640 break; | 564 // Entry point |
641 | 565 void STDMETHODCALLTYPE CPluginClass::OnDocumentComplete(IDispatch* frameBrowserD isp, VARIANT* /*urlOrPidl*/) |
642 case DISPID_HTMLDOCUMENTEVENTS2_ONCLICK: | 566 { |
643 break; | 567 try |
644 | 568 { |
645 case DISPID_EVMETH_ONLOAD: | 569 ATL::CComQIPtr<IWebBrowser2> webBrowser2 = frameBrowserDisp; |
646 DEBUG_NAVI("Navi::OnLoad") | 570 if (!webBrowser2) |
647 break; | 571 { |
648 | 572 return; |
649 case DISPID_EVMETH_ONCHANGE: | 573 } |
650 break; | 574 std::wstring frameSrc = GetLocationUrl(*webBrowser2); |
651 | 575 UnescapeUrl(frameSrc); |
652 case DISPID_EVMETH_ONMOUSEDOWN: | 576 bool isRootPageBrowser = GetBrowser().IsEqualObject(webBrowser2); |
653 break; | 577 m_tab->OnDocumentComplete(webBrowser2, frameSrc, isRootPageBrowser); |
654 | 578 } |
655 case DISPID_EVMETH_ONMOUSEENTER: | 579 catch (...) |
656 break; | 580 { |
657 | 581 } |
658 case DISPID_IHTMLIMGELEMENT_START: | 582 } |
659 break; | 583 |
660 | 584 // Entry point |
661 case STDDISPID_XOBJ_ERRORUPDATE: | 585 void STDMETHODCALLTYPE CPluginClass::OnWindowStateChanged(unsigned long flags, u nsigned long validFlagsMask) |
662 break; | 586 { |
663 | 587 try |
664 case STDDISPID_XOBJ_ONPROPERTYCHANGE: | 588 { |
665 break; | 589 DEBUG_GENERAL("WindowStateChanged (check tab changed)"); |
666 | 590 bool newtabshown = validFlagsMask == (OLECMDIDF_WINDOWSTATE_USERVISIBLE | OL ECMDIDF_WINDOWSTATE_ENABLED) |
667 case DISPID_READYSTATECHANGE: | 591 && flags == (OLECMDIDF_WINDOWSTATE_USERVISIBLE | OLECMDIDF_W INDOWSTATE_ENABLED); |
668 DEBUG_NAVI("Navi::ReadyStateChange"); | 592 if (newtabshown) |
669 break; | 593 { |
670 | 594 std::map<DWORD,CPluginClass*>::const_iterator it = s_threadInstances.find( GetCurrentThreadId()); |
671 case DISPID_BEFORENAVIGATE: | 595 if (it == s_threadInstances.end()) |
672 DEBUG_NAVI("Navi::BeforeNavigate"); | 596 { |
673 break; | 597 s_threadInstances[::GetCurrentThreadId()] = this; |
674 | 598 if (!m_isInitializedOk) |
675 case DISPID_COMMANDSTATECHANGE: | 599 { |
676 if (m_hPaneWnd == NULL) | 600 m_isInitializedOk = true; |
677 { | 601 InitObject(true); |
678 CreateStatusBarPane(); | 602 UpdateStatusBar(); |
679 } | 603 } |
680 else | 604 } |
681 { | 605 } |
606 notificationMessage.Hide(); | |
607 DEBUG_GENERAL("WindowStateChanged (check tab changed) end"); | |
608 } | |
609 catch (...) | |
610 { | |
611 } | |
612 } | |
613 | |
614 // Entry point | |
615 void STDMETHODCALLTYPE CPluginClass::OnCommandStateChange(long /*command*/, VARI ANT_BOOL /*enable*/) | |
616 { | |
617 try | |
618 { | |
619 if (m_hPaneWnd == NULL) | |
620 { | |
621 CreateStatusBarPane(); | |
622 } | |
623 else | |
624 { | |
682 if (AdblockPlus::IE::InstalledMajorVersion() > 6) | 625 if (AdblockPlus::IE::InstalledMajorVersion() > 6) |
683 { | 626 { |
684 RECT rect; | 627 RECT rect; |
685 BOOL rectRes = GetClientRect(m_hStatusBarWnd, &rect); | 628 BOOL rectRes = GetClientRect(m_hStatusBarWnd, &rect); |
686 if (rectRes == TRUE) | 629 if (rectRes == TRUE) |
687 { | 630 { |
688 MoveWindow(m_hPaneWnd, rect.right - 200, 0, m_nPaneWidth, rect.botto m - rect.top, TRUE); | 631 MoveWindow(m_hPaneWnd, rect.right - 200, 0, m_nPaneWidth, rect.bottom - rect.top, TRUE); |
689 } | 632 } |
690 } | 633 } |
691 } | 634 } |
692 break; | 635 } |
693 | 636 catch (...) |
694 case DISPID_STATUSTEXTCHANGE: | 637 { |
695 break; | 638 } |
696 | |
697 case DISPID_BEFORENAVIGATE2: | |
698 { | |
699 // #1163 should validate and convert parameters here | |
700 BeforeNavigate2(pDispParams); | |
701 } | |
702 break; | |
703 | |
704 case DISPID_DOWNLOADBEGIN: | |
705 { | |
706 DEBUG_NAVI("Navi::Download Begin") | |
707 } | |
708 break; | |
709 | |
710 case DISPID_DOWNLOADCOMPLETE: | |
711 { | |
712 DEBUG_NAVI("Navi::Download Complete"); | |
713 CComQIPtr<IWebBrowser2> browser = GetBrowser(); | |
714 if (browser) | |
715 { | |
716 m_tab->OnDownloadComplete(browser); | |
717 } | |
718 } | |
719 break; | |
720 | |
721 case DISPID_DOCUMENTCOMPLETE: | |
722 { | |
723 DEBUG_NAVI("Navi::Document Complete"); | |
724 CComQIPtr<IWebBrowser2> browser = GetBrowser(); | |
725 if (browser && pDispParams->cArgs >= 2 && pDispParams->rgvarg[1].vt == V T_DISPATCH) | |
726 { | |
727 CComQIPtr<IWebBrowser2> pBrowser = pDispParams->rgvarg[1].pdispVal; | |
728 if (pBrowser) | |
729 { | |
730 CComBSTR bstrUrl; | |
731 if (SUCCEEDED(pBrowser->get_LocationURL(&bstrUrl)) && bstrUrl && ::S ysStringLen(bstrUrl) > 0) | |
732 { | |
733 std::wstring url = std::wstring(bstrUrl, SysStringLen(bstrUrl)); | |
734 UnescapeUrl(url); | |
735 m_tab->OnDocumentComplete(browser, url, browser.IsEqualObject(pBro wser)); | |
736 } | |
737 } | |
738 } | |
739 } | |
740 break; | |
741 | |
742 case DISPID_ONQUIT: | |
743 case DISPID_QUIT: | |
744 { | |
745 Unadvice(); | |
746 } | |
747 break; | |
748 | |
749 default: | |
750 { | |
751 CString did; | |
752 did.Format(L"DispId:%u", dispidMember); | |
753 | |
754 DEBUG_NAVI(L"Navi::Default " + did) | |
755 } | |
756 /* | |
757 * Ordinarily a method not dispatched should return DISP_E_MEMBERNOTFOUND. | |
758 * As a conservative initial change, we leave it behaving as before, | |
759 * which is to do nothing and return S_OK. | |
760 */ | |
761 // do nothing | |
762 break; | |
763 } | |
764 } | |
765 catch(...) | |
766 { | |
767 DEBUG_GENERAL( "Caught unknown exception in CPluginClass::Invoke" ); | |
768 return E_FAIL; | |
769 } | |
770 return S_OK; | |
771 } | 639 } |
772 | 640 |
773 bool CPluginClass::InitObject(bool bBHO) | 641 bool CPluginClass::InitObject(bool bBHO) |
774 { | 642 { |
775 DEBUG_GENERAL("InitObject"); | 643 DEBUG_GENERAL("InitObject"); |
776 CPluginSettings* settings = CPluginSettings::GetInstance(); | 644 CPluginSettings* settings = CPluginSettings::GetInstance(); |
777 | 645 |
778 if (!settings->GetPluginEnabled()) | 646 if (!settings->GetPluginEnabled()) |
779 { | 647 { |
780 s_mimeFilter->Unregister(); | 648 s_mimeFilter->Unregister(); |
(...skipping 970 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1751 if (m_hPaneWnd == NULL) | 1619 if (m_hPaneWnd == NULL) |
1752 { | 1620 { |
1753 CreateStatusBarPane(); | 1621 CreateStatusBarPane(); |
1754 } | 1622 } |
1755 if ((m_hPaneWnd != NULL) && !::InvalidateRect(m_hPaneWnd, NULL, FALSE)) | 1623 if ((m_hPaneWnd != NULL) && !::InvalidateRect(m_hPaneWnd, NULL, FALSE)) |
1756 { | 1624 { |
1757 DEBUG_ERROR_LOG(::GetLastError(), PLUGIN_ERROR_UI, PLUGIN_ERROR_UI_INVALID ATE_STATUSBAR, "Class::Invalidate statusbar"); | 1625 DEBUG_ERROR_LOG(::GetLastError(), PLUGIN_ERROR_UI, PLUGIN_ERROR_UI_INVALID ATE_STATUSBAR, "Class::Invalidate statusbar"); |
1758 } | 1626 } |
1759 } | 1627 } |
1760 | 1628 |
1761 | 1629 // Entry point |
1762 void CPluginClass::Unadvice() | 1630 void STDMETHODCALLTYPE CPluginClass::OnOnQuit() |
1631 { | |
1632 try | |
1633 { | |
1634 Unadvise(); | |
1635 } | |
1636 catch (...) | |
1637 { | |
1638 } | |
1639 } | |
1640 | |
1641 void CPluginClass::Unadvise() | |
1763 { | 1642 { |
1764 s_criticalSectionLocal.Lock(); | 1643 s_criticalSectionLocal.Lock(); |
1765 { | 1644 { |
1766 if (m_isAdviced) | 1645 if (m_isAdvised) |
1767 { | 1646 { |
1768 CComPtr<IConnectionPoint> pPoint = GetConnectionPoint(); | 1647 HRESULT hr = DispEventUnadvise(GetBrowser()); |
1769 if (pPoint) | 1648 if (FAILED(hr)) |
1770 { | 1649 { |
1771 HRESULT hr = pPoint->Unadvise(m_nConnectionID); | 1650 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_SET_SITE, PLUGIN_ERROR_SET_SITE_UNADVIS E, "Class::Unadvise - Unadvise"); |
1772 if (FAILED(hr)) | 1651 } |
1773 { | 1652 m_isAdvised = false; |
1774 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_SET_SITE, PLUGIN_ERROR_SET_SITE_UNADV ICE, "Class::Unadvice - Unadvise"); | |
1775 } | |
1776 } | |
1777 | |
1778 m_isAdviced = false; | |
1779 } | 1653 } |
1780 } | 1654 } |
1781 s_criticalSectionLocal.Unlock(); | 1655 s_criticalSectionLocal.Unlock(); |
1782 } | 1656 } |
1783 | 1657 |
1784 HICON CPluginClass::GetIcon(int type) | 1658 HICON CPluginClass::GetIcon(int type) |
1785 { | 1659 { |
1786 HICON icon = NULL; | 1660 HICON icon = NULL; |
1787 | 1661 |
1788 s_criticalSectionLocal.Lock(); | 1662 s_criticalSectionLocal.Lock(); |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1866 break; | 1740 break; |
1867 } | 1741 } |
1868 s_criticalSectionLocal.Unlock(); | 1742 s_criticalSectionLocal.Unlock(); |
1869 | 1743 |
1870 } | 1744 } |
1871 } | 1745 } |
1872 } | 1746 } |
1873 | 1747 |
1874 hTabWnd = ::GetWindow(hTabWnd, GW_HWNDNEXT); | 1748 hTabWnd = ::GetWindow(hTabWnd, GW_HWNDNEXT); |
1875 } | 1749 } |
1876 | |
1877 return hTabWnd; | 1750 return hTabWnd; |
1878 | 1751 } |
1879 } | |
OLD | NEW |