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 "PluginAppNamespaceClient.h" |
25 #include "PluginClient.h" | 25 #include "PluginClient.h" |
26 #include "PluginMutex.h" | 26 #include "PluginMutex.h" |
27 #include "sddl.h" | 27 #include "sddl.h" |
28 #include "PluginUtil.h" | 28 #include "PluginUtil.h" |
29 #include "PluginUserSettings.h" | 29 #include "PluginUserSettings.h" |
30 #include "../shared/Utils.h" | 30 #include "../shared/Utils.h" |
31 #include "../shared/Dictionary.h" | 31 #include "../shared/Dictionary.h" |
32 #include "../shared/IE_version.h" | 32 #include "../shared/IE_version.h" |
33 #include <thread> | 33 #include <thread> |
34 #include <array> | 34 #include <array> |
35 | 35 |
36 #ifdef DEBUG_HIDE_EL | 36 #ifdef DEBUG_HIDE_EL |
37 DWORD profileTime = 0; | 37 DWORD profileTime = 0; |
38 #endif | 38 #endif |
39 | 39 |
40 typedef HANDLE (WINAPI *OPENTHEMEDATA)(HWND, LPCWSTR); | 40 typedef HANDLE (WINAPI *OPENTHEMEDATA)(HWND, LPCWSTR); |
41 typedef HRESULT (WINAPI *DRAWTHEMEBACKGROUND)(HANDLE, HDC, INT, INT, LPRECT, LPR
ECT); | 41 typedef HRESULT (WINAPI *DRAWTHEMEBACKGROUND)(HANDLE, HDC, INT, INT, LPRECT, LPR
ECT); |
42 typedef HRESULT (WINAPI *CLOSETHEMEDATA)(HANDLE); | 42 typedef HRESULT (WINAPI *CLOSETHEMEDATA)(HANDLE); |
43 | 43 |
44 HICON CPluginClass::s_hIcons[ICON_MAX] = { NULL, NULL, NULL }; | 44 HICON CPluginClass::s_hIcons[ICON_MAX] = { NULL, NULL, NULL }; |
45 DWORD CPluginClass::s_hIconTypes[ICON_MAX] = { IDI_ICON_DISABLED, IDI_ICON_ENABL
ED, IDI_ICON_DEACTIVATED }; | 45 DWORD CPluginClass::s_hIconTypes[ICON_MAX] = { IDI_ICON_DISABLED, IDI_ICON_ENABL
ED, IDI_ICON_DEACTIVATED }; |
46 uint32_t iconHeight = 32; | 46 uint32_t iconHeight = 32; |
47 uint32_t iconWidth = 32; | 47 uint32_t iconWidth = 32; |
48 | 48 |
49 std::shared_ptr<CPluginMimeFilterClient> CPluginClass::s_mimeFilter = NULL; | 49 std::shared_ptr<CPluginAppNamespaceClient> CPluginClass::s_mimeFilter = NULL; |
50 | 50 |
51 CLOSETHEMEDATA pfnClose = NULL; | 51 CLOSETHEMEDATA pfnClose = NULL; |
52 DRAWTHEMEBACKGROUND pfnDrawThemeBackground = NULL; | 52 DRAWTHEMEBACKGROUND pfnDrawThemeBackground = NULL; |
53 OPENTHEMEDATA pfnOpenThemeData = NULL; | 53 OPENTHEMEDATA pfnOpenThemeData = NULL; |
54 | 54 |
55 ATOM CPluginClass::s_atomPaneClass = NULL; | 55 ATOM CPluginClass::s_atomPaneClass = NULL; |
56 HINSTANCE CPluginClass::s_hUxtheme = NULL; | 56 HINSTANCE CPluginClass::s_hUxtheme = NULL; |
57 std::set<CPluginClass*> CPluginClass::s_instances; | 57 std::set<CPluginClass*> CPluginClass::s_instances; |
58 std::map<DWORD, CPluginClass*> CPluginClass::s_threadInstances; | 58 std::map<DWORD, CPluginClass*> CPluginClass::s_threadInstances; |
59 | 59 |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 | 241 |
242 //register the mimefilter | 242 //register the mimefilter |
243 //and only mimefilter | 243 //and only mimefilter |
244 //on some few computers the mimefilter does not get properly registered wh
en it is done on another thread | 244 //on some few computers the mimefilter does not get properly registered wh
en it is done on another thread |
245 | 245 |
246 s_criticalSectionLocal.Lock(); | 246 s_criticalSectionLocal.Lock(); |
247 { | 247 { |
248 // Always register on startup, then check if we need to unregister in a
separate thread | 248 // Always register on startup, then check if we need to unregister in a
separate thread |
249 if (!s_mimeFilter) | 249 if (!s_mimeFilter) |
250 { | 250 { |
251 s_mimeFilter.reset(new CPluginMimeFilterClient()); | 251 s_mimeFilter.reset(new CPluginAppNamespaceClient()); |
252 } | 252 } |
253 s_asyncWebBrowser2 = unknownSite; | 253 s_asyncWebBrowser2 = unknownSite; |
254 s_instances.insert(this); | 254 s_instances.insert(this); |
255 } | 255 } |
256 s_criticalSectionLocal.Unlock(); | 256 s_criticalSectionLocal.Unlock(); |
257 | 257 |
258 try | 258 try |
259 { | 259 { |
260 auto webBrowser = GetBrowser(); | 260 auto webBrowser = GetBrowser(); |
261 if (webBrowser) | 261 if (webBrowser) |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
475 { | 475 { |
476 return; | 476 return; |
477 } | 477 } |
478 if (!urlVariant || urlVariant->vt != VT_BSTR) | 478 if (!urlVariant || urlVariant->vt != VT_BSTR) |
479 { | 479 { |
480 return; | 480 return; |
481 } | 481 } |
482 std::wstring url(urlVariant->bstrVal, SysStringLen(urlVariant->bstrVal)); | 482 std::wstring url(urlVariant->bstrVal, SysStringLen(urlVariant->bstrVal)); |
483 UnescapeUrl(url); | 483 UnescapeUrl(url); |
484 | 484 |
| 485 //Register a mime filter if it's not registered yet |
| 486 if (s_mimeFilter == nullptr) |
| 487 { |
| 488 s_mimeFilter = CPluginClientFactory::GetMimeFilterClientInstance(); |
| 489 } |
485 // If webbrowser2 is equal to top level browser (as set in SetSite), we are | 490 // If webbrowser2 is equal to top level browser (as set in SetSite), we are |
486 // navigating new page | 491 // navigating new page |
487 CPluginClient* client = CPluginClient::GetInstance(); | 492 CPluginClient* client = CPluginClient::GetInstance(); |
488 if (url.find(L"javascript") == 0) | 493 if (url.find(L"javascript") == 0) |
489 { | 494 { |
490 } | 495 } |
491 else if (GetBrowser().IsEqualObject(webBrowser)) | 496 else if (GetBrowser().IsEqualObject(webBrowser)) |
492 { | 497 { |
493 m_tab->OnNavigate(url); | 498 m_tab->OnNavigate(url); |
494 DEBUG_GENERAL( | 499 DEBUG_GENERAL( |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
696 } | 701 } |
697 | 702 |
698 int ieVersion = AdblockPlus::IE::InstalledMajorVersion(); | 703 int ieVersion = AdblockPlus::IE::InstalledMajorVersion(); |
699 // Create status pane | 704 // Create status pane |
700 if (ieVersion > 6 && !CreateStatusBarPane()) | 705 if (ieVersion > 6 && !CreateStatusBarPane()) |
701 { | 706 { |
702 return false; | 707 return false; |
703 } | 708 } |
704 | 709 |
705 s_criticalSectionLocal.Lock(); | 710 s_criticalSectionLocal.Lock(); |
706 if (CPluginClient::GetInstance()->GetPref(L"currentVersion", L"0.0").find(L"si
mpleadblock") != std::wstring::npos) | |
707 { | |
708 CPluginClient::GetInstance()->SetPref(L"isFromSimpleAdblock", true); | |
709 CPluginClient::GetInstance()->SetPref(L"currentVersion", std::wstring(IEPLUG
IN_VERSION)); | |
710 } | |
711 int versionCompRes = CPluginClient::GetInstance()->CompareVersions(CPluginClie
nt::GetInstance()->GetPref(L"currentVersion", L"0.0"), L"1.2"); | 711 int versionCompRes = CPluginClient::GetInstance()->CompareVersions(CPluginClie
nt::GetInstance()->GetPref(L"currentVersion", L"0.0"), L"1.2"); |
712 | 712 |
713 bool isFirstRun = CPluginClient::GetInstance()->IsFirstRun(); | 713 bool isFirstRun = CPluginClient::GetInstance()->IsFirstRun(); |
714 CPluginClient::GetInstance()->SetPref(L"currentVersion", std::wstring(IEPLUGIN
_VERSION)); | 714 CPluginClient::GetInstance()->SetPref(L"currentVersion", std::wstring(IEPLUGIN
_VERSION)); |
715 // This is the first time ABP was installed | 715 // This is the first time ABP was installed |
716 // Or ABP was updated from the version that did not support Acceptable Ads (<1
.2) | 716 // Or ABP was updated from the version that did not support Acceptable Ads (<1
.2) |
717 if (isFirstRun || versionCompRes < 0) | 717 if (isFirstRun || versionCompRes < 0) |
718 { | 718 { |
719 if (!isFirstRun) | 719 if (!isFirstRun) |
720 { | 720 { |
721 if (!CPluginClient::GetInstance()->GetPref(std::wstring(L"isFromSimpleAdbl
ock"), false)) | 721 CPluginClient::GetInstance()->SetPref(L"displayUpdatePage", true); |
722 { | |
723 CPluginClient::GetInstance()->SetPref(L"displayUpdatePage", true); | |
724 } | |
725 } | 722 } |
726 | 723 |
727 // IE6 can't be accessed from another thread, execute in current thread | 724 // IE6 can't be accessed from another thread, execute in current thread |
728 if (ieVersion < 7) | 725 if (ieVersion < 7) |
729 { | 726 { |
730 FirstRunThread(); | 727 FirstRunThread(); |
731 } | 728 } |
732 else | 729 else |
733 { | 730 { |
734 CreateThread(NULL, NULL, (LPTHREAD_START_ROUTINE)CPluginClass::FirstRunThr
ead, NULL, NULL, NULL); | 731 CreateThread(NULL, NULL, (LPTHREAD_START_ROUTINE)CPluginClass::FirstRunThr
ead, NULL, NULL, NULL); |
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1079 { | 1076 { |
1080 CPluginSettings* settings = CPluginSettings::GetInstance(); | 1077 CPluginSettings* settings = CPluginSettings::GetInstance(); |
1081 | 1078 |
1082 settings->TogglePluginEnabled(); | 1079 settings->TogglePluginEnabled(); |
1083 | 1080 |
1084 // Enable / disable mime filter | 1081 // Enable / disable mime filter |
1085 s_criticalSectionLocal.Lock(); | 1082 s_criticalSectionLocal.Lock(); |
1086 { | 1083 { |
1087 if (settings->GetPluginEnabled()) | 1084 if (settings->GetPluginEnabled()) |
1088 { | 1085 { |
1089 s_mimeFilter.reset(new CPluginMimeFilterClient()); | 1086 s_mimeFilter.reset(new CPluginAppNamespaceClient()); |
1090 } | 1087 } |
1091 else | 1088 else |
1092 { | 1089 { |
1093 s_mimeFilter.reset(); | 1090 s_mimeFilter.reset(); |
1094 } | 1091 } |
1095 } | 1092 } |
1096 s_criticalSectionLocal.Unlock(); | 1093 s_criticalSectionLocal.Unlock(); |
1097 } | 1094 } |
1098 break; | 1095 break; |
1099 case ID_MENU_SETTINGS: | 1096 case ID_MENU_SETTINGS: |
(...skipping 631 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1731 s_criticalSectionLocal.Unlock(); | 1728 s_criticalSectionLocal.Unlock(); |
1732 | 1729 |
1733 } | 1730 } |
1734 } | 1731 } |
1735 } | 1732 } |
1736 | 1733 |
1737 hTabWnd = ::GetWindow(hTabWnd, GW_HWNDNEXT); | 1734 hTabWnd = ::GetWindow(hTabWnd, GW_HWNDNEXT); |
1738 } | 1735 } |
1739 return hTabWnd; | 1736 return hTabWnd; |
1740 } | 1737 } |
LEFT | RIGHT |