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 according to the comments Created Jan. 28, 2015, 1:22 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
« no previous file with comments | « adblockplus.gyp ('k') | src/plugin/AdblockPlusClient.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
(...skipping 10 matching lines...) Expand all
21 #include <thread> 21 #include <thread>
22 #include <Windows.h> 22 #include <Windows.h>
23 23
24 #include "../shared/AutoHandle.h" 24 #include "../shared/AutoHandle.h"
25 #include "../shared/Communication.h" 25 #include "../shared/Communication.h"
26 #include "../shared/Dictionary.h" 26 #include "../shared/Dictionary.h"
27 #include "../shared/Utils.h" 27 #include "../shared/Utils.h"
28 #include "../shared/Version.h" 28 #include "../shared/Version.h"
29 #include "../shared/CriticalSection.h" 29 #include "../shared/CriticalSection.h"
30 #include "../shared/IE_version.h" 30 #include "../shared/IE_version.h"
31 #include "../shared/ContentType.h"
31 #include "AdblockPlus.h" 32 #include "AdblockPlus.h"
32 #include "Debug.h" 33 #include "Debug.h"
33 #include "Updater.h" 34 #include "Updater.h"
34 35
35 namespace 36 namespace
36 { 37 {
37 std::auto_ptr<AdblockPlus::FilterEngine> filterEngine; 38 std::auto_ptr<AdblockPlus::FilterEngine> filterEngine;
38 std::auto_ptr<Updater> updater; 39 std::auto_ptr<Updater> updater;
39 int activeConnections = 0; 40 int activeConnections = 0;
40 CriticalSection activeConnectionsLock; 41 CriticalSection activeConnectionsLock;
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 { 100 {
100 Communication::OutputBuffer response; 101 Communication::OutputBuffer response;
101 102
102 Communication::ProcType procedure; 103 Communication::ProcType procedure;
103 request >> procedure; 104 request >> procedure;
104 switch (procedure) 105 switch (procedure)
105 { 106 {
106 case Communication::PROC_MATCHES: 107 case Communication::PROC_MATCHES:
107 { 108 {
108 std::string url; 109 std::string url;
109 std::string type; 110 using namespace AdblockPlus;
111 FilterEngine::ContentType contentType;
110 std::string documentUrl; 112 std::string documentUrl;
111 request >> url >> type >> documentUrl; 113 request >> url >> contentType >> documentUrl;
112 referrerMapping.Add(url, documentUrl); 114 auto isFrame = contentType == FilterEngine::ContentType::CONTENT_TYPE_SU BDOCUMENT ?
113 AdblockPlus::FilterPtr filter = filterEngine->Matches(url, type, referre rMapping.BuildReferrerChain(documentUrl)); 115 ReferrerMapping::FrameIndicator::FRAME_INDICATOR_FRAME:
116 ReferrerMapping::FrameIndicator::FRAME_INDICATOR_NOT_FRAME;
117
118 referrerMapping.Add(url, documentUrl, isFrame);
119 AdblockPlus::FilterPtr filter = filterEngine->Matches(url, contentType, referrerMapping.BuildFrameStructure(documentUrl));
114 response << (filter && filter->GetType() != AdblockPlus::Filter::TYPE_EX CEPTION); 120 response << (filter && filter->GetType() != AdblockPlus::Filter::TYPE_EX CEPTION);
115 break; 121 break;
116 } 122 }
117 case Communication::PROC_GET_ELEMHIDE_SELECTORS: 123 case Communication::PROC_GET_ELEMHIDE_SELECTORS:
118 { 124 {
119 std::string domain; 125 std::string domain;
120 request >> domain; 126 request >> domain;
121 WriteStrings(response, filterEngine->GetElementHidingSelectors(domain)); 127 WriteStrings(response, filterEngine->GetElementHidingSelectors(domain));
122 break; 128 break;
123 } 129 }
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 } 209 }
204 } 210 }
205 211
206 WriteStrings(response, domains); 212 WriteStrings(response, domains);
207 break; 213 break;
208 } 214 }
209 case Communication::PROC_IS_WHITELISTED_URL: 215 case Communication::PROC_IS_WHITELISTED_URL:
210 { 216 {
211 std::string url; 217 std::string url;
212 request >> url; 218 request >> url;
213 AdblockPlus::FilterPtr match = filterEngine->Matches(url, "DOCUMENT", ur l); 219 AdblockPlus::FilterPtr match = filterEngine->Matches(url,
220 AdblockPlus::FilterEngine::ContentType::CONTENT_TYPE_DOCUMENT, url);
214 response << (match && match->GetType() == AdblockPlus::Filter::TYPE_EXCE PTION); 221 response << (match && match->GetType() == AdblockPlus::Filter::TYPE_EXCE PTION);
215 break; 222 break;
216 } 223 }
217 case Communication::PROC_IS_ELEMHIDE_WHITELISTED_ON_URL: 224 case Communication::PROC_IS_ELEMHIDE_WHITELISTED_ON_URL:
218 { 225 {
219 std::string url; 226 std::string url;
220 request >> url; 227 request >> url;
221 AdblockPlus::FilterPtr match = filterEngine->Matches(url, "ELEMHIDE", ur l); 228 AdblockPlus::FilterPtr match = filterEngine->Matches(url,
229 AdblockPlus::FilterEngine::ContentType::CONTENT_TYPE_ELEMHIDE, url);
222 response << (match && match->GetType() == AdblockPlus::Filter::TYPE_EXCE PTION); 230 response << (match && match->GetType() == AdblockPlus::Filter::TYPE_EXCE PTION);
223 break; 231 break;
224 } 232 }
225 case Communication::PROC_ADD_FILTER: 233 case Communication::PROC_ADD_FILTER:
226 { 234 {
227 std::string text; 235 std::string text;
228 request >> text; 236 request >> text;
229 237
230 filterEngine->GetFilter(text)->AddToList(); 238 filterEngine->GetFilter(text)->AddToList();
231 break; 239 break;
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
502 } 510 }
503 catch (const std::runtime_error& e) 511 catch (const std::runtime_error& e)
504 { 512 {
505 DebugException(e); 513 DebugException(e);
506 return 1; 514 return 1;
507 } 515 }
508 } 516 }
509 517
510 return 0; 518 return 0;
511 } 519 }
OLDNEW
« no previous file with comments | « adblockplus.gyp ('k') | src/plugin/AdblockPlusClient.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld