Left: | ||
Right: |
LEFT | RIGHT |
---|---|
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 |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 * GNU General Public License for more details. | 12 * GNU General Public License for more details. |
13 * | 13 * |
14 * You should have received a copy of the GNU General Public License | 14 * You should have received a copy of the GNU General Public License |
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. | 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
16 */ | 16 */ |
17 | 17 |
18 #include "PluginStdAfx.h" | 18 #include "PluginStdAfx.h" |
19 | 19 |
20 #include "PluginClass.h" | 20 #include "PluginClass.h" |
21 #include "PluginSettings.h" | 21 #include "PluginSettings.h" |
22 #include "PluginSystem.h" | 22 #include "PluginSystem.h" |
23 #include "PluginFilter.h" | 23 #include "PluginFilter.h" |
24 #include "PluginMimeFilterClient.h" | 24 #include "PluginMimeFilterClient.h" |
25 #include "PluginClient.h" | 25 #include "AdblockPlusClient.h" |
26 #include "PluginClientBase.h" | |
26 #include "PluginClientFactory.h" | 27 #include "PluginClientFactory.h" |
27 #include "PluginMutex.h" | |
28 #include "sddl.h" | |
29 #include "PluginUtil.h" | 28 #include "PluginUtil.h" |
30 #include "PluginUserSettings.h" | |
31 #include "../shared/Utils.h" | 29 #include "../shared/Utils.h" |
32 #include "../shared/Dictionary.h" | 30 #include "../shared/Dictionary.h" |
33 #include "../shared/IE_version.h" | 31 #include "IeVersion.h" |
32 #include "../shared/Version.h" | |
34 #include <thread> | 33 #include <thread> |
35 #include <array> | 34 #include <array> |
36 | 35 |
37 #ifdef DEBUG_HIDE_EL | 36 #ifdef DEBUG_HIDE_EL |
38 DWORD profileTime = 0; | 37 DWORD profileTime = 0; |
39 #endif | 38 #endif |
39 | |
40 extern CComModule _Module; | |
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); |
43 typedef HRESULT (WINAPI *CLOSETHEMEDATA)(HANDLE); | 44 typedef HRESULT (WINAPI *CLOSETHEMEDATA)(HANDLE); |
44 | 45 |
45 HICON CPluginClass::s_hIcons[ICON_MAX] = { NULL, NULL, NULL }; | 46 HICON CPluginClass::s_hIcons[ICON_MAX] = { NULL, NULL, NULL }; |
46 DWORD CPluginClass::s_hIconTypes[ICON_MAX] = { IDI_ICON_DISABLED, IDI_ICON_ENABL ED, IDI_ICON_DEACTIVATED }; | 47 DWORD CPluginClass::s_hIconTypes[ICON_MAX] = { IDI_ICON_DISABLED, IDI_ICON_ENABL ED, IDI_ICON_DEACTIVATED }; |
47 uint32_t iconHeight = 32; | 48 uint32_t iconHeight = 32; |
48 uint32_t iconWidth = 32; | 49 uint32_t iconWidth = 32; |
49 | 50 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
87 return right - left; | 88 return right - left; |
88 } | 89 } |
89 }; | 90 }; |
90 } | 91 } |
91 | 92 |
92 CPluginClass::CPluginClass() | 93 CPluginClass::CPluginClass() |
93 { | 94 { |
94 //Use this line to debug memory leaks | 95 //Use this line to debug memory leaks |
95 // _CrtDumpMemoryLeaks(); | 96 // _CrtDumpMemoryLeaks(); |
96 | 97 |
97 m_isAdviced = false; | 98 m_isAdvised = false; |
98 m_nConnectionID = 0; | |
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 17 matching lines...) Expand all Loading... | |
126 | 126 |
127 void CPluginClass::FinalRelease() | 127 void CPluginClass::FinalRelease() |
128 { | 128 { |
129 s_criticalSectionBrowser.Lock(); | 129 s_criticalSectionBrowser.Lock(); |
130 { | 130 { |
131 m_webBrowser2.Release(); | 131 m_webBrowser2.Release(); |
132 } | 132 } |
133 s_criticalSectionBrowser.Unlock(); | 133 s_criticalSectionBrowser.Unlock(); |
134 } | 134 } |
135 | 135 |
136 | |
137 // This method tries to get a 'connection point' from the stored browser, which can be | |
138 // used to attach or detach from the stream of browser events | |
139 CComPtr<IConnectionPoint> CPluginClass::GetConnectionPoint() | |
140 { | |
141 CComQIPtr<IConnectionPointContainer, &IID_IConnectionPointContainer> pContaine r(GetBrowser()); | |
142 if (!pContainer) | |
143 { | |
144 return NULL; | |
145 } | |
146 | |
147 CComPtr<IConnectionPoint> pPoint; | |
148 HRESULT hr = pContainer->FindConnectionPoint(DIID_DWebBrowserEvents2, &pPoint) ; | |
149 if (FAILED(hr)) | |
150 { | |
151 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_SET_SITE, PLUGIN_ERROR_SET_SITE_FIND_CONNEC TION_POINT, "Class::GetConnectionPoint - FindConnectionPoint") | |
152 return NULL; | |
153 } | |
154 | |
155 return pPoint; | |
156 } | |
157 | |
158 HWND CPluginClass::GetBrowserHWND() const | 136 HWND CPluginClass::GetBrowserHWND() const |
159 { | 137 { |
160 SHANDLE_PTR hBrowserWndHandle = NULL; | 138 SHANDLE_PTR hBrowserWndHandle = NULL; |
161 | 139 |
162 CComQIPtr<IWebBrowser2> browser = GetBrowser(); | 140 CComQIPtr<IWebBrowser2> browser = GetBrowser(); |
163 if (browser) | 141 if (browser) |
164 { | 142 { |
165 HRESULT hr = browser->get_HWND(&hBrowserWndHandle); | 143 HRESULT hr = browser->get_HWND(&hBrowserWndHandle); |
166 if (FAILED(hr)) | 144 if (FAILED(hr)) |
167 { | 145 { |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
217 { | 195 { |
218 url = m_tab->GetDocumentUrl(); | 196 url = m_tab->GetDocumentUrl(); |
219 } | 197 } |
220 return url; | 198 return url; |
221 } | 199 } |
222 | 200 |
223 DWORD WINAPI CPluginClass::StartInitObject(LPVOID thisPtr) | 201 DWORD WINAPI CPluginClass::StartInitObject(LPVOID thisPtr) |
224 { | 202 { |
225 if (thisPtr == NULL) | 203 if (thisPtr == NULL) |
226 return 0; | 204 return 0; |
227 if (!((CPluginClass*)thisPtr)->InitObject(true)) | 205 if (!((CPluginClass*)thisPtr)->InitObject()) |
228 { | 206 { |
229 ((CPluginClass*)thisPtr)->Unadvice(); | 207 ((CPluginClass*)thisPtr)->Unadvise(); |
230 } | 208 } |
231 | 209 |
232 return 0; | 210 return 0; |
233 } | 211 } |
234 | 212 |
235 | 213 /* |
236 | 214 * IE calls this when it creates a new browser window or tab, immediately after it also |
237 // This gets called when a new browser window is created (which also triggers th e | 215 * creates the object. The argument 'unknownSite' in is the OLE "site" of the ob ject, |
238 // creation of this object). The pointer passed in should be to a IWebBrowser2 | 216 * which is an IWebBrowser2 interface associated with the window/tab. |
239 // interface that represents the browser for the window. | 217 * |
240 // it is also called when a tab is closed, this unknownSite will be null | 218 * IE also ordinarily calls this again when its window/tab is closed, in which c ase |
241 // so we should handle that it is called this way several times during a session | 219 * 'unknownSite' will be null. Extraordinarily, this is sometimes _not_ called w hen IE |
220 * is shutting down. Thus 'SetSite(nullptr)' has some similarities with a destru ctor, | |
221 * but it is not a proper substitute for one. | |
222 */ | |
242 STDMETHODIMP CPluginClass::SetSite(IUnknown* unknownSite) | 223 STDMETHODIMP CPluginClass::SetSite(IUnknown* unknownSite) |
243 { | 224 { |
244 CPluginSettings* settings = CPluginSettings::GetInstance(); | 225 try |
245 | 226 { |
246 MULTIPLE_VERSIONS_CHECK(); | 227 if (unknownSite) |
247 | 228 { |
248 if (unknownSite) | 229 |
249 { | 230 DEBUG_GENERAL(L"========================================================== ======================\nNEW TAB UI\n============================================ ====================================") |
250 | 231 |
251 DEBUG_GENERAL(L"============================================================ ====================\nNEW TAB UI\n============================================== ==================================") | 232 HRESULT hr = ::CoInitialize(NULL); |
252 | 233 if (FAILED(hr)) |
253 HRESULT hr = ::CoInitialize(NULL); | 234 { |
254 if (FAILED(hr)) | 235 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_SET_SITE, PLUGIN_ERROR_SET_SITE_COINIT, "Class::SetSite - CoInitialize"); |
255 { | 236 } |
256 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_SET_SITE, PLUGIN_ERROR_SET_SITE_COINIT, " Class::SetSite - CoInitialize"); | 237 |
257 } | 238 s_criticalSectionBrowser.Lock(); |
258 | 239 { |
259 s_criticalSectionBrowser.Lock(); | 240 m_webBrowser2 = unknownSite; |
260 { | 241 } |
261 m_webBrowser2 = unknownSite; | 242 s_criticalSectionBrowser.Unlock(); |
262 } | 243 |
263 s_criticalSectionBrowser.Unlock(); | 244 //register the mimefilter |
264 | 245 //and only mimefilter |
265 //register the mimefilter | 246 //on some few computers the mimefilter does not get properly registered wh en it is done on another thread |
266 //and only mimefilter | 247 |
267 //on some few computers the mimefilter does not get properly registered when it is done on another thread | 248 s_criticalSectionLocal.Lock(); |
268 | 249 { |
269 s_criticalSectionLocal.Lock(); | 250 // Always register on startup, then check if we need to unregister in a separate thread |
270 { | 251 s_mimeFilter = CPluginClientFactory::GetMimeFilterClientInstance(); |
271 // Always register on startup, then check if we need to unregister in a se parate thread | 252 s_asyncWebBrowser2 = unknownSite; |
272 s_mimeFilter = CPluginClientFactory::GetMimeFilterClientInstance(); | 253 s_instances.insert(this); |
273 s_asyncWebBrowser2 = unknownSite; | 254 } |
274 s_instances.insert(this); | 255 s_criticalSectionLocal.Unlock(); |
275 } | 256 |
276 s_criticalSectionLocal.Unlock(); | 257 try |
277 | 258 { |
278 try | 259 auto webBrowser = GetBrowser(); |
279 { | 260 if (webBrowser) |
280 // Check if loaded as BHO | 261 { |
281 if (GetBrowser()) | 262 DEBUG_GENERAL("Loaded as BHO"); |
282 { | 263 HRESULT hr = DispEventAdvise(webBrowser); |
283 DEBUG_GENERAL("Loaded as BHO"); | |
284 CComPtr<IConnectionPoint> pPoint = GetConnectionPoint(); | |
285 if (pPoint) | |
286 { | |
287 HRESULT hr = pPoint->Advise((IDispatch*)this, &m_nConnectionID); | |
288 if (SUCCEEDED(hr)) | 264 if (SUCCEEDED(hr)) |
289 { | 265 { |
290 m_isAdviced = true; | 266 m_isAdvised = true; |
291 | |
292 try | 267 try |
293 { | 268 { |
294 std::thread startInitObjectThread(StartInitObject, this); | 269 std::thread startInitObjectThread(StartInitObject, this); |
295 startInitObjectThread.detach(); // TODO: but actually we should wa it for the thread in the dtr. | 270 startInitObjectThread.detach(); // TODO: but actually we should wa it for the thread in the dtr. |
296 } | 271 } |
297 catch (const std::system_error& ex) | 272 catch (const std::system_error& ex) |
298 { | 273 { |
299 auto errDescription = std::string("Class::Thread - Failed to creat e StartInitObject thread, ") + | 274 DEBUG_SYSTEM_EXCEPTION(ex, PLUGIN_ERROR_THREAD, PLUGIN_ERROR_MAIN_ THREAD_CREATE_PROCESS, |
300 ex.code().message() + ex.what(); | 275 "Class::Thread - Failed to create StartInitObject thread"); |
301 DEBUG_ERROR_LOG(ex.code().value(), PLUGIN_ERROR_THREAD, PLUGIN_ERR OR_MAIN_THREAD_CREATE_PROCESS, errDescription.c_str()); | |
302 } | 276 } |
303 } | 277 } |
304 else | 278 else |
305 { | 279 { |
306 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_SET_SITE, PLUGIN_ERROR_SET_SITE_ADV ICE, "Class::SetSite - Advice"); | 280 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_SET_SITE, PLUGIN_ERROR_SET_SITE_ADV ICE, "Class::SetSite - Advise"); |
307 } | 281 } |
308 } | 282 } |
309 } | 283 } |
310 else // Check if loaded as toolbar handler | 284 catch (const std::runtime_error& ex) |
311 { | 285 { |
312 DEBUG_GENERAL("Loaded as toolbar handler"); | 286 DEBUG_EXCEPTION(ex); |
313 CComPtr<IServiceProvider> pServiceProvider; | 287 Unadvise(); |
314 | 288 } |
315 HRESULT hr = unknownSite->QueryInterface(&pServiceProvider); | 289 } |
316 if (SUCCEEDED(hr)) | 290 else |
317 { | 291 { |
318 if (pServiceProvider) | 292 Unadvise(); |
319 { | 293 |
320 s_criticalSectionBrowser.Lock(); | 294 // Destroy window |
321 { | 295 if (m_pWndProcStatus) |
322 HRESULT hr = pServiceProvider->QueryService(IID_IWebBrowserApp, &m _webBrowser2); | 296 { |
323 if (SUCCEEDED(hr)) | 297 ::SetWindowLongPtr(m_hStatusBarWnd, GWLP_WNDPROC, (LPARAM)(WNDPROC)m_pWn dProcStatus); |
324 { | 298 |
325 if (m_webBrowser2) | 299 m_pWndProcStatus = NULL; |
326 { | 300 } |
327 InitObject(false); | 301 |
328 } | 302 if (m_hPaneWnd) |
329 } | 303 { |
330 else | 304 DestroyWindow(m_hPaneWnd); |
331 { | 305 m_hPaneWnd = NULL; |
332 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_SET_SITE, PLUGIN_ERROR_SET_SITE _QUERY_BROWSER, "Class::SetSite - QueryService (IID_IWebBrowserApp)"); | 306 } |
333 } | 307 |
334 } | 308 m_hTabWnd = NULL; |
335 s_criticalSectionBrowser.Unlock(); | 309 m_hStatusBarWnd = NULL; |
336 } | 310 |
337 } | 311 // Remove instance from the list, shutdown threads |
338 else | 312 HANDLE hMainThread = NULL; |
339 { | 313 HANDLE hTabThread = NULL; |
340 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_SET_SITE, PLUGIN_ERROR_SET_SITE_QUERY _SERVICE_PROVIDER, "Class::SetSite - QueryInterface (service provider)"); | 314 |
341 } | 315 s_criticalSectionLocal.Lock(); |
342 } | 316 { |
343 } | 317 s_instances.erase(this); |
344 catch (std::runtime_error e) | 318 |
345 { | 319 std::map<DWORD,CPluginClass*>::iterator it = s_threadInstances.find(::Ge tCurrentThreadId()); |
346 DEBUG_ERROR(e.what()); | 320 if (it != s_threadInstances.end()) |
347 Unadvice(); | 321 { |
348 } | 322 s_threadInstances.erase(it); |
349 } | 323 } |
350 else | 324 if (s_instances.empty()) |
351 { | 325 { |
352 // Unadvice | 326 // TODO: Explicitly releasing a resource when a container becomes empt y looks like a job better suited for shared_ptr |
353 Unadvice(); | 327 CPluginClientFactory::ReleaseMimeFilterClientInstance(); |
354 | 328 } |
355 // Destroy window | 329 } |
356 if (m_pWndProcStatus) | 330 s_criticalSectionLocal.Unlock(); |
357 { | 331 |
358 ::SetWindowLongPtr(m_hStatusBarWnd, GWLP_WNDPROC, (LPARAM)(WNDPROC)m_pWndP rocStatus); | 332 // Release browser interface |
359 | 333 s_criticalSectionBrowser.Lock(); |
360 m_pWndProcStatus = NULL; | 334 { |
361 } | 335 m_webBrowser2.Release(); |
362 | 336 } |
363 if (m_hPaneWnd) | 337 s_criticalSectionBrowser.Unlock(); |
364 { | 338 |
365 DestroyWindow(m_hPaneWnd); | 339 DEBUG_GENERAL("=========================================================== =====================\nNEW TAB UI - END\n======================================= =========================================") |
366 m_hPaneWnd = NULL; | 340 |
367 } | 341 ::CoUninitialize(); |
368 | 342 } |
369 m_hTabWnd = NULL; | 343 |
370 m_hStatusBarWnd = NULL; | 344 IObjectWithSiteImpl<CPluginClass>::SetSite(unknownSite); |
371 | 345 } |
372 // Remove instance from the list, shutdown threads | 346 catch (...) |
373 HANDLE hMainThread = NULL; | 347 { |
374 HANDLE hTabThread = NULL; | 348 } |
375 | 349 return S_OK; |
376 s_criticalSectionLocal.Lock(); | |
377 { | |
378 s_instances.erase(this); | |
379 | |
380 std::map<DWORD,CPluginClass*>::iterator it = s_threadInstances.find(::GetC urrentThreadId()); | |
381 if (it != s_threadInstances.end()) | |
382 { | |
383 s_threadInstances.erase(it); | |
384 } | |
385 if (s_instances.empty()) | |
386 { | |
387 // TODO: Explicitly releasing a resource when a container becomes empty looks like a job better suited for shared_ptr | |
388 CPluginClientFactory::ReleaseMimeFilterClientInstance(); | |
389 } | |
390 } | |
391 s_criticalSectionLocal.Unlock(); | |
392 | |
393 // Release browser interface | |
394 s_criticalSectionBrowser.Lock(); | |
395 { | |
396 m_webBrowser2.Release(); | |
397 } | |
398 s_criticalSectionBrowser.Unlock(); | |
399 | |
400 DEBUG_GENERAL("============================================================= ===================\nNEW TAB UI - END\n========================================= =======================================") | |
401 | |
402 ::CoUninitialize(); | |
403 } | |
404 | |
405 return IObjectWithSiteImpl<CPluginClass>::SetSite(unknownSite); | |
406 } | 350 } |
407 | 351 |
408 bool CPluginClass::IsStatusBarEnabled() | 352 bool CPluginClass::IsStatusBarEnabled() |
409 { | 353 { |
410 DEBUG_GENERAL("IsStatusBarEnabled start"); | 354 DEBUG_GENERAL("IsStatusBarEnabled start"); |
411 HKEY pHkey; | 355 HKEY pHkey; |
412 HKEY pHkeySub; | 356 HKEY pHkeySub; |
413 RegOpenCurrentUser(KEY_QUERY_VALUE, &pHkey); | 357 RegOpenCurrentUser(KEY_QUERY_VALUE, &pHkey); |
414 DWORD truth = 1; | 358 DWORD truth = 1; |
415 DWORD truthSize = sizeof(truth); | 359 DWORD truthSize = sizeof(truth); |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
511 } | 455 } |
512 } | 456 } |
513 else | 457 else |
514 { | 458 { |
515 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_UI, PLUGIN_ERROR_UI_GET_STATUSBAR, "Class ::Get statusbar state"); | 459 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_UI, PLUGIN_ERROR_UI_GET_STATUSBAR, "Class ::Get statusbar state"); |
516 } | 460 } |
517 } | 461 } |
518 DEBUG_GENERAL("ShowStatusBar end"); | 462 DEBUG_GENERAL("ShowStatusBar end"); |
519 } | 463 } |
520 | 464 |
521 /* | 465 // Entry point |
522 * #1163 This class is the implementation for method DISPID_BEFORENAVIGATE2 in C PluginClass::Invoke. | 466 void STDMETHODCALLTYPE CPluginClass::OnBeforeNavigate2( |
523 * - It validates and convertes its own arguments, rather than unifying them in the Invoke body. | 467 IDispatch* frameBrowserDisp /**< [in] */, |
524 * - It's declared void and not HRESULT, so DISPID_BEFORENAVIGATE2 can only retu rn S_OK. | 468 VARIANT* urlVariant /**< [in] */, |
525 */ | 469 VARIANT* /**< [in] Flags*/, |
526 void CPluginClass::BeforeNavigate2(DISPPARAMS* pDispParams) | 470 VARIANT* /**< [in] TargetFrameName*/, |
527 { | 471 VARIANT* /**< [in] PostData*/, |
528 | 472 VARIANT* /**< [in] Headers*/, |
529 if (pDispParams->cArgs < 7) | 473 VARIANT_BOOL* /**< [in, out] Cancel*/) |
530 { | 474 { |
531 return; | 475 try |
532 } | 476 { |
533 //Register a mime filter if it's not registered yet | 477 ATL::CComQIPtr<IWebBrowser2> webBrowser = frameBrowserDisp; |
534 if (s_mimeFilter == NULL) | 478 if (!webBrowser) |
535 { | 479 { |
536 s_mimeFilter = CPluginClientFactory::GetMimeFilterClientInstance(); | 480 return; |
537 } | 481 } |
538 | 482 if (!urlVariant || urlVariant->vt != VT_BSTR) |
539 // Get the IWebBrowser2 interface | 483 { |
540 CComQIPtr<IWebBrowser2, &IID_IWebBrowser2> WebBrowser2Ptr; | 484 return; |
541 VARTYPE vt = pDispParams->rgvarg[6].vt; | 485 } |
542 if (vt == VT_DISPATCH) | 486 std::wstring url(urlVariant->bstrVal, SysStringLen(urlVariant->bstrVal)); |
543 { | 487 UnescapeUrl(url); |
544 WebBrowser2Ptr = pDispParams->rgvarg[6].pdispVal; | 488 |
545 } | 489 // If webbrowser2 is equal to top level browser (as set in SetSite), we are |
546 else | 490 // navigating new page |
547 { | 491 CPluginClient* client = CPluginClient::GetInstance(); |
548 // Wrong type, return. | 492 if (url.find(L"javascript") == 0) |
549 return; | 493 { |
550 } | 494 } |
551 | 495 else if (GetBrowser().IsEqualObject(webBrowser)) |
552 // Get the URL | 496 { |
553 std::wstring url; | 497 m_tab->OnNavigate(url); |
554 const auto& arg = pDispParams->rgvarg[5]; | 498 DEBUG_GENERAL( |
555 vt = arg.vt; | 499 L"======================================================================== ========\n" |
556 if (vt == (VT_BYREF | VT_VARIANT) && arg.pvarVal->vt == VT_BSTR) | 500 L"Begin main navigation url:" + url + L"\n" |
557 { | 501 L"======================================================================== ========") |
558 BSTR b = arg.pvarVal->bstrVal; | |
559 if (b) { | |
560 url = std::wstring(b, SysStringLen(b)); | |
561 UnescapeUrl(url); | |
562 } | |
563 } | |
564 else | |
565 { | |
566 // Wrong type, return. | |
567 return; | |
568 } | |
569 | |
570 // If webbrowser2 is equal to top level browser (as set in SetSite), we are na vigating new page | |
571 CPluginClient* client = CPluginClient::GetInstance(); | |
572 CString urlLegacy = ToCString(url); | |
573 if (urlLegacy.Find(L"javascript") == 0) | |
574 { | |
575 } | |
576 else if (GetBrowser().IsEqualObject(WebBrowser2Ptr)) | |
577 { | |
578 m_tab->OnNavigate(url); | |
579 | |
580 DEBUG_GENERAL(L"============================================================ ====================\nBegin main navigation url:" + urlLegacy + "\n============= ===================================================================") | |
581 | 502 |
582 #ifdef ENABLE_DEBUG_RESULT | 503 #ifdef ENABLE_DEBUG_RESULT |
583 CPluginDebug::DebugResultDomain(urlLegacy); | 504 CPluginDebug::DebugResultDomain(url); |
584 #endif | 505 #endif |
585 | 506 UpdateStatusBar(); |
586 UpdateStatusBar(); | 507 } |
587 } | 508 else |
588 else | 509 { |
589 { | 510 DEBUG_NAVI(L"Navi::Begin navigation url:" + url) |
590 DEBUG_NAVI(L"Navi::Begin navigation url:" + urlLegacy) | 511 m_tab->CacheFrame(url); |
591 m_tab->CacheFrame(url); | 512 } |
592 } | 513 } |
593 } | 514 catch (...) |
594 | 515 { |
595 /* | 516 } |
596 * #1163 implements behavior for method DISPID_WINDOWSTATECHANGED in CPluginClas s::Invoke | 517 } |
597 * - should validate and convert arguments in Invoke, not here | 518 |
598 * - does not validate number of arguments before indexing into 'rgvarg' | 519 // Entry point |
599 * - does not validate type of argument before using its value | 520 void STDMETHODCALLTYPE CPluginClass::OnDownloadComplete() |
600 */ | |
601 STDMETHODIMP CPluginClass::OnTabChanged(DISPPARAMS* pDispParams, WORD wFlags) | |
602 { | |
603 DEBUG_GENERAL("Tab changed"); | |
604 bool newtabshown = pDispParams->rgvarg[1].intVal==3; | |
605 if (newtabshown) | |
606 { | |
607 std::map<DWORD,CPluginClass*>::const_iterator it = s_threadInstances.find(Ge tCurrentThreadId()); | |
608 if (it == s_threadInstances.end()) | |
609 { | |
610 s_threadInstances[::GetCurrentThreadId()] = this; | |
611 if (!m_isInitializedOk) | |
612 { | |
613 m_isInitializedOk = true; | |
614 InitObject(true); | |
615 UpdateStatusBar(); | |
616 } | |
617 } | |
618 } | |
619 notificationMessage.Hide(); | |
620 DEBUG_GENERAL("Tab change end"); | |
621 return S_OK; | |
622 } | |
623 | |
624 // This gets called whenever there's a browser event | |
625 // ENTRY POINT | |
626 STDMETHODIMP CPluginClass::Invoke(DISPID dispidMember, REFIID riid, LCID lcid, W ORD wFlags, DISPPARAMS* pDispParams, VARIANT* pvarResult, EXCEPINFO* pExcepInfo, UINT* puArgErr) | |
627 { | 521 { |
628 try | 522 try |
629 { | 523 { |
630 WCHAR tmp[256]; | 524 DEBUG_NAVI(L"Navi::Download Complete") |
631 wsprintf(tmp, L"Invoke: %d\n", dispidMember); | 525 ATL::CComPtr<IWebBrowser2> browser = GetBrowser(); |
632 DEBUG_GENERAL(tmp); | 526 if (browser) |
633 switch (dispidMember) | 527 { |
634 { | 528 m_tab->OnDownloadComplete(browser); |
635 case DISPID_WINDOWSTATECHANGED: | 529 } |
636 { | 530 } |
637 // #1163 should validate and convert arguments here | 531 catch (...) |
638 return OnTabChanged(pDispParams, wFlags); | 532 { |
639 } | 533 } |
640 | 534 } |
641 case DISPID_HTMLDOCUMENTEVENTS2_ONBEFOREUPDATE: | 535 |
642 break; | 536 // Entry point |
643 | 537 void STDMETHODCALLTYPE CPluginClass::OnDocumentComplete(IDispatch* frameBrowserD isp, VARIANT* /*urlOrPidl*/) |
644 case DISPID_HTMLDOCUMENTEVENTS2_ONCLICK: | 538 { |
645 break; | 539 try |
646 | 540 { |
647 case DISPID_EVMETH_ONLOAD: | 541 DEBUG_NAVI(L"Navi::Document Complete"); |
648 DEBUG_NAVI("Navi::OnLoad") | 542 ATL::CComQIPtr<IWebBrowser2> webBrowser2 = frameBrowserDisp; |
649 break; | 543 if (!webBrowser2) |
650 | 544 { |
651 case DISPID_EVMETH_ONCHANGE: | 545 return; |
652 break; | 546 } |
653 | 547 std::wstring frameSrc = GetLocationUrl(*webBrowser2); |
654 case DISPID_EVMETH_ONMOUSEDOWN: | 548 UnescapeUrl(frameSrc); |
655 break; | 549 bool isRootPageBrowser = GetBrowser().IsEqualObject(webBrowser2); |
656 | 550 m_tab->OnDocumentComplete(webBrowser2, frameSrc, isRootPageBrowser); |
657 case DISPID_EVMETH_ONMOUSEENTER: | 551 } |
658 break; | 552 catch (...) |
659 | 553 { |
660 case DISPID_IHTMLIMGELEMENT_START: | 554 } |
661 break; | 555 } |
662 | 556 |
663 case STDDISPID_XOBJ_ERRORUPDATE: | 557 // Entry point |
664 break; | 558 void STDMETHODCALLTYPE CPluginClass::OnWindowStateChanged(unsigned long flags, u nsigned long validFlagsMask) |
665 | 559 { |
666 case STDDISPID_XOBJ_ONPROPERTYCHANGE: | 560 try |
667 break; | 561 { |
668 | 562 DEBUG_GENERAL(L"WindowStateChanged (check tab changed)"); |
669 case DISPID_READYSTATECHANGE: | 563 bool newtabshown = validFlagsMask == (OLECMDIDF_WINDOWSTATE_USERVISIBLE | OL ECMDIDF_WINDOWSTATE_ENABLED) |
670 DEBUG_NAVI("Navi::ReadyStateChange"); | 564 && flags == (OLECMDIDF_WINDOWSTATE_USERVISIBLE | OLECMDIDF_WINDOWSTATE_ENA BLED); |
671 break; | 565 if (newtabshown) |
672 | 566 { |
673 case DISPID_BEFORENAVIGATE: | 567 std::map<DWORD,CPluginClass*>::const_iterator it = s_threadInstances.find( GetCurrentThreadId()); |
674 DEBUG_NAVI("Navi::BeforeNavigate"); | 568 if (it == s_threadInstances.end()) |
675 break; | 569 { |
676 | 570 s_threadInstances[::GetCurrentThreadId()] = this; |
677 case DISPID_COMMANDSTATECHANGE: | 571 if (!m_isInitializedOk) |
678 if (m_hPaneWnd == NULL) | 572 { |
679 { | 573 m_isInitializedOk = true; |
680 CreateStatusBarPane(); | 574 InitObject(); |
681 } | 575 UpdateStatusBar(); |
682 else | 576 } |
683 { | 577 } |
578 } | |
579 notificationMessage.Hide(); | |
580 DEBUG_GENERAL(L"WindowStateChanged (check tab changed) end"); | |
581 } | |
582 catch (...) | |
583 { | |
584 } | |
585 } | |
586 | |
587 // Entry point | |
588 void STDMETHODCALLTYPE CPluginClass::OnCommandStateChange(long /*command*/, VARI ANT_BOOL /*enable*/) | |
589 { | |
590 try | |
591 { | |
592 if (m_hPaneWnd == NULL) | |
593 { | |
594 CreateStatusBarPane(); | |
595 } | |
596 else | |
597 { | |
684 if (AdblockPlus::IE::InstalledMajorVersion() > 6) | 598 if (AdblockPlus::IE::InstalledMajorVersion() > 6) |
685 { | 599 { |
686 RECT rect; | 600 RECT rect; |
687 //Get the RECT for the leftmost pane (the status text pane) | 601 //Get the RECT for the leftmost pane (the status text pane) |
688 BOOL rectRes = ::SendMessage(m_hStatusBarWnd, SB_GETRECT, 0, (LPARAM)& rect); | 602 BOOL rectRes = ::SendMessage(m_hStatusBarWnd, SB_GETRECT, 0, (LPARAM)&re ct); |
689 if (rectRes == TRUE) | 603 if (rectRes == TRUE) |
690 { | 604 { |
691 MoveWindow(m_hPaneWnd, rect.right - m_nPaneWidth, 0, m_nPaneWidth, r ect.bottom - rect.top, TRUE); | 605 MoveWindow(m_hPaneWnd, rect.right - m_nPaneWidth, 0, m_nPaneWidth, rec t.bottom - rect.top, TRUE); |
692 } | 606 } |
693 } | 607 } |
694 } | 608 } |
695 break; | 609 } |
696 | 610 catch (...) |
697 case DISPID_STATUSTEXTCHANGE: | 611 { |
698 break; | 612 } |
699 | 613 } |
700 case DISPID_BEFORENAVIGATE2: | 614 |
701 { | 615 // Entry point |
702 // #1163 should validate and convert parameters here | 616 void STDMETHODCALLTYPE CPluginClass::OnOnQuit() |
703 BeforeNavigate2(pDispParams); | 617 { |
704 } | 618 try |
705 break; | 619 { |
706 | 620 Unadvise(); |
707 case DISPID_DOWNLOADBEGIN: | 621 } |
708 { | 622 catch (...) |
709 DEBUG_NAVI("Navi::Download Begin") | 623 { |
710 } | 624 } |
711 break; | 625 } |
712 | 626 |
713 case DISPID_DOWNLOADCOMPLETE: | 627 bool CPluginClass::InitObject() |
714 { | |
715 DEBUG_NAVI("Navi::Download Complete"); | |
716 CComQIPtr<IWebBrowser2> browser = GetBrowser(); | |
717 if (browser) | |
718 { | |
719 m_tab->OnDownloadComplete(browser); | |
720 } | |
721 } | |
722 break; | |
723 | |
724 case DISPID_DOCUMENTCOMPLETE: | |
725 { | |
726 DEBUG_NAVI("Navi::Document Complete"); | |
727 CComQIPtr<IWebBrowser2> browser = GetBrowser(); | |
728 if (browser && pDispParams->cArgs >= 2 && pDispParams->rgvarg[1].vt == V T_DISPATCH) | |
729 { | |
730 CComQIPtr<IWebBrowser2> pBrowser = pDispParams->rgvarg[1].pdispVal; | |
731 if (pBrowser) | |
732 { | |
733 CComBSTR bstrUrl; | |
734 if (SUCCEEDED(pBrowser->get_LocationURL(&bstrUrl)) && bstrUrl && ::S ysStringLen(bstrUrl) > 0) | |
735 { | |
736 std::wstring url = std::wstring(bstrUrl, SysStringLen(bstrUrl)); | |
737 UnescapeUrl(url); | |
738 m_tab->OnDocumentComplete(browser, url, browser.IsEqualObject(pBro wser)); | |
739 } | |
740 } | |
741 } | |
742 } | |
743 break; | |
744 | |
745 case DISPID_ONQUIT: | |
746 case DISPID_QUIT: | |
747 { | |
748 Unadvice(); | |
749 } | |
750 break; | |
751 | |
752 default: | |
753 { | |
754 CString did; | |
755 did.Format(L"DispId:%u", dispidMember); | |
756 | |
757 DEBUG_NAVI(L"Navi::Default " + did) | |
758 } | |
759 /* | |
760 * Ordinarily a method not dispatched should return DISP_E_MEMBERNOTFOUND. | |
761 * As a conservative initial change, we leave it behaving as before, | |
762 * which is to do nothing and return S_OK. | |
763 */ | |
764 // do nothing | |
765 break; | |
766 } | |
767 } | |
768 catch(...) | |
769 { | |
770 DEBUG_GENERAL( "Caught unknown exception in CPluginClass::Invoke" ); | |
771 return E_FAIL; | |
772 } | |
773 return S_OK; | |
774 } | |
775 | |
776 bool CPluginClass::InitObject(bool bBHO) | |
777 { | 628 { |
778 DEBUG_GENERAL("InitObject"); | 629 DEBUG_GENERAL("InitObject"); |
779 CPluginSettings* settings = CPluginSettings::GetInstance(); | 630 CPluginSettings* settings = CPluginSettings::GetInstance(); |
780 | 631 |
781 if (!settings->GetPluginEnabled()) | 632 if (!settings->GetPluginEnabled()) |
782 { | 633 { |
783 s_mimeFilter->Unregister(); | 634 s_mimeFilter->Unregister(); |
784 } | 635 } |
785 | 636 |
786 // Load theme module | 637 // Load theme module |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
843 | 694 |
844 if (!GetAtomPaneClass()) | 695 if (!GetAtomPaneClass()) |
845 { | 696 { |
846 DEBUG_ERROR_LOG(::GetLastError(), PLUGIN_ERROR_UI, PLUGIN_ERROR_UI_REGISTE R_PANE_CLASS, "Class::InitObject - RegisterClassEx"); | 697 DEBUG_ERROR_LOG(::GetLastError(), PLUGIN_ERROR_UI, PLUGIN_ERROR_UI_REGISTE R_PANE_CLASS, "Class::InitObject - RegisterClassEx"); |
847 return false; | 698 return false; |
848 } | 699 } |
849 } | 700 } |
850 | 701 |
851 int ieVersion = AdblockPlus::IE::InstalledMajorVersion(); | 702 int ieVersion = AdblockPlus::IE::InstalledMajorVersion(); |
852 // Create status pane | 703 // Create status pane |
853 if (bBHO && ieVersion > 6 && !CreateStatusBarPane()) | 704 if (ieVersion > 6 && !CreateStatusBarPane()) |
854 { | 705 { |
855 return false; | 706 return false; |
856 } | 707 } |
857 s_criticalSectionLocal.Lock(); | 708 s_criticalSectionLocal.Lock(); |
858 std::wstring curVer = CPluginClient::GetInstance()->GetPref(std::wstring(L"cur rentVersion"), std::wstring(L"0.0")); | 709 std::wstring curVer = CPluginClient::GetInstance()->GetPref(L"currentVersion", L"0.0"); |
sergei
2015/04/22 10:37:09
How does "0.0" affect `versionCompRes`? I'm not th
Oleksandr
2015/04/24 11:50:32
I don't think we should default to current version
| |
859 if (curVer.find(L".") == std::wstring::npos) | |
sergei
2015/04/22 10:37:09
I would live a comment here about "simpleadblock"
| |
860 { | |
861 CPluginClient::GetInstance()->SetPref(L"convertedFrom", curVer); | |
862 } | |
863 int versionCompRes = CPluginClient::GetInstance()->CompareVersions(curVer, L"1 .2"); | 710 int versionCompRes = CPluginClient::GetInstance()->CompareVersions(curVer, L"1 .2"); |
864 | 711 |
865 bool isFirstRun = CPluginClient::GetInstance()->IsFirstRun(); | 712 bool isFirstRun = CPluginClient::GetInstance()->IsFirstRun(); |
866 CPluginClient::GetInstance()->SetPref(L"currentVersion", std::wstring(IEPLUGIN _VERSION)); | 713 CPluginClient::GetInstance()->SetPref(L"currentVersion", std::wstring(IEPLUGIN _VERSION)); |
867 // This is the first time ABP was installed | 714 // This is the first time ABP was installed |
868 // Or ABP was updated from the version that did not support Acceptable Ads (<1 .2) | 715 // Or ABP was updated from the version that did not support Acceptable Ads (<1 .2) |
869 if (isFirstRun || versionCompRes < 0) | 716 if (isFirstRun || versionCompRes < 0) |
870 { | 717 { |
871 if (!isFirstRun) | 718 if (!isFirstRun) |
872 { | 719 { |
873 if (!CPluginClient::GetInstance()->GetPref(curVer, false)) | 720 // Display an update page only if it's not a conversion from other product |
721 if (CPluginClient::GetInstance()->GetConvertedFrom() == L"") | |
874 { | 722 { |
875 CPluginClient::GetInstance()->SetPref(L"displayUpdatePage", true); | 723 CPluginClient::GetInstance()->SetPref(L"displayUpdatePage", true); |
876 } | 724 } |
877 } | 725 } |
878 | 726 |
879 // IE6 can't be accessed from another thread, execute in current thread | 727 // IE6 can't be accessed from another thread, execute in current thread |
880 if (ieVersion < 7) | 728 if (ieVersion < 7) |
881 { | 729 { |
882 FirstRunThread(); | 730 FirstRunThread(); |
883 } | 731 } |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1064 | 912 |
1065 HDC hdc = GetWindowDC(m_hStatusBarWnd); | 913 HDC hdc = GetWindowDC(m_hStatusBarWnd); |
1066 SendMessage(m_hStatusBarWnd, WM_PAINT, (WPARAM)hdc, 0); | 914 SendMessage(m_hStatusBarWnd, WM_PAINT, (WPARAM)hdc, 0); |
1067 ReleaseDC(m_hStatusBarWnd, hdc); | 915 ReleaseDC(m_hStatusBarWnd, hdc); |
1068 | 916 |
1069 return true; | 917 return true; |
1070 } | 918 } |
1071 | 919 |
1072 void CPluginClass::FirstRunThread() | 920 void CPluginClass::FirstRunThread() |
1073 { | 921 { |
922 // Just return if the First Run Page should be suppressed | |
923 if (CPluginClient::GetInstance()->GetPref(L"suppress_first_run_page", false)) | |
924 return; | |
925 | |
1074 CoInitialize(NULL); | 926 CoInitialize(NULL); |
1075 VARIANT vFlags; | 927 VARIANT vFlags; |
1076 vFlags.vt = VT_I4; | 928 vFlags.vt = VT_I4; |
1077 vFlags.intVal = navOpenInNewTab; | 929 vFlags.intVal = navOpenInNewTab; |
1078 | 930 |
1079 CComBSTR navigatePath = CComBSTR(FirstRunPageFileUrl().c_str()); | 931 CComBSTR navigatePath = CComBSTR(FirstRunPageFileUrl().c_str()); |
1080 | 932 |
1081 HRESULT hr = GetAsyncBrowser()->Navigate(navigatePath, &vFlags, NULL, NULL, NU LL); | 933 HRESULT hr = GetAsyncBrowser()->Navigate(navigatePath, &vFlags, NULL, NULL, NU LL); |
1082 if (FAILED(hr)) | 934 if (FAILED(hr)) |
1083 { | 935 { |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1272 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_NAVIGATION, PLUGIN_ERROR_NAVIGATION _SETTINGS, "Navigation::Failed") | 1124 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_NAVIGATION, PLUGIN_ERROR_NAVIGATION _SETTINGS, "Navigation::Failed") |
1273 } | 1125 } |
1274 } | 1126 } |
1275 } | 1127 } |
1276 break; | 1128 break; |
1277 } | 1129 } |
1278 case ID_MENU_DISABLE_ON_SITE: | 1130 case ID_MENU_DISABLE_ON_SITE: |
1279 { | 1131 { |
1280 CPluginSettings* settings = CPluginSettings::GetInstance(); | 1132 CPluginSettings* settings = CPluginSettings::GetInstance(); |
1281 std::wstring urlString = GetTab()->GetDocumentUrl(); | 1133 std::wstring urlString = GetTab()->GetDocumentUrl(); |
1282 if (client->IsWhitelistedUrl(urlString)) | 1134 std::string filterText = client->GetWhitelistingFilter(urlString); |
1283 { | 1135 if (!filterText.empty()) |
1284 settings->RemoveWhiteListedDomain(ToCString(client->GetHostFromUrl(urlSt ring))); | 1136 { |
1137 client->RemoveFilter(filterText); | |
1285 } | 1138 } |
1286 else | 1139 else |
1287 { | 1140 { |
1288 settings->AddWhiteListedDomain(ToCString(client->GetHostFromUrl(urlStrin g))); | 1141 settings->AddWhiteListedDomain(ToCString(client->GetHostFromUrl(urlStrin g))); |
1289 } | 1142 } |
1290 GetBrowser()->Refresh(); | |
1291 } | 1143 } |
1292 default: | 1144 default: |
1293 break; | 1145 break; |
1294 } | 1146 } |
1295 | 1147 |
1296 // Invalidate and redraw the control | 1148 // Invalidate and redraw the control |
1297 UpdateStatusBar(); | 1149 UpdateStatusBar(); |
1298 } | 1150 } |
1299 | 1151 |
1300 | 1152 |
(...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1771 { | 1623 { |
1772 CreateStatusBarPane(); | 1624 CreateStatusBarPane(); |
1773 } | 1625 } |
1774 if ((m_hPaneWnd != NULL) && !::InvalidateRect(m_hPaneWnd, NULL, FALSE)) | 1626 if ((m_hPaneWnd != NULL) && !::InvalidateRect(m_hPaneWnd, NULL, FALSE)) |
1775 { | 1627 { |
1776 DEBUG_ERROR_LOG(::GetLastError(), PLUGIN_ERROR_UI, PLUGIN_ERROR_UI_INVALID ATE_STATUSBAR, "Class::Invalidate statusbar"); | 1628 DEBUG_ERROR_LOG(::GetLastError(), PLUGIN_ERROR_UI, PLUGIN_ERROR_UI_INVALID ATE_STATUSBAR, "Class::Invalidate statusbar"); |
1777 } | 1629 } |
1778 } | 1630 } |
1779 | 1631 |
1780 | 1632 |
1781 void CPluginClass::Unadvice() | 1633 void CPluginClass::Unadvise() |
1782 { | 1634 { |
1783 s_criticalSectionLocal.Lock(); | 1635 s_criticalSectionLocal.Lock(); |
1784 { | 1636 { |
1785 if (m_isAdviced) | 1637 if (m_isAdvised) |
1786 { | 1638 { |
1787 CComPtr<IConnectionPoint> pPoint = GetConnectionPoint(); | 1639 HRESULT hr = DispEventUnadvise(GetBrowser()); |
1788 if (pPoint) | 1640 if (FAILED(hr)) |
1789 { | 1641 { |
1790 HRESULT hr = pPoint->Unadvise(m_nConnectionID); | 1642 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_SET_SITE, PLUGIN_ERROR_SET_SITE_UNADVIS E, "Class::Unadvise - Unadvise"); |
1791 if (FAILED(hr)) | 1643 } |
1792 { | 1644 m_isAdvised = false; |
1793 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_SET_SITE, PLUGIN_ERROR_SET_SITE_UNADV ICE, "Class::Unadvice - Unadvise"); | |
1794 } | |
1795 } | |
1796 | |
1797 m_isAdviced = false; | |
1798 } | 1645 } |
1799 } | 1646 } |
1800 s_criticalSectionLocal.Unlock(); | 1647 s_criticalSectionLocal.Unlock(); |
1801 } | 1648 } |
1802 | 1649 |
1803 HICON CPluginClass::GetIcon(int type) | 1650 HICON CPluginClass::GetIcon(int type) |
1804 { | 1651 { |
1805 HICON icon = NULL; | 1652 HICON icon = NULL; |
1806 | 1653 |
1807 s_criticalSectionLocal.Lock(); | 1654 s_criticalSectionLocal.Lock(); |
1808 { | 1655 { |
1809 if (!s_hIcons[type]) | 1656 if (!s_hIcons[type]) |
1810 { | 1657 { |
1811 std::wstring imageToLoad = L"#"; | 1658 std::wstring imageToLoad = L"#"; |
1812 imageToLoad += std::to_wstring(s_hIconTypes[type]); | 1659 imageToLoad += std::to_wstring(s_hIconTypes[type]); |
1813 s_hIcons[type] = (HICON)::LoadImage(_Module.m_hInst, imageToLoad.c_str(), IMAGE_ICON, iconWidth, iconHeight, LR_SHARED); | 1660 s_hIcons[type] = (HICON)::LoadImage(_Module.m_hInst, imageToLoad.c_str(), IMAGE_ICON, iconWidth, iconHeight, LR_SHARED); |
1814 if (!s_hIcons[type]) | 1661 if (!s_hIcons[type]) |
1815 { | 1662 { |
1816 DEBUG_ERROR_LOG(::GetLastError(), PLUGIN_ERROR_UI, PLUGIN_ERROR_UI_LOAD_ ICON, "Class::GetIcon - LoadIcon") | 1663 DEBUG_ERROR_LOG(::GetLastError(), PLUGIN_ERROR_UI, PLUGIN_ERROR_UI_LOAD_ ICON, "Class::GetIcon - LoadIcon"); |
1817 } | 1664 } |
1818 } | 1665 } |
1819 | 1666 |
1820 icon = s_hIcons[type]; | 1667 icon = s_hIcons[type]; |
1821 } | 1668 } |
1822 s_criticalSectionLocal.Unlock(); | 1669 s_criticalSectionLocal.Unlock(); |
1823 | 1670 |
1824 return icon; | 1671 return icon; |
1825 } | 1672 } |
1826 | 1673 |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1887 break; | 1734 break; |
1888 } | 1735 } |
1889 s_criticalSectionLocal.Unlock(); | 1736 s_criticalSectionLocal.Unlock(); |
1890 | 1737 |
1891 } | 1738 } |
1892 } | 1739 } |
1893 } | 1740 } |
1894 | 1741 |
1895 hTabWnd = ::GetWindow(hTabWnd, GW_HWNDNEXT); | 1742 hTabWnd = ::GetWindow(hTabWnd, GW_HWNDNEXT); |
1896 } | 1743 } |
1897 | |
1898 return hTabWnd; | 1744 return hTabWnd; |
1899 | 1745 } |
1900 } | |
LEFT | RIGHT |