Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: src/engine/Main.cpp

Issue 5316782940225536: Issue 1557 - Update to the recent libadblockplus to reduce additional updates in the logic later. (Closed)
Patch Set: remove debugging code Created Nov. 24, 2014, 11:09 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
1 #include <AdblockPlus.h> 1 #include <AdblockPlus.h>
2 #include <functional> 2 #include <functional>
3 #include <vector> 3 #include <vector>
4 #include <thread> 4 #include <thread>
5 #include <Windows.h> 5 #include <Windows.h>
6 6
7 #include "../shared/AutoHandle.h" 7 #include "../shared/AutoHandle.h"
8 #include "../shared/Communication.h" 8 #include "../shared/Communication.h"
9 #include "../shared/Dictionary.h" 9 #include "../shared/Dictionary.h"
10 #include "../shared/Utils.h" 10 #include "../shared/Utils.h"
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 { 81 {
82 Communication::OutputBuffer response; 82 Communication::OutputBuffer response;
83 83
84 Communication::ProcType procedure; 84 Communication::ProcType procedure;
85 request >> procedure; 85 request >> procedure;
86 switch (procedure) 86 switch (procedure)
87 { 87 {
88 case Communication::PROC_MATCHES: 88 case Communication::PROC_MATCHES:
89 { 89 {
90 std::string url; 90 std::string url;
91 std::string type; 91 int32_t type;
92 std::string documentUrl; 92 std::string documentUrl;
93 request >> url >> type >> documentUrl; 93 request >> url >> type >> documentUrl;
94 referrerMapping.Add(url, documentUrl); 94 referrerMapping.Add(url, documentUrl);
95 AdblockPlus::FilterPtr filter = filterEngine->Matches(url, type, referre rMapping.BuildReferrerChain(documentUrl)); 95 auto contentType = static_cast<AdblockPlus::FilterEngine::ContentType>(t ype);
96 AdblockPlus::FilterPtr filter = filterEngine->Matches(url, contentType, referrerMapping.BuildReferrerChain(documentUrl));
96 response << (filter && filter->GetType() != AdblockPlus::Filter::TYPE_EX CEPTION); 97 response << (filter && filter->GetType() != AdblockPlus::Filter::TYPE_EX CEPTION);
97 break; 98 break;
98 } 99 }
99 case Communication::PROC_GET_ELEMHIDE_SELECTORS: 100 case Communication::PROC_GET_ELEMHIDE_SELECTORS:
100 { 101 {
101 std::string domain; 102 std::string domain;
102 request >> domain; 103 request >> domain;
103 WriteStrings(response, filterEngine->GetElementHidingSelectors(domain)); 104 WriteStrings(response, filterEngine->GetElementHidingSelectors(domain));
104 break; 105 break;
105 } 106 }
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 } 186 }
186 } 187 }
187 188
188 WriteStrings(response, domains); 189 WriteStrings(response, domains);
189 break; 190 break;
190 } 191 }
191 case Communication::PROC_IS_WHITELISTED_URL: 192 case Communication::PROC_IS_WHITELISTED_URL:
192 { 193 {
193 std::string url; 194 std::string url;
194 request >> url; 195 request >> url;
195 AdblockPlus::FilterPtr match = filterEngine->Matches(url, "DOCUMENT", ur l); 196 AdblockPlus::FilterPtr match = filterEngine->Matches(url,
197 AdblockPlus::FilterEngine::ContentType::CONTENT_TYPE_DOCUMENT, url);
196 response << (match && match->GetType() == AdblockPlus::Filter::TYPE_EXCE PTION); 198 response << (match && match->GetType() == AdblockPlus::Filter::TYPE_EXCE PTION);
197 break; 199 break;
198 } 200 }
199 case Communication::PROC_IS_ELEMHIDE_WHITELISTED_ON_URL: 201 case Communication::PROC_IS_ELEMHIDE_WHITELISTED_ON_URL:
200 { 202 {
201 std::string url; 203 std::string url;
202 request >> url; 204 request >> url;
203 AdblockPlus::FilterPtr match = filterEngine->Matches(url, "ELEMHIDE", ur l); 205 AdblockPlus::FilterPtr match = filterEngine->Matches(url,
206 AdblockPlus::FilterEngine::ContentType::CONTENT_TYPE_ELEMHIDE, url);
204 response << (match && match->GetType() == AdblockPlus::Filter::TYPE_EXCE PTION); 207 response << (match && match->GetType() == AdblockPlus::Filter::TYPE_EXCE PTION);
205 break; 208 break;
206 } 209 }
207 case Communication::PROC_ADD_FILTER: 210 case Communication::PROC_ADD_FILTER:
208 { 211 {
209 std::string text; 212 std::string text;
210 request >> text; 213 request >> text;
211 214
212 filterEngine->GetFilter(text)->AddToList(); 215 filterEngine->GetFilter(text)->AddToList();
213 break; 216 break;
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 } 487 }
485 catch (const std::runtime_error& e) 488 catch (const std::runtime_error& e)
486 { 489 {
487 DebugException(e); 490 DebugException(e);
488 return 1; 491 return 1;
489 } 492 }
490 } 493 }
491 494
492 return 0; 495 return 0;
493 } 496 }
OLDNEW

Powered by Google App Engine
This is Rietveld