| 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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 194 { | 195 { |
| 195 url = m_tab->GetDocumentUrl(); | 196 url = m_tab->GetDocumentUrl(); |
| 196 } | 197 } |
| 197 return url; | 198 return url; |
| 198 } | 199 } |
| 199 | 200 |
| 200 DWORD WINAPI CPluginClass::StartInitObject(LPVOID thisPtr) | 201 DWORD WINAPI CPluginClass::StartInitObject(LPVOID thisPtr) |
| 201 { | 202 { |
| 202 if (thisPtr == NULL) | 203 if (thisPtr == NULL) |
| 203 return 0; | 204 return 0; |
| 204 if (!((CPluginClass*)thisPtr)->InitObject(true)) | 205 if (!((CPluginClass*)thisPtr)->InitObject()) |
| 205 { | 206 { |
| 206 ((CPluginClass*)thisPtr)->Unadvise(); | 207 ((CPluginClass*)thisPtr)->Unadvise(); |
| 207 } | 208 } |
| 208 | 209 |
| 209 return 0; | 210 return 0; |
| 210 } | 211 } |
| 211 | 212 |
| 212 // This gets called when a new browser window is created (which also triggers th e | 213 /* |
| 213 // creation of this object). The pointer passed in should be to a IWebBrowser2 | 214 * IE calls this when it creates a new browser window or tab, immediately after it also |
| 214 // interface that represents the browser for the window. | 215 * creates the object. The argument 'unknownSite' in is the OLE "site" of the ob ject, |
| 215 // it is also called when a tab is closed, this unknownSite will be null | 216 * which is an IWebBrowser2 interface associated with the window/tab. |
| 216 // so we should handle that it is called this way several times during a session | 217 * |
| 218 * IE also ordinarily calls this again when its window/tab is closed, in which c ase | |
| 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 */ | |
| 217 STDMETHODIMP CPluginClass::SetSite(IUnknown* unknownSite) | 223 STDMETHODIMP CPluginClass::SetSite(IUnknown* unknownSite) |
| 218 { | 224 { |
| 219 CPluginSettings* settings = CPluginSettings::GetInstance(); | 225 try |
| 220 | 226 { |
| 221 MULTIPLE_VERSIONS_CHECK(); | 227 if (unknownSite) |
| 222 | 228 { |
| 223 if (unknownSite) | 229 |
| 224 { | 230 DEBUG_GENERAL(L"========================================================== ======================\nNEW TAB UI\n============================================ ====================================") |
| 225 | 231 |
| 226 DEBUG_GENERAL(L"============================================================ ====================\nNEW TAB UI\n============================================== ==================================") | 232 HRESULT hr = ::CoInitialize(NULL); |
| 227 | 233 if (FAILED(hr)) |
| 228 HRESULT hr = ::CoInitialize(NULL); | 234 { |
| 229 if (FAILED(hr)) | 235 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_SET_SITE, PLUGIN_ERROR_SET_SITE_COINIT, "Class::SetSite - CoInitialize"); |
| 230 { | 236 } |
| 231 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_SET_SITE, PLUGIN_ERROR_SET_SITE_COINIT, " Class::SetSite - CoInitialize"); | 237 |
| 232 } | 238 s_criticalSectionBrowser.Lock(); |
| 233 | 239 { |
| 234 s_criticalSectionBrowser.Lock(); | 240 m_webBrowser2 = unknownSite; |
| 235 { | 241 } |
| 236 m_webBrowser2 = unknownSite; | 242 s_criticalSectionBrowser.Unlock(); |
| 237 } | 243 |
| 238 s_criticalSectionBrowser.Unlock(); | 244 //register the mimefilter |
| 239 | 245 //and only mimefilter |
| 240 //register the mimefilter | 246 //on some few computers the mimefilter does not get properly registered wh en it is done on another thread |
| 241 //and only mimefilter | 247 |
| 242 //on some few computers the mimefilter does not get properly registered when it is done on another thread | 248 s_criticalSectionLocal.Lock(); |
| 243 | 249 { |
| 244 s_criticalSectionLocal.Lock(); | 250 // Always register on startup, then check if we need to unregister in a separate thread |
| 245 { | 251 s_mimeFilter = CPluginClientFactory::GetMimeFilterClientInstance(); |
| 246 // Always register on startup, then check if we need to unregister in a se parate thread | 252 s_asyncWebBrowser2 = unknownSite; |
| 247 s_mimeFilter = CPluginClientFactory::GetMimeFilterClientInstance(); | 253 s_instances.insert(this); |
| 248 s_asyncWebBrowser2 = unknownSite; | 254 } |
| 249 s_instances.insert(this); | 255 s_criticalSectionLocal.Unlock(); |
| 250 } | 256 |
| 251 s_criticalSectionLocal.Unlock(); | 257 try |
| 252 | 258 { |
| 253 try | 259 auto webBrowser = GetBrowser(); |
| 254 { | 260 if (webBrowser) |
| 255 // Check if loaded as BHO | 261 { |
| 256 auto webBrowser = GetBrowser(); | 262 DEBUG_GENERAL("Loaded as BHO"); |
| 257 if (webBrowser) | 263 HRESULT hr = DispEventAdvise(webBrowser); |
| 258 { | 264 if (SUCCEEDED(hr)) |
| 259 DEBUG_GENERAL("Loaded as BHO"); | |
| 260 HRESULT hr = DispEventAdvise(webBrowser); | |
| 261 if (SUCCEEDED(hr)) | |
| 262 { | |
| 263 m_isAdvised = true; | |
| 264 try | |
| 265 { | 265 { |
| 266 std::thread startInitObjectThread(StartInitObject, this); | 266 m_isAdvised = true; |
| 267 startInitObjectThread.detach(); // TODO: but actually we should wait for the thread in the dtr. | 267 try |
| 268 { | |
| 269 std::thread startInitObjectThread(StartInitObject, this); | |
| 270 startInitObjectThread.detach(); // TODO: but actually we should wa it for the thread in the dtr. | |
| 271 } | |
| 272 catch (const std::system_error& ex) | |
| 273 { | |
| 274 DEBUG_SYSTEM_EXCEPTION(ex, PLUGIN_ERROR_THREAD, PLUGIN_ERROR_MAIN_ THREAD_CREATE_PROCESS, | |
| 275 "Class::Thread - Failed to create StartInitObject thread"); | |
| 276 } | |
| 268 } | 277 } |
| 269 catch (const std::system_error& ex) | 278 else |
| 270 { | 279 { |
| 271 DEBUG_SYSTEM_EXCEPTION(ex, PLUGIN_ERROR_THREAD, PLUGIN_ERROR_MAIN_TH READ_CREATE_PROCESS, | 280 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_SET_SITE, PLUGIN_ERROR_SET_SITE_ADV ICE, "Class::SetSite - Advise"); |
| 272 "Class::Thread - Failed to create StartInitObject thread"); | |
| 273 } | 281 } |
| 274 } | 282 } |
| 275 else | 283 } |
| 276 { | 284 catch (const std::runtime_error& ex) |
| 277 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_SET_SITE, PLUGIN_ERROR_SET_SITE_ADVIC E, "Class::SetSite - Advise"); | 285 { |
| 278 } | 286 DEBUG_EXCEPTION(ex); |
| 279 } | 287 Unadvise(); |
| 280 else // Check if loaded as toolbar handler | 288 } |
| 281 { | 289 } |
| 282 DEBUG_GENERAL("Loaded as toolbar handler"); | 290 else |
| 283 CComPtr<IServiceProvider> pServiceProvider; | 291 { |
| 284 | |
| 285 HRESULT hr = unknownSite->QueryInterface(&pServiceProvider); | |
| 286 if (SUCCEEDED(hr)) | |
| 287 { | |
| 288 if (pServiceProvider) | |
| 289 { | |
| 290 s_criticalSectionBrowser.Lock(); | |
| 291 { | |
| 292 HRESULT hr = pServiceProvider->QueryService(IID_IWebBrowserApp, &m _webBrowser2); | |
| 293 if (SUCCEEDED(hr)) | |
| 294 { | |
| 295 if (m_webBrowser2) | |
| 296 { | |
| 297 InitObject(false); | |
| 298 } | |
| 299 } | |
| 300 else | |
| 301 { | |
| 302 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_SET_SITE, PLUGIN_ERROR_SET_SITE _QUERY_BROWSER, "Class::SetSite - QueryService (IID_IWebBrowserApp)"); | |
| 303 } | |
| 304 } | |
| 305 s_criticalSectionBrowser.Unlock(); | |
| 306 } | |
| 307 } | |
| 308 else | |
| 309 { | |
| 310 DEBUG_ERROR_LOG(hr, PLUGIN_ERROR_SET_SITE, PLUGIN_ERROR_SET_SITE_QUERY _SERVICE_PROVIDER, "Class::SetSite - QueryInterface (service provider)"); | |
| 311 } | |
| 312 } | |
| 313 } | |
| 314 catch (const std::runtime_error& ex) | |
| 315 { | |
| 316 DEBUG_EXCEPTION(ex); | |
| 317 Unadvise(); | 292 Unadvise(); |
| 318 } | 293 |
| 319 } | 294 // Destroy window |
| 320 else | 295 if (m_pWndProcStatus) |
| 321 { | 296 { |
| 322 Unadvise(); | 297 ::SetWindowLongPtr(m_hStatusBarWnd, GWLP_WNDPROC, (LPARAM)(WNDPROC)m_pWn dProcStatus); |
| 323 | 298 |
| 324 // Destroy window | 299 m_pWndProcStatus = NULL; |
| 325 if (m_pWndProcStatus) | 300 } |
| 326 { | 301 |
| 327 ::SetWindowLongPtr(m_hStatusBarWnd, GWLP_WNDPROC, (LPARAM)(WNDPROC)m_pWndP rocStatus); | 302 if (m_hPaneWnd) |
| 328 | 303 { |
| 329 m_pWndProcStatus = NULL; | 304 DestroyWindow(m_hPaneWnd); |
| 330 } | 305 m_hPaneWnd = NULL; |
| 331 | 306 } |
| 332 if (m_hPaneWnd) | 307 |
| 333 { | 308 m_hTabWnd = NULL; |
| 334 DestroyWindow(m_hPaneWnd); | 309 m_hStatusBarWnd = NULL; |
| 335 m_hPaneWnd = NULL; | 310 |
| 336 } | 311 // Remove instance from the list, shutdown threads |
| 337 | 312 HANDLE hMainThread = NULL; |
| 338 m_hTabWnd = NULL; | 313 HANDLE hTabThread = NULL; |
| 339 m_hStatusBarWnd = NULL; | 314 |
| 340 | 315 s_criticalSectionLocal.Lock(); |
| 341 // Remove instance from the list, shutdown threads | 316 { |
| 342 HANDLE hMainThread = NULL; | 317 s_instances.erase(this); |
| 343 HANDLE hTabThread = NULL; | 318 |
| 344 | 319 std::map<DWORD,CPluginClass*>::iterator it = s_threadInstances.find(::Ge tCurrentThreadId()); |
| 345 s_criticalSectionLocal.Lock(); | 320 if (it != s_threadInstances.end()) |
| 346 { | 321 { |
| 347 s_instances.erase(this); | 322 s_threadInstances.erase(it); |
| 348 | 323 } |
| 349 std::map<DWORD,CPluginClass*>::iterator it = s_threadInstances.find(::GetC urrentThreadId()); | 324 if (s_instances.empty()) |
| 350 if (it != s_threadInstances.end()) | 325 { |
| 351 { | 326 // TODO: Explicitly releasing a resource when a container becomes empt y looks like a job better suited for shared_ptr |
| 352 s_threadInstances.erase(it); | 327 CPluginClientFactory::ReleaseMimeFilterClientInstance(); |
| 353 } | 328 } |
| 354 if (s_instances.empty()) | 329 } |
| 355 { | 330 s_criticalSectionLocal.Unlock(); |
| 356 // TODO: Explicitly releasing a resource when a container becomes empty looks like a job better suited for shared_ptr | 331 |
| 357 CPluginClientFactory::ReleaseMimeFilterClientInstance(); | 332 // Release browser interface |
| 358 } | 333 s_criticalSectionBrowser.Lock(); |
| 359 } | 334 { |
| 360 s_criticalSectionLocal.Unlock(); | 335 m_webBrowser2.Release(); |
| 361 | 336 } |
| 362 // Release browser interface | 337 s_criticalSectionBrowser.Unlock(); |
| 363 s_criticalSectionBrowser.Lock(); | 338 |
| 364 { | 339 DEBUG_GENERAL("=========================================================== =====================\nNEW TAB UI - END\n======================================= =========================================") |
| 365 m_webBrowser2.Release(); | 340 |
| 366 } | 341 ::CoUninitialize(); |
| 367 s_criticalSectionBrowser.Unlock(); | 342 } |
| 368 | 343 |
| 369 DEBUG_GENERAL("============================================================= ===================\nNEW TAB UI - END\n========================================= =======================================") | 344 IObjectWithSiteImpl<CPluginClass>::SetSite(unknownSite); |
| 370 | 345 } |
| 371 ::CoUninitialize(); | 346 catch (...) |
| 372 } | 347 { |
| 373 | 348 } |
| 374 return IObjectWithSiteImpl<CPluginClass>::SetSite(unknownSite); | 349 return S_OK; |
| 375 } | 350 } |
| 376 | 351 |
| 377 bool CPluginClass::IsStatusBarEnabled() | 352 bool CPluginClass::IsStatusBarEnabled() |
| 378 { | 353 { |
| 379 DEBUG_GENERAL("IsStatusBarEnabled start"); | 354 DEBUG_GENERAL("IsStatusBarEnabled start"); |
| 380 HKEY pHkey; | 355 HKEY pHkey; |
| 381 HKEY pHkeySub; | 356 HKEY pHkeySub; |
| 382 RegOpenCurrentUser(KEY_QUERY_VALUE, &pHkey); | 357 RegOpenCurrentUser(KEY_QUERY_VALUE, &pHkey); |
| 383 DWORD truth = 1; | 358 DWORD truth = 1; |
| 384 DWORD truthSize = sizeof(truth); | 359 DWORD truthSize = sizeof(truth); |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 504 { | 479 { |
| 505 return; | 480 return; |
| 506 } | 481 } |
| 507 if (!urlVariant || urlVariant->vt != VT_BSTR) | 482 if (!urlVariant || urlVariant->vt != VT_BSTR) |
| 508 { | 483 { |
| 509 return; | 484 return; |
| 510 } | 485 } |
| 511 std::wstring url(urlVariant->bstrVal, SysStringLen(urlVariant->bstrVal)); | 486 std::wstring url(urlVariant->bstrVal, SysStringLen(urlVariant->bstrVal)); |
| 512 UnescapeUrl(url); | 487 UnescapeUrl(url); |
| 513 | 488 |
| 514 //Register a mime filter if it's not registered yet | |
| 515 if (s_mimeFilter == nullptr) | |
| 516 { | |
| 517 s_mimeFilter = CPluginClientFactory::GetMimeFilterClientInstance(); | |
| 518 } | |
| 519 // If webbrowser2 is equal to top level browser (as set in SetSite), we are | 489 // If webbrowser2 is equal to top level browser (as set in SetSite), we are |
| 520 // navigating new page | 490 // navigating new page |
| 521 CPluginClient* client = CPluginClient::GetInstance(); | 491 CPluginClient* client = CPluginClient::GetInstance(); |
| 522 if (url.find(L"javascript") == 0) | 492 if (url.find(L"javascript") == 0) |
| 523 { | 493 { |
| 524 } | 494 } |
| 525 else if (GetBrowser().IsEqualObject(webBrowser)) | 495 else if (GetBrowser().IsEqualObject(webBrowser)) |
| 526 { | 496 { |
| 527 m_tab->OnNavigate(url); | 497 m_tab->OnNavigate(url); |
| 528 DEBUG_GENERAL( | 498 DEBUG_GENERAL( |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 594 && flags == (OLECMDIDF_WINDOWSTATE_USERVISIBLE | OLECMDIDF_WINDOWSTATE_ENA BLED); | 564 && flags == (OLECMDIDF_WINDOWSTATE_USERVISIBLE | OLECMDIDF_WINDOWSTATE_ENA BLED); |
| 595 if (newtabshown) | 565 if (newtabshown) |
| 596 { | 566 { |
| 597 std::map<DWORD,CPluginClass*>::const_iterator it = s_threadInstances.find( GetCurrentThreadId()); | 567 std::map<DWORD,CPluginClass*>::const_iterator it = s_threadInstances.find( GetCurrentThreadId()); |
| 598 if (it == s_threadInstances.end()) | 568 if (it == s_threadInstances.end()) |
| 599 { | 569 { |
| 600 s_threadInstances[::GetCurrentThreadId()] = this; | 570 s_threadInstances[::GetCurrentThreadId()] = this; |
| 601 if (!m_isInitializedOk) | 571 if (!m_isInitializedOk) |
| 602 { | 572 { |
| 603 m_isInitializedOk = true; | 573 m_isInitializedOk = true; |
| 604 InitObject(true); | 574 InitObject(); |
| 605 UpdateStatusBar(); | 575 UpdateStatusBar(); |
| 606 } | 576 } |
| 607 } | 577 } |
| 608 } | 578 } |
| 609 notificationMessage.Hide(); | 579 notificationMessage.Hide(); |
| 610 DEBUG_GENERAL(L"WindowStateChanged (check tab changed) end"); | 580 DEBUG_GENERAL(L"WindowStateChanged (check tab changed) end"); |
| 611 } | 581 } |
| 612 catch (...) | 582 catch (...) |
| 613 { | 583 { |
| 614 } | 584 } |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 647 { | 617 { |
| 648 try | 618 try |
| 649 { | 619 { |
| 650 Unadvise(); | 620 Unadvise(); |
| 651 } | 621 } |
| 652 catch (...) | 622 catch (...) |
| 653 { | 623 { |
| 654 } | 624 } |
| 655 } | 625 } |
| 656 | 626 |
| 657 bool CPluginClass::InitObject(bool bBHO) | 627 bool CPluginClass::InitObject() |
| 658 { | 628 { |
| 659 DEBUG_GENERAL("InitObject"); | 629 DEBUG_GENERAL("InitObject"); |
| 660 CPluginSettings* settings = CPluginSettings::GetInstance(); | 630 CPluginSettings* settings = CPluginSettings::GetInstance(); |
| 661 | 631 |
| 662 if (!settings->GetPluginEnabled()) | 632 if (!settings->GetPluginEnabled()) |
| 663 { | 633 { |
| 664 s_mimeFilter->Unregister(); | 634 s_mimeFilter->Unregister(); |
| 665 } | 635 } |
| 666 | 636 |
| 667 // Load theme module | 637 // Load theme module |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 724 | 694 |
| 725 if (!GetAtomPaneClass()) | 695 if (!GetAtomPaneClass()) |
| 726 { | 696 { |
| 727 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"); |
| 728 return false; | 698 return false; |
| 729 } | 699 } |
| 730 } | 700 } |
| 731 | 701 |
| 732 int ieVersion = AdblockPlus::IE::InstalledMajorVersion(); | 702 int ieVersion = AdblockPlus::IE::InstalledMajorVersion(); |
| 733 // Create status pane | 703 // Create status pane |
| 734 if (bBHO && ieVersion > 6 && !CreateStatusBarPane()) | 704 if (ieVersion > 6 && !CreateStatusBarPane()) |
| 735 { | 705 { |
| 736 return false; | 706 return false; |
| 737 } | 707 } |
| 738 | |
| 739 s_criticalSectionLocal.Lock(); | 708 s_criticalSectionLocal.Lock(); |
| 740 if (CPluginClient::GetInstance()->GetPref(L"currentVersion", L"0.0").find(L"si mpleadblock") != std::wstring::npos) | 709 std::wstring curVer = CPluginClient::GetInstance()->GetPref(L"currentVersion", L"0.0"); |
| 741 { | 710 int versionCompRes = CPluginClient::GetInstance()->CompareVersions(curVer, L"1 .2"); |
| 742 CPluginClient::GetInstance()->SetPref(L"isFromSimpleAdblock", true); | |
| 743 CPluginClient::GetInstance()->SetPref(L"currentVersion", std::wstring(IEPLUG IN_VERSION)); | |
|
Eric
2015/03/27 12:51:45
Instead of overloading "currentVersion", is it imp
Oleksandr
2015/04/16 09:58:09
We can only use one of the default prefs
| |
| 744 } | |
| 745 int versionCompRes = CPluginClient::GetInstance()->CompareVersions(CPluginClie nt::GetInstance()->GetPref(L"currentVersion", L"0.0"), L"1.2"); | |
| 746 | 711 |
| 747 bool isFirstRun = CPluginClient::GetInstance()->IsFirstRun(); | 712 bool isFirstRun = CPluginClient::GetInstance()->IsFirstRun(); |
| 748 CPluginClient::GetInstance()->SetPref(L"currentVersion", std::wstring(IEPLUGIN _VERSION)); | 713 CPluginClient::GetInstance()->SetPref(L"currentVersion", std::wstring(IEPLUGIN _VERSION)); |
| 749 // This is the first time ABP was installed | 714 // This is the first time ABP was installed |
| 750 // 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) |
| 751 if (isFirstRun || versionCompRes < 0) | 716 if (isFirstRun || versionCompRes < 0) |
| 752 { | 717 { |
| 753 if (!isFirstRun) | 718 if (!isFirstRun) |
| 754 { | 719 { |
| 755 if (!CPluginClient::GetInstance()->GetPref(std::wstring(L"isFromSimpleAdbl ock"), false)) | 720 // Display an update page only if it's not a conversion from other product |
| 721 if (CPluginClient::GetInstance()->GetConvertedFrom() == L"") | |
| 756 { | 722 { |
| 757 CPluginClient::GetInstance()->SetPref(L"displayUpdatePage", true); | 723 CPluginClient::GetInstance()->SetPref(L"displayUpdatePage", true); |
| 758 } | 724 } |
| 759 } | 725 } |
| 760 | 726 |
| 761 // 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 |
| 762 if (ieVersion < 7) | 728 if (ieVersion < 7) |
| 763 { | 729 { |
| 764 FirstRunThread(); | 730 FirstRunThread(); |
| 765 } | 731 } |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 946 | 912 |
| 947 HDC hdc = GetWindowDC(m_hStatusBarWnd); | 913 HDC hdc = GetWindowDC(m_hStatusBarWnd); |
| 948 SendMessage(m_hStatusBarWnd, WM_PAINT, (WPARAM)hdc, 0); | 914 SendMessage(m_hStatusBarWnd, WM_PAINT, (WPARAM)hdc, 0); |
| 949 ReleaseDC(m_hStatusBarWnd, hdc); | 915 ReleaseDC(m_hStatusBarWnd, hdc); |
| 950 | 916 |
| 951 return true; | 917 return true; |
| 952 } | 918 } |
| 953 | 919 |
| 954 void CPluginClass::FirstRunThread() | 920 void CPluginClass::FirstRunThread() |
| 955 { | 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 | |
| 956 CoInitialize(NULL); | 926 CoInitialize(NULL); |
| 957 VARIANT vFlags; | 927 VARIANT vFlags; |
| 958 vFlags.vt = VT_I4; | 928 vFlags.vt = VT_I4; |
| 959 vFlags.intVal = navOpenInNewTab; | 929 vFlags.intVal = navOpenInNewTab; |
| 960 | 930 |
| 961 CComBSTR navigatePath = CComBSTR(FirstRunPageFileUrl().c_str()); | 931 CComBSTR navigatePath = CComBSTR(FirstRunPageFileUrl().c_str()); |
| 962 | 932 |
| 963 HRESULT hr = GetAsyncBrowser()->Navigate(navigatePath, &vFlags, NULL, NULL, NU LL); | 933 HRESULT hr = GetAsyncBrowser()->Navigate(navigatePath, &vFlags, NULL, NULL, NU LL); |
| 964 if (FAILED(hr)) | 934 if (FAILED(hr)) |
| 965 { | 935 { |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1154 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") |
| 1155 } | 1125 } |
| 1156 } | 1126 } |
| 1157 } | 1127 } |
| 1158 break; | 1128 break; |
| 1159 } | 1129 } |
| 1160 case ID_MENU_DISABLE_ON_SITE: | 1130 case ID_MENU_DISABLE_ON_SITE: |
| 1161 { | 1131 { |
| 1162 CPluginSettings* settings = CPluginSettings::GetInstance(); | 1132 CPluginSettings* settings = CPluginSettings::GetInstance(); |
| 1163 std::wstring urlString = GetTab()->GetDocumentUrl(); | 1133 std::wstring urlString = GetTab()->GetDocumentUrl(); |
| 1164 if (client->IsWhitelistedUrl(urlString)) | 1134 std::string filterText = client->GetWhitelistingFilter(urlString); |
| 1165 { | 1135 if (!filterText.empty()) |
| 1166 settings->RemoveWhiteListedDomain(ToCString(client->GetHostFromUrl(urlSt ring))); | 1136 { |
| 1137 client->RemoveFilter(filterText); | |
| 1167 } | 1138 } |
| 1168 else | 1139 else |
| 1169 { | 1140 { |
| 1170 settings->AddWhiteListedDomain(ToCString(client->GetHostFromUrl(urlStrin g))); | 1141 settings->AddWhiteListedDomain(ToCString(client->GetHostFromUrl(urlStrin g))); |
| 1171 } | 1142 } |
| 1172 GetBrowser()->Refresh(); | |
| 1173 } | 1143 } |
| 1174 default: | 1144 default: |
| 1175 break; | 1145 break; |
| 1176 } | 1146 } |
| 1177 | 1147 |
| 1178 // Invalidate and redraw the control | 1148 // Invalidate and redraw the control |
| 1179 UpdateStatusBar(); | 1149 UpdateStatusBar(); |
| 1180 } | 1150 } |
| 1181 | 1151 |
| 1182 | 1152 |
| (...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1766 s_criticalSectionLocal.Unlock(); | 1736 s_criticalSectionLocal.Unlock(); |
| 1767 | 1737 |
| 1768 } | 1738 } |
| 1769 } | 1739 } |
| 1770 } | 1740 } |
| 1771 | 1741 |
| 1772 hTabWnd = ::GetWindow(hTabWnd, GW_HWNDNEXT); | 1742 hTabWnd = ::GetWindow(hTabWnd, GW_HWNDNEXT); |
| 1773 } | 1743 } |
| 1774 return hTabWnd; | 1744 return hTabWnd; |
| 1775 } | 1745 } |
| LEFT | RIGHT |