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-2016 Eyeo GmbH | 3 * Copyright (C) 2006-2016 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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 if (right < left) | 124 if (right < left) |
125 { | 125 { |
126 throw std::runtime_error("invariant violation: rectangle right < left"); | 126 throw std::runtime_error("invariant violation: rectangle right < left"); |
127 } | 127 } |
128 return static_cast<unsigned long>(right - left); | 128 return static_cast<unsigned long>(right - left); |
129 } | 129 } |
130 }; | 130 }; |
131 } | 131 } |
132 | 132 |
133 CPluginClass::CPluginClass() | 133 CPluginClass::CPluginClass() |
134 : m_webBrowser2(nullptr) | 134 : m_webBrowser2(nullptr), |
| 135 detachedInitializationFailed(false) |
135 { | 136 { |
136 DEBUG_GENERAL([this]() -> std::wstring | 137 DEBUG_GENERAL([this]() -> std::wstring |
137 { | 138 { |
138 std::wstring s = L"CPluginClass::<constructor>, this = "; | 139 std::wstring s = L"CPluginClass::<constructor>, this = "; |
139 s += ToHexLiteral(this); | 140 s += ToHexLiteral(this); |
140 return s; | 141 return s; |
141 }()); | 142 }()); |
142 | 143 |
143 //Use this line to debug memory leaks | 144 //Use this line to debug memory leaks |
144 // _CrtDumpMemoryLeaks(); | 145 // _CrtDumpMemoryLeaks(); |
145 | 146 |
146 m_isAdvised = false; | |
147 m_hTabWnd = NULL; | 147 m_hTabWnd = NULL; |
148 m_hStatusBarWnd = NULL; | 148 m_hStatusBarWnd = NULL; |
149 m_hPaneWnd = NULL; | 149 m_hPaneWnd = NULL; |
150 m_nPaneWidth = 0; | 150 m_nPaneWidth = 0; |
151 m_pWndProcStatus = NULL; | 151 m_pWndProcStatus = NULL; |
152 m_hTheme = NULL; | 152 m_hTheme = NULL; |
153 m_isInitializedOk = false; | 153 m_isInitializedOk = false; |
154 m_tab = new CPluginTab(); | 154 m_tab = new CPluginTab(); |
155 Dictionary::Create(GetBrowserLanguage()); | 155 Dictionary::Create(GetBrowserLanguage()); |
156 } | 156 } |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 { | 221 { |
222 url = m_tab->GetDocumentUrl(); | 222 url = m_tab->GetDocumentUrl(); |
223 } | 223 } |
224 return url; | 224 return url; |
225 } | 225 } |
226 | 226 |
227 DWORD WINAPI CPluginClass::StartInitObject(LPVOID thisPtr) | 227 DWORD WINAPI CPluginClass::StartInitObject(LPVOID thisPtr) |
228 { | 228 { |
229 if (thisPtr == NULL) | 229 if (thisPtr == NULL) |
230 return 0; | 230 return 0; |
231 if (!((CPluginClass*)thisPtr)->InitObject()) | 231 auto self = static_cast<CPluginClass*>(thisPtr); |
| 232 if (!self->InitObject()) |
232 { | 233 { |
233 ((CPluginClass*)thisPtr)->Unadvise(); | 234 self->detachedInitializationFailed = true; |
234 } | 235 } |
235 | |
236 return 0; | 236 return 0; |
237 } | 237 } |
238 | 238 |
239 /* | 239 /* |
240 * IE calls this when it creates a new browser window or tab, immediately after
it also | 240 * IE calls this when it creates a new browser window or tab, immediately after
it also |
241 * creates the object. The argument 'unknownSite' in is the OLE "site" of the ob
ject, | 241 * creates the object. The argument 'unknownSite' in is the OLE "site" of the ob
ject, |
242 * which is an IWebBrowser2 interface associated with the window/tab. | 242 * which is an IWebBrowser2 interface associated with the window/tab. |
243 * | 243 * |
244 * IE also ordinarily calls this again when its window/tab is closed, in which c
ase | 244 * IE also ordinarily calls this again when its window/tab is closed, in which c
ase |
245 * 'unknownSite' will be null. Extraordinarily, this is sometimes _not_ called w
hen IE | 245 * 'unknownSite' will be null. Extraordinarily, this is sometimes _not_ called w
hen IE |
246 * is shutting down. Thus 'SetSite(nullptr)' has some similarities with a destru
ctor, | 246 * is shutting down. Thus 'SetSite(nullptr)' has some similarities with a destru
ctor, |
247 * but it is not a proper substitute for one. | 247 * but it is not a proper substitute for one. |
248 */ | 248 */ |
249 STDMETHODIMP CPluginClass::SetSite(IUnknown* unknownSite) | 249 STDMETHODIMP CPluginClass::SetSite(IUnknown* unknownSite) |
250 { | 250 { |
251 try | 251 try |
252 { | 252 { |
253 if (unknownSite) | 253 if (unknownSite) |
254 { | 254 { |
255 DEBUG_GENERAL(L"==========================================================
======================\nNEW TAB UI\n============================================
===================================="); | 255 DEBUG_GENERAL(L"==========================================================
======================\nNEW TAB UI\n============================================
===================================="); |
256 | 256 |
257 HRESULT hr = ::CoInitialize(NULL); | 257 HRESULT hr = ::CoInitialize(NULL); |
258 if (FAILED(hr)) | 258 if (FAILED(hr)) |
259 { | 259 { |
260 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_SET_SITE, PLUGIN_ERROR_SET_SITE_COINIT,
"Class::SetSite - CoInitialize"); | 260 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_SET_SITE, PLUGIN_ERROR_SET_SITE_COINIT,
"Class::SetSite - CoInitialize"); |
261 } | 261 } |
262 | |
263 /* | 262 /* |
264 * We were instantiated as a BHO, so our site is always of type IWebBrowse
r2. | 263 * We were instantiated as a BHO, so our site is always of type IWebBrowse
r2. |
265 */ | 264 */ |
266 m_webBrowser2 = ATL::CComQIPtr<IWebBrowser2>(unknownSite); | 265 m_webBrowser2 = ATL::CComQIPtr<IWebBrowser2>(unknownSite); |
267 if (!m_webBrowser2) | 266 if (!m_webBrowser2) |
268 { | 267 { |
269 throw std::logic_error("CPluginClass::SetSite - Unable to convert site p
ointer to IWebBrowser2*"); | 268 throw std::logic_error("CPluginClass::SetSite - Unable to convert site p
ointer to IWebBrowser2*"); |
270 } | 269 } |
271 DEBUG_GENERAL([this]() -> std::wstring | 270 DEBUG_GENERAL([this]() -> std::wstring |
272 { | 271 { |
(...skipping 18 matching lines...) Expand all Loading... |
291 { | 290 { |
292 // Always register on startup, then check if we need to unregister in a
separate thread | 291 // Always register on startup, then check if we need to unregister in a
separate thread |
293 s_mimeFilter = CPluginClientFactory::GetMimeFilterClientInstance(); | 292 s_mimeFilter = CPluginClientFactory::GetMimeFilterClientInstance(); |
294 s_asyncWebBrowser2 = unknownSite; | 293 s_asyncWebBrowser2 = unknownSite; |
295 s_instances.insert(this); | 294 s_instances.insert(this); |
296 } | 295 } |
297 s_criticalSectionLocal.Unlock(); | 296 s_criticalSectionLocal.Unlock(); |
298 | 297 |
299 try | 298 try |
300 { | 299 { |
301 HRESULT hr = DispEventAdvise(m_webBrowser2); | 300 std::thread startInitObjectThread(StartInitObject, this); |
302 if (SUCCEEDED(hr)) | 301 startInitObjectThread.detach(); // TODO: but actually we should wait for
the thread in the dtr. |
303 { | |
304 m_isAdvised = true; | |
305 try | |
306 { | |
307 std::thread startInitObjectThread(StartInitObject, this); | |
308 startInitObjectThread.detach(); // TODO: but actually we should wait
for the thread in the dtr. | |
309 } | |
310 catch (const std::system_error& ex) | |
311 { | |
312 DEBUG_SYSTEM_EXCEPTION(ex, PLUGIN_ERROR_THREAD, PLUGIN_ERROR_MAIN_TH
READ_CREATE_PROCESS, | |
313 "Class::Thread - Failed to create StartInitObject thread"); | |
314 } | |
315 } | |
316 else | |
317 { | |
318 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_SET_SITE, PLUGIN_ERROR_SET_SITE_ADVIC
E, "Class::SetSite - Advise"); | |
319 } | |
320 } | 302 } |
321 catch (const std::runtime_error& ex) | 303 catch (const std::system_error& ex) |
322 { | 304 { |
323 DEBUG_EXCEPTION(ex); | 305 detachedInitializationFailed = true; |
324 Unadvise(); | 306 DEBUG_SYSTEM_EXCEPTION(ex, PLUGIN_ERROR_THREAD, PLUGIN_ERROR_MAIN_THREAD
_CREATE_PROCESS, |
| 307 "Class::Thread - Failed to create StartInitObject thread"); |
325 } | 308 } |
| 309 |
| 310 // Start events last to alleviate issues with deferred evaluation |
| 311 browserEvents.Start(this, m_webBrowser2); |
326 } | 312 } |
327 else | 313 else |
328 { | 314 { |
| 315 browserEvents.Stop(); |
329 DEBUG_GENERAL([this]() -> std::wstring | 316 DEBUG_GENERAL([this]() -> std::wstring |
330 { | 317 { |
331 std::wstringstream ss; | 318 std::wstringstream ss; |
332 ss << L"CPluginClass::SetSite, this = " << ToHexLiteral(this); | 319 ss << L"CPluginClass::SetSite, this = " << ToHexLiteral(this); |
333 ss << L", browser = nullptr"; | 320 ss << L", browser = nullptr"; |
334 return ss.str(); | 321 return ss.str(); |
335 }()); | 322 }()); |
336 | 323 |
337 Unadvise(); | |
338 | 324 |
339 // Destroy window | 325 // Destroy window |
340 if (m_pWndProcStatus) | 326 if (m_pWndProcStatus) |
341 { | 327 { |
342 ::SetWindowLongPtr(m_hStatusBarWnd, GWLP_WNDPROC, (LPARAM)(WNDPROC)m_pWn
dProcStatus); | 328 ::SetWindowLongPtr(m_hStatusBarWnd, GWLP_WNDPROC, (LPARAM)(WNDPROC)m_pWn
dProcStatus); |
343 | 329 |
344 m_pWndProcStatus = NULL; | 330 m_pWndProcStatus = NULL; |
345 } | 331 } |
346 | 332 |
347 if (m_hPaneWnd) | 333 if (m_hPaneWnd) |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
506 IDispatch* frameBrowserDisp /**< [in] */, | 492 IDispatch* frameBrowserDisp /**< [in] */, |
507 VARIANT* urlVariant /**< [in] */, | 493 VARIANT* urlVariant /**< [in] */, |
508 VARIANT* /**< [in] Flags*/, | 494 VARIANT* /**< [in] Flags*/, |
509 VARIANT* /**< [in] TargetFrameName*/, | 495 VARIANT* /**< [in] TargetFrameName*/, |
510 VARIANT* /**< [in] PostData*/, | 496 VARIANT* /**< [in] PostData*/, |
511 VARIANT* /**< [in] Headers*/, | 497 VARIANT* /**< [in] Headers*/, |
512 VARIANT_BOOL* /**< [in, out] Cancel*/) | 498 VARIANT_BOOL* /**< [in, out] Cancel*/) |
513 { | 499 { |
514 try | 500 try |
515 { | 501 { |
| 502 if (detachedInitializationFailed) return; |
| 503 |
516 ATL::CComQIPtr<IWebBrowser2> webBrowser = frameBrowserDisp; | 504 ATL::CComQIPtr<IWebBrowser2> webBrowser = frameBrowserDisp; |
517 if (!webBrowser) | 505 if (!webBrowser) |
518 { | 506 { |
519 return; | 507 return; |
520 } | 508 } |
521 if (!urlVariant || urlVariant->vt != VT_BSTR) | 509 if (!urlVariant || urlVariant->vt != VT_BSTR) |
522 { | 510 { |
523 return; | 511 return; |
524 } | 512 } |
525 std::wstring url = ToWstring(urlVariant->bstrVal); | 513 std::wstring url = ToWstring(urlVariant->bstrVal); |
(...skipping 24 matching lines...) Expand all Loading... |
550 } | 538 } |
551 } | 539 } |
552 catch (...) | 540 catch (...) |
553 { | 541 { |
554 } | 542 } |
555 } | 543 } |
556 | 544 |
557 // Entry point | 545 // Entry point |
558 void STDMETHODCALLTYPE CPluginClass::OnDownloadComplete() | 546 void STDMETHODCALLTYPE CPluginClass::OnDownloadComplete() |
559 { | 547 { |
| 548 if (detachedInitializationFailed) return; |
560 try | 549 try |
561 { | 550 { |
562 if (!m_webBrowser2) | 551 if (!m_webBrowser2) |
563 { | 552 { |
564 DEBUG_ERROR_LOG(0, 0, 0, "CPluginClass::OnDownloadComplete - Reached with
m_webBrowser2 == nullptr"); | 553 DEBUG_ERROR_LOG(0, 0, 0, "CPluginClass::OnDownloadComplete - Reached with
m_webBrowser2 == nullptr"); |
565 return; | 554 return; |
566 } | 555 } |
567 DEBUG_NAVI(L"Navi::Download Complete") | 556 DEBUG_NAVI(L"Navi::Download Complete") |
568 m_tab->OnDownloadComplete(m_webBrowser2); | 557 m_tab->OnDownloadComplete(m_webBrowser2); |
569 } | 558 } |
570 catch (...) | 559 catch (...) |
571 { | 560 { |
572 } | 561 } |
573 } | 562 } |
574 | 563 |
575 // Entry point | 564 // Entry point |
576 void STDMETHODCALLTYPE CPluginClass::OnDocumentComplete(IDispatch* frameBrowserD
isp, VARIANT* /*urlOrPidl*/) | 565 void STDMETHODCALLTYPE CPluginClass::OnDocumentComplete(IDispatch* frameBrowserD
isp, VARIANT* /*urlOrPidl*/) |
577 { | 566 { |
| 567 if (detachedInitializationFailed) return; |
578 try | 568 try |
579 { | 569 { |
580 DEBUG_NAVI(L"Navi::Document Complete"); | 570 DEBUG_NAVI(L"Navi::Document Complete"); |
581 ATL::CComQIPtr<IWebBrowser2> webBrowser2 = frameBrowserDisp; | 571 ATL::CComQIPtr<IWebBrowser2> webBrowser2 = frameBrowserDisp; |
582 if (!webBrowser2) | 572 if (!webBrowser2) |
583 { | 573 { |
584 return; | 574 return; |
585 } | 575 } |
586 std::wstring frameSrc = GetLocationUrl(*webBrowser2); | 576 std::wstring frameSrc = GetLocationUrl(*webBrowser2); |
587 m_tab->OnDocumentComplete(webBrowser2, frameSrc, IsRootBrowser(webBrowser2))
; | 577 m_tab->OnDocumentComplete(webBrowser2, frameSrc, IsRootBrowser(webBrowser2))
; |
588 } | 578 } |
589 catch (...) | 579 catch (...) |
590 { | 580 { |
591 } | 581 } |
592 } | 582 } |
593 | 583 |
594 // Entry point | 584 // Entry point |
595 void STDMETHODCALLTYPE CPluginClass::OnWindowStateChanged(unsigned long flags, u
nsigned long validFlagsMask) | 585 void STDMETHODCALLTYPE CPluginClass::OnWindowStateChanged(unsigned long flags, u
nsigned long validFlagsMask) |
596 { | 586 { |
| 587 if (detachedInitializationFailed) return; |
597 try | 588 try |
598 { | 589 { |
599 DEBUG_GENERAL(L"WindowStateChanged (check tab changed)"); | 590 DEBUG_GENERAL(L"WindowStateChanged (check tab changed)"); |
600 bool newtabshown = validFlagsMask == (OLECMDIDF_WINDOWSTATE_USERVISIBLE | OL
ECMDIDF_WINDOWSTATE_ENABLED) | 591 bool newtabshown = validFlagsMask == (OLECMDIDF_WINDOWSTATE_USERVISIBLE | OL
ECMDIDF_WINDOWSTATE_ENABLED) |
601 && flags == (OLECMDIDF_WINDOWSTATE_USERVISIBLE | OLECMDIDF_WINDOWSTATE_ENA
BLED); | 592 && flags == (OLECMDIDF_WINDOWSTATE_USERVISIBLE | OLECMDIDF_WINDOWSTATE_ENA
BLED); |
602 if (newtabshown) | 593 if (newtabshown) |
603 { | 594 { |
604 if (!m_isInitializedOk) | 595 if (!m_isInitializedOk) |
605 { | 596 { |
606 m_isInitializedOk = true; | 597 m_isInitializedOk = true; |
607 InitObject(); | 598 InitObject(); |
608 UpdateStatusBar(); | 599 UpdateStatusBar(); |
609 } | 600 } |
610 } | 601 } |
611 notificationMessage.Hide(); | 602 notificationMessage.Hide(); |
612 DEBUG_GENERAL(L"WindowStateChanged (check tab changed) end"); | 603 DEBUG_GENERAL(L"WindowStateChanged (check tab changed) end"); |
613 } | 604 } |
614 catch (...) | 605 catch (...) |
615 { | 606 { |
616 } | 607 } |
617 } | 608 } |
618 | 609 |
619 // Entry point | 610 // Entry point |
620 void STDMETHODCALLTYPE CPluginClass::OnCommandStateChange(long /*command*/, VARI
ANT_BOOL /*enable*/) | 611 void STDMETHODCALLTYPE CPluginClass::OnCommandStateChange(long /*command*/, VARI
ANT_BOOL /*enable*/) |
621 { | 612 { |
| 613 if (detachedInitializationFailed) return; |
622 try | 614 try |
623 { | 615 { |
624 if (m_hPaneWnd == NULL) | 616 if (m_hPaneWnd == NULL) |
625 { | 617 { |
626 CreateStatusBarPane(); | 618 CreateStatusBarPane(); |
627 } | 619 } |
628 else | 620 else |
629 { | 621 { |
630 if (AdblockPlus::IE::InstalledMajorVersion() > 6) | 622 if (AdblockPlus::IE::InstalledMajorVersion() > 6) |
631 { | 623 { |
632 RECT rect; | 624 RECT rect; |
633 //Get the RECT for the leftmost pane (the status text pane) | 625 //Get the RECT for the leftmost pane (the status text pane) |
634 BOOL rectRes = ::SendMessage(m_hStatusBarWnd, SB_GETRECT, 0, (LPARAM)&re
ct); | 626 BOOL rectRes = ::SendMessage(m_hStatusBarWnd, SB_GETRECT, 0, (LPARAM)&re
ct); |
635 if (rectRes == TRUE) | 627 if (rectRes == TRUE) |
636 { | 628 { |
637 MoveWindow(m_hPaneWnd, rect.right - m_nPaneWidth, 0, m_nPaneWidth, rec
t.bottom - rect.top, TRUE); | 629 MoveWindow(m_hPaneWnd, rect.right - m_nPaneWidth, 0, m_nPaneWidth, rec
t.bottom - rect.top, TRUE); |
638 } | 630 } |
639 } | 631 } |
640 } | 632 } |
641 } | 633 } |
642 catch (...) | 634 catch (...) |
643 { | 635 { |
644 } | 636 } |
645 } | 637 } |
646 | 638 |
647 // Entry point | |
648 void STDMETHODCALLTYPE CPluginClass::OnOnQuit() | |
649 { | |
650 try | |
651 { | |
652 Unadvise(); | |
653 } | |
654 catch (...) | |
655 { | |
656 } | |
657 } | |
658 | |
659 bool CPluginClass::InitObject() | 639 bool CPluginClass::InitObject() |
660 { | 640 { |
661 DEBUG_GENERAL("InitObject - begin"); | 641 DEBUG_GENERAL("InitObject - begin"); |
662 CPluginSettings* settings = CPluginSettings::GetInstance(); | 642 CPluginSettings* settings = CPluginSettings::GetInstance(); |
663 | 643 |
664 if (!settings->GetPluginEnabled()) | 644 if (!settings->GetPluginEnabled()) |
665 { | 645 { |
666 s_mimeFilter->Unregister(); | 646 s_mimeFilter->Unregister(); |
667 } | 647 } |
668 | 648 |
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1026 | 1006 |
1027 CPluginTab* CPluginClass::GetTabForCurrentThread() | 1007 CPluginTab* CPluginClass::GetTabForCurrentThread() |
1028 { | 1008 { |
1029 auto p = threadMap.Locate(); | 1009 auto p = threadMap.Locate(); |
1030 return p ? p->m_tab : nullptr; | 1010 return p ? p->m_tab : nullptr; |
1031 } | 1011 } |
1032 | 1012 |
1033 // Entry point | 1013 // Entry point |
1034 STDMETHODIMP CPluginClass::QueryStatus(const GUID* pguidCmdGroup, ULONG cCmds, O
LECMD prgCmds[], OLECMDTEXT* pCmdText) | 1014 STDMETHODIMP CPluginClass::QueryStatus(const GUID* pguidCmdGroup, ULONG cCmds, O
LECMD prgCmds[], OLECMDTEXT* pCmdText) |
1035 { | 1015 { |
| 1016 if (detachedInitializationFailed) return S_OK; |
1036 try | 1017 try |
1037 { | 1018 { |
1038 if (cCmds == 0) return E_INVALIDARG; | 1019 if (cCmds == 0) return E_INVALIDARG; |
1039 if (prgCmds == 0) return E_POINTER; | 1020 if (prgCmds == 0) return E_POINTER; |
1040 | 1021 |
1041 prgCmds[0].cmdf = OLECMDF_ENABLED; | 1022 prgCmds[0].cmdf = OLECMDF_ENABLED; |
1042 } | 1023 } |
1043 catch (...) | 1024 catch (...) |
1044 { | 1025 { |
1045 DEBUG_GENERAL(L"CPluginClass::QueryStatus - exception"); | 1026 DEBUG_GENERAL(L"CPluginClass::QueryStatus - exception"); |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1251 fmii.dwTypeData = const_cast<LPWSTR>(ctext.c_str()); | 1232 fmii.dwTypeData = const_cast<LPWSTR>(ctext.c_str()); |
1252 fmii.cch = static_cast<UINT>(ctext.size()); | 1233 fmii.cch = static_cast<UINT>(ctext.size()); |
1253 ::SetMenuItemInfoW(hMenu, ID_MENU_SETTINGS, FALSE, &fmii); | 1234 ::SetMenuItemInfoW(hMenu, ID_MENU_SETTINGS, FALSE, &fmii); |
1254 | 1235 |
1255 return true; | 1236 return true; |
1256 } | 1237 } |
1257 | 1238 |
1258 // Entry point | 1239 // Entry point |
1259 STDMETHODIMP CPluginClass::Exec(const GUID*, DWORD nCmdID, DWORD, VARIANTARG*, V
ARIANTARG*) | 1240 STDMETHODIMP CPluginClass::Exec(const GUID*, DWORD nCmdID, DWORD, VARIANTARG*, V
ARIANTARG*) |
1260 { | 1241 { |
| 1242 if (detachedInitializationFailed) return S_OK; |
1261 try | 1243 try |
1262 { | 1244 { |
1263 HWND hBrowserWnd = GetBrowserHWND(); | 1245 HWND hBrowserWnd = GetBrowserHWND(); |
1264 if (!hBrowserWnd) | 1246 if (!hBrowserWnd) |
1265 { | 1247 { |
1266 return E_FAIL; | 1248 return E_FAIL; |
1267 } | 1249 } |
1268 | 1250 |
1269 // Create menu | 1251 // Create menu |
1270 HMENU hMenu = CreatePluginMenu(m_tab->GetDocumentUrl()); | 1252 HMENU hMenu = CreatePluginMenu(m_tab->GetDocumentUrl()); |
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1676 if (m_hPaneWnd == NULL) | 1658 if (m_hPaneWnd == NULL) |
1677 { | 1659 { |
1678 CreateStatusBarPane(); | 1660 CreateStatusBarPane(); |
1679 } | 1661 } |
1680 if ((m_hPaneWnd != NULL) && !::InvalidateRect(m_hPaneWnd, NULL, FALSE)) | 1662 if ((m_hPaneWnd != NULL) && !::InvalidateRect(m_hPaneWnd, NULL, FALSE)) |
1681 { | 1663 { |
1682 DEBUG_ERROR_LOG(::GetLastError(), PLUGIN_ERROR_UI, PLUGIN_ERROR_UI_INVALID
ATE_STATUSBAR, "Class::Invalidate statusbar"); | 1664 DEBUG_ERROR_LOG(::GetLastError(), PLUGIN_ERROR_UI, PLUGIN_ERROR_UI_INVALID
ATE_STATUSBAR, "Class::Invalidate statusbar"); |
1683 } | 1665 } |
1684 } | 1666 } |
1685 | 1667 |
1686 | |
1687 void CPluginClass::Unadvise() | |
1688 { | |
1689 if (!m_webBrowser2) | |
1690 { | |
1691 DEBUG_ERROR_LOG(0, 0, 0, "CPluginClass::Unadvise - Reached with m_webBrowser
2 == nullptr"); | |
1692 return; | |
1693 } | |
1694 s_criticalSectionLocal.Lock(); | |
1695 { | |
1696 if (m_isAdvised) | |
1697 { | |
1698 HRESULT hr = DispEventUnadvise(m_webBrowser2); | |
1699 if (FAILED(hr)) | |
1700 { | |
1701 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_SET_SITE, PLUGIN_ERROR_SET_SITE_UNADVIS
E, "Class::Unadvise - Unadvise"); | |
1702 } | |
1703 m_isAdvised = false; | |
1704 } | |
1705 } | |
1706 s_criticalSectionLocal.Unlock(); | |
1707 } | |
1708 | |
1709 HICON CPluginClass::GetIcon(int type) | 1668 HICON CPluginClass::GetIcon(int type) |
1710 { | 1669 { |
1711 HICON icon = NULL; | 1670 HICON icon = NULL; |
1712 | 1671 |
1713 s_criticalSectionLocal.Lock(); | 1672 s_criticalSectionLocal.Lock(); |
1714 { | 1673 { |
1715 if (!s_hIcons[type]) | 1674 if (!s_hIcons[type]) |
1716 { | 1675 { |
1717 std::wstring imageToLoad = L"#"; | 1676 std::wstring imageToLoad = L"#"; |
1718 imageToLoad += std::to_wstring(s_hIconTypes[type]); | 1677 imageToLoad += std::to_wstring(s_hIconTypes[type]); |
1719 s_hIcons[type] = (HICON)::LoadImage(_Module.m_hInst, imageToLoad.c_str(),
IMAGE_ICON, iconWidth, iconHeight, LR_SHARED); | 1678 s_hIcons[type] = (HICON)::LoadImage(_Module.m_hInst, imageToLoad.c_str(),
IMAGE_ICON, iconWidth, iconHeight, LR_SHARED); |
1720 if (!s_hIcons[type]) | 1679 if (!s_hIcons[type]) |
1721 { | 1680 { |
1722 DEBUG_ERROR_LOG(::GetLastError(), PLUGIN_ERROR_UI, PLUGIN_ERROR_UI_LOAD_
ICON, "Class::GetIcon - LoadIcon"); | 1681 DEBUG_ERROR_LOG(::GetLastError(), PLUGIN_ERROR_UI, PLUGIN_ERROR_UI_LOAD_
ICON, "Class::GetIcon - LoadIcon"); |
1723 } | 1682 } |
1724 } | 1683 } |
1725 | 1684 |
1726 icon = s_hIcons[type]; | 1685 icon = s_hIcons[type]; |
1727 } | 1686 } |
1728 s_criticalSectionLocal.Unlock(); | 1687 s_criticalSectionLocal.Unlock(); |
1729 | 1688 |
1730 return icon; | 1689 return icon; |
1731 } | 1690 } |
1732 | 1691 |
1733 ATOM CPluginClass::GetAtomPaneClass() | 1692 ATOM CPluginClass::GetAtomPaneClass() |
1734 { | 1693 { |
1735 return s_atomPaneClass; | 1694 return s_atomPaneClass; |
1736 } | 1695 } |
1737 | 1696 |
OLD | NEW |