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 Created Jan. 5, 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 event last, after everything is ready to go
sergei 2016/01/06 08:41:57 This comment is confusing because not everything i
Eric 2016/01/07 16:24:47 Reworded.
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;
sergei 2016/01/06 08:41:57 Basically all these checks in each method are indi
sergei 2016/01/06 08:41:57 it would be better to use some method `bool IsInit
Eric 2016/01/07 16:24:47 Something is definitely wrong with the design. It'
Eric 2016/01/07 16:24:48 I don't disagree in principle, but that change is
sergei 2016/02/04 13:45:49 Acknowledged.
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 981
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;
1004 if (cCmds == 0) return E_INVALIDARG; 985 if (cCmds == 0) return E_INVALIDARG;
1005 if (prgCmds == 0) return E_POINTER; 986 if (prgCmds == 0) return E_POINTER;
1006 987
1007 prgCmds[0].cmdf = OLECMDF_ENABLED; 988 prgCmds[0].cmdf = OLECMDF_ENABLED;
1008 989
1009 return S_OK; 990 return S_OK;
1010 } 991 }
1011 992
1012 HMENU CPluginClass::CreatePluginMenu(const std::wstring& url) 993 HMENU CPluginClass::CreatePluginMenu(const std::wstring& url)
1013 { 994 {
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
1203 fmii.dwTypeData = const_cast<LPWSTR>(ctext.c_str()); 1184 fmii.dwTypeData = const_cast<LPWSTR>(ctext.c_str());
1204 fmii.cch = static_cast<UINT>(ctext.size()); 1185 fmii.cch = static_cast<UINT>(ctext.size());
1205 ::SetMenuItemInfoW(hMenu, ID_MENU_SETTINGS, FALSE, &fmii); 1186 ::SetMenuItemInfoW(hMenu, ID_MENU_SETTINGS, FALSE, &fmii);
1206 1187
1207 return true; 1188 return true;
1208 } 1189 }
1209 1190
1210 1191
1211 STDMETHODIMP CPluginClass::Exec(const GUID*, DWORD nCmdID, DWORD, VARIANTARG*, V ARIANTARG*) 1192 STDMETHODIMP CPluginClass::Exec(const GUID*, DWORD nCmdID, DWORD, VARIANTARG*, V ARIANTARG*)
1212 { 1193 {
1194 if (detachedInitializationFailed) return;
1213 HWND hBrowserWnd = GetBrowserHWND(); 1195 HWND hBrowserWnd = GetBrowserHWND();
1214 if (!hBrowserWnd) 1196 if (!hBrowserWnd)
1215 { 1197 {
1216 return E_FAIL; 1198 return E_FAIL;
1217 } 1199 }
1218 1200
1219 // Create menu 1201 // Create menu
1220 HMENU hMenu = CreatePluginMenu(m_tab->GetDocumentUrl()); 1202 HMENU hMenu = CreatePluginMenu(m_tab->GetDocumentUrl());
1221 if (!hMenu) 1203 if (!hMenu)
1222 { 1204 {
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after
1608 if (m_hPaneWnd == NULL) 1590 if (m_hPaneWnd == NULL)
1609 { 1591 {
1610 CreateStatusBarPane(); 1592 CreateStatusBarPane();
1611 } 1593 }
1612 if ((m_hPaneWnd != NULL) && !::InvalidateRect(m_hPaneWnd, NULL, FALSE)) 1594 if ((m_hPaneWnd != NULL) && !::InvalidateRect(m_hPaneWnd, NULL, FALSE))
1613 { 1595 {
1614 DEBUG_ERROR_LOG(::GetLastError(), PLUGIN_ERROR_UI, PLUGIN_ERROR_UI_INVALID ATE_STATUSBAR, "Class::Invalidate statusbar"); 1596 DEBUG_ERROR_LOG(::GetLastError(), PLUGIN_ERROR_UI, PLUGIN_ERROR_UI_INVALID ATE_STATUSBAR, "Class::Invalidate statusbar");
1615 } 1597 }
1616 } 1598 }
1617 1599
1618
1619 void CPluginClass::Unadvise()
1620 {
1621 if (!m_webBrowser2)
1622 {
1623 DEBUG_ERROR_LOG(0, 0, 0, "CPluginClass::Unadvise - Reached with m_webBrowser 2 == nullptr");
1624 return;
1625 }
1626 s_criticalSectionLocal.Lock();
1627 {
1628 if (m_isAdvised)
1629 {
1630 HRESULT hr = DispEventUnadvise(m_webBrowser2);
1631 if (FAILED(hr))
1632 {
1633 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_SET_SITE, PLUGIN_ERROR_SET_SITE_UNADVIS E, "Class::Unadvise - Unadvise");
1634 }
1635 m_isAdvised = false;
1636 }
1637 }
1638 s_criticalSectionLocal.Unlock();
1639 }
1640
1641 HICON CPluginClass::GetIcon(int type) 1600 HICON CPluginClass::GetIcon(int type)
1642 { 1601 {
1643 HICON icon = NULL; 1602 HICON icon = NULL;
1644 1603
1645 s_criticalSectionLocal.Lock(); 1604 s_criticalSectionLocal.Lock();
1646 { 1605 {
1647 if (!s_hIcons[type]) 1606 if (!s_hIcons[type])
1648 { 1607 {
1649 std::wstring imageToLoad = L"#"; 1608 std::wstring imageToLoad = L"#";
1650 imageToLoad += std::to_wstring(s_hIconTypes[type]); 1609 imageToLoad += std::to_wstring(s_hIconTypes[type]);
1651 s_hIcons[type] = (HICON)::LoadImage(_Module.m_hInst, imageToLoad.c_str(), IMAGE_ICON, iconWidth, iconHeight, LR_SHARED); 1610 s_hIcons[type] = (HICON)::LoadImage(_Module.m_hInst, imageToLoad.c_str(), IMAGE_ICON, iconWidth, iconHeight, LR_SHARED);
1652 if (!s_hIcons[type]) 1611 if (!s_hIcons[type])
1653 { 1612 {
1654 DEBUG_ERROR_LOG(::GetLastError(), PLUGIN_ERROR_UI, PLUGIN_ERROR_UI_LOAD_ ICON, "Class::GetIcon - LoadIcon"); 1613 DEBUG_ERROR_LOG(::GetLastError(), PLUGIN_ERROR_UI, PLUGIN_ERROR_UI_LOAD_ ICON, "Class::GetIcon - LoadIcon");
1655 } 1614 }
1656 } 1615 }
1657 1616
1658 icon = s_hIcons[type]; 1617 icon = s_hIcons[type];
1659 } 1618 }
1660 s_criticalSectionLocal.Unlock(); 1619 s_criticalSectionLocal.Unlock();
1661 1620
1662 return icon; 1621 return icon;
1663 } 1622 }
1664 1623
1665 ATOM CPluginClass::GetAtomPaneClass() 1624 ATOM CPluginClass::GetAtomPaneClass()
1666 { 1625 {
1667 return s_atomPaneClass; 1626 return s_atomPaneClass;
1668 } 1627 }
1669 1628
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