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

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

Issue 6567422169448448: Issue 119 - Switch to injecting CSS for element hiding (Closed)
Patch Set: fix injecting of CSS when plugin is enabled/disabled and rearrange variables in InjectABPCSS Created April 13, 2015, 8:52 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/plugin/PluginClass.h ('k') | src/plugin/PluginFilter.h » ('j') | 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 12 matching lines...) Expand all
23 #include "PluginFilter.h" 23 #include "PluginFilter.h"
24 #include "PluginMimeFilterClient.h" 24 #include "PluginMimeFilterClient.h"
25 #include "PluginClient.h" 25 #include "PluginClient.h"
26 #include "PluginClientFactory.h" 26 #include "PluginClientFactory.h"
27 #include "PluginMutex.h" 27 #include "PluginMutex.h"
28 #include "sddl.h" 28 #include "sddl.h"
29 #include "PluginUtil.h" 29 #include "PluginUtil.h"
30 #include "PluginUserSettings.h" 30 #include "PluginUserSettings.h"
31 #include "../shared/Utils.h" 31 #include "../shared/Utils.h"
32 #include "../shared/Dictionary.h" 32 #include "../shared/Dictionary.h"
33 #include "WebBrowserEventsListener.h"
33 #include "../shared/IE_version.h" 34 #include "../shared/IE_version.h"
34 #include <thread> 35 #include <thread>
35 #include <array> 36 #include <array>
36 37
37 #ifdef DEBUG_HIDE_EL 38 #ifdef DEBUG_HIDE_EL
38 DWORD profileTime = 0; 39 DWORD profileTime = 0;
39 #endif 40 #endif
40 41
41 typedef HANDLE (WINAPI *OPENTHEMEDATA)(HWND, LPCWSTR); 42 typedef HANDLE (WINAPI *OPENTHEMEDATA)(HWND, LPCWSTR);
42 typedef HRESULT (WINAPI *DRAWTHEMEBACKGROUND)(HANDLE, HDC, INT, INT, LPRECT, LPR ECT); 43 typedef HRESULT (WINAPI *DRAWTHEMEBACKGROUND)(HANDLE, HDC, INT, INT, LPRECT, LPR ECT);
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 } 84 }
84 85
85 int Width() const 86 int Width() const
86 { 87 {
87 return right - left; 88 return right - left;
88 } 89 }
89 }; 90 };
90 } 91 }
91 92
92 CPluginClass::CPluginClass() 93 CPluginClass::CPluginClass()
94 : m_data(std::make_shared<Data>())
93 { 95 {
94 //Use this line to debug memory leaks 96 //Use this line to debug memory leaks
95 // _CrtDumpMemoryLeaks(); 97 // _CrtDumpMemoryLeaks();
96 98
97 m_isAdvised = false; 99 m_isAdvised = false;
98 m_hTabWnd = NULL; 100 m_hTabWnd = NULL;
99 m_hStatusBarWnd = NULL; 101 m_hStatusBarWnd = NULL;
100 m_hPaneWnd = NULL; 102 m_hPaneWnd = NULL;
101 m_nPaneWidth = 0; 103 m_nPaneWidth = 0;
102 m_pWndProcStatus = NULL; 104 m_pWndProcStatus = NULL;
103 m_hTheme = NULL; 105 m_hTheme = NULL;
104 m_isInitializedOk = false; 106 m_isInitializedOk = false;
105 107
106 108
107 m_tab = new CPluginTab(this); 109 m_data->tab.reset(new CPluginTab(this));
108
109 Dictionary::Create(GetBrowserLanguage()); 110 Dictionary::Create(GetBrowserLanguage());
110 } 111 }
111 112
112 CPluginClass::~CPluginClass() 113 CPluginClass::~CPluginClass()
113 { 114 {
114 delete m_tab;
115 } 115 }
116 116
117
118 ///////////////////////////////////////////////////////////////////////////// 117 /////////////////////////////////////////////////////////////////////////////
119 // Initialization 118 // Initialization
120 119
121 HRESULT CPluginClass::FinalConstruct() 120 HRESULT CPluginClass::FinalConstruct()
122 { 121 {
123 return S_OK; 122 return S_OK;
124 } 123 }
125 124
126 void CPluginClass::FinalRelease() 125 void CPluginClass::FinalRelease()
127 { 126 {
128 s_criticalSectionBrowser.Lock(); 127 s_criticalSectionBrowser.Lock();
129 { 128 {
130 m_webBrowser2.Release(); 129 m_data.reset();
131 } 130 }
132 s_criticalSectionBrowser.Unlock(); 131 s_criticalSectionBrowser.Unlock();
133 } 132 }
134 133
135 HWND CPluginClass::GetBrowserHWND() const 134 HWND CPluginClass::GetBrowserHWND() const
136 { 135 {
137 SHANDLE_PTR hBrowserWndHandle = NULL; 136 SHANDLE_PTR hBrowserWndHandle = NULL;
138 137
139 CComQIPtr<IWebBrowser2> browser = GetBrowser(); 138 CComQIPtr<IWebBrowser2> browser = GetBrowser();
140 if (browser) 139 if (browser)
141 { 140 {
142 HRESULT hr = browser->get_HWND(&hBrowserWndHandle); 141 HRESULT hr = browser->get_HWND(&hBrowserWndHandle);
143 if (FAILED(hr)) 142 if (FAILED(hr))
144 { 143 {
145 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_UI, PLUGIN_ERROR_UI_GET_BROWSER_WINDOW, " Class::GetBrowserHWND - failed") 144 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_UI, PLUGIN_ERROR_UI_GET_BROWSER_WINDOW, " Class::GetBrowserHWND - failed")
146 } 145 }
147 } 146 }
148 147
149 return (HWND)hBrowserWndHandle; 148 return (HWND)hBrowserWndHandle;
150 } 149 }
151 150
152 151
153 CComQIPtr<IWebBrowser2> CPluginClass::GetBrowser() const 152 CComQIPtr<IWebBrowser2> CPluginClass::GetBrowser() const
154 { 153 {
155 CComQIPtr<IWebBrowser2> browser; 154 CComQIPtr<IWebBrowser2> browser;
156 155
157 s_criticalSectionBrowser.Lock(); 156 s_criticalSectionBrowser.Lock();
158 { 157 {
159 browser = m_webBrowser2; 158 browser = m_data->webBrowser2;
160 } 159 }
161 s_criticalSectionBrowser.Unlock(); 160 s_criticalSectionBrowser.Unlock();
162 161
163 return browser; 162 return browser;
164 } 163 }
165 164
166 165
167 CComQIPtr<IWebBrowser2> CPluginClass::GetAsyncBrowser() 166 CComQIPtr<IWebBrowser2> CPluginClass::GetAsyncBrowser()
168 { 167 {
169 CComQIPtr<IWebBrowser2> browser; 168 CComQIPtr<IWebBrowser2> browser;
(...skipping 15 matching lines...) Expand all
185 { 184 {
186 CComBSTR bstrURL; 185 CComBSTR bstrURL;
187 if (SUCCEEDED(browser->get_LocationURL(&bstrURL)) && bstrURL) 186 if (SUCCEEDED(browser->get_LocationURL(&bstrURL)) && bstrURL)
188 { 187 {
189 url = std::wstring(bstrURL, SysStringLen(bstrURL)); 188 url = std::wstring(bstrURL, SysStringLen(bstrURL));
190 UnescapeUrl(url); 189 UnescapeUrl(url);
191 } 190 }
192 } 191 }
193 else 192 else
194 { 193 {
195 url = m_tab->GetDocumentUrl(); 194 url = m_data->tab->GetDocumentUrl();
196 } 195 }
197 return url; 196 return url;
198 } 197 }
199 198
200 DWORD WINAPI CPluginClass::StartInitObject(LPVOID thisPtr) 199 DWORD WINAPI CPluginClass::StartInitObject(LPVOID thisPtr)
201 { 200 {
202 if (thisPtr == NULL) 201 if (thisPtr == NULL)
203 return 0; 202 return 0;
204 if (!((CPluginClass*)thisPtr)->InitObject()) 203 if (!((CPluginClass*)thisPtr)->InitObject())
205 { 204 {
(...skipping 23 matching lines...) Expand all
229 DEBUG_GENERAL(L"========================================================== ======================\nNEW TAB UI\n============================================ ====================================") 228 DEBUG_GENERAL(L"========================================================== ======================\nNEW TAB UI\n============================================ ====================================")
230 229
231 HRESULT hr = ::CoInitialize(NULL); 230 HRESULT hr = ::CoInitialize(NULL);
232 if (FAILED(hr)) 231 if (FAILED(hr))
233 { 232 {
234 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_SET_SITE, PLUGIN_ERROR_SET_SITE_COINIT, "Class::SetSite - CoInitialize"); 233 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_SET_SITE, PLUGIN_ERROR_SET_SITE_COINIT, "Class::SetSite - CoInitialize");
235 } 234 }
236 235
237 s_criticalSectionBrowser.Lock(); 236 s_criticalSectionBrowser.Lock();
238 { 237 {
239 m_webBrowser2 = unknownSite; 238 m_data->webBrowser2 = ATL::CComQIPtr<IWebBrowser2>(unknownSite);
240 } 239 }
241 s_criticalSectionBrowser.Unlock(); 240 s_criticalSectionBrowser.Unlock();
242 241
243 //register the mimefilter 242 //register the mimefilter
244 //and only mimefilter 243 //and only mimefilter
245 //on some few computers the mimefilter does not get properly registered wh en it is done on another thread 244 //on some few computers the mimefilter does not get properly registered wh en it is done on another thread
246 245
247 s_criticalSectionLocal.Lock(); 246 s_criticalSectionLocal.Lock();
248 { 247 {
249 // Always register on startup, then check if we need to unregister in a separate thread 248 // Always register on startup, then check if we need to unregister in a separate thread
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 { 323 {
325 // TODO: Explicitly releasing a resource when a container becomes empt y looks like a job better suited for shared_ptr 324 // TODO: Explicitly releasing a resource when a container becomes empt y looks like a job better suited for shared_ptr
326 CPluginClientFactory::ReleaseMimeFilterClientInstance(); 325 CPluginClientFactory::ReleaseMimeFilterClientInstance();
327 } 326 }
328 } 327 }
329 s_criticalSectionLocal.Unlock(); 328 s_criticalSectionLocal.Unlock();
330 329
331 // Release browser interface 330 // Release browser interface
332 s_criticalSectionBrowser.Lock(); 331 s_criticalSectionBrowser.Lock();
333 { 332 {
334 m_webBrowser2.Release(); 333 m_data->webBrowser2.Release();
335 } 334 }
336 s_criticalSectionBrowser.Unlock(); 335 s_criticalSectionBrowser.Unlock();
337 336
338 DEBUG_GENERAL("=========================================================== =====================\nNEW TAB UI - END\n======================================= =========================================") 337 DEBUG_GENERAL("=========================================================== =====================\nNEW TAB UI - END\n======================================= =========================================")
339 338
340 ::CoUninitialize(); 339 ::CoUninitialize();
341 } 340 }
342 341
343 IObjectWithSiteImpl<CPluginClass>::SetSite(unknownSite); 342 IObjectWithSiteImpl<CPluginClass>::SetSite(unknownSite);
344 } 343 }
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
477 if (!webBrowser) 476 if (!webBrowser)
478 { 477 {
479 return; 478 return;
480 } 479 }
481 if (!urlVariant || urlVariant->vt != VT_BSTR) 480 if (!urlVariant || urlVariant->vt != VT_BSTR)
482 { 481 {
483 return; 482 return;
484 } 483 }
485 std::wstring url(urlVariant->bstrVal, SysStringLen(urlVariant->bstrVal)); 484 std::wstring url(urlVariant->bstrVal, SysStringLen(urlVariant->bstrVal));
486 UnescapeUrl(url); 485 UnescapeUrl(url);
487 486 EnsureWebBrowserConnected(webBrowser);
488 //Register a mime filter if it's not registered yet 487 //Register a mime filter if it's not registered yet
489 if (s_mimeFilter == nullptr) 488 if (s_mimeFilter == nullptr)
490 { 489 {
491 s_mimeFilter = CPluginClientFactory::GetMimeFilterClientInstance(); 490 s_mimeFilter = CPluginClientFactory::GetMimeFilterClientInstance();
492 } 491 }
493 // If webbrowser2 is equal to top level browser (as set in SetSite), we are 492 // If webbrowser2 is equal to top level browser (as set in SetSite), we are
494 // navigating new page 493 // navigating new page
495 CPluginClient* client = CPluginClient::GetInstance(); 494 CPluginClient* client = CPluginClient::GetInstance();
496 if (url.find(L"javascript") == 0) 495 if (url.find(L"javascript") == 0)
497 { 496 {
498 } 497 }
499 else if (GetBrowser().IsEqualObject(webBrowser)) 498 else if (GetBrowser().IsEqualObject(webBrowser))
500 { 499 {
501 m_tab->OnNavigate(url); 500 m_data->tab->OnNavigate(url);
502 DEBUG_GENERAL( 501 DEBUG_GENERAL(
503 L"======================================================================== ========\n" 502 L"======================================================================== ========\n"
504 L"Begin main navigation url:" + url + L"\n" 503 L"Begin main navigation url:" + url + L"\n"
505 L"======================================================================== ========") 504 L"======================================================================== ========")
506 505
507 #ifdef ENABLE_DEBUG_RESULT 506 #ifdef ENABLE_DEBUG_RESULT
508 CPluginDebug::DebugResultDomain(url); 507 CPluginDebug::DebugResultDomain(url);
509 #endif 508 #endif
510 UpdateStatusBar(); 509 UpdateStatusBar();
511 } 510 }
512 else 511 else
513 { 512 {
514 DEBUG_NAVI(L"Navi::Begin navigation url:" + url) 513 DEBUG_NAVI(L"Navi::Begin navigation url:" + url)
515 m_tab->CacheFrame(url); 514 m_data->tab->CacheFrame(url);
516 } 515 }
517 } 516 }
518 catch (...) 517 catch (...)
519 { 518 {
520 } 519 }
521 } 520 }
522 521
523 // Entry point 522 // Entry point
524 void STDMETHODCALLTYPE CPluginClass::OnDownloadComplete() 523 void STDMETHODCALLTYPE CPluginClass::OnDownloadComplete()
525 { 524 {
526 try 525 try
527 { 526 {
528 DEBUG_NAVI(L"Navi::Download Complete") 527 DEBUG_NAVI(L"Navi::Download Complete")
529 ATL::CComPtr<IWebBrowser2> browser = GetBrowser(); 528 ATL::CComPtr<IWebBrowser2> browser = GetBrowser();
530 if (browser) 529 if (browser)
531 { 530 {
532 m_tab->OnDownloadComplete(browser); 531 m_data->tab->OnDownloadComplete(browser);
533 } 532 }
534 } 533 }
535 catch (...) 534 catch (...)
536 { 535 {
537 }
538 }
539
540 // Entry point
541 void STDMETHODCALLTYPE CPluginClass::OnDocumentComplete(IDispatch* frameBrowserD isp, VARIANT* /*urlOrPidl*/)
542 {
543 try
544 {
545 DEBUG_NAVI(L"Navi::Document Complete");
546 ATL::CComQIPtr<IWebBrowser2> webBrowser2 = frameBrowserDisp;
547 if (!webBrowser2)
548 {
549 return;
550 }
551 std::wstring frameSrc = GetLocationUrl(*webBrowser2);
552 UnescapeUrl(frameSrc);
553 bool isRootPageBrowser = GetBrowser().IsEqualObject(webBrowser2);
554 m_tab->OnDocumentComplete(webBrowser2, frameSrc, isRootPageBrowser);
555 }
556 catch (...)
557 {
558 } 536 }
559 } 537 }
560 538
561 // Entry point 539 // Entry point
562 void STDMETHODCALLTYPE CPluginClass::OnWindowStateChanged(unsigned long flags, u nsigned long validFlagsMask) 540 void STDMETHODCALLTYPE CPluginClass::OnWindowStateChanged(unsigned long flags, u nsigned long validFlagsMask)
563 { 541 {
564 try 542 try
565 { 543 {
566 DEBUG_GENERAL(L"WindowStateChanged (check tab changed)"); 544 DEBUG_GENERAL(L"WindowStateChanged (check tab changed)");
567 bool newtabshown = validFlagsMask == (OLECMDIDF_WINDOWSTATE_USERVISIBLE | OL ECMDIDF_WINDOWSTATE_ENABLED) 545 bool newtabshown = validFlagsMask == (OLECMDIDF_WINDOWSTATE_USERVISIBLE | OL ECMDIDF_WINDOWSTATE_ENABLED)
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after
980 } 958 }
981 } 959 }
982 } 960 }
983 s_criticalSectionLocal.Unlock(); 961 s_criticalSectionLocal.Unlock();
984 962
985 return result; 963 return result;
986 } 964 }
987 965
988 CPluginTab* CPluginClass::GetTab() 966 CPluginTab* CPluginClass::GetTab()
989 { 967 {
990 return m_tab; 968 return m_data->tab.get();
991 } 969 }
992 970
993 CPluginTab* CPluginClass::GetTab(DWORD dwThreadId) 971 CPluginTab* CPluginClass::GetTab(DWORD dwThreadId)
994 { 972 {
995 CPluginTab* tab = NULL; 973 CPluginTab* tab = NULL;
996 974
997 s_criticalSectionLocal.Lock(); 975 s_criticalSectionLocal.Lock();
998 { 976 {
999 std::map<DWORD,CPluginClass*>::const_iterator it = s_threadInstances.find(dw ThreadId); 977 std::map<DWORD,CPluginClass*>::const_iterator it = s_threadInstances.find(dw ThreadId);
1000 if (it != s_threadInstances.end()) 978 if (it != s_threadInstances.end())
1001 { 979 {
1002 tab = it->second->m_tab; 980 tab = it->second->m_data->tab.get();
1003 } 981 }
1004 } 982 }
1005 s_criticalSectionLocal.Unlock(); 983 s_criticalSectionLocal.Unlock();
1006 984
1007 return tab; 985 return tab;
1008 } 986 }
1009 987
1010 988
1011 STDMETHODIMP CPluginClass::QueryStatus(const GUID* pguidCmdGroup, ULONG cCmds, O LECMD prgCmds[], OLECMDTEXT* pCmdText) 989 STDMETHODIMP CPluginClass::QueryStatus(const GUID* pguidCmdGroup, ULONG cCmds, O LECMD prgCmds[], OLECMDTEXT* pCmdText)
1012 { 990 {
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
1221 1199
1222 STDMETHODIMP CPluginClass::Exec(const GUID*, DWORD nCmdID, DWORD, VARIANTARG*, V ARIANTARG*) 1200 STDMETHODIMP CPluginClass::Exec(const GUID*, DWORD nCmdID, DWORD, VARIANTARG*, V ARIANTARG*)
1223 { 1201 {
1224 HWND hBrowserWnd = GetBrowserHWND(); 1202 HWND hBrowserWnd = GetBrowserHWND();
1225 if (!hBrowserWnd) 1203 if (!hBrowserWnd)
1226 { 1204 {
1227 return E_FAIL; 1205 return E_FAIL;
1228 } 1206 }
1229 1207
1230 // Create menu 1208 // Create menu
1231 HMENU hMenu = CreatePluginMenu(m_tab->GetDocumentUrl()); 1209 HMENU hMenu = CreatePluginMenu(m_data->tab->GetDocumentUrl());
1232 if (!hMenu) 1210 if (!hMenu)
1233 { 1211 {
1234 return E_FAIL; 1212 return E_FAIL;
1235 } 1213 }
1236 1214
1237 // Check if button in toolbar was pressed 1215 // Check if button in toolbar was pressed
1238 int nIDCommand = -1; 1216 int nIDCommand = -1;
1239 BOOL bRightAlign = FALSE; 1217 BOOL bRightAlign = FALSE;
1240 1218
1241 POINT pt; 1219 POINT pt;
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after
1619 if (m_hPaneWnd == NULL) 1597 if (m_hPaneWnd == NULL)
1620 { 1598 {
1621 CreateStatusBarPane(); 1599 CreateStatusBarPane();
1622 } 1600 }
1623 if ((m_hPaneWnd != NULL) && !::InvalidateRect(m_hPaneWnd, NULL, FALSE)) 1601 if ((m_hPaneWnd != NULL) && !::InvalidateRect(m_hPaneWnd, NULL, FALSE))
1624 { 1602 {
1625 DEBUG_ERROR_LOG(::GetLastError(), PLUGIN_ERROR_UI, PLUGIN_ERROR_UI_INVALID ATE_STATUSBAR, "Class::Invalidate statusbar"); 1603 DEBUG_ERROR_LOG(::GetLastError(), PLUGIN_ERROR_UI, PLUGIN_ERROR_UI_INVALID ATE_STATUSBAR, "Class::Invalidate statusbar");
1626 } 1604 }
1627 } 1605 }
1628 1606
1629
1630 void CPluginClass::Unadvise() 1607 void CPluginClass::Unadvise()
1631 { 1608 {
1632 s_criticalSectionLocal.Lock(); 1609 s_criticalSectionLocal.Lock();
1633 { 1610 {
1634 if (m_isAdvised) 1611 if (m_isAdvised)
1635 { 1612 {
1636 HRESULT hr = DispEventUnadvise(GetBrowser()); 1613 HRESULT hr = DispEventUnadvise(GetBrowser());
1637 if (FAILED(hr)) 1614 if (FAILED(hr))
1638 { 1615 {
1639 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_SET_SITE, PLUGIN_ERROR_SET_SITE_UNADVIS E, "Class::Unadvise - Unadvise"); 1616 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_SET_SITE, PLUGIN_ERROR_SET_SITE_UNADVIS E, "Class::Unadvise - Unadvise");
1640 } 1617 }
1641 m_isAdvised = false; 1618 m_isAdvised = false;
1642 } 1619 }
1643 } 1620 }
1644 s_criticalSectionLocal.Unlock(); 1621 s_criticalSectionLocal.Unlock();
1645 } 1622 }
1646 1623
1624 void CPluginClass::EnsureWebBrowserConnected(const ATL::CComPtr<IWebBrowser2>& w ebBrowser)
1625 {
1626 auto it = m_data->connectedWebBrowsersCache.find(webBrowser);
1627 if (it != m_data->connectedWebBrowsersCache.end())
1628 {
1629 return;
1630 }
1631 ATL::CComObject<WebBrowserEventsListener>* listenerImpl = nullptr;
1632 if (FAILED(ATL::CComObject<WebBrowserEventsListener>::CreateInstance(&listener Impl)))
1633 {
1634 return;
1635 }
1636 ATL::CComPtr<IUnknown> listenerRefCounterGuard(listenerImpl->GetUnknown());
1637 std::weak_ptr<Data> dataForCapturing = m_data;
1638 auto onListenerDestroy = [webBrowser, dataForCapturing]
1639 {
1640 if (auto data = dataForCapturing.lock())
1641 {
1642 data->connectedWebBrowsersCache.erase(webBrowser);
1643 }
1644 };
1645 if (FAILED(listenerImpl->Init(webBrowser, onListenerDestroy)))
1646 {
1647 return;
1648 }
1649 listenerImpl->reloaded = [webBrowser, dataForCapturing]
1650 {
1651 if (auto data = dataForCapturing.lock())
1652 {
1653 auto frameSrc = GetLocationUrl(*webBrowser);
1654 UnescapeUrl(frameSrc);
1655 data->tab->OnDocumentComplete(webBrowser, frameSrc, data->webBrowser2.IsEq ualObject(webBrowser));
1656 }
1657 };
1658 m_data->connectedWebBrowsersCache.emplace(webBrowser, listenerImpl);
1659 }
1660
1647 HICON CPluginClass::GetIcon(int type) 1661 HICON CPluginClass::GetIcon(int type)
1648 { 1662 {
1649 HICON icon = NULL; 1663 HICON icon = NULL;
1650 1664
1651 s_criticalSectionLocal.Lock(); 1665 s_criticalSectionLocal.Lock();
1652 { 1666 {
1653 if (!s_hIcons[type]) 1667 if (!s_hIcons[type])
1654 { 1668 {
1655 std::wstring imageToLoad = L"#"; 1669 std::wstring imageToLoad = L"#";
1656 imageToLoad += std::to_wstring(s_hIconTypes[type]); 1670 imageToLoad += std::to_wstring(s_hIconTypes[type]);
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
1733 s_criticalSectionLocal.Unlock(); 1747 s_criticalSectionLocal.Unlock();
1734 1748
1735 } 1749 }
1736 } 1750 }
1737 } 1751 }
1738 1752
1739 hTabWnd = ::GetWindow(hTabWnd, GW_HWNDNEXT); 1753 hTabWnd = ::GetWindow(hTabWnd, GW_HWNDNEXT);
1740 } 1754 }
1741 return hTabWnd; 1755 return hTabWnd;
1742 } 1756 }
OLDNEW
« no previous file with comments | « src/plugin/PluginClass.h ('k') | src/plugin/PluginFilter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld