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

Side by Side Diff: src/FilterEngine.cpp

Issue 29453651: Noissue - fix typo "dowload" to "download" (n is absent) (Closed) Base URL: https://github.com/adblockplus/libadblockplus.git
Patch Set: Created June 1, 2017, 4:07 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 | « include/AdblockPlus/FilterEngine.h ('k') | test/FilterEngine.cpp » ('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-2017 eyeo GmbH 3 * Copyright (C) 2006-2017 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 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 218
219 void FilterEngine::CreateAsync(const JsEnginePtr& jsEngine, 219 void FilterEngine::CreateAsync(const JsEnginePtr& jsEngine,
220 const FilterEngine::OnCreatedCallback& onCreated, 220 const FilterEngine::OnCreatedCallback& onCreated,
221 const FilterEngine::CreationParameters& params) 221 const FilterEngine::CreationParameters& params)
222 { 222 {
223 FilterEnginePtr filterEngine(new FilterEngine(jsEngine)); 223 FilterEnginePtr filterEngine(new FilterEngine(jsEngine));
224 { 224 {
225 // TODO: replace weakFilterEngine by this when it's possible to control the 225 // TODO: replace weakFilterEngine by this when it's possible to control the
226 // execution time of the asynchronous part below. 226 // execution time of the asynchronous part below.
227 std::weak_ptr<FilterEngine> weakFilterEngine = filterEngine; 227 std::weak_ptr<FilterEngine> weakFilterEngine = filterEngine;
228 auto isSubscriptionDowloadAllowedCallback = params.isSubscriptionDowloadAllo wedCallback; 228 auto isSubscriptionDownloadAllowedCallback = params.isSubscriptionDownloadAl lowedCallback;
229 jsEngine->SetEventCallback("_isSubscriptionDownloadAllowed", [weakFilterEngi ne, isSubscriptionDowloadAllowedCallback](JsValueList&& params){ 229 jsEngine->SetEventCallback("_isSubscriptionDownloadAllowed", [weakFilterEngi ne, isSubscriptionDownloadAllowedCallback](JsValueList&& params){
230 auto filterEngine = weakFilterEngine.lock(); 230 auto filterEngine = weakFilterEngine.lock();
231 if (!filterEngine) 231 if (!filterEngine)
232 return; 232 return;
233 auto jsEngine = filterEngine->GetJsEngine(); 233 auto jsEngine = filterEngine->GetJsEngine();
234 234
235 // param[0] - nullable string Prefs.allowed_connection_type 235 // param[0] - nullable string Prefs.allowed_connection_type
236 // param[1] - function(Boolean) 236 // param[1] - function(Boolean)
237 bool areArgumentsValid = params.size() == 2 && (params[0].IsNull() || para ms[0].IsString()) && params[1].IsFunction(); 237 bool areArgumentsValid = params.size() == 2 && (params[0].IsNull() || para ms[0].IsString()) && params[1].IsFunction();
238 assert(areArgumentsValid && "Invalid argument: there should be two args an d the second one should be a function"); 238 assert(areArgumentsValid && "Invalid argument: there should be two args an d the second one should be a function");
239 if (!areArgumentsValid) 239 if (!areArgumentsValid)
240 return; 240 return;
241 if (!isSubscriptionDowloadAllowedCallback) 241 if (!isSubscriptionDownloadAllowedCallback)
242 { 242 {
243 params[1].Call(jsEngine->NewValue(true)); 243 params[1].Call(jsEngine->NewValue(true));
244 return; 244 return;
245 } 245 }
246 auto valuesID = jsEngine->StoreJsValues(params); 246 auto valuesID = jsEngine->StoreJsValues(params);
247 auto callJsCallback = [weakFilterEngine, valuesID](bool isAllowed) 247 auto callJsCallback = [weakFilterEngine, valuesID](bool isAllowed)
248 { 248 {
249 auto filterEngine = weakFilterEngine.lock(); 249 auto filterEngine = weakFilterEngine.lock();
250 if (!filterEngine) 250 if (!filterEngine)
251 return; 251 return;
252 auto jsEngine = filterEngine->GetJsEngine(); 252 auto jsEngine = filterEngine->GetJsEngine();
253 auto jsParams = jsEngine->TakeJsValues(valuesID); 253 auto jsParams = jsEngine->TakeJsValues(valuesID);
254 jsParams[1].Call(jsEngine->NewValue(isAllowed)); 254 jsParams[1].Call(jsEngine->NewValue(isAllowed));
255 }; 255 };
256 std::string allowedConnectionType = params[0].IsString() ? params[0].AsStr ing() : std::string(); 256 std::string allowedConnectionType = params[0].IsString() ? params[0].AsStr ing() : std::string();
257 isSubscriptionDowloadAllowedCallback(params[0].IsString() ? &allowedConnec tionType : nullptr, callJsCallback); 257 isSubscriptionDownloadAllowedCallback(params[0].IsString() ? &allowedConne ctionType : nullptr, callJsCallback);
258 }); 258 });
259 } 259 }
260 260
261 jsEngine->SetEventCallback("_init", [jsEngine, filterEngine, onCreated](JsValu eList&& params) 261 jsEngine->SetEventCallback("_init", [jsEngine, filterEngine, onCreated](JsValu eList&& params)
262 { 262 {
263 filterEngine->firstRun = params.size() && params[0].AsBool(); 263 filterEngine->firstRun = params.size() && params[0].AsBool();
264 onCreated(filterEngine); 264 onCreated(filterEngine);
265 jsEngine->RemoveEventCallback("_init"); 265 jsEngine->RemoveEventCallback("_init");
266 }); 266 });
267 267
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
636 FilterPtr filter = GetWhitelistingFilter(currentUrl, contentTypeMask, parent Url); 636 FilterPtr filter = GetWhitelistingFilter(currentUrl, contentTypeMask, parent Url);
637 if (filter) 637 if (filter)
638 { 638 {
639 return filter; 639 return filter;
640 } 640 }
641 currentUrl = parentUrl; 641 currentUrl = parentUrl;
642 } 642 }
643 while (urlIterator != documentUrls.end()); 643 while (urlIterator != documentUrls.end());
644 return FilterPtr(); 644 return FilterPtr();
645 } 645 }
OLDNEW
« no previous file with comments | « include/AdblockPlus/FilterEngine.h ('k') | test/FilterEngine.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld