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: fix accoring to comments Created Jan. 13, 2015, 12:59 p.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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 { 82 {
83 Communication::OutputBuffer response; 83 Communication::OutputBuffer response;
84 84
85 Communication::ProcType procedure; 85 Communication::ProcType procedure;
86 request >> procedure; 86 request >> procedure;
87 switch (procedure) 87 switch (procedure)
88 { 88 {
89 case Communication::PROC_MATCHES: 89 case Communication::PROC_MATCHES:
90 { 90 {
91 std::string url; 91 std::string url;
92 std::string type; 92 int32_t type;
93 std::string documentUrl; 93 std::string documentUrl;
94 request >> url >> type >> documentUrl; 94 request >> url >> type >> documentUrl;
95 referrerMapping.Add(url, documentUrl); 95 using namespace AdblockPlus;
96 AdblockPlus::FilterPtr filter = filterEngine->Matches(url, type, referre rMapping.BuildReferrerChain(documentUrl)); 96 auto contentType = static_cast<FilterEngine::ContentType>(type);
97 auto isFrame = contentType == FilterEngine::ContentType::CONTENT_TYPE_SU BDOCUMENT ?
98 ReferrerMapping::FrameIndicator::FRAME_INDICATOR_FRAME:
99 ReferrerMapping::FrameIndicator::FRAME_INDICATOR_NOT_FRAME;
Eric 2015/01/13 17:29:36 The indentation is off. Also, the expression woul
sergei 2015/01/28 13:44:45 Indentation is fixed. I don't find it easier to re
100
101 referrerMapping.Add(url, documentUrl, isFrame);
Eric 2015/01/13 17:29:36 ReferrerMapping::Add() is declared with only two a
sergei 2015/01/28 13:44:45 Sure, the main aim of the whole change is to updat
102 AdblockPlus::FilterPtr filter = filterEngine->Matches(url, contentType, referrerMapping.BuildFrameStructure(documentUrl));
97 response << (filter && filter->GetType() != AdblockPlus::Filter::TYPE_EX CEPTION); 103 response << (filter && filter->GetType() != AdblockPlus::Filter::TYPE_EX CEPTION);
98 break; 104 break;
99 } 105 }
100 case Communication::PROC_GET_ELEMHIDE_SELECTORS: 106 case Communication::PROC_GET_ELEMHIDE_SELECTORS:
101 { 107 {
102 std::string domain; 108 std::string domain;
103 request >> domain; 109 request >> domain;
104 WriteStrings(response, filterEngine->GetElementHidingSelectors(domain)); 110 WriteStrings(response, filterEngine->GetElementHidingSelectors(domain));
105 break; 111 break;
106 } 112 }
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 } 192 }
187 } 193 }
188 194
189 WriteStrings(response, domains); 195 WriteStrings(response, domains);
190 break; 196 break;
191 } 197 }
192 case Communication::PROC_IS_WHITELISTED_URL: 198 case Communication::PROC_IS_WHITELISTED_URL:
193 { 199 {
194 std::string url; 200 std::string url;
195 request >> url; 201 request >> url;
196 AdblockPlus::FilterPtr match = filterEngine->Matches(url, "DOCUMENT", ur l); 202 AdblockPlus::FilterPtr match = filterEngine->Matches(url,
203 AdblockPlus::FilterEngine::ContentType::CONTENT_TYPE_DOCUMENT, url);
197 response << (match && match->GetType() == AdblockPlus::Filter::TYPE_EXCE PTION); 204 response << (match && match->GetType() == AdblockPlus::Filter::TYPE_EXCE PTION);
198 break; 205 break;
199 } 206 }
200 case Communication::PROC_IS_ELEMHIDE_WHITELISTED_ON_URL: 207 case Communication::PROC_IS_ELEMHIDE_WHITELISTED_ON_URL:
201 { 208 {
202 std::string url; 209 std::string url;
203 request >> url; 210 request >> url;
204 AdblockPlus::FilterPtr match = filterEngine->Matches(url, "ELEMHIDE", ur l); 211 AdblockPlus::FilterPtr match = filterEngine->Matches(url,
212 AdblockPlus::FilterEngine::ContentType::CONTENT_TYPE_ELEMHIDE, url);
205 response << (match && match->GetType() == AdblockPlus::Filter::TYPE_EXCE PTION); 213 response << (match && match->GetType() == AdblockPlus::Filter::TYPE_EXCE PTION);
206 break; 214 break;
207 } 215 }
208 case Communication::PROC_ADD_FILTER: 216 case Communication::PROC_ADD_FILTER:
209 { 217 {
210 std::string text; 218 std::string text;
211 request >> text; 219 request >> text;
212 220
213 filterEngine->GetFilter(text)->AddToList(); 221 filterEngine->GetFilter(text)->AddToList();
214 break; 222 break;
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
485 } 493 }
486 catch (const std::runtime_error& e) 494 catch (const std::runtime_error& e)
487 { 495 {
488 DebugException(e); 496 DebugException(e);
489 return 1; 497 return 1;
490 } 498 }
491 } 499 }
492 500
493 return 0; 501 return 0;
494 } 502 }
OLDNEW

Powered by Google App Engine
This is Rietveld