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 <AdblockPlus.h> | 18 #include <AdblockPlus.h> |
2 #include <functional> | 19 #include <functional> |
3 #include <vector> | 20 #include <vector> |
4 #include <thread> | 21 #include <thread> |
5 #include <Windows.h> | 22 #include <Windows.h> |
6 | 23 |
7 #include "../shared/AutoHandle.h" | 24 #include "../shared/AutoHandle.h" |
8 #include "../shared/Communication.h" | 25 #include "../shared/Communication.h" |
9 #include "../shared/Dictionary.h" | 26 #include "../shared/Dictionary.h" |
10 #include "../shared/Utils.h" | 27 #include "../shared/Utils.h" |
11 #include "../shared/Version.h" | 28 #include "../shared/Version.h" |
12 #include "../shared/CriticalSection.h" | 29 #include "../shared/CriticalSection.h" |
| 30 #include "../shared/IE_version.h" |
13 #include "AdblockPlus.h" | 31 #include "AdblockPlus.h" |
14 #include "Debug.h" | 32 #include "Debug.h" |
15 #include "Updater.h" | 33 #include "Updater.h" |
16 | 34 |
17 namespace | 35 namespace |
18 { | 36 { |
19 std::auto_ptr<AdblockPlus::FilterEngine> filterEngine; | 37 std::auto_ptr<AdblockPlus::FilterEngine> filterEngine; |
20 std::auto_ptr<Updater> updater; | 38 std::auto_ptr<Updater> updater; |
21 int activeConnections = 0; | 39 int activeConnections = 0; |
22 CriticalSection activeConnectionsLock; | 40 CriticalSection activeConnectionsLock; |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 { | 99 { |
82 Communication::OutputBuffer response; | 100 Communication::OutputBuffer response; |
83 | 101 |
84 Communication::ProcType procedure; | 102 Communication::ProcType procedure; |
85 request >> procedure; | 103 request >> procedure; |
86 switch (procedure) | 104 switch (procedure) |
87 { | 105 { |
88 case Communication::PROC_MATCHES: | 106 case Communication::PROC_MATCHES: |
89 { | 107 { |
90 std::string url; | 108 std::string url; |
| 109 using namespace AdblockPlus; |
| 110 std::string documentUrl; |
91 int32_t type; | 111 int32_t type; |
92 std::string documentUrl; | |
93 request >> url >> type >> documentUrl; | 112 request >> url >> type >> documentUrl; |
94 referrerMapping.Add(url, documentUrl); | 113 referrerMapping.Add(url, documentUrl); |
95 auto contentType = static_cast<AdblockPlus::FilterEngine::ContentType>(t
ype); | 114 auto contentType = static_cast<FilterEngine::ContentType>(type); |
96 AdblockPlus::FilterPtr filter = filterEngine->Matches(url, contentType,
referrerMapping.BuildReferrerChain(documentUrl)); | 115 FilterPtr filter = filterEngine->Matches(url, contentType, referrerMappi
ng.BuildReferrerChain(documentUrl)); |
97 response << (filter && filter->GetType() != AdblockPlus::Filter::TYPE_EX
CEPTION); | 116 response << (filter && filter->GetType() != Filter::TYPE_EXCEPTION); |
98 break; | 117 break; |
99 } | 118 } |
100 case Communication::PROC_GET_ELEMHIDE_SELECTORS: | 119 case Communication::PROC_GET_ELEMHIDE_SELECTORS: |
101 { | 120 { |
102 std::string domain; | 121 std::string domain; |
103 request >> domain; | 122 request >> domain; |
104 WriteStrings(response, filterEngine->GetElementHidingSelectors(domain)); | 123 WriteStrings(response, filterEngine->GetElementHidingSelectors(domain)); |
105 break; | 124 break; |
106 } | 125 } |
107 case Communication::PROC_AVAILABLE_SUBSCRIPTIONS: | 126 case Communication::PROC_AVAILABLE_SUBSCRIPTIONS: |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 response << (match && match->GetType() == AdblockPlus::Filter::TYPE_EXCE
PTION); | 217 response << (match && match->GetType() == AdblockPlus::Filter::TYPE_EXCE
PTION); |
199 break; | 218 break; |
200 } | 219 } |
201 case Communication::PROC_IS_ELEMHIDE_WHITELISTED_ON_URL: | 220 case Communication::PROC_IS_ELEMHIDE_WHITELISTED_ON_URL: |
202 { | 221 { |
203 std::string url; | 222 std::string url; |
204 request >> url; | 223 request >> url; |
205 AdblockPlus::FilterPtr match = filterEngine->Matches(url, | 224 AdblockPlus::FilterPtr match = filterEngine->Matches(url, |
206 AdblockPlus::FilterEngine::ContentType::CONTENT_TYPE_ELEMHIDE, url); | 225 AdblockPlus::FilterEngine::ContentType::CONTENT_TYPE_ELEMHIDE, url); |
207 response << (match && match->GetType() == AdblockPlus::Filter::TYPE_EXCE
PTION); | 226 response << (match && match->GetType() == AdblockPlus::Filter::TYPE_EXCE
PTION); |
208 if (match && match->GetType() == AdblockPlus::Filter::TYPE_EXCEPTION) | |
209 { | |
210 std::string(); | |
211 } | |
212 break; | 227 break; |
213 } | 228 } |
214 case Communication::PROC_ADD_FILTER: | 229 case Communication::PROC_ADD_FILTER: |
215 { | 230 { |
216 std::string text; | 231 std::string text; |
217 request >> text; | 232 request >> text; |
218 | 233 |
219 filterEngine->GetFilter(text)->AddToList(); | 234 filterEngine->GetFilter(text)->AddToList(); |
220 break; | 235 break; |
221 } | 236 } |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
324 case Communication::PROC_COMPARE_VERSIONS: | 339 case Communication::PROC_COMPARE_VERSIONS: |
325 { | 340 { |
326 std::string v1, v2; | 341 std::string v1, v2; |
327 request >> v1 >> v2; | 342 request >> v1 >> v2; |
328 | 343 |
329 response << filterEngine->CompareVersions(v1, v2); | 344 response << filterEngine->CompareVersions(v1, v2); |
330 break; | 345 break; |
331 } | 346 } |
332 case Communication::PROC_GET_DOCUMENTATION_LINK: | 347 case Communication::PROC_GET_DOCUMENTATION_LINK: |
333 { | 348 { |
334 response << ToUtf16String(filterEngine->GetPref("documentation_link")->A
sString()); | 349 response << filterEngine->GetPref("documentation_link")->AsString(); |
335 break; | 350 break; |
336 } | 351 } |
337 case Communication::PROC_TOGGLE_PLUGIN_ENABLED: | 352 case Communication::PROC_TOGGLE_PLUGIN_ENABLED: |
338 { | 353 { |
339 filterEngine->SetPref("enabled", filterEngine->GetJsEngine()->NewValue(!
filterEngine->GetPref("enabled")->AsBool())); | 354 filterEngine->SetPref("enabled", filterEngine->GetJsEngine()->NewValue(!
filterEngine->GetPref("enabled")->AsBool())); |
340 response << filterEngine->GetPref("enabled")->AsBool(); | 355 response << filterEngine->GetPref("enabled")->AsBool(); |
341 break; | 356 break; |
342 } | 357 } |
343 case Communication::PROC_GET_HOST: | 358 case Communication::PROC_GET_HOST: |
344 { | 359 { |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
422 std::auto_ptr<AdblockPlus::FilterEngine> CreateFilterEngine(const std::wstring&
locale) | 437 std::auto_ptr<AdblockPlus::FilterEngine> CreateFilterEngine(const std::wstring&
locale) |
423 { | 438 { |
424 AdblockPlus::AppInfo appInfo; | 439 AdblockPlus::AppInfo appInfo; |
425 appInfo.version = ToUtf8String(IEPLUGIN_VERSION); | 440 appInfo.version = ToUtf8String(IEPLUGIN_VERSION); |
426 appInfo.name = "adblockplusie"; | 441 appInfo.name = "adblockplusie"; |
427 #ifdef _WIN64 | 442 #ifdef _WIN64 |
428 appInfo.application = "msie64"; | 443 appInfo.application = "msie64"; |
429 #else | 444 #else |
430 appInfo.application = "msie32"; | 445 appInfo.application = "msie32"; |
431 #endif | 446 #endif |
432 // TODO: Set applicationVersion parameter | 447 appInfo.applicationVersion = ToUtf8String(AdblockPlus::IE::InstalledVersionStr
ing()); |
433 appInfo.locale = ToUtf8String(locale); | 448 appInfo.locale = ToUtf8String(locale); |
434 #ifdef ADBLOCK_PLUS_TEST_MODE | 449 #ifdef ADBLOCK_PLUS_TEST_MODE |
435 appInfo.developmentBuild = true; | 450 appInfo.developmentBuild = true; |
436 #else | 451 #else |
437 appInfo.developmentBuild = false; | 452 appInfo.developmentBuild = false; |
438 #endif | 453 #endif |
439 | 454 |
440 AdblockPlus::JsEnginePtr jsEngine = AdblockPlus::JsEngine::New(appInfo); | 455 AdblockPlus::JsEnginePtr jsEngine = AdblockPlus::JsEngine::New(appInfo); |
441 jsEngine->SetEventCallback("updateAvailable", &OnUpdateAvailable); | 456 jsEngine->SetEventCallback("updateAvailable", &OnUpdateAvailable); |
442 | 457 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
491 } | 506 } |
492 catch (const std::runtime_error& e) | 507 catch (const std::runtime_error& e) |
493 { | 508 { |
494 DebugException(e); | 509 DebugException(e); |
495 return 1; | 510 return 1; |
496 } | 511 } |
497 } | 512 } |
498 | 513 |
499 return 0; | 514 return 0; |
500 } | 515 } |
LEFT | RIGHT |