| 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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 } | 83 } |
| 84 | 84 |
| 85 int Width() const | 85 int Width() const |
| 86 { | 86 { |
| 87 return right - left; | 87 return right - left; |
| 88 } | 88 } |
| 89 }; | 89 }; |
| 90 } | 90 } |
| 91 | 91 |
| 92 CPluginClass::CPluginClass() | 92 CPluginClass::CPluginClass() |
| 93 : m_webBrowser2(nullptr) | 93 : m_webBrowser2(nullptr), |
| 94 detachedInitializationFailed(false) |
| 94 { | 95 { |
| 95 //Use this line to debug memory leaks | 96 //Use this line to debug memory leaks |
| 96 // _CrtDumpMemoryLeaks(); | 97 // _CrtDumpMemoryLeaks(); |
| 97 | 98 |
| 98 m_isAdvised = false; | |
| 99 m_hTabWnd = NULL; | 99 m_hTabWnd = NULL; |
| 100 m_hStatusBarWnd = NULL; | 100 m_hStatusBarWnd = NULL; |
| 101 m_hPaneWnd = NULL; | 101 m_hPaneWnd = NULL; |
| 102 m_nPaneWidth = 0; | 102 m_nPaneWidth = 0; |
| 103 m_pWndProcStatus = NULL; | 103 m_pWndProcStatus = NULL; |
| 104 m_hTheme = NULL; | 104 m_hTheme = NULL; |
| 105 m_isInitializedOk = false; | 105 m_isInitializedOk = false; |
| 106 | 106 |
| 107 | 107 |
| 108 m_tab = new CPluginTab(this); | 108 m_tab = new CPluginTab(this); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 DEBUG_ERROR_LOG(0, 0, 0, "CPluginClass::GetBrowserUrl - Reached with m_webBr
owser2 == nullptr"); | 166 DEBUG_ERROR_LOG(0, 0, 0, "CPluginClass::GetBrowserUrl - Reached with m_webBr
owser2 == nullptr"); |
| 167 url = m_tab->GetDocumentUrl(); | 167 url = m_tab->GetDocumentUrl(); |
| 168 } | 168 } |
| 169 return url; | 169 return url; |
| 170 } | 170 } |
| 171 | 171 |
| 172 DWORD WINAPI CPluginClass::StartInitObject(LPVOID thisPtr) | 172 DWORD WINAPI CPluginClass::StartInitObject(LPVOID thisPtr) |
| 173 { | 173 { |
| 174 if (thisPtr == NULL) | 174 if (thisPtr == NULL) |
| 175 return 0; | 175 return 0; |
| 176 if (!((CPluginClass*)thisPtr)->InitObject()) | 176 auto self = static_cast<CPluginClass*>(thisPtr); |
| 177 if (!self->InitObject()) |
| 177 { | 178 { |
| 178 ((CPluginClass*)thisPtr)->Unadvise(); | 179 self->detachedInitializationFailed = true; |
| 179 } | 180 } |
| 180 | |
| 181 return 0; | 181 return 0; |
| 182 } | 182 } |
| 183 | 183 |
| 184 /* | 184 /* |
| 185 * IE calls this when it creates a new browser window or tab, immediately after
it also | 185 * IE calls this when it creates a new browser window or tab, immediately after
it also |
| 186 * creates the object. The argument 'unknownSite' in is the OLE "site" of the ob
ject, | 186 * creates the object. The argument 'unknownSite' in is the OLE "site" of the ob
ject, |
| 187 * which is an IWebBrowser2 interface associated with the window/tab. | 187 * which is an IWebBrowser2 interface associated with the window/tab. |
| 188 * | 188 * |
| 189 * IE also ordinarily calls this again when its window/tab is closed, in which c
ase | 189 * IE also ordinarily calls this again when its window/tab is closed, in which c
ase |
| 190 * 'unknownSite' will be null. Extraordinarily, this is sometimes _not_ called w
hen IE | 190 * 'unknownSite' will be null. Extraordinarily, this is sometimes _not_ called w
hen IE |
| 191 * is shutting down. Thus 'SetSite(nullptr)' has some similarities with a destru
ctor, | 191 * is shutting down. Thus 'SetSite(nullptr)' has some similarities with a destru
ctor, |
| 192 * but it is not a proper substitute for one. | 192 * but it is not a proper substitute for one. |
| 193 */ | 193 */ |
| 194 STDMETHODIMP CPluginClass::SetSite(IUnknown* unknownSite) | 194 STDMETHODIMP CPluginClass::SetSite(IUnknown* unknownSite) |
| 195 { | 195 { |
| 196 try | 196 try |
| 197 { | 197 { |
| 198 if (unknownSite) | 198 if (unknownSite) |
| 199 { | 199 { |
| 200 | 200 |
| 201 DEBUG_GENERAL(L"==========================================================
======================\nNEW TAB UI\n============================================
====================================") | 201 DEBUG_GENERAL(L"==========================================================
======================\nNEW TAB UI\n============================================
====================================") |
| 202 | 202 |
| 203 HRESULT hr = ::CoInitialize(NULL); | 203 HRESULT hr = ::CoInitialize(NULL); |
| 204 if (FAILED(hr)) | 204 if (FAILED(hr)) |
| 205 { | 205 { |
| 206 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_SET_SITE, PLUGIN_ERROR_SET_SITE_COINIT,
"Class::SetSite - CoInitialize"); | 206 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_SET_SITE, PLUGIN_ERROR_SET_SITE_COINIT,
"Class::SetSite - CoInitialize"); |
| 207 } | 207 } |
| 208 | |
| 209 /* | 208 /* |
| 210 * We were instantiated as a BHO, so our site is always of type IWebBrowse
r2. | 209 * We were instantiated as a BHO, so our site is always of type IWebBrowse
r2. |
| 211 */ | 210 */ |
| 212 m_webBrowser2 = ATL::CComQIPtr<IWebBrowser2>(unknownSite); | 211 m_webBrowser2 = ATL::CComQIPtr<IWebBrowser2>(unknownSite); |
| 213 if (!m_webBrowser2) | 212 if (!m_webBrowser2) |
| 214 { | 213 { |
| 215 throw std::logic_error("CPluginClass::SetSite - Unable to convert site p
ointer to IWebBrowser2*"); | 214 throw std::logic_error("CPluginClass::SetSite - Unable to convert site p
ointer to IWebBrowser2*"); |
| 216 } | 215 } |
| 217 | 216 |
| 218 //register the mimefilter | 217 //register the mimefilter |
| 219 //and only mimefilter | 218 //and only mimefilter |
| 220 //on some few computers the mimefilter does not get properly registered wh
en it is done on another thread | 219 //on some few computers the mimefilter does not get properly registered wh
en it is done on another thread |
| 221 s_criticalSectionLocal.Lock(); | 220 s_criticalSectionLocal.Lock(); |
| 222 { | 221 { |
| 223 // Always register on startup, then check if we need to unregister in a
separate thread | 222 // Always register on startup, then check if we need to unregister in a
separate thread |
| 224 s_mimeFilter = CPluginClientFactory::GetMimeFilterClientInstance(); | 223 s_mimeFilter = CPluginClientFactory::GetMimeFilterClientInstance(); |
| 225 s_asyncWebBrowser2 = unknownSite; | 224 s_asyncWebBrowser2 = unknownSite; |
| 226 s_instances.insert(this); | 225 s_instances.insert(this); |
| 227 } | 226 } |
| 228 s_criticalSectionLocal.Unlock(); | 227 s_criticalSectionLocal.Unlock(); |
| 229 | 228 |
| 229 DEBUG_GENERAL("Loaded as BHO"); |
| 230 try | 230 try |
| 231 { | 231 { |
| 232 DEBUG_GENERAL("Loaded as BHO"); | 232 std::thread startInitObjectThread(StartInitObject, this); |
| 233 HRESULT hr = DispEventAdvise(m_webBrowser2); | 233 startInitObjectThread.detach(); // TODO: but actually we should wait for
the thread in the dtr. |
| 234 if (SUCCEEDED(hr)) | |
| 235 { | |
| 236 m_isAdvised = true; | |
| 237 try | |
| 238 { | |
| 239 std::thread startInitObjectThread(StartInitObject, this); | |
| 240 startInitObjectThread.detach(); // TODO: but actually we should wait
for the thread in the dtr. | |
| 241 } | |
| 242 catch (const std::system_error& ex) | |
| 243 { | |
| 244 DEBUG_SYSTEM_EXCEPTION(ex, PLUGIN_ERROR_THREAD, PLUGIN_ERROR_MAIN_TH
READ_CREATE_PROCESS, | |
| 245 "Class::Thread - Failed to create StartInitObject thread"); | |
| 246 } | |
| 247 } | |
| 248 else | |
| 249 { | |
| 250 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_SET_SITE, PLUGIN_ERROR_SET_SITE_ADVIC
E, "Class::SetSite - Advise"); | |
| 251 } | |
| 252 } | 234 } |
| 253 catch (const std::runtime_error& ex) | 235 catch (const std::system_error& ex) |
| 254 { | 236 { |
| 255 DEBUG_EXCEPTION(ex); | 237 detachedInitializationFailed = true; |
| 256 Unadvise(); | 238 DEBUG_SYSTEM_EXCEPTION(ex, PLUGIN_ERROR_THREAD, PLUGIN_ERROR_MAIN_THREAD
_CREATE_PROCESS, |
| 239 "Class::Thread - Failed to create StartInitObject thread"); |
| 257 } | 240 } |
| 241 |
| 242 // Start event last, after everything is ready to go |
| 243 browserEvents.Start(this, m_webBrowser2); |
| 258 } | 244 } |
| 259 else | 245 else |
| 260 { | 246 { |
| 261 Unadvise(); | 247 browserEvents.Stop(); |
| 262 | 248 |
| 263 // Destroy window | 249 // Destroy window |
| 264 if (m_pWndProcStatus) | 250 if (m_pWndProcStatus) |
| 265 { | 251 { |
| 266 ::SetWindowLongPtr(m_hStatusBarWnd, GWLP_WNDPROC, (LPARAM)(WNDPROC)m_pWn
dProcStatus); | 252 ::SetWindowLongPtr(m_hStatusBarWnd, GWLP_WNDPROC, (LPARAM)(WNDPROC)m_pWn
dProcStatus); |
| 267 | 253 |
| 268 m_pWndProcStatus = NULL; | 254 m_pWndProcStatus = NULL; |
| 269 } | 255 } |
| 270 | 256 |
| 271 if (m_hPaneWnd) | 257 if (m_hPaneWnd) |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 431 IDispatch* frameBrowserDisp /**< [in] */, | 417 IDispatch* frameBrowserDisp /**< [in] */, |
| 432 VARIANT* urlVariant /**< [in] */, | 418 VARIANT* urlVariant /**< [in] */, |
| 433 VARIANT* /**< [in] Flags*/, | 419 VARIANT* /**< [in] Flags*/, |
| 434 VARIANT* /**< [in] TargetFrameName*/, | 420 VARIANT* /**< [in] TargetFrameName*/, |
| 435 VARIANT* /**< [in] PostData*/, | 421 VARIANT* /**< [in] PostData*/, |
| 436 VARIANT* /**< [in] Headers*/, | 422 VARIANT* /**< [in] Headers*/, |
| 437 VARIANT_BOOL* /**< [in, out] Cancel*/) | 423 VARIANT_BOOL* /**< [in, out] Cancel*/) |
| 438 { | 424 { |
| 439 try | 425 try |
| 440 { | 426 { |
| 427 if (detachedInitializationFailed) return; |
| 428 |
| 441 ATL::CComQIPtr<IWebBrowser2> webBrowser = frameBrowserDisp; | 429 ATL::CComQIPtr<IWebBrowser2> webBrowser = frameBrowserDisp; |
| 442 if (!webBrowser) | 430 if (!webBrowser) |
| 443 { | 431 { |
| 444 return; | 432 return; |
| 445 } | 433 } |
| 446 if (!urlVariant || urlVariant->vt != VT_BSTR) | 434 if (!urlVariant || urlVariant->vt != VT_BSTR) |
| 447 { | 435 { |
| 448 return; | 436 return; |
| 449 } | 437 } |
| 450 std::wstring url(urlVariant->bstrVal, SysStringLen(urlVariant->bstrVal)); | 438 std::wstring url(urlVariant->bstrVal, SysStringLen(urlVariant->bstrVal)); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 475 } | 463 } |
| 476 } | 464 } |
| 477 catch (...) | 465 catch (...) |
| 478 { | 466 { |
| 479 } | 467 } |
| 480 } | 468 } |
| 481 | 469 |
| 482 // Entry point | 470 // Entry point |
| 483 void STDMETHODCALLTYPE CPluginClass::OnDownloadComplete() | 471 void STDMETHODCALLTYPE CPluginClass::OnDownloadComplete() |
| 484 { | 472 { |
| 473 if (detachedInitializationFailed) return; |
| 485 try | 474 try |
| 486 { | 475 { |
| 487 if (!m_webBrowser2) | 476 if (!m_webBrowser2) |
| 488 { | 477 { |
| 489 DEBUG_ERROR_LOG(0, 0, 0, "CPluginClass::OnDownloadComplete - Reached with
m_webBrowser2 == nullptr"); | 478 DEBUG_ERROR_LOG(0, 0, 0, "CPluginClass::OnDownloadComplete - Reached with
m_webBrowser2 == nullptr"); |
| 490 return; | 479 return; |
| 491 } | 480 } |
| 492 DEBUG_NAVI(L"Navi::Download Complete") | 481 DEBUG_NAVI(L"Navi::Download Complete") |
| 493 m_tab->OnDownloadComplete(m_webBrowser2); | 482 m_tab->OnDownloadComplete(m_webBrowser2); |
| 494 } | 483 } |
| 495 catch (...) | 484 catch (...) |
| 496 { | 485 { |
| 497 } | 486 } |
| 498 } | 487 } |
| 499 | 488 |
| 500 // Entry point | 489 // Entry point |
| 501 void STDMETHODCALLTYPE CPluginClass::OnDocumentComplete(IDispatch* frameBrowserD
isp, VARIANT* /*urlOrPidl*/) | 490 void STDMETHODCALLTYPE CPluginClass::OnDocumentComplete(IDispatch* frameBrowserD
isp, VARIANT* /*urlOrPidl*/) |
| 502 { | 491 { |
| 492 if (detachedInitializationFailed) return; |
| 503 try | 493 try |
| 504 { | 494 { |
| 505 DEBUG_NAVI(L"Navi::Document Complete"); | 495 DEBUG_NAVI(L"Navi::Document Complete"); |
| 506 ATL::CComQIPtr<IWebBrowser2> webBrowser2 = frameBrowserDisp; | 496 ATL::CComQIPtr<IWebBrowser2> webBrowser2 = frameBrowserDisp; |
| 507 if (!webBrowser2) | 497 if (!webBrowser2) |
| 508 { | 498 { |
| 509 return; | 499 return; |
| 510 } | 500 } |
| 511 std::wstring frameSrc = GetLocationUrl(*webBrowser2); | 501 std::wstring frameSrc = GetLocationUrl(*webBrowser2); |
| 512 m_tab->OnDocumentComplete(webBrowser2, frameSrc, IsRootBrowser(webBrowser2))
; | 502 m_tab->OnDocumentComplete(webBrowser2, frameSrc, IsRootBrowser(webBrowser2))
; |
| 513 } | 503 } |
| 514 catch (...) | 504 catch (...) |
| 515 { | 505 { |
| 516 } | 506 } |
| 517 } | 507 } |
| 518 | 508 |
| 519 // Entry point | 509 // Entry point |
| 520 void STDMETHODCALLTYPE CPluginClass::OnWindowStateChanged(unsigned long flags, u
nsigned long validFlagsMask) | 510 void STDMETHODCALLTYPE CPluginClass::OnWindowStateChanged(unsigned long flags, u
nsigned long validFlagsMask) |
| 521 { | 511 { |
| 512 if (detachedInitializationFailed) return; |
| 522 try | 513 try |
| 523 { | 514 { |
| 524 DEBUG_GENERAL(L"WindowStateChanged (check tab changed)"); | 515 DEBUG_GENERAL(L"WindowStateChanged (check tab changed)"); |
| 525 bool newtabshown = validFlagsMask == (OLECMDIDF_WINDOWSTATE_USERVISIBLE | OL
ECMDIDF_WINDOWSTATE_ENABLED) | 516 bool newtabshown = validFlagsMask == (OLECMDIDF_WINDOWSTATE_USERVISIBLE | OL
ECMDIDF_WINDOWSTATE_ENABLED) |
| 526 && flags == (OLECMDIDF_WINDOWSTATE_USERVISIBLE | OLECMDIDF_WINDOWSTATE_ENA
BLED); | 517 && flags == (OLECMDIDF_WINDOWSTATE_USERVISIBLE | OLECMDIDF_WINDOWSTATE_ENA
BLED); |
| 527 if (newtabshown) | 518 if (newtabshown) |
| 528 { | 519 { |
| 529 std::map<DWORD,CPluginClass*>::const_iterator it = s_threadInstances.find(
GetCurrentThreadId()); | 520 std::map<DWORD,CPluginClass*>::const_iterator it = s_threadInstances.find(
GetCurrentThreadId()); |
| 530 if (it == s_threadInstances.end()) | 521 if (it == s_threadInstances.end()) |
| 531 { | 522 { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 542 DEBUG_GENERAL(L"WindowStateChanged (check tab changed) end"); | 533 DEBUG_GENERAL(L"WindowStateChanged (check tab changed) end"); |
| 543 } | 534 } |
| 544 catch (...) | 535 catch (...) |
| 545 { | 536 { |
| 546 } | 537 } |
| 547 } | 538 } |
| 548 | 539 |
| 549 // Entry point | 540 // Entry point |
| 550 void STDMETHODCALLTYPE CPluginClass::OnCommandStateChange(long /*command*/, VARI
ANT_BOOL /*enable*/) | 541 void STDMETHODCALLTYPE CPluginClass::OnCommandStateChange(long /*command*/, VARI
ANT_BOOL /*enable*/) |
| 551 { | 542 { |
| 543 if (detachedInitializationFailed) return; |
| 552 try | 544 try |
| 553 { | 545 { |
| 554 if (m_hPaneWnd == NULL) | 546 if (m_hPaneWnd == NULL) |
| 555 { | 547 { |
| 556 CreateStatusBarPane(); | 548 CreateStatusBarPane(); |
| 557 } | 549 } |
| 558 else | 550 else |
| 559 { | 551 { |
| 560 if (AdblockPlus::IE::InstalledMajorVersion() > 6) | 552 if (AdblockPlus::IE::InstalledMajorVersion() > 6) |
| 561 { | 553 { |
| 562 RECT rect; | 554 RECT rect; |
| 563 //Get the RECT for the leftmost pane (the status text pane) | 555 //Get the RECT for the leftmost pane (the status text pane) |
| 564 BOOL rectRes = ::SendMessage(m_hStatusBarWnd, SB_GETRECT, 0, (LPARAM)&re
ct); | 556 BOOL rectRes = ::SendMessage(m_hStatusBarWnd, SB_GETRECT, 0, (LPARAM)&re
ct); |
| 565 if (rectRes == TRUE) | 557 if (rectRes == TRUE) |
| 566 { | 558 { |
| 567 MoveWindow(m_hPaneWnd, rect.right - m_nPaneWidth, 0, m_nPaneWidth, rec
t.bottom - rect.top, TRUE); | 559 MoveWindow(m_hPaneWnd, rect.right - m_nPaneWidth, 0, m_nPaneWidth, rec
t.bottom - rect.top, TRUE); |
| 568 } | 560 } |
| 569 } | 561 } |
| 570 } | 562 } |
| 571 } | 563 } |
| 572 catch (...) | 564 catch (...) |
| 573 { | 565 { |
| 574 } | 566 } |
| 575 } | 567 } |
| 576 | 568 |
| 577 // Entry point | |
| 578 void STDMETHODCALLTYPE CPluginClass::OnOnQuit() | |
| 579 { | |
| 580 try | |
| 581 { | |
| 582 Unadvise(); | |
| 583 } | |
| 584 catch (...) | |
| 585 { | |
| 586 } | |
| 587 } | |
| 588 | |
| 589 bool CPluginClass::InitObject() | 569 bool CPluginClass::InitObject() |
| 590 { | 570 { |
| 591 DEBUG_GENERAL("InitObject - begin"); | 571 DEBUG_GENERAL("InitObject - begin"); |
| 592 CPluginSettings* settings = CPluginSettings::GetInstance(); | 572 CPluginSettings* settings = CPluginSettings::GetInstance(); |
| 593 | 573 |
| 594 if (!settings->GetPluginEnabled()) | 574 if (!settings->GetPluginEnabled()) |
| 595 { | 575 { |
| 596 s_mimeFilter->Unregister(); | 576 s_mimeFilter->Unregister(); |
| 597 } | 577 } |
| 598 | 578 |
| (...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 967 } | 947 } |
| 968 } | 948 } |
| 969 s_criticalSectionLocal.Unlock(); | 949 s_criticalSectionLocal.Unlock(); |
| 970 | 950 |
| 971 return tab; | 951 return tab; |
| 972 } | 952 } |
| 973 | 953 |
| 974 | 954 |
| 975 STDMETHODIMP CPluginClass::QueryStatus(const GUID* pguidCmdGroup, ULONG cCmds, O
LECMD prgCmds[], OLECMDTEXT* pCmdText) | 955 STDMETHODIMP CPluginClass::QueryStatus(const GUID* pguidCmdGroup, ULONG cCmds, O
LECMD prgCmds[], OLECMDTEXT* pCmdText) |
| 976 { | 956 { |
| 957 if (detachedInitializationFailed) return; |
| 977 if (cCmds == 0) return E_INVALIDARG; | 958 if (cCmds == 0) return E_INVALIDARG; |
| 978 if (prgCmds == 0) return E_POINTER; | 959 if (prgCmds == 0) return E_POINTER; |
| 979 | 960 |
| 980 prgCmds[0].cmdf = OLECMDF_ENABLED; | 961 prgCmds[0].cmdf = OLECMDF_ENABLED; |
| 981 | 962 |
| 982 return S_OK; | 963 return S_OK; |
| 983 } | 964 } |
| 984 | 965 |
| 985 HMENU CPluginClass::CreatePluginMenu(const std::wstring& url) | 966 HMENU CPluginClass::CreatePluginMenu(const std::wstring& url) |
| 986 { | 967 { |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1176 fmii.dwTypeData = const_cast<LPWSTR>(ctext.c_str()); | 1157 fmii.dwTypeData = const_cast<LPWSTR>(ctext.c_str()); |
| 1177 fmii.cch = static_cast<UINT>(ctext.size()); | 1158 fmii.cch = static_cast<UINT>(ctext.size()); |
| 1178 ::SetMenuItemInfoW(hMenu, ID_MENU_SETTINGS, FALSE, &fmii); | 1159 ::SetMenuItemInfoW(hMenu, ID_MENU_SETTINGS, FALSE, &fmii); |
| 1179 | 1160 |
| 1180 return true; | 1161 return true; |
| 1181 } | 1162 } |
| 1182 | 1163 |
| 1183 | 1164 |
| 1184 STDMETHODIMP CPluginClass::Exec(const GUID*, DWORD nCmdID, DWORD, VARIANTARG*, V
ARIANTARG*) | 1165 STDMETHODIMP CPluginClass::Exec(const GUID*, DWORD nCmdID, DWORD, VARIANTARG*, V
ARIANTARG*) |
| 1185 { | 1166 { |
| 1167 if (detachedInitializationFailed) return; |
| 1186 HWND hBrowserWnd = GetBrowserHWND(); | 1168 HWND hBrowserWnd = GetBrowserHWND(); |
| 1187 if (!hBrowserWnd) | 1169 if (!hBrowserWnd) |
| 1188 { | 1170 { |
| 1189 return E_FAIL; | 1171 return E_FAIL; |
| 1190 } | 1172 } |
| 1191 | 1173 |
| 1192 // Create menu | 1174 // Create menu |
| 1193 HMENU hMenu = CreatePluginMenu(m_tab->GetDocumentUrl()); | 1175 HMENU hMenu = CreatePluginMenu(m_tab->GetDocumentUrl()); |
| 1194 if (!hMenu) | 1176 if (!hMenu) |
| 1195 { | 1177 { |
| (...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1581 if (m_hPaneWnd == NULL) | 1563 if (m_hPaneWnd == NULL) |
| 1582 { | 1564 { |
| 1583 CreateStatusBarPane(); | 1565 CreateStatusBarPane(); |
| 1584 } | 1566 } |
| 1585 if ((m_hPaneWnd != NULL) && !::InvalidateRect(m_hPaneWnd, NULL, FALSE)) | 1567 if ((m_hPaneWnd != NULL) && !::InvalidateRect(m_hPaneWnd, NULL, FALSE)) |
| 1586 { | 1568 { |
| 1587 DEBUG_ERROR_LOG(::GetLastError(), PLUGIN_ERROR_UI, PLUGIN_ERROR_UI_INVALID
ATE_STATUSBAR, "Class::Invalidate statusbar"); | 1569 DEBUG_ERROR_LOG(::GetLastError(), PLUGIN_ERROR_UI, PLUGIN_ERROR_UI_INVALID
ATE_STATUSBAR, "Class::Invalidate statusbar"); |
| 1588 } | 1570 } |
| 1589 } | 1571 } |
| 1590 | 1572 |
| 1591 | |
| 1592 void CPluginClass::Unadvise() | |
| 1593 { | |
| 1594 if (!m_webBrowser2) | |
| 1595 { | |
| 1596 DEBUG_ERROR_LOG(0, 0, 0, "CPluginClass::Unadvise - Reached with m_webBrowser
2 == nullptr"); | |
| 1597 return; | |
| 1598 } | |
| 1599 s_criticalSectionLocal.Lock(); | |
| 1600 { | |
| 1601 if (m_isAdvised) | |
| 1602 { | |
| 1603 HRESULT hr = DispEventUnadvise(m_webBrowser2); | |
| 1604 if (FAILED(hr)) | |
| 1605 { | |
| 1606 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_SET_SITE, PLUGIN_ERROR_SET_SITE_UNADVIS
E, "Class::Unadvise - Unadvise"); | |
| 1607 } | |
| 1608 m_isAdvised = false; | |
| 1609 } | |
| 1610 } | |
| 1611 s_criticalSectionLocal.Unlock(); | |
| 1612 } | |
| 1613 | |
| 1614 HICON CPluginClass::GetIcon(int type) | 1573 HICON CPluginClass::GetIcon(int type) |
| 1615 { | 1574 { |
| 1616 HICON icon = NULL; | 1575 HICON icon = NULL; |
| 1617 | 1576 |
| 1618 s_criticalSectionLocal.Lock(); | 1577 s_criticalSectionLocal.Lock(); |
| 1619 { | 1578 { |
| 1620 if (!s_hIcons[type]) | 1579 if (!s_hIcons[type]) |
| 1621 { | 1580 { |
| 1622 std::wstring imageToLoad = L"#"; | 1581 std::wstring imageToLoad = L"#"; |
| 1623 imageToLoad += std::to_wstring(s_hIconTypes[type]); | 1582 imageToLoad += std::to_wstring(s_hIconTypes[type]); |
| 1624 s_hIcons[type] = (HICON)::LoadImage(_Module.m_hInst, imageToLoad.c_str(),
IMAGE_ICON, iconWidth, iconHeight, LR_SHARED); | 1583 s_hIcons[type] = (HICON)::LoadImage(_Module.m_hInst, imageToLoad.c_str(),
IMAGE_ICON, iconWidth, iconHeight, LR_SHARED); |
| 1625 if (!s_hIcons[type]) | 1584 if (!s_hIcons[type]) |
| 1626 { | 1585 { |
| 1627 DEBUG_ERROR_LOG(::GetLastError(), PLUGIN_ERROR_UI, PLUGIN_ERROR_UI_LOAD_
ICON, "Class::GetIcon - LoadIcon"); | 1586 DEBUG_ERROR_LOG(::GetLastError(), PLUGIN_ERROR_UI, PLUGIN_ERROR_UI_LOAD_
ICON, "Class::GetIcon - LoadIcon"); |
| 1628 } | 1587 } |
| 1629 } | 1588 } |
| 1630 | 1589 |
| 1631 icon = s_hIcons[type]; | 1590 icon = s_hIcons[type]; |
| 1632 } | 1591 } |
| 1633 s_criticalSectionLocal.Unlock(); | 1592 s_criticalSectionLocal.Unlock(); |
| 1634 | 1593 |
| 1635 return icon; | 1594 return icon; |
| 1636 } | 1595 } |
| 1637 | 1596 |
| 1638 ATOM CPluginClass::GetAtomPaneClass() | 1597 ATOM CPluginClass::GetAtomPaneClass() |
| 1639 { | 1598 { |
| 1640 return s_atomPaneClass; | 1599 return s_atomPaneClass; |
| 1641 } | 1600 } |
| 1642 | 1601 |
| OLD | NEW |