OLD | NEW |
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 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 { | 166 { |
167 FilterEnginePtr filterEngine(new FilterEngine(jsEngine)); | 167 FilterEnginePtr filterEngine(new FilterEngine(jsEngine)); |
168 auto sync = std::make_shared<Sync>(); | 168 auto sync = std::make_shared<Sync>(); |
169 auto isConnectionAllowedCallback = params.isConnectionAllowedCallback; | 169 auto isConnectionAllowedCallback = params.isConnectionAllowedCallback; |
170 if (isConnectionAllowedCallback) | 170 if (isConnectionAllowedCallback) |
171 jsEngine->SetIsConnectionAllowedCallback([sync, jsEngine]()->bool | 171 jsEngine->SetIsConnectionAllowedCallback([sync, jsEngine]()->bool |
172 { | 172 { |
173 sync->Wait(); | 173 sync->Wait(); |
174 return jsEngine->IsConnectionAllowed(); | 174 return jsEngine->IsConnectionAllowed(); |
175 }); | 175 }); |
176 jsEngine->SetEventCallback("_init", [jsEngine, filterEngine, onCreated, sync,
isConnectionAllowedCallback](const JsConstValueList& params) | 176 jsEngine->SetEventCallback("_init", [jsEngine, filterEngine, onCreated, sync,
isConnectionAllowedCallback](const JsValueList& params) |
177 { | 177 { |
178 filterEngine->firstRun = params.size() && params[0]->AsBool(); | 178 filterEngine->firstRun = params.size() && params[0].AsBool(); |
179 if (isConnectionAllowedCallback) | 179 if (isConnectionAllowedCallback) |
180 { | 180 { |
181 std::weak_ptr<FilterEngine> weakFilterEngine = filterEngine; | 181 std::weak_ptr<FilterEngine> weakFilterEngine = filterEngine; |
182 jsEngine->SetIsConnectionAllowedCallback([weakFilterEngine, isConnectionAl
lowedCallback]()->bool | 182 jsEngine->SetIsConnectionAllowedCallback([weakFilterEngine, isConnectionAl
lowedCallback]()->bool |
183 { | 183 { |
184 auto filterEngine = weakFilterEngine.lock(); | 184 auto filterEngine = weakFilterEngine.lock(); |
185 if (!filterEngine) | 185 if (!filterEngine) |
186 return false; | 186 return false; |
187 return isConnectionAllowedCallback(filterEngine->GetAllowedConnectionTyp
e().get()); | 187 return isConnectionAllowedCallback(filterEngine->GetAllowedConnectionTyp
e().get()); |
188 }); | 188 }); |
189 } | 189 } |
190 sync->Set(); | 190 sync->Set(); |
191 onCreated(filterEngine); | 191 onCreated(filterEngine); |
192 jsEngine->RemoveEventCallback("_init"); | 192 jsEngine->RemoveEventCallback("_init"); |
193 }); | 193 }); |
194 | 194 |
195 // Lock the JS engine while we are loading scripts, no timeouts should fire | 195 // Lock the JS engine while we are loading scripts, no timeouts should fire |
196 // until we are done. | 196 // until we are done. |
197 const JsContext context(jsEngine); | 197 const JsContext context(jsEngine); |
198 | 198 |
199 // Set the preconfigured prefs | 199 // Set the preconfigured prefs |
200 JsValuePtr preconfiguredPrefsObject = jsEngine->NewObject(); | 200 auto preconfiguredPrefsObject = jsEngine->NewObject(); |
201 for (FilterEngine::Prefs::const_iterator it = params.preconfiguredPrefs.begin(
); | 201 for (FilterEngine::Prefs::const_iterator it = params.preconfiguredPrefs.begin(
); |
202 it != params.preconfiguredPrefs.end(); it++) | 202 it != params.preconfiguredPrefs.end(); it++) |
203 { | 203 { |
204 preconfiguredPrefsObject->SetProperty(it->first, *it->second); | 204 preconfiguredPrefsObject.SetProperty(it->first, it->second); |
205 } | 205 } |
206 jsEngine->SetGlobalProperty("_preconfiguredPrefs", *preconfiguredPrefsObject); | 206 jsEngine->SetGlobalProperty("_preconfiguredPrefs", preconfiguredPrefsObject); |
207 // Load adblockplus scripts | 207 // Load adblockplus scripts |
208 for (int i = 0; !jsSources[i].empty(); i += 2) | 208 for (int i = 0; !jsSources[i].empty(); i += 2) |
209 jsEngine->Evaluate(jsSources[i + 1], jsSources[i]); | 209 jsEngine->Evaluate(jsSources[i + 1], jsSources[i]); |
210 } | 210 } |
211 | 211 |
212 FilterEnginePtr FilterEngine::Create(const JsEnginePtr& jsEngine, | 212 FilterEnginePtr FilterEngine::Create(const JsEnginePtr& jsEngine, |
213 const FilterEngine::CreationParameters& params) | 213 const FilterEngine::CreationParameters& params) |
214 { | 214 { |
215 FilterEnginePtr retValue; | 215 FilterEnginePtr retValue; |
216 Sync sync; | 216 Sync sync; |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 } | 272 } |
273 | 273 |
274 bool FilterEngine::IsFirstRun() const | 274 bool FilterEngine::IsFirstRun() const |
275 { | 275 { |
276 return firstRun; | 276 return firstRun; |
277 } | 277 } |
278 | 278 |
279 FilterPtr FilterEngine::GetFilter(const std::string& text) const | 279 FilterPtr FilterEngine::GetFilter(const std::string& text) const |
280 { | 280 { |
281 JsValuePtr func = jsEngine->Evaluate("API.getFilterFromText"); | 281 JsValuePtr func = jsEngine->Evaluate("API.getFilterFromText"); |
282 return FilterPtr(new Filter(func->Call(*jsEngine->NewValue(text)))); | 282 return FilterPtr(new Filter(func->Call(jsEngine->NewValue(text)))); |
283 } | 283 } |
284 | 284 |
285 SubscriptionPtr FilterEngine::GetSubscription(const std::string& url) const | 285 SubscriptionPtr FilterEngine::GetSubscription(const std::string& url) const |
286 { | 286 { |
287 JsValuePtr func = jsEngine->Evaluate("API.getSubscriptionFromUrl"); | 287 JsValuePtr func = jsEngine->Evaluate("API.getSubscriptionFromUrl"); |
288 return SubscriptionPtr(new Subscription(func->Call(*jsEngine->NewValue(url))))
; | 288 return SubscriptionPtr(new Subscription(func->Call(jsEngine->NewValue(url)))); |
289 } | 289 } |
290 | 290 |
291 std::vector<FilterPtr> FilterEngine::GetListedFilters() const | 291 std::vector<FilterPtr> FilterEngine::GetListedFilters() const |
292 { | 292 { |
293 JsValuePtr func = jsEngine->Evaluate("API.getListedFilters"); | 293 JsValuePtr func = jsEngine->Evaluate("API.getListedFilters"); |
294 JsValueList values = func->Call().AsList(); | 294 JsValueList values = func->Call().AsList(); |
295 std::vector<FilterPtr> result; | 295 std::vector<FilterPtr> result; |
296 for (JsValueList::iterator it = values.begin(); it != values.end(); it++) | 296 for (JsValueList::iterator it = values.begin(); it != values.end(); it++) |
297 result.push_back(FilterPtr(new Filter(std::move(**it)))); | 297 result.push_back(FilterPtr(new Filter(std::move(*it)))); |
298 return result; | 298 return result; |
299 } | 299 } |
300 | 300 |
301 std::vector<SubscriptionPtr> FilterEngine::GetListedSubscriptions() const | 301 std::vector<SubscriptionPtr> FilterEngine::GetListedSubscriptions() const |
302 { | 302 { |
303 JsValuePtr func = jsEngine->Evaluate("API.getListedSubscriptions"); | 303 JsValuePtr func = jsEngine->Evaluate("API.getListedSubscriptions"); |
304 JsValueList values = func->Call().AsList(); | 304 JsValueList values = func->Call().AsList(); |
305 std::vector<SubscriptionPtr> result; | 305 std::vector<SubscriptionPtr> result; |
306 for (JsValueList::iterator it = values.begin(); it != values.end(); it++) | 306 for (JsValueList::iterator it = values.begin(); it != values.end(); it++) |
307 result.push_back(SubscriptionPtr(new Subscription(std::move(**it)))); | 307 result.push_back(SubscriptionPtr(new Subscription(std::move(*it)))); |
308 return result; | 308 return result; |
309 } | 309 } |
310 | 310 |
311 std::vector<SubscriptionPtr> FilterEngine::FetchAvailableSubscriptions() const | 311 std::vector<SubscriptionPtr> FilterEngine::FetchAvailableSubscriptions() const |
312 { | 312 { |
313 JsValuePtr func = jsEngine->Evaluate("API.getRecommendedSubscriptions"); | 313 JsValuePtr func = jsEngine->Evaluate("API.getRecommendedSubscriptions"); |
314 JsValueList values = func->Call().AsList(); | 314 JsValueList values = func->Call().AsList(); |
315 std::vector<SubscriptionPtr> result; | 315 std::vector<SubscriptionPtr> result; |
316 for (JsValueList::iterator it = values.begin(); it != values.end(); it++) | 316 for (JsValueList::iterator it = values.begin(); it != values.end(); it++) |
317 result.push_back(SubscriptionPtr(new Subscription(std::move(**it)))); | 317 result.push_back(SubscriptionPtr(new Subscription(std::move(*it)))); |
318 return result; | 318 return result; |
319 } | 319 } |
320 | 320 |
321 void FilterEngine::SetAAEnabled(bool enabled) | 321 void FilterEngine::SetAAEnabled(bool enabled) |
322 { | 322 { |
323 jsEngine->Evaluate("API.setAASubscriptionEnabled")->Call(*jsEngine->NewValue(e
nabled)); | 323 jsEngine->Evaluate("API.setAASubscriptionEnabled")->Call(jsEngine->NewValue(en
abled)); |
324 } | 324 } |
325 | 325 |
326 bool FilterEngine::IsAAEnabled() const | 326 bool FilterEngine::IsAAEnabled() const |
327 { | 327 { |
328 return jsEngine->Evaluate("API.isAASubscriptionEnabled()")->AsBool(); | 328 return jsEngine->Evaluate("API.isAASubscriptionEnabled()")->AsBool(); |
329 } | 329 } |
330 | 330 |
331 std::string FilterEngine::GetAAUrl() const | 331 std::string FilterEngine::GetAAUrl() const |
332 { | 332 { |
333 return GetPref("subscriptions_exceptionsurl")->AsString(); | 333 return GetPref("subscriptions_exceptionsurl").AsString(); |
334 } | 334 } |
335 | 335 |
336 void FilterEngine::ShowNextNotification(const std::string& url) const | 336 void FilterEngine::ShowNextNotification(const std::string& url) const |
337 { | 337 { |
338 JsValuePtr func = jsEngine->Evaluate("API.showNextNotification"); | 338 JsValuePtr func = jsEngine->Evaluate("API.showNextNotification"); |
339 JsConstValueList params; | 339 JsValueList params; |
340 if (!url.empty()) | 340 if (!url.empty()) |
341 { | 341 { |
342 params.push_back(jsEngine->NewValue(url)); | 342 params.push_back(jsEngine->NewValue(url)); |
343 } | 343 } |
344 func->Call(params); | 344 func->Call(params); |
345 } | 345 } |
346 | 346 |
347 void FilterEngine::SetShowNotificationCallback(const ShowNotificationCallback& v
alue) | 347 void FilterEngine::SetShowNotificationCallback(const ShowNotificationCallback& v
alue) |
348 { | 348 { |
349 if (!value) | 349 if (!value) |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
398 const std::vector<std::string>& documentUrls) const | 398 const std::vector<std::string>& documentUrls) const |
399 { | 399 { |
400 return !!GetWhitelistingFilter(url, CONTENT_TYPE_ELEMHIDE, documentUrls); | 400 return !!GetWhitelistingFilter(url, CONTENT_TYPE_ELEMHIDE, documentUrls); |
401 } | 401 } |
402 | 402 |
403 AdblockPlus::FilterPtr FilterEngine::CheckFilterMatch(const std::string& url, | 403 AdblockPlus::FilterPtr FilterEngine::CheckFilterMatch(const std::string& url, |
404 ContentTypeMask contentTypeMask, | 404 ContentTypeMask contentTypeMask, |
405 const std::string& documentUrl) const | 405 const std::string& documentUrl) const |
406 { | 406 { |
407 JsValuePtr func = jsEngine->Evaluate("API.checkFilterMatch"); | 407 JsValuePtr func = jsEngine->Evaluate("API.checkFilterMatch"); |
408 JsConstValueList params; | 408 JsValueList params; |
409 params.push_back(jsEngine->NewValue(url)); | 409 params.push_back(jsEngine->NewValue(url)); |
410 params.push_back(jsEngine->NewValue(contentTypeMask)); | 410 params.push_back(jsEngine->NewValue(contentTypeMask)); |
411 params.push_back(jsEngine->NewValue(documentUrl)); | 411 params.push_back(jsEngine->NewValue(documentUrl)); |
412 JsValue result = func->Call(params); | 412 JsValue result = func->Call(params); |
413 if (!result.IsNull()) | 413 if (!result.IsNull()) |
414 return FilterPtr(new Filter(std::move(result))); | 414 return FilterPtr(new Filter(std::move(result))); |
415 else | 415 else |
416 return FilterPtr(); | 416 return FilterPtr(); |
417 } | 417 } |
418 | 418 |
419 std::vector<std::string> FilterEngine::GetElementHidingSelectors(const std::stri
ng& domain) const | 419 std::vector<std::string> FilterEngine::GetElementHidingSelectors(const std::stri
ng& domain) const |
420 { | 420 { |
421 JsValuePtr func = jsEngine->Evaluate("API.getElementHidingSelectors"); | 421 JsValuePtr func = jsEngine->Evaluate("API.getElementHidingSelectors"); |
422 JsValueList result = func->Call(*jsEngine->NewValue(domain)).AsList(); | 422 JsValueList result = func->Call(jsEngine->NewValue(domain)).AsList(); |
423 std::vector<std::string> selectors; | 423 std::vector<std::string> selectors; |
424 for (const auto& r: result) | 424 for (const auto& r: result) |
425 selectors.push_back(r->AsString()); | 425 selectors.push_back(r.AsString()); |
426 return selectors; | 426 return selectors; |
427 } | 427 } |
428 | 428 |
429 JsValuePtr FilterEngine::GetPref(const std::string& pref) const | 429 JsValue FilterEngine::GetPref(const std::string& pref) const |
430 { | 430 { |
431 JsValuePtr func = jsEngine->Evaluate("API.getPref"); | 431 JsValuePtr func = jsEngine->Evaluate("API.getPref"); |
432 return std::make_shared<JsValue>(func->Call(*jsEngine->NewValue(pref))); | 432 return func->Call(jsEngine->NewValue(pref)); |
433 } | 433 } |
434 | 434 |
435 void FilterEngine::SetPref(const std::string& pref, const JsValuePtr& value) | 435 void FilterEngine::SetPref(const std::string& pref, const JsValue& value) |
436 { | 436 { |
437 JsValuePtr func = jsEngine->Evaluate("API.setPref"); | 437 JsValuePtr func = jsEngine->Evaluate("API.setPref"); |
438 JsConstValueList params; | 438 JsValueList params; |
439 params.push_back(jsEngine->NewValue(pref)); | 439 params.push_back(jsEngine->NewValue(pref)); |
440 if (value) | 440 params.push_back(value); |
441 params.push_back(value); | |
442 func->Call(params); | 441 func->Call(params); |
443 } | 442 } |
444 | 443 |
445 std::string FilterEngine::GetHostFromURL(const std::string& url) const | 444 std::string FilterEngine::GetHostFromURL(const std::string& url) const |
446 { | 445 { |
447 JsValuePtr func = jsEngine->Evaluate("API.getHostFromUrl"); | 446 JsValuePtr func = jsEngine->Evaluate("API.getHostFromUrl"); |
448 return func->Call(*jsEngine->NewValue(url)).AsString(); | 447 return func->Call(jsEngine->NewValue(url)).AsString(); |
449 } | 448 } |
450 | 449 |
451 void FilterEngine::SetUpdateAvailableCallback( | 450 void FilterEngine::SetUpdateAvailableCallback( |
452 const FilterEngine::UpdateAvailableCallback& callback) | 451 const FilterEngine::UpdateAvailableCallback& callback) |
453 { | 452 { |
454 jsEngine->SetEventCallback("updateAvailable", | 453 jsEngine->SetEventCallback("updateAvailable", |
455 std::bind(&FilterEngine::UpdateAvailable, this, callback, | 454 std::bind(&FilterEngine::UpdateAvailable, this, callback, |
456 std::placeholders::_1)); | 455 std::placeholders::_1)); |
457 } | 456 } |
458 | 457 |
459 void FilterEngine::RemoveUpdateAvailableCallback() | 458 void FilterEngine::RemoveUpdateAvailableCallback() |
460 { | 459 { |
461 jsEngine->RemoveEventCallback("updateAvailable"); | 460 jsEngine->RemoveEventCallback("updateAvailable"); |
462 } | 461 } |
463 | 462 |
464 void FilterEngine::UpdateAvailable( | 463 void FilterEngine::UpdateAvailable( |
465 const FilterEngine::UpdateAvailableCallback& callback, const JsConstValueLis
t& params) const | 464 const FilterEngine::UpdateAvailableCallback& callback, const JsValueList& pa
rams) const |
466 { | 465 { |
467 if (params.size() >= 1 && !params[0]->IsNull()) | 466 if (params.size() >= 1 && !params[0].IsNull()) |
468 callback(params[0]->AsString()); | 467 callback(params[0].AsString()); |
469 } | 468 } |
470 | 469 |
471 void FilterEngine::ForceUpdateCheck( | 470 void FilterEngine::ForceUpdateCheck( |
472 const FilterEngine::UpdateCheckDoneCallback& callback) | 471 const FilterEngine::UpdateCheckDoneCallback& callback) |
473 { | 472 { |
474 JsValuePtr func = jsEngine->Evaluate("API.forceUpdateCheck"); | 473 JsValuePtr func = jsEngine->Evaluate("API.forceUpdateCheck"); |
475 JsConstValueList params; | 474 JsValueList params; |
476 if (callback) | 475 if (callback) |
477 { | 476 { |
478 std::string eventName = "_updateCheckDone" + std::to_string(++updateCheckId)
; | 477 std::string eventName = "_updateCheckDone" + std::to_string(++updateCheckId)
; |
479 jsEngine->SetEventCallback(eventName, std::bind(&FilterEngine::UpdateCheckDo
ne, | 478 jsEngine->SetEventCallback(eventName, std::bind(&FilterEngine::UpdateCheckDo
ne, |
480 this, eventName, callback, std::placeholders::_1)); | 479 this, eventName, callback, std::placeholders::_1)); |
481 params.push_back(jsEngine->NewValue(eventName)); | 480 params.push_back(jsEngine->NewValue(eventName)); |
482 } | 481 } |
483 func->Call(params); | 482 func->Call(params); |
484 } | 483 } |
485 | 484 |
486 void FilterEngine::UpdateCheckDone(const std::string& eventName, | 485 void FilterEngine::UpdateCheckDone(const std::string& eventName, |
487 const FilterEngine::UpdateCheckDoneCallback& callback, const JsConstValueLis
t& params) | 486 const FilterEngine::UpdateCheckDoneCallback& callback, const JsValueList& pa
rams) |
488 { | 487 { |
489 jsEngine->RemoveEventCallback(eventName); | 488 jsEngine->RemoveEventCallback(eventName); |
490 | 489 |
491 std::string error(params.size() >= 1 && !params[0]->IsNull() ? params[0]->AsSt
ring() : ""); | 490 std::string error(params.size() >= 1 && !params[0].IsNull() ? params[0].AsStri
ng() : ""); |
492 callback(error); | 491 callback(error); |
493 } | 492 } |
494 | 493 |
495 void FilterEngine::SetFilterChangeCallback(const FilterEngine::FilterChangeCallb
ack& callback) | 494 void FilterEngine::SetFilterChangeCallback(const FilterEngine::FilterChangeCallb
ack& callback) |
496 { | 495 { |
497 jsEngine->SetEventCallback("filterChange", std::bind(&FilterEngine::FilterChan
ged, | 496 jsEngine->SetEventCallback("filterChange", std::bind(&FilterEngine::FilterChan
ged, |
498 this, callback, std::placeholders::_1)); | 497 this, callback, std::placeholders::_1)); |
499 } | 498 } |
500 | 499 |
501 void FilterEngine::RemoveFilterChangeCallback() | 500 void FilterEngine::RemoveFilterChangeCallback() |
502 { | 501 { |
503 jsEngine->RemoveEventCallback("filterChange"); | 502 jsEngine->RemoveEventCallback("filterChange"); |
504 } | 503 } |
505 | 504 |
506 void FilterEngine::SetAllowedConnectionType(const std::string* value) | 505 void FilterEngine::SetAllowedConnectionType(const std::string* value) |
507 { | 506 { |
508 SetPref("allowed_connection_type", value ? jsEngine->NewValue(*value) : jsEngi
ne->NewValue("")); | 507 SetPref("allowed_connection_type", value ? jsEngine->NewValue(*value) : jsEngi
ne->NewValue("")); |
509 } | 508 } |
510 | 509 |
511 std::unique_ptr<std::string> FilterEngine::GetAllowedConnectionType() const | 510 std::unique_ptr<std::string> FilterEngine::GetAllowedConnectionType() const |
512 { | 511 { |
513 auto prefValue = GetPref("allowed_connection_type"); | 512 auto prefValue = GetPref("allowed_connection_type"); |
514 if (prefValue->AsString().empty()) | 513 if (prefValue.AsString().empty()) |
515 return nullptr; | 514 return nullptr; |
516 return std::unique_ptr<std::string>(new std::string(prefValue->AsString())); | 515 return std::unique_ptr<std::string>(new std::string(prefValue.AsString())); |
517 } | 516 } |
518 | 517 |
519 void FilterEngine::FilterChanged(const FilterEngine::FilterChangeCallback& callb
ack, const JsConstValueList& params) const | 518 void FilterEngine::FilterChanged(const FilterEngine::FilterChangeCallback& callb
ack, const JsValueList& params) const |
520 { | 519 { |
521 std::string action(params.size() >= 1 && !params[0]->IsNull() ? params[0]->AsS
tring() : ""); | 520 std::string action(params.size() >= 1 && !params[0].IsNull() ? params[0].AsStr
ing() : ""); |
522 JsConstValuePtr item(params.size() >= 2 ? params[1] : jsEngine->NewValue(false
)); | 521 JsValue item(params.size() >= 2 ? params[1] : jsEngine->NewValue(false)); |
523 callback(action, *item); | 522 callback(action, item); |
524 } | 523 } |
525 | 524 |
526 void FilterEngine::ShowNotification(const ShowNotificationCallback& callback, | 525 void FilterEngine::ShowNotification(const ShowNotificationCallback& callback, |
527 const JsConstValueList& params) const | 526 const JsValueList& params) const |
528 { | 527 { |
529 if (params.size() < 1) | 528 if (params.size() < 1) |
530 return; | 529 return; |
531 | 530 |
532 if (!params[0]->IsObject()) | 531 if (!params[0].IsObject()) |
533 { | 532 { |
534 return; | 533 return; |
535 } | 534 } |
536 callback(NotificationPtr(new Notification(params[0]->Clone()))); | 535 callback(NotificationPtr(new Notification(JsValue(params[0])))); |
537 } | 536 } |
538 | 537 |
539 | 538 |
540 int FilterEngine::CompareVersions(const std::string& v1, const std::string& v2)
const | 539 int FilterEngine::CompareVersions(const std::string& v1, const std::string& v2)
const |
541 { | 540 { |
542 JsConstValueList params; | 541 JsValueList params; |
543 params.push_back(jsEngine->NewValue(v1)); | 542 params.push_back(jsEngine->NewValue(v1)); |
544 params.push_back(jsEngine->NewValue(v2)); | 543 params.push_back(jsEngine->NewValue(v2)); |
545 JsValuePtr func = jsEngine->Evaluate("API.compareVersions"); | 544 JsValuePtr func = jsEngine->Evaluate("API.compareVersions"); |
546 return func->Call(params).AsInt(); | 545 return func->Call(params).AsInt(); |
547 } | 546 } |
548 | 547 |
549 FilterPtr FilterEngine::GetWhitelistingFilter(const std::string& url, | 548 FilterPtr FilterEngine::GetWhitelistingFilter(const std::string& url, |
550 ContentTypeMask contentTypeMask, const std::string& documentUrl) const | 549 ContentTypeMask contentTypeMask, const std::string& documentUrl) const |
551 { | 550 { |
552 FilterPtr match = Matches(url, contentTypeMask, documentUrl); | 551 FilterPtr match = Matches(url, contentTypeMask, documentUrl); |
(...skipping 21 matching lines...) Expand all Loading... |
574 FilterPtr filter = GetWhitelistingFilter(currentUrl, contentTypeMask, parent
Url); | 573 FilterPtr filter = GetWhitelistingFilter(currentUrl, contentTypeMask, parent
Url); |
575 if (filter) | 574 if (filter) |
576 { | 575 { |
577 return filter; | 576 return filter; |
578 } | 577 } |
579 currentUrl = parentUrl; | 578 currentUrl = parentUrl; |
580 } | 579 } |
581 while (urlIterator != documentUrls.end()); | 580 while (urlIterator != documentUrls.end()); |
582 return FilterPtr(); | 581 return FilterPtr(); |
583 } | 582 } |
OLD | NEW |