Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: src/plugin/PluginClass.cpp

Issue 29332848: Issue #3432 - Manage COM events with a resource class
Patch Set: rebase, address comments Created Jan. 7, 2016, 4:21 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« src/plugin/PluginClass.h ('K') | « src/plugin/PluginClass.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 DEBUG_GENERAL([this]() -> std::wstring 96 DEBUG_GENERAL([this]() -> std::wstring
96 { 97 {
97 std::wstring s = L"CPluginClass::<constructor>, this = "; 98 std::wstring s = L"CPluginClass::<constructor>, this = ";
98 s += ToHexLiteral(this); 99 s += ToHexLiteral(this);
99 return s; 100 return s;
100 }()); 101 }());
101 102
102 //Use this line to debug memory leaks 103 //Use this line to debug memory leaks
103 // _CrtDumpMemoryLeaks(); 104 // _CrtDumpMemoryLeaks();
104 105
105 m_isAdvised = false;
106 m_hTabWnd = NULL; 106 m_hTabWnd = NULL;
107 m_hStatusBarWnd = NULL; 107 m_hStatusBarWnd = NULL;
108 m_hPaneWnd = NULL; 108 m_hPaneWnd = NULL;
109 m_nPaneWidth = 0; 109 m_nPaneWidth = 0;
110 m_pWndProcStatus = NULL; 110 m_pWndProcStatus = NULL;
111 m_hTheme = NULL; 111 m_hTheme = NULL;
112 m_isInitializedOk = false; 112 m_isInitializedOk = false;
113 113
114 114
115 m_tab = new CPluginTab(); 115 m_tab = new CPluginTab();
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 DEBUG_ERROR_LOG(0, 0, 0, "CPluginClass::GetBrowserUrl - Reached with m_webBr owser2 == nullptr"); 180 DEBUG_ERROR_LOG(0, 0, 0, "CPluginClass::GetBrowserUrl - Reached with m_webBr owser2 == nullptr");
181 url = m_tab->GetDocumentUrl(); 181 url = m_tab->GetDocumentUrl();
182 } 182 }
183 return url; 183 return url;
184 } 184 }
185 185
186 DWORD WINAPI CPluginClass::StartInitObject(LPVOID thisPtr) 186 DWORD WINAPI CPluginClass::StartInitObject(LPVOID thisPtr)
187 { 187 {
188 if (thisPtr == NULL) 188 if (thisPtr == NULL)
189 return 0; 189 return 0;
190 if (!((CPluginClass*)thisPtr)->InitObject()) 190 auto self = static_cast<CPluginClass*>(thisPtr);
191 if (!self->InitObject())
191 { 192 {
192 ((CPluginClass*)thisPtr)->Unadvise(); 193 self->detachedInitializationFailed = true;
193 } 194 }
194
195 return 0; 195 return 0;
196 } 196 }
197 197
198 /* 198 /*
199 * IE calls this when it creates a new browser window or tab, immediately after it also 199 * IE calls this when it creates a new browser window or tab, immediately after it also
200 * creates the object. The argument 'unknownSite' in is the OLE "site" of the ob ject, 200 * creates the object. The argument 'unknownSite' in is the OLE "site" of the ob ject,
201 * which is an IWebBrowser2 interface associated with the window/tab. 201 * which is an IWebBrowser2 interface associated with the window/tab.
202 * 202 *
203 * IE also ordinarily calls this again when its window/tab is closed, in which c ase 203 * IE also ordinarily calls this again when its window/tab is closed, in which c ase
204 * 'unknownSite' will be null. Extraordinarily, this is sometimes _not_ called w hen IE 204 * 'unknownSite' will be null. Extraordinarily, this is sometimes _not_ called w hen IE
205 * is shutting down. Thus 'SetSite(nullptr)' has some similarities with a destru ctor, 205 * is shutting down. Thus 'SetSite(nullptr)' has some similarities with a destru ctor,
206 * but it is not a proper substitute for one. 206 * but it is not a proper substitute for one.
207 */ 207 */
208 STDMETHODIMP CPluginClass::SetSite(IUnknown* unknownSite) 208 STDMETHODIMP CPluginClass::SetSite(IUnknown* unknownSite)
209 { 209 {
210 try 210 try
211 { 211 {
212 if (unknownSite) 212 if (unknownSite)
213 { 213 {
214 DEBUG_GENERAL(L"========================================================== ======================\nNEW TAB UI\n============================================ ===================================="); 214 DEBUG_GENERAL(L"========================================================== ======================\nNEW TAB UI\n============================================ ====================================");
215 215
216 HRESULT hr = ::CoInitialize(NULL); 216 HRESULT hr = ::CoInitialize(NULL);
217 if (FAILED(hr)) 217 if (FAILED(hr))
218 { 218 {
219 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_SET_SITE, PLUGIN_ERROR_SET_SITE_COINIT, "Class::SetSite - CoInitialize"); 219 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_SET_SITE, PLUGIN_ERROR_SET_SITE_COINIT, "Class::SetSite - CoInitialize");
220 } 220 }
221
222 /* 221 /*
223 * We were instantiated as a BHO, so our site is always of type IWebBrowse r2. 222 * We were instantiated as a BHO, so our site is always of type IWebBrowse r2.
224 */ 223 */
225 m_webBrowser2 = ATL::CComQIPtr<IWebBrowser2>(unknownSite); 224 m_webBrowser2 = ATL::CComQIPtr<IWebBrowser2>(unknownSite);
226 if (!m_webBrowser2) 225 if (!m_webBrowser2)
227 { 226 {
228 throw std::logic_error("CPluginClass::SetSite - Unable to convert site p ointer to IWebBrowser2*"); 227 throw std::logic_error("CPluginClass::SetSite - Unable to convert site p ointer to IWebBrowser2*");
229 } 228 }
230 DEBUG_GENERAL([this]() -> std::wstring 229 DEBUG_GENERAL([this]() -> std::wstring
231 { 230 {
(...skipping 10 matching lines...) Expand all
242 { 241 {
243 // Always register on startup, then check if we need to unregister in a separate thread 242 // Always register on startup, then check if we need to unregister in a separate thread
244 s_mimeFilter = CPluginClientFactory::GetMimeFilterClientInstance(); 243 s_mimeFilter = CPluginClientFactory::GetMimeFilterClientInstance();
245 s_asyncWebBrowser2 = unknownSite; 244 s_asyncWebBrowser2 = unknownSite;
246 s_instances.insert(this); 245 s_instances.insert(this);
247 } 246 }
248 s_criticalSectionLocal.Unlock(); 247 s_criticalSectionLocal.Unlock();
249 248
250 try 249 try
251 { 250 {
252 HRESULT hr = DispEventAdvise(m_webBrowser2); 251 std::thread startInitObjectThread(StartInitObject, this);
253 if (SUCCEEDED(hr)) 252 startInitObjectThread.detach(); // TODO: but actually we should wait for the thread in the dtr.
254 {
255 m_isAdvised = true;
256 try
257 {
258 std::thread startInitObjectThread(StartInitObject, this);
259 startInitObjectThread.detach(); // TODO: but actually we should wait for the thread in the dtr.
260 }
261 catch (const std::system_error& ex)
262 {
263 DEBUG_SYSTEM_EXCEPTION(ex, PLUGIN_ERROR_THREAD, PLUGIN_ERROR_MAIN_TH READ_CREATE_PROCESS,
264 "Class::Thread - Failed to create StartInitObject thread");
265 }
266 }
267 else
268 {
269 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_SET_SITE, PLUGIN_ERROR_SET_SITE_ADVIC E, "Class::SetSite - Advise");
270 }
271 } 253 }
272 catch (const std::runtime_error& ex) 254 catch (const std::system_error& ex)
273 { 255 {
274 DEBUG_EXCEPTION(ex); 256 detachedInitializationFailed = true;
275 Unadvise(); 257 DEBUG_SYSTEM_EXCEPTION(ex, PLUGIN_ERROR_THREAD, PLUGIN_ERROR_MAIN_THREAD _CREATE_PROCESS,
258 "Class::Thread - Failed to create StartInitObject thread");
276 } 259 }
260
261 // Start events last to alleviate issues with deferred evaluation
262 browserEvents.Start(this, m_webBrowser2);
277 } 263 }
278 else 264 else
279 { 265 {
266 browserEvents.Stop();
280 DEBUG_GENERAL([this]() -> std::wstring 267 DEBUG_GENERAL([this]() -> std::wstring
281 { 268 {
282 std::wstringstream ss; 269 std::wstringstream ss;
283 ss << L"CPluginClass::SetSite, this = " << ToHexLiteral(this); 270 ss << L"CPluginClass::SetSite, this = " << ToHexLiteral(this);
284 ss << L", browser = nullptr"; 271 ss << L", browser = nullptr";
285 return ss.str(); 272 return ss.str();
286 }()); 273 }());
287 274
288 Unadvise();
289 275
290 // Destroy window 276 // Destroy window
291 if (m_pWndProcStatus) 277 if (m_pWndProcStatus)
292 { 278 {
293 ::SetWindowLongPtr(m_hStatusBarWnd, GWLP_WNDPROC, (LPARAM)(WNDPROC)m_pWn dProcStatus); 279 ::SetWindowLongPtr(m_hStatusBarWnd, GWLP_WNDPROC, (LPARAM)(WNDPROC)m_pWn dProcStatus);
294 280
295 m_pWndProcStatus = NULL; 281 m_pWndProcStatus = NULL;
296 } 282 }
297 283
298 if (m_hPaneWnd) 284 if (m_hPaneWnd)
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 IDispatch* frameBrowserDisp /**< [in] */, 444 IDispatch* frameBrowserDisp /**< [in] */,
459 VARIANT* urlVariant /**< [in] */, 445 VARIANT* urlVariant /**< [in] */,
460 VARIANT* /**< [in] Flags*/, 446 VARIANT* /**< [in] Flags*/,
461 VARIANT* /**< [in] TargetFrameName*/, 447 VARIANT* /**< [in] TargetFrameName*/,
462 VARIANT* /**< [in] PostData*/, 448 VARIANT* /**< [in] PostData*/,
463 VARIANT* /**< [in] Headers*/, 449 VARIANT* /**< [in] Headers*/,
464 VARIANT_BOOL* /**< [in, out] Cancel*/) 450 VARIANT_BOOL* /**< [in, out] Cancel*/)
465 { 451 {
466 try 452 try
467 { 453 {
454 if (detachedInitializationFailed) return;
455
468 ATL::CComQIPtr<IWebBrowser2> webBrowser = frameBrowserDisp; 456 ATL::CComQIPtr<IWebBrowser2> webBrowser = frameBrowserDisp;
469 if (!webBrowser) 457 if (!webBrowser)
470 { 458 {
471 return; 459 return;
472 } 460 }
473 if (!urlVariant || urlVariant->vt != VT_BSTR) 461 if (!urlVariant || urlVariant->vt != VT_BSTR)
474 { 462 {
475 return; 463 return;
476 } 464 }
477 std::wstring url(urlVariant->bstrVal, SysStringLen(urlVariant->bstrVal)); 465 std::wstring url(urlVariant->bstrVal, SysStringLen(urlVariant->bstrVal));
(...skipping 24 matching lines...) Expand all
502 } 490 }
503 } 491 }
504 catch (...) 492 catch (...)
505 { 493 {
506 } 494 }
507 } 495 }
508 496
509 // Entry point 497 // Entry point
510 void STDMETHODCALLTYPE CPluginClass::OnDownloadComplete() 498 void STDMETHODCALLTYPE CPluginClass::OnDownloadComplete()
511 { 499 {
500 if (detachedInitializationFailed) return;
512 try 501 try
513 { 502 {
514 if (!m_webBrowser2) 503 if (!m_webBrowser2)
515 { 504 {
516 DEBUG_ERROR_LOG(0, 0, 0, "CPluginClass::OnDownloadComplete - Reached with m_webBrowser2 == nullptr"); 505 DEBUG_ERROR_LOG(0, 0, 0, "CPluginClass::OnDownloadComplete - Reached with m_webBrowser2 == nullptr");
517 return; 506 return;
518 } 507 }
519 DEBUG_NAVI(L"Navi::Download Complete") 508 DEBUG_NAVI(L"Navi::Download Complete")
520 m_tab->OnDownloadComplete(m_webBrowser2); 509 m_tab->OnDownloadComplete(m_webBrowser2);
521 } 510 }
522 catch (...) 511 catch (...)
523 { 512 {
524 } 513 }
525 } 514 }
526 515
527 // Entry point 516 // Entry point
528 void STDMETHODCALLTYPE CPluginClass::OnDocumentComplete(IDispatch* frameBrowserD isp, VARIANT* /*urlOrPidl*/) 517 void STDMETHODCALLTYPE CPluginClass::OnDocumentComplete(IDispatch* frameBrowserD isp, VARIANT* /*urlOrPidl*/)
529 { 518 {
519 if (detachedInitializationFailed) return;
530 try 520 try
531 { 521 {
532 DEBUG_NAVI(L"Navi::Document Complete"); 522 DEBUG_NAVI(L"Navi::Document Complete");
533 ATL::CComQIPtr<IWebBrowser2> webBrowser2 = frameBrowserDisp; 523 ATL::CComQIPtr<IWebBrowser2> webBrowser2 = frameBrowserDisp;
534 if (!webBrowser2) 524 if (!webBrowser2)
535 { 525 {
536 return; 526 return;
537 } 527 }
538 std::wstring frameSrc = GetLocationUrl(*webBrowser2); 528 std::wstring frameSrc = GetLocationUrl(*webBrowser2);
539 m_tab->OnDocumentComplete(webBrowser2, frameSrc, IsRootBrowser(webBrowser2)) ; 529 m_tab->OnDocumentComplete(webBrowser2, frameSrc, IsRootBrowser(webBrowser2)) ;
540 } 530 }
541 catch (...) 531 catch (...)
542 { 532 {
543 } 533 }
544 } 534 }
545 535
546 // Entry point 536 // Entry point
547 void STDMETHODCALLTYPE CPluginClass::OnWindowStateChanged(unsigned long flags, u nsigned long validFlagsMask) 537 void STDMETHODCALLTYPE CPluginClass::OnWindowStateChanged(unsigned long flags, u nsigned long validFlagsMask)
548 { 538 {
539 if (detachedInitializationFailed) return;
549 try 540 try
550 { 541 {
551 DEBUG_GENERAL(L"WindowStateChanged (check tab changed)"); 542 DEBUG_GENERAL(L"WindowStateChanged (check tab changed)");
552 bool newtabshown = validFlagsMask == (OLECMDIDF_WINDOWSTATE_USERVISIBLE | OL ECMDIDF_WINDOWSTATE_ENABLED) 543 bool newtabshown = validFlagsMask == (OLECMDIDF_WINDOWSTATE_USERVISIBLE | OL ECMDIDF_WINDOWSTATE_ENABLED)
553 && flags == (OLECMDIDF_WINDOWSTATE_USERVISIBLE | OLECMDIDF_WINDOWSTATE_ENA BLED); 544 && flags == (OLECMDIDF_WINDOWSTATE_USERVISIBLE | OLECMDIDF_WINDOWSTATE_ENA BLED);
554 if (newtabshown) 545 if (newtabshown)
555 { 546 {
556 std::map<DWORD,CPluginClass*>::const_iterator it = s_threadInstances.find( GetCurrentThreadId()); 547 std::map<DWORD,CPluginClass*>::const_iterator it = s_threadInstances.find( GetCurrentThreadId());
557 if (it == s_threadInstances.end()) 548 if (it == s_threadInstances.end())
558 { 549 {
(...skipping 10 matching lines...) Expand all
569 DEBUG_GENERAL(L"WindowStateChanged (check tab changed) end"); 560 DEBUG_GENERAL(L"WindowStateChanged (check tab changed) end");
570 } 561 }
571 catch (...) 562 catch (...)
572 { 563 {
573 } 564 }
574 } 565 }
575 566
576 // Entry point 567 // Entry point
577 void STDMETHODCALLTYPE CPluginClass::OnCommandStateChange(long /*command*/, VARI ANT_BOOL /*enable*/) 568 void STDMETHODCALLTYPE CPluginClass::OnCommandStateChange(long /*command*/, VARI ANT_BOOL /*enable*/)
578 { 569 {
570 if (detachedInitializationFailed) return;
579 try 571 try
580 { 572 {
581 if (m_hPaneWnd == NULL) 573 if (m_hPaneWnd == NULL)
582 { 574 {
583 CreateStatusBarPane(); 575 CreateStatusBarPane();
584 } 576 }
585 else 577 else
586 { 578 {
587 if (AdblockPlus::IE::InstalledMajorVersion() > 6) 579 if (AdblockPlus::IE::InstalledMajorVersion() > 6)
588 { 580 {
589 RECT rect; 581 RECT rect;
590 //Get the RECT for the leftmost pane (the status text pane) 582 //Get the RECT for the leftmost pane (the status text pane)
591 BOOL rectRes = ::SendMessage(m_hStatusBarWnd, SB_GETRECT, 0, (LPARAM)&re ct); 583 BOOL rectRes = ::SendMessage(m_hStatusBarWnd, SB_GETRECT, 0, (LPARAM)&re ct);
592 if (rectRes == TRUE) 584 if (rectRes == TRUE)
593 { 585 {
594 MoveWindow(m_hPaneWnd, rect.right - m_nPaneWidth, 0, m_nPaneWidth, rec t.bottom - rect.top, TRUE); 586 MoveWindow(m_hPaneWnd, rect.right - m_nPaneWidth, 0, m_nPaneWidth, rec t.bottom - rect.top, TRUE);
595 } 587 }
596 } 588 }
597 } 589 }
598 } 590 }
599 catch (...) 591 catch (...)
600 { 592 {
601 } 593 }
602 } 594 }
603 595
604 // Entry point
605 void STDMETHODCALLTYPE CPluginClass::OnOnQuit()
606 {
607 try
608 {
609 Unadvise();
610 }
611 catch (...)
612 {
613 }
614 }
615
616 bool CPluginClass::InitObject() 596 bool CPluginClass::InitObject()
617 { 597 {
618 DEBUG_GENERAL("InitObject - begin"); 598 DEBUG_GENERAL("InitObject - begin");
619 CPluginSettings* settings = CPluginSettings::GetInstance(); 599 CPluginSettings* settings = CPluginSettings::GetInstance();
620 600
621 if (!settings->GetPluginEnabled()) 601 if (!settings->GetPluginEnabled())
622 { 602 {
623 s_mimeFilter->Unregister(); 603 s_mimeFilter->Unregister();
624 } 604 }
625 605
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
994 } 974 }
995 } 975 }
996 s_criticalSectionLocal.Unlock(); 976 s_criticalSectionLocal.Unlock();
997 977
998 return tab; 978 return tab;
999 } 979 }
1000 980
1001 // Entry point 981 // Entry point
1002 STDMETHODIMP CPluginClass::QueryStatus(const GUID* pguidCmdGroup, ULONG cCmds, O LECMD prgCmds[], OLECMDTEXT* pCmdText) 982 STDMETHODIMP CPluginClass::QueryStatus(const GUID* pguidCmdGroup, ULONG cCmds, O LECMD prgCmds[], OLECMDTEXT* pCmdText)
1003 { 983 {
984 if (detachedInitializationFailed) return S_OK;
1004 try 985 try
1005 { 986 {
1006 if (cCmds == 0) return E_INVALIDARG; 987 if (cCmds == 0) return E_INVALIDARG;
1007 if (prgCmds == 0) return E_POINTER; 988 if (prgCmds == 0) return E_POINTER;
1008 989
1009 prgCmds[0].cmdf = OLECMDF_ENABLED; 990 prgCmds[0].cmdf = OLECMDF_ENABLED;
1010 } 991 }
1011 catch (...) 992 catch (...)
1012 { 993 {
1013 DEBUG_GENERAL(L"CPluginClass::QueryStatus - exception"); 994 DEBUG_GENERAL(L"CPluginClass::QueryStatus - exception");
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
1210 fmii.dwTypeData = const_cast<LPWSTR>(ctext.c_str()); 1191 fmii.dwTypeData = const_cast<LPWSTR>(ctext.c_str());
1211 fmii.cch = static_cast<UINT>(ctext.size()); 1192 fmii.cch = static_cast<UINT>(ctext.size());
1212 ::SetMenuItemInfoW(hMenu, ID_MENU_SETTINGS, FALSE, &fmii); 1193 ::SetMenuItemInfoW(hMenu, ID_MENU_SETTINGS, FALSE, &fmii);
1213 1194
1214 return true; 1195 return true;
1215 } 1196 }
1216 1197
1217 // Entry point 1198 // Entry point
1218 STDMETHODIMP CPluginClass::Exec(const GUID*, DWORD nCmdID, DWORD, VARIANTARG*, V ARIANTARG*) 1199 STDMETHODIMP CPluginClass::Exec(const GUID*, DWORD nCmdID, DWORD, VARIANTARG*, V ARIANTARG*)
1219 { 1200 {
1201 if (detachedInitializationFailed) return S_OK;
1220 try 1202 try
1221 { 1203 {
1222 HWND hBrowserWnd = GetBrowserHWND(); 1204 HWND hBrowserWnd = GetBrowserHWND();
1223 if (!hBrowserWnd) 1205 if (!hBrowserWnd)
1224 { 1206 {
1225 return E_FAIL; 1207 return E_FAIL;
1226 } 1208 }
1227 1209
1228 // Create menu 1210 // Create menu
1229 HMENU hMenu = CreatePluginMenu(m_tab->GetDocumentUrl()); 1211 HMENU hMenu = CreatePluginMenu(m_tab->GetDocumentUrl());
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after
1635 if (m_hPaneWnd == NULL) 1617 if (m_hPaneWnd == NULL)
1636 { 1618 {
1637 CreateStatusBarPane(); 1619 CreateStatusBarPane();
1638 } 1620 }
1639 if ((m_hPaneWnd != NULL) && !::InvalidateRect(m_hPaneWnd, NULL, FALSE)) 1621 if ((m_hPaneWnd != NULL) && !::InvalidateRect(m_hPaneWnd, NULL, FALSE))
1640 { 1622 {
1641 DEBUG_ERROR_LOG(::GetLastError(), PLUGIN_ERROR_UI, PLUGIN_ERROR_UI_INVALID ATE_STATUSBAR, "Class::Invalidate statusbar"); 1623 DEBUG_ERROR_LOG(::GetLastError(), PLUGIN_ERROR_UI, PLUGIN_ERROR_UI_INVALID ATE_STATUSBAR, "Class::Invalidate statusbar");
1642 } 1624 }
1643 } 1625 }
1644 1626
1645
1646 void CPluginClass::Unadvise()
1647 {
1648 if (!m_webBrowser2)
1649 {
1650 DEBUG_ERROR_LOG(0, 0, 0, "CPluginClass::Unadvise - Reached with m_webBrowser 2 == nullptr");
1651 return;
1652 }
1653 s_criticalSectionLocal.Lock();
1654 {
1655 if (m_isAdvised)
1656 {
1657 HRESULT hr = DispEventUnadvise(m_webBrowser2);
1658 if (FAILED(hr))
1659 {
1660 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_SET_SITE, PLUGIN_ERROR_SET_SITE_UNADVIS E, "Class::Unadvise - Unadvise");
1661 }
1662 m_isAdvised = false;
1663 }
1664 }
1665 s_criticalSectionLocal.Unlock();
1666 }
1667
1668 HICON CPluginClass::GetIcon(int type) 1627 HICON CPluginClass::GetIcon(int type)
1669 { 1628 {
1670 HICON icon = NULL; 1629 HICON icon = NULL;
1671 1630
1672 s_criticalSectionLocal.Lock(); 1631 s_criticalSectionLocal.Lock();
1673 { 1632 {
1674 if (!s_hIcons[type]) 1633 if (!s_hIcons[type])
1675 { 1634 {
1676 std::wstring imageToLoad = L"#"; 1635 std::wstring imageToLoad = L"#";
1677 imageToLoad += std::to_wstring(s_hIconTypes[type]); 1636 imageToLoad += std::to_wstring(s_hIconTypes[type]);
1678 s_hIcons[type] = (HICON)::LoadImage(_Module.m_hInst, imageToLoad.c_str(), IMAGE_ICON, iconWidth, iconHeight, LR_SHARED); 1637 s_hIcons[type] = (HICON)::LoadImage(_Module.m_hInst, imageToLoad.c_str(), IMAGE_ICON, iconWidth, iconHeight, LR_SHARED);
1679 if (!s_hIcons[type]) 1638 if (!s_hIcons[type])
1680 { 1639 {
1681 DEBUG_ERROR_LOG(::GetLastError(), PLUGIN_ERROR_UI, PLUGIN_ERROR_UI_LOAD_ ICON, "Class::GetIcon - LoadIcon"); 1640 DEBUG_ERROR_LOG(::GetLastError(), PLUGIN_ERROR_UI, PLUGIN_ERROR_UI_LOAD_ ICON, "Class::GetIcon - LoadIcon");
1682 } 1641 }
1683 } 1642 }
1684 1643
1685 icon = s_hIcons[type]; 1644 icon = s_hIcons[type];
1686 } 1645 }
1687 s_criticalSectionLocal.Unlock(); 1646 s_criticalSectionLocal.Unlock();
1688 1647
1689 return icon; 1648 return icon;
1690 } 1649 }
1691 1650
1692 ATOM CPluginClass::GetAtomPaneClass() 1651 ATOM CPluginClass::GetAtomPaneClass()
1693 { 1652 {
1694 return s_atomPaneClass; 1653 return s_atomPaneClass;
1695 } 1654 }
1696 1655
OLDNEW
« src/plugin/PluginClass.h ('K') | « src/plugin/PluginClass.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld