| Left: | ||
| Right: |
| LEFT | RIGHT |
|---|---|
| 1 /* | |
| 2 * This file is part of Adblock Plus <https://adblockplus.org/>, | |
| 3 * Copyright (C) 2006-2015 Eyeo GmbH | |
| 4 * | |
| 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 | |
| 7 * published by the Free Software Foundation. | |
| 8 * | |
| 9 * Adblock Plus is distributed in the hope that it will be useful, | |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 12 * GNU General Public License for more details. | |
| 13 * | |
| 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/>. | |
| 16 */ | |
| 17 | |
| 1 #include "PluginStdAfx.h" | 18 #include "PluginStdAfx.h" |
| 2 | 19 |
| 3 #include "PluginClass.h" | 20 #include "PluginClass.h" |
| 4 #include "PluginSettings.h" | 21 #include "PluginSettings.h" |
| 5 #include "PluginSystem.h" | 22 #include "PluginSystem.h" |
| 6 #include "PluginFilter.h" | 23 #include "PluginFilter.h" |
| 7 #include "PluginMimeFilterClient.h" | 24 #include "PluginMimeFilterClient.h" |
| 8 #include "PluginClient.h" | 25 #include "PluginClient.h" |
| 9 #include "PluginClientFactory.h" | 26 #include "PluginClientFactory.h" |
| 10 #include "PluginMutex.h" | 27 #include "PluginMutex.h" |
| 11 #include "sddl.h" | 28 #include "sddl.h" |
| 12 #include "PluginUtil.h" | 29 #include "PluginUtil.h" |
| 13 #include "PluginUserSettings.h" | 30 #include "PluginUserSettings.h" |
| 14 #include "../shared/Utils.h" | 31 #include "../shared/Utils.h" |
| 15 #include "../shared/Dictionary.h" | 32 #include "../shared/Dictionary.h" |
| 16 #include "../shared/IE_version.h" | 33 #include "../shared/IE_version.h" |
| 17 #include <thread> | 34 #include <thread> |
| 18 #include <array> | 35 #include <array> |
| 19 | 36 |
| 20 #ifdef DEBUG_HIDE_EL | 37 #ifdef DEBUG_HIDE_EL |
| 21 DWORD profileTime = 0; | 38 DWORD profileTime = 0; |
| 22 #endif | 39 #endif |
| 23 | 40 |
| 24 typedef HANDLE (WINAPI *OPENTHEMEDATA)(HWND, LPCWSTR); | 41 typedef HANDLE (WINAPI *OPENTHEMEDATA)(HWND, LPCWSTR); |
| 25 typedef HRESULT (WINAPI *DRAWTHEMEBACKGROUND)(HANDLE, HDC, INT, INT, LPRECT, LPR ECT); | 42 typedef HRESULT (WINAPI *DRAWTHEMEBACKGROUND)(HANDLE, HDC, INT, INT, LPRECT, LPR ECT); |
| 26 typedef HRESULT (WINAPI *CLOSETHEMEDATA)(HANDLE); | 43 typedef HRESULT (WINAPI *CLOSETHEMEDATA)(HANDLE); |
| 27 | 44 |
| 28 HICON CPluginClass::s_hIcons[ICON_MAX] = { NULL, NULL, NULL }; | 45 HICON CPluginClass::s_hIcons[ICON_MAX] = { NULL, NULL, NULL }; |
| 29 DWORD CPluginClass::s_hIconTypes[ICON_MAX] = { IDI_ICON_DISABLED, IDI_ICON_ENABL ED, IDI_ICON_DEACTIVATED }; | 46 DWORD CPluginClass::s_hIconTypes[ICON_MAX] = { IDI_ICON_DISABLED, IDI_ICON_ENABL ED, IDI_ICON_DEACTIVATED }; |
| 47 uint32_t iconHeight = 32; | |
| 48 uint32_t iconWidth = 32; | |
| 30 | 49 |
| 31 CPluginMimeFilterClient* CPluginClass::s_mimeFilter = NULL; | 50 CPluginMimeFilterClient* CPluginClass::s_mimeFilter = NULL; |
| 32 | 51 |
| 33 CLOSETHEMEDATA pfnClose = NULL; | 52 CLOSETHEMEDATA pfnClose = NULL; |
| 34 DRAWTHEMEBACKGROUND pfnDrawThemeBackground = NULL; | 53 DRAWTHEMEBACKGROUND pfnDrawThemeBackground = NULL; |
| 35 OPENTHEMEDATA pfnOpenThemeData = NULL; | 54 OPENTHEMEDATA pfnOpenThemeData = NULL; |
| 36 | 55 |
| 37 ATOM CPluginClass::s_atomPaneClass = NULL; | 56 ATOM CPluginClass::s_atomPaneClass = NULL; |
| 38 HINSTANCE CPluginClass::s_hUxtheme = NULL; | 57 HINSTANCE CPluginClass::s_hUxtheme = NULL; |
| 39 std::set<CPluginClass*> CPluginClass::s_instances; | 58 std::set<CPluginClass*> CPluginClass::s_instances; |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 151 | 170 |
| 152 s_criticalSectionLocal.Lock(); | 171 s_criticalSectionLocal.Lock(); |
| 153 { | 172 { |
| 154 browser = s_asyncWebBrowser2; | 173 browser = s_asyncWebBrowser2; |
| 155 } | 174 } |
| 156 s_criticalSectionLocal.Unlock(); | 175 s_criticalSectionLocal.Unlock(); |
| 157 | 176 |
| 158 return browser; | 177 return browser; |
| 159 } | 178 } |
| 160 | 179 |
| 161 CString CPluginClass::GetBrowserUrl() const | 180 std::wstring CPluginClass::GetBrowserUrl() const |
| 162 { | 181 { |
| 163 CString url; | 182 std::wstring url; |
| 164 | |
| 165 CComQIPtr<IWebBrowser2> browser = GetBrowser(); | 183 CComQIPtr<IWebBrowser2> browser = GetBrowser(); |
| 166 if (browser) | 184 if (browser) |
| 167 { | 185 { |
| 168 CComBSTR bstrURL; | 186 CComBSTR bstrURL; |
| 169 | 187 if (SUCCEEDED(browser->get_LocationURL(&bstrURL)) && bstrURL) |
| 170 if (SUCCEEDED(browser->get_LocationURL(&bstrURL))) | 188 { |
| 171 { | 189 url = std::wstring(bstrURL, SysStringLen(bstrURL)); |
| 172 url = bstrURL; | 190 UnescapeUrl(url); |
| 173 CPluginClient::UnescapeUrl(url); | |
| 174 } | 191 } |
| 175 } | 192 } |
| 176 else | 193 else |
| 177 { | 194 { |
| 178 url = m_tab->GetDocumentUrl(); | 195 url = m_tab->GetDocumentUrl(); |
| 179 } | 196 } |
| 180 | |
| 181 return url; | 197 return url; |
| 182 } | 198 } |
| 183 | 199 |
| 184 DWORD WINAPI CPluginClass::StartInitObject(LPVOID thisPtr) | 200 DWORD WINAPI CPluginClass::StartInitObject(LPVOID thisPtr) |
| 185 { | 201 { |
| 186 if (thisPtr == NULL) | 202 if (thisPtr == NULL) |
| 187 return 0; | 203 return 0; |
| 188 if (!((CPluginClass*)thisPtr)->InitObject(true)) | 204 if (!((CPluginClass*)thisPtr)->InitObject(true)) |
| 189 { | 205 { |
| 190 ((CPluginClass*)thisPtr)->Unadvise(); | 206 ((CPluginClass*)thisPtr)->Unadvise(); |
| 191 } | 207 } |
| 192 | 208 |
| 193 return 0; | 209 return 0; |
| 194 } | 210 } |
| 195 | |
| 196 | |
| 197 | 211 |
| 198 // This gets called when a new browser window is created (which also triggers th e | 212 // This gets called when a new browser window is created (which also triggers th e |
| 199 // creation of this object). The pointer passed in should be to a IWebBrowser2 | 213 // creation of this object). The pointer passed in should be to a IWebBrowser2 |
| 200 // interface that represents the browser for the window. | 214 // interface that represents the browser for the window. |
| 201 // it is also called when a tab is closed, this unknownSite will be null | 215 // it is also called when a tab is closed, this unknownSite will be null |
| 202 // so we should handle that it is called this way several times during a session | 216 // so we should handle that it is called this way several times during a session |
| 203 STDMETHODIMP CPluginClass::SetSite(IUnknown* unknownSite) | 217 STDMETHODIMP CPluginClass::SetSite(IUnknown* unknownSite) |
| 204 { | 218 { |
| 205 CPluginSettings* settings = CPluginSettings::GetInstance(); | 219 CPluginSettings* settings = CPluginSettings::GetInstance(); |
| 206 | 220 |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 236 } | 250 } |
| 237 s_criticalSectionLocal.Unlock(); | 251 s_criticalSectionLocal.Unlock(); |
| 238 | 252 |
| 239 try | 253 try |
| 240 { | 254 { |
| 241 // Check if loaded as BHO | 255 // Check if loaded as BHO |
| 242 auto webBrowser = GetBrowser(); | 256 auto webBrowser = GetBrowser(); |
| 243 if (webBrowser) | 257 if (webBrowser) |
| 244 { | 258 { |
| 245 DEBUG_GENERAL("Loaded as BHO"); | 259 DEBUG_GENERAL("Loaded as BHO"); |
| 246 HRESULT hr = DispEventAdvise(webBrowser); | 260 HRESULT hr = DispEventAdvise(webBrowser); |
|
Eric
2015/01/12 14:18:07
The Advise/Unadvise life cycle belong in a constru
sergei
2015/01/13 11:49:12
It does not belong to constructor/destructor pair.
Eric
2015/01/13 18:44:30
It absolutely should be paired.
As it's written n
| |
| 247 if (SUCCEEDED(hr)) | 261 if (SUCCEEDED(hr)) |
| 248 { | 262 { |
| 249 m_isAdvised = true; | 263 m_isAdvised = true; |
| 250 try | 264 try |
| 251 { | 265 { |
| 252 std::thread startInitObjectThread(StartInitObject, this); | 266 std::thread startInitObjectThread(StartInitObject, this); |
| 253 startInitObjectThread.detach(); // TODO: but actually we should wait for the thread in the dtr. | 267 startInitObjectThread.detach(); // TODO: but actually we should wait for the thread in the dtr. |
| 254 } | 268 } |
| 255 catch (const std::system_error& ex) | 269 catch (const std::system_error& ex) |
| 256 { | 270 { |
| 257 auto errDescription = std::string("Class::Thread - Failed to create StartInitObject thread, ") + | 271 DEBUG_SYSTEM_EXCEPTION(ex, PLUGIN_ERROR_THREAD, PLUGIN_ERROR_MAIN_TH READ_CREATE_PROCESS, |
| 258 ex.code().message() + ex.what(); | 272 "Class::Thread - Failed to create StartInitObject thread"); |
| 259 DEBUG_ERROR_LOG(ex.code().value(), PLUGIN_ERROR_THREAD, PLUGIN_ERROR _MAIN_THREAD_CREATE_PROCESS, errDescription.c_str()); | |
| 260 } | 273 } |
| 261 } | 274 } |
| 262 else | 275 else |
| 263 { | 276 { |
| 264 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_SET_SITE, PLUGIN_ERROR_SET_SITE_ADVIC E, "Class::SetSite - Advice"); | 277 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_SET_SITE, PLUGIN_ERROR_SET_SITE_ADVIC E, "Class::SetSite - Advise"); |
| 265 } | 278 } |
| 266 } | 279 } |
| 267 else // Check if loaded as toolbar handler | 280 else // Check if loaded as toolbar handler |
| 268 { | 281 { |
| 269 DEBUG_GENERAL("Loaded as toolbar handler"); | 282 DEBUG_GENERAL("Loaded as toolbar handler"); |
| 270 CComPtr<IServiceProvider> pServiceProvider; | 283 CComPtr<IServiceProvider> pServiceProvider; |
| 271 | 284 |
| 272 HRESULT hr = unknownSite->QueryInterface(&pServiceProvider); | 285 HRESULT hr = unknownSite->QueryInterface(&pServiceProvider); |
| 273 if (SUCCEEDED(hr)) | 286 if (SUCCEEDED(hr)) |
| 274 { | 287 { |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 291 } | 304 } |
| 292 s_criticalSectionBrowser.Unlock(); | 305 s_criticalSectionBrowser.Unlock(); |
| 293 } | 306 } |
| 294 } | 307 } |
| 295 else | 308 else |
| 296 { | 309 { |
| 297 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_SET_SITE, PLUGIN_ERROR_SET_SITE_QUERY _SERVICE_PROVIDER, "Class::SetSite - QueryInterface (service provider)"); | 310 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_SET_SITE, PLUGIN_ERROR_SET_SITE_QUERY _SERVICE_PROVIDER, "Class::SetSite - QueryInterface (service provider)"); |
| 298 } | 311 } |
| 299 } | 312 } |
| 300 } | 313 } |
| 301 catch (std::runtime_error e) | 314 catch (const std::runtime_error& ex) |
| 302 { | 315 { |
| 303 DEBUG_ERROR(e.what()); | 316 DEBUG_EXCEPTION(ex); |
| 304 Unadvise(); | 317 Unadvise(); |
| 305 } | 318 } |
| 306 } | 319 } |
| 307 else | 320 else |
| 308 { | 321 { |
| 309 // Unadvise | |
|
Oleksandr
2015/01/10 23:27:24
I guess we can loose the captain obvious comment h
sergei
2015/01/13 11:49:12
removed
| |
| 310 Unadvise(); | 322 Unadvise(); |
| 311 | 323 |
| 312 // Destroy window | 324 // Destroy window |
| 313 if (m_pWndProcStatus) | 325 if (m_pWndProcStatus) |
| 314 { | 326 { |
| 315 ::SetWindowLongPtr(m_hStatusBarWnd, GWLP_WNDPROC, (LPARAM)(WNDPROC)m_pWndP rocStatus); | 327 ::SetWindowLongPtr(m_hStatusBarWnd, GWLP_WNDPROC, (LPARAM)(WNDPROC)m_pWndP rocStatus); |
| 316 | 328 |
| 317 m_pWndProcStatus = NULL; | 329 m_pWndProcStatus = NULL; |
| 318 } | 330 } |
| 319 | 331 |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 467 } | 479 } |
| 468 } | 480 } |
| 469 } | 481 } |
| 470 else | 482 else |
| 471 { | 483 { |
| 472 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_UI, PLUGIN_ERROR_UI_GET_STATUSBAR, "Class ::Get statusbar state"); | 484 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_UI, PLUGIN_ERROR_UI_GET_STATUSBAR, "Class ::Get statusbar state"); |
| 473 } | 485 } |
| 474 } | 486 } |
| 475 DEBUG_GENERAL("ShowStatusBar end"); | 487 DEBUG_GENERAL("ShowStatusBar end"); |
| 476 } | 488 } |
| 477 | 489 |
|
Eric
2015/01/12 14:18:07
// Entry point
We need to annotate all the entry
| |
| 490 // Entry point | |
| 478 void STDMETHODCALLTYPE CPluginClass::OnBeforeNavigate2( | 491 void STDMETHODCALLTYPE CPluginClass::OnBeforeNavigate2( |
| 479 /* [in] */ IDispatch* frameBrowserDisp, | 492 /* [in] */ IDispatch* frameBrowserDisp, |
| 480 /* [in] */ VARIANT* urlVariant, | 493 /* [in] */ VARIANT* urlVariant, |
| 481 /* [in] */ VARIANT* /*Flags*/, | 494 /* [in] */ VARIANT* /*Flags*/, |
| 482 /* [in] */ VARIANT* /*TargetFrameName*/, | 495 /* [in] */ VARIANT* /*TargetFrameName*/, |
| 483 /* [in] */ VARIANT* /*PostData*/, | 496 /* [in] */ VARIANT* /*PostData*/, |
| 484 /* [in] */ VARIANT* /*Headers*/, | 497 /* [in] */ VARIANT* /*Headers*/, |
| 485 /* [in, out] */ VARIANT_BOOL* /*Cancel*/) | 498 /* [in, out] */ VARIANT_BOOL* /*Cancel*/) |
| 486 { | 499 { |
|
Eric
2015/01/12 14:18:07
This patch set changes OnBeforeNavigate2 into an e
| |
| 487 ATL::CComQIPtr<IWebBrowser2> webBrowser = frameBrowserDisp; | 500 try |
| 488 if (!webBrowser) | 501 { |
| 489 { | 502 ATL::CComQIPtr<IWebBrowser2> webBrowser = frameBrowserDisp; |
| 490 return; | 503 if (!webBrowser) |
| 491 } | 504 { |
| 492 | 505 return; |
| 493 if (!urlVariant || urlVariant->vt != VT_BSTR) | 506 } |
| 494 { | 507 if (!urlVariant || urlVariant->vt != VT_BSTR) |
| 495 return; | 508 { |
| 496 } | 509 return; |
| 497 std::wstring url(urlVariant->bstrVal, SysStringLen(urlVariant->bstrVal)); | 510 } |
| 498 UnescapeUrl(url); | 511 std::wstring url(urlVariant->bstrVal, SysStringLen(urlVariant->bstrVal)); |
| 499 | 512 UnescapeUrl(url); |
| 500 //Register a mime filter if it's not registered yet | 513 |
| 501 if (s_mimeFilter == NULL) | 514 //Register a mime filter if it's not registered yet |
| 502 { | 515 if (s_mimeFilter == nullptr) |
| 503 s_mimeFilter = CPluginClientFactory::GetMimeFilterClientInstance(); | 516 { |
| 504 } | 517 s_mimeFilter = CPluginClientFactory::GetMimeFilterClientInstance(); |
| 505 | 518 } |
| 506 CString urlCString = ToCString(url); | 519 // If webbrowser2 is equal to top level browser (as set in SetSite), we are |
| 507 | 520 // navigating new page |
| 508 // If webbrowser2 is equal to top level browser (as set in SetSite), we are na vigating new page | 521 CPluginClient* client = CPluginClient::GetInstance(); |
| 509 CPluginClient* client = CPluginClient::GetInstance(); | 522 if (url.find(L"javascript") == 0) |
| 510 | 523 { |
| 511 if (urlCString.Find(L"javascript") == 0) | 524 } |
| 512 { | 525 else if (GetBrowser().IsEqualObject(webBrowser)) |
| 513 } | 526 { |
| 514 else if (GetBrowser().IsEqualObject(webBrowser)) | 527 m_tab->OnNavigate(url); |
| 515 { | 528 DEBUG_GENERAL( |
| 516 m_tab->OnNavigate(urlCString); | 529 L"======================================================================== ========\n" |
| 517 | 530 L"Begin main navigation url:" + url + L"\n" |
| 518 DEBUG_GENERAL(L"============================================================ ====================\nBegin main navigation url:" + urlCString + "\n============ ====================================================================") | 531 L"======================================================================== ========") |
| 519 | 532 |
| 520 #ifdef ENABLE_DEBUG_RESULT | 533 #ifdef ENABLE_DEBUG_RESULT |
| 521 CPluginDebug::DebugResultDomain(urlCString); | 534 CPluginDebug::DebugResultDomain(url); |
| 522 #endif | 535 #endif |
| 523 | 536 UpdateStatusBar(); |
| 524 UpdateStatusBar(); | 537 } |
| 525 } | 538 else |
| 526 else | 539 { |
| 527 { | 540 DEBUG_NAVI(L"Navi::Begin navigation url:" + url) |
| 528 DEBUG_NAVI(L"Navi::Begin navigation url:" + urlCString) | 541 m_tab->CacheFrame(url); |
| 529 m_tab->CacheFrame(urlCString); | 542 } |
| 530 } | 543 } |
| 531 } | 544 catch (...) |
| 532 | 545 { |
|
Eric
2015/01/12 14:18:07
// Entry point
| |
| 533 void STDMETHODCALLTYPE CPluginClass::OnDownloadBegin() | 546 } |
| 534 { | 547 } |
| 535 DEBUG_NAVI("Navi::Download Begin") | 548 |
| 536 } | 549 // Entry point |
| 537 | |
|
Eric
2015/01/12 14:18:07
// Entry point
| |
| 538 void STDMETHODCALLTYPE CPluginClass::OnDownloadComplete() | 550 void STDMETHODCALLTYPE CPluginClass::OnDownloadComplete() |
| 539 { | 551 { |
|
Eric
2015/01/12 14:18:07
try-statement and catch-all
| |
| 540 DEBUG_NAVI("Navi::Download Complete") | 552 try |
| 541 ATL::CComPtr<IWebBrowser2> browser = GetBrowser(); | 553 { |
| 542 if (browser) | 554 DEBUG_NAVI(L"Navi::Download Complete") |
| 543 { | 555 ATL::CComPtr<IWebBrowser2> browser = GetBrowser(); |
| 544 m_tab->OnDownloadComplete(browser); | 556 if (browser) |
| 545 } | 557 { |
| 546 } | 558 m_tab->OnDownloadComplete(browser); |
| 547 | 559 } |
|
Eric
2015/01/12 14:18:07
// Entry point
| |
| 560 } | |
| 561 catch (...) | |
| 562 { | |
| 563 } | |
| 564 } | |
| 565 | |
| 566 // Entry point | |
| 548 void STDMETHODCALLTYPE CPluginClass::OnDocumentComplete(IDispatch* frameBrowserD isp, VARIANT* /*urlOrPidl*/) | 567 void STDMETHODCALLTYPE CPluginClass::OnDocumentComplete(IDispatch* frameBrowserD isp, VARIANT* /*urlOrPidl*/) |
| 549 { | 568 { |
|
Eric
2015/01/12 14:18:07
try-statement and catch-all
| |
| 550 ATL::CComQIPtr<IWebBrowser2> webBrowser2 = frameBrowserDisp; | 569 try |
| 551 if (!webBrowser2) | 570 { |
| 552 { | 571 DEBUG_NAVI(L"Navi::Document Complete"); |
| 553 return; | 572 ATL::CComQIPtr<IWebBrowser2> webBrowser2 = frameBrowserDisp; |
| 554 } | 573 if (!webBrowser2) |
| 555 ATL::CString frameSrc; | 574 { |
| 556 ATL::CComBSTR locationUrl; | 575 return; |
| 557 if (FAILED(webBrowser2->get_LocationURL(&locationUrl)) && !!locationUrl) | 576 } |
| 558 { | 577 std::wstring frameSrc = GetLocationUrl(*webBrowser2); |
| 559 return; | 578 UnescapeUrl(frameSrc); |
| 560 } | 579 bool isRootPageBrowser = GetBrowser().IsEqualObject(webBrowser2); |
| 561 frameSrc = locationUrl; | 580 m_tab->OnDocumentComplete(webBrowser2, frameSrc, isRootPageBrowser); |
| 562 CPluginClient::UnescapeUrl(frameSrc); | 581 } |
| 563 bool isRootPageBrowser = GetBrowser().IsEqualObject(webBrowser2); | 582 catch (...) |
| 564 m_tab->OnDocumentComplete(webBrowser2, frameSrc, isRootPageBrowser); | 583 { |
| 565 } | 584 } |
| 566 | 585 } |
|
Eric
2015/01/12 14:18:07
// Entry point
| |
| 586 | |
| 587 // Entry point | |
| 567 void STDMETHODCALLTYPE CPluginClass::OnWindowStateChanged(unsigned long flags, u nsigned long validFlagsMask) | 588 void STDMETHODCALLTYPE CPluginClass::OnWindowStateChanged(unsigned long flags, u nsigned long validFlagsMask) |
| 568 { | 589 { |
|
Eric
2015/01/12 14:18:07
try-statement and catch-all
| |
| 569 DEBUG_GENERAL("Tab changed"); | 590 try |
| 570 bool newtabshown = validFlagsMask == (OLECMDIDF_WINDOWSTATE_USERVISIBLE | OLEC MDIDF_WINDOWSTATE_ENABLED) | 591 { |
| 571 && flags == (OLECMDIDF_WINDOWSTATE_USERVISIBLE | OLECMDIDF_WIN DOWSTATE_ENABLED); | 592 DEBUG_GENERAL(L"WindowStateChanged (check tab changed)"); |
| 572 if (newtabshown) | 593 bool newtabshown = validFlagsMask == (OLECMDIDF_WINDOWSTATE_USERVISIBLE | OL ECMDIDF_WINDOWSTATE_ENABLED) |
| 573 { | 594 && flags == (OLECMDIDF_WINDOWSTATE_USERVISIBLE | OLECMDIDF_WINDOWSTATE_ENA BLED); |
| 574 std::map<DWORD,CPluginClass*>::const_iterator it = s_threadInstances.find(Ge tCurrentThreadId()); | 595 if (newtabshown) |
| 575 if (it == s_threadInstances.end()) | 596 { |
| 576 { | 597 std::map<DWORD,CPluginClass*>::const_iterator it = s_threadInstances.find( GetCurrentThreadId()); |
| 577 s_threadInstances[::GetCurrentThreadId()] = this; | 598 if (it == s_threadInstances.end()) |
| 578 if (!m_isInitializedOk) | 599 { |
| 579 { | 600 s_threadInstances[::GetCurrentThreadId()] = this; |
| 580 m_isInitializedOk = true; | 601 if (!m_isInitializedOk) |
| 581 if (!InitObject(true)) | 602 { |
| 582 { | 603 m_isInitializedOk = true; |
| 583 //» » » » » Unadvise(); | 604 InitObject(true); |
| 584 } | 605 UpdateStatusBar(); |
|
Oleksandr
2015/01/10 23:27:24
This doesn't seem to be rebased to the current tip
| |
| 585 UpdateStatusBar(); | 606 } |
| 586 } | 607 } |
| 587 } | 608 } |
| 588 } | 609 notificationMessage.Hide(); |
| 589 notificationMessage.Hide(); | 610 DEBUG_GENERAL(L"WindowStateChanged (check tab changed) end"); |
| 590 DEBUG_GENERAL("Tab change end"); | 611 } |
| 591 } | 612 catch (...) |
| 592 | 613 { |
|
Eric
2015/01/12 14:18:07
// Entry point
| |
| 614 } | |
| 615 } | |
| 616 | |
| 617 // Entry point | |
| 593 void STDMETHODCALLTYPE CPluginClass::OnCommandStateChange(long /*command*/, VARI ANT_BOOL /*enable*/) | 618 void STDMETHODCALLTYPE CPluginClass::OnCommandStateChange(long /*command*/, VARI ANT_BOOL /*enable*/) |
| 594 { | 619 { |
|
Eric
2015/01/12 14:18:07
try-statement and catch-all
| |
| 595 if (m_hPaneWnd == NULL) | 620 try |
| 596 { | 621 { |
| 597 CreateStatusBarPane(); | 622 if (m_hPaneWnd == NULL) |
| 598 } | 623 { |
| 599 else | 624 CreateStatusBarPane(); |
| 600 { | 625 } |
| 601 if (AdblockPlus::IE::InstalledMajorVersion() > 6) | 626 else |
| 602 { | 627 { |
| 603 RECT rect; | 628 if (AdblockPlus::IE::InstalledMajorVersion() > 6) |
| 604 BOOL rectRes = GetClientRect(m_hStatusBarWnd, &rect); | 629 { |
| 605 if (rectRes == TRUE) | 630 RECT rect; |
| 606 { | 631 //Get the RECT for the leftmost pane (the status text pane) |
| 607 MoveWindow(m_hPaneWnd, rect.right - 200, 0, m_nPaneWidth, rect.bottom - rect.top, TRUE); | 632 BOOL rectRes = ::SendMessage(m_hStatusBarWnd, SB_GETRECT, 0, (LPARAM)&re ct); |
| 608 } | 633 if (rectRes == TRUE) |
| 609 } | 634 { |
| 635 MoveWindow(m_hPaneWnd, rect.right - m_nPaneWidth, 0, m_nPaneWidth, rec t.bottom - rect.top, TRUE); | |
| 636 } | |
| 637 } | |
| 638 } | |
| 639 } | |
| 640 catch (...) | |
| 641 { | |
| 642 } | |
| 643 } | |
| 644 | |
| 645 // Entry point | |
| 646 void STDMETHODCALLTYPE CPluginClass::OnOnQuit() | |
| 647 { | |
| 648 try | |
| 649 { | |
| 650 Unadvise(); | |
| 651 } | |
| 652 catch (...) | |
| 653 { | |
| 610 } | 654 } |
| 611 } | 655 } |
| 612 | 656 |
| 613 bool CPluginClass::InitObject(bool bBHO) | 657 bool CPluginClass::InitObject(bool bBHO) |
| 614 { | 658 { |
| 615 DEBUG_GENERAL("InitObject"); | 659 DEBUG_GENERAL("InitObject"); |
| 616 CPluginSettings* settings = CPluginSettings::GetInstance(); | 660 CPluginSettings* settings = CPluginSettings::GetInstance(); |
| 617 | 661 |
| 618 if (!settings->GetPluginEnabled()) | 662 if (!settings->GetPluginEnabled()) |
| 619 { | 663 { |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 824 DEBUG_ERROR_LOG(0, PLUGIN_ERROR_UI, PLUGIN_ERROR_UI_NO_STATUSBAR_WIN, "Class ::CreateStatusBarPane - No status bar") | 868 DEBUG_ERROR_LOG(0, PLUGIN_ERROR_UI, PLUGIN_ERROR_UI_NO_STATUSBAR_WIN, "Class ::CreateStatusBarPane - No status bar") |
| 825 return true; | 869 return true; |
| 826 } | 870 } |
| 827 | 871 |
| 828 // Calculate pane height | 872 // Calculate pane height |
| 829 AdblockPlus::Rectangle rcStatusBar; | 873 AdblockPlus::Rectangle rcStatusBar; |
| 830 ::GetClientRect(hWndStatusBar, &rcStatusBar); | 874 ::GetClientRect(hWndStatusBar, &rcStatusBar); |
| 831 | 875 |
| 832 if (rcStatusBar.Height() > 0) | 876 if (rcStatusBar.Height() > 0) |
| 833 { | 877 { |
| 878 if (rcStatusBar.Height() < iconWidth) | |
| 879 { | |
| 880 iconWidth = 19; | |
| 881 iconHeight = 19; | |
| 882 } | |
| 883 | |
| 834 #ifdef _DEBUG | 884 #ifdef _DEBUG |
| 835 m_nPaneWidth = 70; | 885 m_nPaneWidth = 70; |
| 836 #else | 886 #else |
| 837 m_nPaneWidth = min(rcStatusBar.Height(), 22); | 887 m_nPaneWidth = min(rcStatusBar.Height(), iconWidth); |
| 838 #endif | 888 #endif |
| 839 } | 889 } |
| 840 else | 890 else |
| 841 { | 891 { |
| 842 #ifdef _DEBUG | 892 #ifdef _DEBUG |
| 843 m_nPaneWidth = 70; | 893 m_nPaneWidth = 70; |
| 844 #else | 894 #else |
| 845 m_nPaneWidth = 22; | 895 m_nPaneWidth = iconWidth; |
| 846 #endif | 896 #endif |
| 847 } | 897 } |
| 848 // Create pane window | 898 // Create pane window |
| 849 HWND hWndNewPane = ::CreateWindowEx( | 899 HWND hWndNewPane = ::CreateWindowEx( |
| 850 NULL, | 900 NULL, |
| 851 MAKEINTATOM(GetAtomPaneClass()), | 901 MAKEINTATOM(GetAtomPaneClass()), |
| 852 L"", | 902 L"", |
| 853 WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, | 903 WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, |
| 854 rcStatusBar.Width() - 500,0,m_nPaneWidth,rcStatusBar.Height(), | 904 rcStatusBar.Width() - 500, 0, m_nPaneWidth, rcStatusBar.Height(), |
| 855 hWndStatusBar, | 905 hWndStatusBar, |
| 856 (HMENU)3671, | 906 (HMENU)3671, |
| 857 _Module.m_hInst, | 907 _Module.m_hInst, |
| 858 NULL); | 908 NULL); |
| 859 | 909 |
| 860 if (!hWndNewPane) | 910 if (!hWndNewPane) |
| 861 { | 911 { |
| 862 DEBUG_ERROR_LOG(::GetLastError(), PLUGIN_ERROR_UI, PLUGIN_ERROR_UI_CREATE_ST ATUSBAR_PANE, "Class::CreateStatusBarPane - CreateWindowEx") | 912 DEBUG_ERROR_LOG(::GetLastError(), PLUGIN_ERROR_UI, PLUGIN_ERROR_UI_CREATE_ST ATUSBAR_PANE, "Class::CreateStatusBarPane - CreateWindowEx") |
| 863 return false; | 913 return false; |
| 864 } | 914 } |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 987 STDMETHODIMP CPluginClass::QueryStatus(const GUID* pguidCmdGroup, ULONG cCmds, O LECMD prgCmds[], OLECMDTEXT* pCmdText) | 1037 STDMETHODIMP CPluginClass::QueryStatus(const GUID* pguidCmdGroup, ULONG cCmds, O LECMD prgCmds[], OLECMDTEXT* pCmdText) |
| 988 { | 1038 { |
| 989 if (cCmds == 0) return E_INVALIDARG; | 1039 if (cCmds == 0) return E_INVALIDARG; |
| 990 if (prgCmds == 0) return E_POINTER; | 1040 if (prgCmds == 0) return E_POINTER; |
| 991 | 1041 |
| 992 prgCmds[0].cmdf = OLECMDF_ENABLED; | 1042 prgCmds[0].cmdf = OLECMDF_ENABLED; |
| 993 | 1043 |
| 994 return S_OK; | 1044 return S_OK; |
| 995 } | 1045 } |
| 996 | 1046 |
| 997 HMENU CPluginClass::CreatePluginMenu(const CString& url) | 1047 HMENU CPluginClass::CreatePluginMenu(const std::wstring& url) |
| 998 { | 1048 { |
| 999 DEBUG_GENERAL("CreatePluginMenu"); | 1049 DEBUG_GENERAL("CreatePluginMenu"); |
| 1000 HINSTANCE hInstance = _AtlBaseModule.GetModuleInstance(); | 1050 HINSTANCE hInstance = _AtlBaseModule.GetModuleInstance(); |
| 1001 | 1051 |
| 1002 HMENU hMenu = ::LoadMenu(hInstance, MAKEINTRESOURCE(IDR_MENU1)); | 1052 HMENU hMenu = ::LoadMenu(hInstance, MAKEINTRESOURCE(IDR_MENU1)); |
| 1003 | 1053 |
| 1004 HMENU hMenuTrackPopup = GetSubMenu(hMenu, 0); | 1054 HMENU hMenuTrackPopup = GetSubMenu(hMenu, 0); |
| 1005 | 1055 |
| 1006 SetMenuBar(hMenuTrackPopup, url); | 1056 SetMenuBar(hMenuTrackPopup, url); |
| 1007 | 1057 |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1095 { | 1145 { |
| 1096 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_NAVIGATION, PLUGIN_ERROR_NAVIGATION _SETTINGS, "Navigation::Failed") | 1146 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_NAVIGATION, PLUGIN_ERROR_NAVIGATION _SETTINGS, "Navigation::Failed") |
| 1097 } | 1147 } |
| 1098 } | 1148 } |
| 1099 } | 1149 } |
| 1100 break; | 1150 break; |
| 1101 } | 1151 } |
| 1102 case ID_MENU_DISABLE_ON_SITE: | 1152 case ID_MENU_DISABLE_ON_SITE: |
| 1103 { | 1153 { |
| 1104 CPluginSettings* settings = CPluginSettings::GetInstance(); | 1154 CPluginSettings* settings = CPluginSettings::GetInstance(); |
| 1105 CString urlString = GetTab()->GetDocumentUrl(); | 1155 std::wstring urlString = GetTab()->GetDocumentUrl(); |
| 1106 if (client->IsWhitelistedUrl(to_wstring(urlString))) | 1156 if (client->IsWhitelistedUrl(urlString)) |
| 1107 { | 1157 { |
| 1108 settings->RemoveWhiteListedDomain(to_CString(client->GetHostFromUrl(to_w string(urlString)))); | 1158 settings->RemoveWhiteListedDomain(ToCString(client->GetHostFromUrl(urlSt ring))); |
| 1109 } | 1159 } |
| 1110 else | 1160 else |
| 1111 { | 1161 { |
| 1112 settings->AddWhiteListedDomain(to_CString(client->GetHostFromUrl(to_wstr ing(urlString)))); | 1162 settings->AddWhiteListedDomain(ToCString(client->GetHostFromUrl(urlStrin g))); |
| 1113 } | 1163 } |
| 1114 GetBrowser()->Refresh(); | 1164 GetBrowser()->Refresh(); |
| 1115 } | 1165 } |
| 1116 default: | 1166 default: |
| 1117 break; | 1167 break; |
| 1118 } | 1168 } |
| 1119 | 1169 |
| 1120 // Invalidate and redraw the control | 1170 // Invalidate and redraw the control |
| 1121 UpdateStatusBar(); | 1171 UpdateStatusBar(); |
| 1122 } | 1172 } |
| 1123 | 1173 |
| 1124 | 1174 |
| 1125 bool CPluginClass::SetMenuBar(HMENU hMenu, const CString& url) | 1175 bool CPluginClass::SetMenuBar(HMENU hMenu, const std::wstring& url) |
| 1126 { | 1176 { |
| 1127 DEBUG_GENERAL("SetMenuBar"); | 1177 DEBUG_GENERAL("SetMenuBar"); |
| 1128 | 1178 |
| 1129 std::wstring ctext; | 1179 std::wstring ctext; |
| 1130 Dictionary* dictionary = Dictionary::GetInstance(); | 1180 Dictionary* dictionary = Dictionary::GetInstance(); |
| 1131 | 1181 |
| 1132 MENUITEMINFOW fmii = {}; | 1182 MENUITEMINFOW fmii = {}; |
| 1133 fmii.cbSize = sizeof(fmii); | 1183 fmii.cbSize = sizeof(fmii); |
| 1134 | 1184 |
| 1135 MENUITEMINFOW miiSep = {}; | 1185 MENUITEMINFOW miiSep = {}; |
| 1136 miiSep.cbSize = sizeof(miiSep); | 1186 miiSep.cbSize = sizeof(miiSep); |
| 1137 miiSep.fMask = MIIM_TYPE | MIIM_FTYPE; | 1187 miiSep.fMask = MIIM_TYPE | MIIM_FTYPE; |
| 1138 miiSep.fType = MFT_SEPARATOR; | 1188 miiSep.fType = MFT_SEPARATOR; |
| 1139 | 1189 |
| 1140 CPluginClient* client = CPluginClient::GetInstance(); | 1190 CPluginClient* client = CPluginClient::GetInstance(); |
| 1141 CPluginSettings* settings = CPluginSettings::GetInstance(); | 1191 CPluginSettings* settings = CPluginSettings::GetInstance(); |
| 1142 { | 1192 { |
| 1143 ctext = dictionary->Lookup("menu", "menu-disable-on-site"); | 1193 ctext = dictionary->Lookup("menu", "menu-disable-on-site"); |
| 1144 // Is domain in white list? | 1194 // Is domain in white list? |
| 1145 ReplaceString(ctext, L"?1?", client->GetHostFromUrl(to_wstring(url))); | 1195 ReplaceString(ctext, L"?1?", client->GetHostFromUrl(url)); |
| 1146 if (client->IsWhitelistedUrl(to_wstring(GetTab()->GetDocumentUrl()))) | 1196 if (client->IsWhitelistedUrl(GetTab()->GetDocumentUrl())) |
| 1147 { | 1197 { |
| 1148 fmii.fState = MFS_CHECKED | MFS_ENABLED; | 1198 fmii.fState = MFS_CHECKED | MFS_ENABLED; |
| 1149 } | 1199 } |
| 1150 else | 1200 else |
| 1151 { | 1201 { |
| 1152 fmii.fState = MFS_UNCHECKED | MFS_ENABLED; | 1202 fmii.fState = MFS_UNCHECKED | MFS_ENABLED; |
| 1153 } | 1203 } |
| 1154 fmii.fMask = MIIM_STRING | MIIM_STATE; | 1204 fmii.fMask = MIIM_STRING | MIIM_STATE; |
| 1155 fmii.dwTypeData = const_cast<LPWSTR>(ctext.c_str()); | 1205 fmii.dwTypeData = const_cast<LPWSTR>(ctext.c_str()); |
| 1156 fmii.cch = static_cast<UINT>(ctext.size()); | 1206 fmii.cch = static_cast<UINT>(ctext.size()); |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1350 } | 1400 } |
| 1351 | 1401 |
| 1352 LRESULT result = CallWindowProc(pClass->m_pWndProcStatus, hWnd, message, wPara m, lParam); | 1402 LRESULT result = CallWindowProc(pClass->m_pWndProcStatus, hWnd, message, wPara m, lParam); |
| 1353 | 1403 |
| 1354 | 1404 |
| 1355 return result; | 1405 return result; |
| 1356 | 1406 |
| 1357 } | 1407 } |
| 1358 | 1408 |
| 1359 | 1409 |
| 1360 HICON CPluginClass::GetStatusBarIcon(const CString& url) | 1410 HICON CPluginClass::GetStatusBarIcon(const std::wstring& url) |
| 1361 { | 1411 { |
| 1362 // use the disable icon as defualt, if the client doesn't exists | 1412 // use the disable icon as defualt, if the client doesn't exists |
| 1363 HICON hIcon = GetIcon(ICON_PLUGIN_DEACTIVATED); | 1413 HICON hIcon = GetIcon(ICON_PLUGIN_DEACTIVATED); |
| 1364 | 1414 |
| 1365 CPluginTab* tab = GetTab(::GetCurrentThreadId()); | 1415 CPluginTab* tab = GetTab(::GetCurrentThreadId()); |
| 1366 if (tab) | 1416 if (tab) |
| 1367 { | 1417 { |
| 1368 CPluginClient* client = CPluginClient::GetInstance(); | 1418 CPluginClient* client = CPluginClient::GetInstance(); |
| 1369 if (CPluginSettings::GetInstance()->IsPluginEnabled()) | 1419 if (CPluginSettings::GetInstance()->IsPluginEnabled()) |
| 1370 { | 1420 { |
| 1371 if (client->IsWhitelistedUrl(ToWstring(url))) | 1421 if (client->IsWhitelistedUrl(url)) |
| 1372 { | 1422 { |
| 1373 hIcon = GetIcon(ICON_PLUGIN_DISABLED); | 1423 hIcon = GetIcon(ICON_PLUGIN_DISABLED); |
| 1374 } | 1424 } |
| 1375 else | 1425 else |
| 1376 { | 1426 { |
| 1377 CPluginSettings* settings = CPluginSettings::GetInstance(); | 1427 CPluginSettings* settings = CPluginSettings::GetInstance(); |
| 1378 hIcon = GetIcon(ICON_PLUGIN_ENABLED); | 1428 hIcon = GetIcon(ICON_PLUGIN_ENABLED); |
| 1379 } | 1429 } |
| 1380 } | 1430 } |
| 1381 } | 1431 } |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1450 } | 1500 } |
| 1451 } | 1501 } |
| 1452 } | 1502 } |
| 1453 } | 1503 } |
| 1454 | 1504 |
| 1455 // Draw icon | 1505 // Draw icon |
| 1456 if (CPluginClient::GetInstance()) | 1506 if (CPluginClient::GetInstance()) |
| 1457 { | 1507 { |
| 1458 HICON hIcon = GetStatusBarIcon(pClass->GetTab()->GetDocumentUrl()); | 1508 HICON hIcon = GetStatusBarIcon(pClass->GetTab()->GetDocumentUrl()); |
| 1459 | 1509 |
| 1460 int offx = (rcClient.Height() - 16)/2 + nDrawEdge; | 1510 int offx = nDrawEdge; |
| 1461 if (hIcon) | 1511 if (hIcon) |
| 1462 { | 1512 { |
| 1463 ::DrawIconEx(hDC, offx, (rcClient.Height() - 16)/2 + 2, hIcon, 16, 16, NULL, NULL, DI_NORMAL); | 1513 //Get the RECT for the leftmost pane (the status text pane) |
| 1464 offx += 22; | 1514 RECT rect; |
| 1515 BOOL rectRes = ::SendMessage(pClass->m_hStatusBarWnd, SB_GETRECT, 0, ( LPARAM)&rect); | |
| 1516 ::DrawIconEx(hDC, 0, rect.bottom - rect.top - iconHeight, hIcon, iconW idth, iconHeight, NULL, NULL, DI_NORMAL); | |
| 1517 offx += iconWidth; | |
| 1465 } | 1518 } |
| 1466 #ifdef _DEBUG | 1519 #ifdef _DEBUG |
| 1467 // Display version | 1520 // Display version |
| 1468 HFONT hFont = (HFONT)::SendMessage(pClass->m_hStatusBarWnd, WM_GETFONT, 0, 0); | 1521 HFONT hFont = (HFONT)::SendMessage(pClass->m_hStatusBarWnd, WM_GETFONT, 0, 0); |
| 1469 HGDIOBJ hOldFont = ::SelectObject(hDC,hFont); | 1522 HGDIOBJ hOldFont = ::SelectObject(hDC,hFont); |
| 1470 | 1523 |
| 1471 AdblockPlus::Rectangle rcText = rcClient; | 1524 AdblockPlus::Rectangle rcText = rcClient; |
| 1472 rcText.left += offx; | 1525 rcText.left += offx; |
| 1473 ::SetBkMode(hDC, TRANSPARENT); | 1526 ::SetBkMode(hDC, TRANSPARENT); |
| 1474 ::DrawTextW(hDC, IEPLUGIN_VERSION, -1, &rcText, DT_WORD_ELLIPSIS|DT_LEFT |DT_SINGLELINE|DT_VCENTER); | 1527 ::DrawTextW(hDC, IEPLUGIN_VERSION, -1, &rcText, DT_WORD_ELLIPSIS|DT_LEFT |DT_SINGLELINE|DT_VCENTER); |
| 1475 | 1528 |
| 1476 ::SelectObject(hDC, hOldFont); | 1529 ::SelectObject(hDC, hOldFont); |
| 1477 #endif // _DEBUG | 1530 #endif // _DEBUG |
| 1478 } | 1531 } |
| 1479 | 1532 |
| 1480 // Done! | 1533 // Done! |
| 1481 EndPaint(hWnd, &ps); | 1534 EndPaint(hWnd, &ps); |
| 1482 | 1535 |
| 1483 return 0; | 1536 return 0; |
| 1484 } | 1537 } |
| 1485 | 1538 |
| 1486 case WM_LBUTTONUP: | 1539 case WM_LBUTTONUP: |
| 1487 case WM_RBUTTONUP: | 1540 case WM_RBUTTONUP: |
| 1488 { | 1541 { |
| 1489 CString strURL = pClass->GetBrowserUrl(); | 1542 std::wstring url = pClass->GetBrowserUrl(); |
| 1490 if (strURL != pClass->GetTab()->GetDocumentUrl()) | 1543 if (url != pClass->GetTab()->GetDocumentUrl()) |
| 1491 { | 1544 { |
| 1492 pClass->GetTab()->SetDocumentUrl(strURL); | 1545 pClass->GetTab()->SetDocumentUrl(url); |
| 1493 } | 1546 } |
| 1494 | 1547 |
| 1495 // Create menu | 1548 // Create menu |
| 1496 HMENU hMenu = pClass->CreatePluginMenu(strURL); | 1549 HMENU hMenu = pClass->CreatePluginMenu(url); |
| 1497 if (!hMenu) | 1550 if (!hMenu) |
| 1498 { | 1551 { |
| 1499 return 0; | 1552 return 0; |
| 1500 } | 1553 } |
| 1501 | 1554 |
| 1502 // Display menu | 1555 // Display menu |
| 1503 POINT pt; | 1556 POINT pt; |
| 1504 ::GetCursorPos(&pt); | 1557 ::GetCursorPos(&pt); |
| 1505 | 1558 |
| 1506 RECT rc; | 1559 RECT rc; |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1592 { | 1645 { |
| 1593 CreateStatusBarPane(); | 1646 CreateStatusBarPane(); |
| 1594 } | 1647 } |
| 1595 if ((m_hPaneWnd != NULL) && !::InvalidateRect(m_hPaneWnd, NULL, FALSE)) | 1648 if ((m_hPaneWnd != NULL) && !::InvalidateRect(m_hPaneWnd, NULL, FALSE)) |
| 1596 { | 1649 { |
| 1597 DEBUG_ERROR_LOG(::GetLastError(), PLUGIN_ERROR_UI, PLUGIN_ERROR_UI_INVALID ATE_STATUSBAR, "Class::Invalidate statusbar"); | 1650 DEBUG_ERROR_LOG(::GetLastError(), PLUGIN_ERROR_UI, PLUGIN_ERROR_UI_INVALID ATE_STATUSBAR, "Class::Invalidate statusbar"); |
| 1598 } | 1651 } |
| 1599 } | 1652 } |
| 1600 | 1653 |
| 1601 | 1654 |
| 1602 void STDMETHODCALLTYPE CPluginClass::Unadvise() | 1655 void CPluginClass::Unadvise() |
|
Eric
2015/01/12 14:18:07
If no OnQuit function is provided, this is an entr
| |
| 1603 { | 1656 { |
| 1604 s_criticalSectionLocal.Lock(); | 1657 s_criticalSectionLocal.Lock(); |
| 1605 { | 1658 { |
| 1606 if (m_isAdvised) | 1659 if (m_isAdvised) |
| 1607 { | 1660 { |
| 1608 HRESULT hr = DispEventUnadvise(GetBrowser()); | 1661 HRESULT hr = DispEventUnadvise(GetBrowser()); |
| 1609 if (FAILED(hr)) | 1662 if (FAILED(hr)) |
| 1610 { | 1663 { |
| 1611 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_SET_SITE, PLUGIN_ERROR_SET_SITE_UNADVIS E, "Class::Unadvise - Unadvise"); | 1664 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_SET_SITE, PLUGIN_ERROR_SET_SITE_UNADVIS E, "Class::Unadvise - Unadvise"); |
| 1612 } | 1665 } |
| 1613 m_isAdvised = false; | 1666 m_isAdvised = false; |
| 1614 } | 1667 } |
| 1615 } | 1668 } |
| 1616 s_criticalSectionLocal.Unlock(); | 1669 s_criticalSectionLocal.Unlock(); |
| 1617 } | 1670 } |
| 1618 | 1671 |
| 1619 HICON CPluginClass::GetIcon(int type) | 1672 HICON CPluginClass::GetIcon(int type) |
| 1620 { | 1673 { |
| 1621 HICON icon = NULL; | 1674 HICON icon = NULL; |
| 1622 | 1675 |
| 1623 s_criticalSectionLocal.Lock(); | 1676 s_criticalSectionLocal.Lock(); |
| 1624 { | 1677 { |
| 1625 if (!s_hIcons[type]) | 1678 if (!s_hIcons[type]) |
| 1626 { | 1679 { |
| 1627 s_hIcons[type] = ::LoadIcon(_Module.m_hInst, MAKEINTRESOURCE(s_hIconTypes[ type])); | 1680 std::wstring imageToLoad = L"#"; |
| 1681 imageToLoad += std::to_wstring(s_hIconTypes[type]); | |
| 1682 s_hIcons[type] = (HICON)::LoadImage(_Module.m_hInst, imageToLoad.c_str(), IMAGE_ICON, iconWidth, iconHeight, LR_SHARED); | |
| 1628 if (!s_hIcons[type]) | 1683 if (!s_hIcons[type]) |
| 1629 { | 1684 { |
| 1630 DEBUG_ERROR_LOG(::GetLastError(), PLUGIN_ERROR_UI, PLUGIN_ERROR_UI_LOAD_ ICON, "Class::GetIcon - LoadIcon") | 1685 DEBUG_ERROR_LOG(::GetLastError(), PLUGIN_ERROR_UI, PLUGIN_ERROR_UI_LOAD_ ICON, "Class::GetIcon - LoadIcon"); |
| 1631 } | 1686 } |
| 1632 } | 1687 } |
| 1633 | 1688 |
| 1634 icon = s_hIcons[type]; | 1689 icon = s_hIcons[type]; |
| 1635 } | 1690 } |
| 1636 s_criticalSectionLocal.Unlock(); | 1691 s_criticalSectionLocal.Unlock(); |
| 1637 | 1692 |
| 1638 return icon; | 1693 return icon; |
| 1639 } | 1694 } |
| 1640 | 1695 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1701 break; | 1756 break; |
| 1702 } | 1757 } |
| 1703 s_criticalSectionLocal.Unlock(); | 1758 s_criticalSectionLocal.Unlock(); |
| 1704 | 1759 |
| 1705 } | 1760 } |
| 1706 } | 1761 } |
| 1707 } | 1762 } |
| 1708 | 1763 |
| 1709 hTabWnd = ::GetWindow(hTabWnd, GW_HWNDNEXT); | 1764 hTabWnd = ::GetWindow(hTabWnd, GW_HWNDNEXT); |
| 1710 } | 1765 } |
| 1711 | |
| 1712 return hTabWnd; | 1766 return hTabWnd; |
| 1713 | 1767 } |
| 1714 } | |
| LEFT | RIGHT |