| 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 19 matching lines...) Expand all Loading... |
| 30 | 30 |
| 31 extern std::string jsSources[]; | 31 extern std::string jsSources[]; |
| 32 | 32 |
| 33 Filter::Filter(JsValue&& value) | 33 Filter::Filter(JsValue&& value) |
| 34 : JsValue(std::move(value)) | 34 : JsValue(std::move(value)) |
| 35 { | 35 { |
| 36 if (!IsObject()) | 36 if (!IsObject()) |
| 37 throw std::runtime_error("JavaScript value is not an object"); | 37 throw std::runtime_error("JavaScript value is not an object"); |
| 38 } | 38 } |
| 39 | 39 |
| 40 Filter::Type Filter::GetType() | 40 Filter::Type Filter::GetType() const |
| 41 { | 41 { |
| 42 std::string className = GetClass(); | 42 std::string className = GetClass(); |
| 43 if (className == "BlockingFilter") | 43 if (className == "BlockingFilter") |
| 44 return TYPE_BLOCKING; | 44 return TYPE_BLOCKING; |
| 45 else if (className == "WhitelistFilter") | 45 else if (className == "WhitelistFilter") |
| 46 return TYPE_EXCEPTION; | 46 return TYPE_EXCEPTION; |
| 47 else if (className == "ElemHideFilter") | 47 else if (className == "ElemHideFilter") |
| 48 return TYPE_ELEMHIDE; | 48 return TYPE_ELEMHIDE; |
| 49 else if (className == "ElemHideException") | 49 else if (className == "ElemHideException") |
| 50 return TYPE_ELEMHIDE_EXCEPTION; | 50 return TYPE_ELEMHIDE_EXCEPTION; |
| 51 else if (className == "CommentFilter") | 51 else if (className == "CommentFilter") |
| 52 return TYPE_COMMENT; | 52 return TYPE_COMMENT; |
| 53 else | 53 else |
| 54 return TYPE_INVALID; | 54 return TYPE_INVALID; |
| 55 } | 55 } |
| 56 | 56 |
| 57 bool Filter::IsListed() | 57 bool Filter::IsListed() const |
| 58 { | 58 { |
| 59 JsValuePtr func = jsEngine->Evaluate("API.isListedFilter"); | 59 JsValuePtr func = jsEngine->Evaluate("API.isListedFilter"); |
| 60 JsValueList params; | 60 return func->Call(shared_from_this())->AsBool(); |
| 61 params.push_back(shared_from_this()); | |
| 62 return func->Call(params)->AsBool(); | |
| 63 } | 61 } |
| 64 | 62 |
| 65 void Filter::AddToList() | 63 void Filter::AddToList() |
| 66 { | 64 { |
| 67 JsValuePtr func = jsEngine->Evaluate("API.addFilterToList"); | 65 JsValuePtr func = jsEngine->Evaluate("API.addFilterToList"); |
| 68 JsValueList params; | 66 func->Call(shared_from_this()); |
| 69 params.push_back(shared_from_this()); | |
| 70 func->Call(params); | |
| 71 } | 67 } |
| 72 | 68 |
| 73 void Filter::RemoveFromList() | 69 void Filter::RemoveFromList() |
| 74 { | 70 { |
| 75 JsValuePtr func = jsEngine->Evaluate("API.removeFilterFromList"); | 71 JsValuePtr func = jsEngine->Evaluate("API.removeFilterFromList"); |
| 76 JsValueList params; | 72 func->Call(shared_from_this()); |
| 77 params.push_back(shared_from_this()); | |
| 78 func->Call(params); | |
| 79 } | 73 } |
| 80 | 74 |
| 81 bool Filter::operator==(const Filter& filter) const | 75 bool Filter::operator==(const Filter& filter) const |
| 82 { | 76 { |
| 83 return GetProperty("text")->AsString() == filter.GetProperty("text")->AsString
(); | 77 return GetProperty("text")->AsString() == filter.GetProperty("text")->AsString
(); |
| 84 } | 78 } |
| 85 | 79 |
| 86 Subscription::Subscription(JsValue&& value) | 80 Subscription::Subscription(JsValue&& value) |
| 87 : JsValue(std::move(value)) | 81 : JsValue(std::move(value)) |
| 88 { | 82 { |
| 89 if (!IsObject()) | 83 if (!IsObject()) |
| 90 throw std::runtime_error("JavaScript value is not an object"); | 84 throw std::runtime_error("JavaScript value is not an object"); |
| 91 } | 85 } |
| 92 | 86 |
| 93 bool Subscription::IsListed() | 87 bool Subscription::IsListed() const |
| 94 { | 88 { |
| 95 JsValuePtr func = jsEngine->Evaluate("API.isListedSubscription"); | 89 JsValuePtr func = jsEngine->Evaluate("API.isListedSubscription"); |
| 96 JsValueList params; | 90 return func->Call(shared_from_this())->AsBool(); |
| 97 params.push_back(shared_from_this()); | |
| 98 return func->Call(params)->AsBool(); | |
| 99 } | 91 } |
| 100 | 92 |
| 101 void Subscription::AddToList() | 93 void Subscription::AddToList() |
| 102 { | 94 { |
| 103 JsValuePtr func = jsEngine->Evaluate("API.addSubscriptionToList"); | 95 JsValuePtr func = jsEngine->Evaluate("API.addSubscriptionToList"); |
| 104 JsValueList params; | 96 func->Call(shared_from_this()); |
| 105 params.push_back(shared_from_this()); | |
| 106 func->Call(params); | |
| 107 } | 97 } |
| 108 | 98 |
| 109 void Subscription::RemoveFromList() | 99 void Subscription::RemoveFromList() |
| 110 { | 100 { |
| 111 JsValuePtr func = jsEngine->Evaluate("API.removeSubscriptionFromList"); | 101 JsValuePtr func = jsEngine->Evaluate("API.removeSubscriptionFromList"); |
| 112 JsValueList params; | 102 func->Call(shared_from_this()); |
| 113 params.push_back(shared_from_this()); | |
| 114 func->Call(params); | |
| 115 } | 103 } |
| 116 | 104 |
| 117 void Subscription::UpdateFilters() | 105 void Subscription::UpdateFilters() |
| 118 { | 106 { |
| 119 JsValuePtr func = jsEngine->Evaluate("API.updateSubscription"); | 107 JsValuePtr func = jsEngine->Evaluate("API.updateSubscription"); |
| 120 JsValueList params; | 108 func->Call(shared_from_this()); |
| 121 params.push_back(shared_from_this()); | |
| 122 func->Call(params); | |
| 123 } | 109 } |
| 124 | 110 |
| 125 bool Subscription::IsUpdating() | 111 bool Subscription::IsUpdating() const |
| 126 { | 112 { |
| 127 JsValuePtr func = jsEngine->Evaluate("API.isSubscriptionUpdating"); | 113 JsValuePtr func = jsEngine->Evaluate("API.isSubscriptionUpdating"); |
| 128 JsValueList params; | 114 JsValuePtr result = func->Call(shared_from_this()); |
| 129 params.push_back(shared_from_this()); | |
| 130 JsValuePtr result = func->Call(params); | |
| 131 return result->AsBool(); | 115 return result->AsBool(); |
| 132 } | 116 } |
| 133 | 117 |
| 134 bool Subscription::operator==(const Subscription& subscription) const | 118 bool Subscription::operator==(const Subscription& subscription) const |
| 135 { | 119 { |
| 136 return GetProperty("url")->AsString() == subscription.GetProperty("url")->AsSt
ring(); | 120 return GetProperty("url")->AsString() == subscription.GetProperty("url")->AsSt
ring(); |
| 137 } | 121 } |
| 138 | 122 |
| 139 namespace | 123 namespace |
| 140 { | 124 { |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 return contentType.first; | 265 return contentType.first; |
| 282 } | 266 } |
| 283 throw std::invalid_argument("Cannot convert argument to ContentType"); | 267 throw std::invalid_argument("Cannot convert argument to ContentType"); |
| 284 } | 268 } |
| 285 | 269 |
| 286 bool FilterEngine::IsFirstRun() const | 270 bool FilterEngine::IsFirstRun() const |
| 287 { | 271 { |
| 288 return firstRun; | 272 return firstRun; |
| 289 } | 273 } |
| 290 | 274 |
| 291 FilterPtr FilterEngine::GetFilter(const std::string& text) | 275 FilterPtr FilterEngine::GetFilter(const std::string& text) const |
| 292 { | 276 { |
| 293 JsValuePtr func = jsEngine->Evaluate("API.getFilterFromText"); | 277 JsValuePtr func = jsEngine->Evaluate("API.getFilterFromText"); |
| 294 JsValueList params; | 278 return FilterPtr(new Filter(std::move(*func->Call(jsEngine->NewValue(text)))))
; |
| 295 params.push_back(jsEngine->NewValue(text)); | |
| 296 return FilterPtr(new Filter(std::move(*func->Call(params)))); | |
| 297 } | 279 } |
| 298 | 280 |
| 299 SubscriptionPtr FilterEngine::GetSubscription(const std::string& url) | 281 SubscriptionPtr FilterEngine::GetSubscription(const std::string& url) const |
| 300 { | 282 { |
| 301 JsValuePtr func = jsEngine->Evaluate("API.getSubscriptionFromUrl"); | 283 JsValuePtr func = jsEngine->Evaluate("API.getSubscriptionFromUrl"); |
| 302 JsValueList params; | 284 return SubscriptionPtr(new Subscription(std::move(*func->Call(jsEngine->NewVal
ue(url))))); |
| 303 params.push_back(jsEngine->NewValue(url)); | |
| 304 return SubscriptionPtr(new Subscription(std::move(*func->Call(params)))); | |
| 305 } | 285 } |
| 306 | 286 |
| 307 std::vector<FilterPtr> FilterEngine::GetListedFilters() const | 287 std::vector<FilterPtr> FilterEngine::GetListedFilters() const |
| 308 { | 288 { |
| 309 JsValuePtr func = jsEngine->Evaluate("API.getListedFilters"); | 289 JsValuePtr func = jsEngine->Evaluate("API.getListedFilters"); |
| 310 JsValueList values = func->Call()->AsList(); | 290 JsValueList values = func->Call()->AsList(); |
| 311 std::vector<FilterPtr> result; | 291 std::vector<FilterPtr> result; |
| 312 for (JsValueList::iterator it = values.begin(); it != values.end(); it++) | 292 for (JsValueList::iterator it = values.begin(); it != values.end(); it++) |
| 313 result.push_back(FilterPtr(new Filter(std::move(**it)))); | 293 result.push_back(FilterPtr(new Filter(std::move(**it)))); |
| 314 return result; | 294 return result; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 330 JsValueList values = func->Call()->AsList(); | 310 JsValueList values = func->Call()->AsList(); |
| 331 std::vector<SubscriptionPtr> result; | 311 std::vector<SubscriptionPtr> result; |
| 332 for (JsValueList::iterator it = values.begin(); it != values.end(); it++) | 312 for (JsValueList::iterator it = values.begin(); it != values.end(); it++) |
| 333 result.push_back(SubscriptionPtr(new Subscription(std::move(**it)))); | 313 result.push_back(SubscriptionPtr(new Subscription(std::move(**it)))); |
| 334 return result; | 314 return result; |
| 335 } | 315 } |
| 336 | 316 |
| 337 void FilterEngine::ShowNextNotification(const std::string& url) | 317 void FilterEngine::ShowNextNotification(const std::string& url) |
| 338 { | 318 { |
| 339 JsValuePtr func = jsEngine->Evaluate("API.showNextNotification"); | 319 JsValuePtr func = jsEngine->Evaluate("API.showNextNotification"); |
| 340 JsValueList params; | 320 JsConstValueList params; |
| 341 if (!url.empty()) | 321 if (!url.empty()) |
| 342 { | 322 { |
| 343 params.push_back(jsEngine->NewValue(url)); | 323 params.push_back(jsEngine->NewValue(url)); |
| 344 } | 324 } |
| 345 func->Call(params); | 325 func->Call(params); |
| 346 } | 326 } |
| 347 | 327 |
| 348 void FilterEngine::SetShowNotificationCallback(const ShowNotificationCallback& v
alue) | 328 void FilterEngine::SetShowNotificationCallback(const ShowNotificationCallback& v
alue) |
| 349 { | 329 { |
| 350 if (!value) | 330 if (!value) |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 399 const std::vector<std::string>& documentUrls) const | 379 const std::vector<std::string>& documentUrls) const |
| 400 { | 380 { |
| 401 return !!GetWhitelistingFilter(url, CONTENT_TYPE_ELEMHIDE, documentUrls); | 381 return !!GetWhitelistingFilter(url, CONTENT_TYPE_ELEMHIDE, documentUrls); |
| 402 } | 382 } |
| 403 | 383 |
| 404 AdblockPlus::FilterPtr FilterEngine::CheckFilterMatch(const std::string& url, | 384 AdblockPlus::FilterPtr FilterEngine::CheckFilterMatch(const std::string& url, |
| 405 ContentTypeMask contentTypeMask, | 385 ContentTypeMask contentTypeMask, |
| 406 const std::string& documentUrl) const | 386 const std::string& documentUrl) const |
| 407 { | 387 { |
| 408 JsValuePtr func = jsEngine->Evaluate("API.checkFilterMatch"); | 388 JsValuePtr func = jsEngine->Evaluate("API.checkFilterMatch"); |
| 409 JsValueList params; | 389 JsConstValueList params; |
| 410 params.push_back(jsEngine->NewValue(url)); | 390 params.push_back(jsEngine->NewValue(url)); |
| 411 params.push_back(jsEngine->NewValue(contentTypeMask)); | 391 params.push_back(jsEngine->NewValue(contentTypeMask)); |
| 412 params.push_back(jsEngine->NewValue(documentUrl)); | 392 params.push_back(jsEngine->NewValue(documentUrl)); |
| 413 JsValuePtr result = func->Call(params); | 393 JsValuePtr result = func->Call(params); |
| 414 if (!result->IsNull()) | 394 if (!result->IsNull()) |
| 415 return FilterPtr(new Filter(std::move(*result))); | 395 return FilterPtr(new Filter(std::move(*result))); |
| 416 else | 396 else |
| 417 return FilterPtr(); | 397 return FilterPtr(); |
| 418 } | 398 } |
| 419 | 399 |
| 420 std::vector<std::string> FilterEngine::GetElementHidingSelectors(const std::stri
ng& domain) const | 400 std::vector<std::string> FilterEngine::GetElementHidingSelectors(const std::stri
ng& domain) const |
| 421 { | 401 { |
| 422 JsValuePtr func = jsEngine->Evaluate("API.getElementHidingSelectors"); | 402 JsValuePtr func = jsEngine->Evaluate("API.getElementHidingSelectors"); |
| 423 JsValueList params; | 403 JsValueList result = func->Call(jsEngine->NewValue(domain))->AsList(); |
| 424 params.push_back(jsEngine->NewValue(domain)); | |
| 425 JsValueList result = func->Call(params)->AsList(); | |
| 426 std::vector<std::string> selectors; | 404 std::vector<std::string> selectors; |
| 427 for (const auto& r: result) | 405 for (const auto& r: result) |
| 428 selectors.push_back(r->AsString()); | 406 selectors.push_back(r->AsString()); |
| 429 return selectors; | 407 return selectors; |
| 430 } | 408 } |
| 431 | 409 |
| 432 JsValuePtr FilterEngine::GetPref(const std::string& pref) const | 410 JsValuePtr FilterEngine::GetPref(const std::string& pref) const |
| 433 { | 411 { |
| 434 JsValuePtr func = jsEngine->Evaluate("API.getPref"); | 412 JsValuePtr func = jsEngine->Evaluate("API.getPref"); |
| 435 JsValueList params; | 413 return func->Call(jsEngine->NewValue(pref)); |
| 436 params.push_back(jsEngine->NewValue(pref)); | |
| 437 return func->Call(params); | |
| 438 } | 414 } |
| 439 | 415 |
| 440 void FilterEngine::SetPref(const std::string& pref, JsValuePtr value) | 416 void FilterEngine::SetPref(const std::string& pref, JsValuePtr value) |
| 441 { | 417 { |
| 442 JsValuePtr func = jsEngine->Evaluate("API.setPref"); | 418 JsValuePtr func = jsEngine->Evaluate("API.setPref"); |
| 443 JsValueList params; | 419 JsConstValueList params; |
| 444 params.push_back(jsEngine->NewValue(pref)); | 420 params.push_back(jsEngine->NewValue(pref)); |
| 445 if (value) | 421 if (value) |
| 446 params.push_back(value); | 422 params.push_back(value); |
| 447 func->Call(params); | 423 func->Call(params); |
| 448 } | 424 } |
| 449 | 425 |
| 450 std::string FilterEngine::GetHostFromURL(const std::string& url) | 426 std::string FilterEngine::GetHostFromURL(const std::string& url) const |
| 451 { | 427 { |
| 452 JsValuePtr func = jsEngine->Evaluate("API.getHostFromUrl"); | 428 JsValuePtr func = jsEngine->Evaluate("API.getHostFromUrl"); |
| 453 JsValueList params; | 429 return func->Call(jsEngine->NewValue(url))->AsString(); |
| 454 params.push_back(jsEngine->NewValue(url)); | |
| 455 return func->Call(params)->AsString(); | |
| 456 } | 430 } |
| 457 | 431 |
| 458 void FilterEngine::SetUpdateAvailableCallback( | 432 void FilterEngine::SetUpdateAvailableCallback( |
| 459 FilterEngine::UpdateAvailableCallback callback) | 433 FilterEngine::UpdateAvailableCallback callback) |
| 460 { | 434 { |
| 461 jsEngine->SetEventCallback("updateAvailable", | 435 jsEngine->SetEventCallback("updateAvailable", |
| 462 std::bind(&FilterEngine::UpdateAvailable, this, callback, | 436 std::bind(&FilterEngine::UpdateAvailable, this, callback, |
| 463 std::placeholders::_1)); | 437 std::placeholders::_1)); |
| 464 } | 438 } |
| 465 | 439 |
| 466 void FilterEngine::RemoveUpdateAvailableCallback() | 440 void FilterEngine::RemoveUpdateAvailableCallback() |
| 467 { | 441 { |
| 468 jsEngine->RemoveEventCallback("updateAvailable"); | 442 jsEngine->RemoveEventCallback("updateAvailable"); |
| 469 } | 443 } |
| 470 | 444 |
| 471 void FilterEngine::UpdateAvailable( | 445 void FilterEngine::UpdateAvailable( |
| 472 FilterEngine::UpdateAvailableCallback callback, JsValueList& params) | 446 FilterEngine::UpdateAvailableCallback callback, JsValueList& params) |
| 473 { | 447 { |
| 474 if (params.size() >= 1 && !params[0]->IsNull()) | 448 if (params.size() >= 1 && !params[0]->IsNull()) |
| 475 callback(params[0]->AsString()); | 449 callback(params[0]->AsString()); |
| 476 } | 450 } |
| 477 | 451 |
| 478 void FilterEngine::ForceUpdateCheck( | 452 void FilterEngine::ForceUpdateCheck( |
| 479 const FilterEngine::UpdateCheckDoneCallback& callback) | 453 const FilterEngine::UpdateCheckDoneCallback& callback) |
| 480 { | 454 { |
| 481 JsValuePtr func = jsEngine->Evaluate("API.forceUpdateCheck"); | 455 JsValuePtr func = jsEngine->Evaluate("API.forceUpdateCheck"); |
| 482 JsValueList params; | 456 JsConstValueList params; |
| 483 if (callback) | 457 if (callback) |
| 484 { | 458 { |
| 485 std::string eventName = "_updateCheckDone" + std::to_string(++updateCheckId)
; | 459 std::string eventName = "_updateCheckDone" + std::to_string(++updateCheckId)
; |
| 486 jsEngine->SetEventCallback(eventName, std::bind(&FilterEngine::UpdateCheckDo
ne, | 460 jsEngine->SetEventCallback(eventName, std::bind(&FilterEngine::UpdateCheckDo
ne, |
| 487 this, eventName, callback, std::placeholders::_1)); | 461 this, eventName, callback, std::placeholders::_1)); |
| 488 params.push_back(jsEngine->NewValue(eventName)); | 462 params.push_back(jsEngine->NewValue(eventName)); |
| 489 } | 463 } |
| 490 func->Call(params); | 464 func->Call(params); |
| 491 } | 465 } |
| 492 | 466 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 508 void FilterEngine::RemoveFilterChangeCallback() | 482 void FilterEngine::RemoveFilterChangeCallback() |
| 509 { | 483 { |
| 510 jsEngine->RemoveEventCallback("filterChange"); | 484 jsEngine->RemoveEventCallback("filterChange"); |
| 511 } | 485 } |
| 512 | 486 |
| 513 void FilterEngine::SetAllowedConnectionType(const std::string* value) | 487 void FilterEngine::SetAllowedConnectionType(const std::string* value) |
| 514 { | 488 { |
| 515 SetPref("allowed_connection_type", value ? jsEngine->NewValue(*value) : nullpt
r); | 489 SetPref("allowed_connection_type", value ? jsEngine->NewValue(*value) : nullpt
r); |
| 516 } | 490 } |
| 517 | 491 |
| 518 std::unique_ptr<std::string> FilterEngine::GetAllowedConnectionType() | 492 std::unique_ptr<std::string> FilterEngine::GetAllowedConnectionType() const |
| 519 { | 493 { |
| 520 auto prefValue = GetPref("allowed_connection_type"); | 494 auto prefValue = GetPref("allowed_connection_type"); |
| 521 if (prefValue->IsUndefined()) | 495 if (prefValue->IsUndefined()) |
| 522 return nullptr; | 496 return nullptr; |
| 523 return std::unique_ptr<std::string>(new std::string(prefValue->AsString())); | 497 return std::unique_ptr<std::string>(new std::string(prefValue->AsString())); |
| 524 } | 498 } |
| 525 | 499 |
| 526 void FilterEngine::FilterChanged(FilterEngine::FilterChangeCallback callback, Js
ValueList& params) | 500 void FilterEngine::FilterChanged(FilterEngine::FilterChangeCallback callback, Js
ValueList& params) |
| 527 { | 501 { |
| 528 std::string action(params.size() >= 1 && !params[0]->IsNull() ? params[0]->AsS
tring() : ""); | 502 std::string action(params.size() >= 1 && !params[0]->IsNull() ? params[0]->AsS
tring() : ""); |
| 529 JsValuePtr item(params.size() >= 2 ? params[1] : jsEngine->NewValue(false)); | 503 JsValuePtr item(params.size() >= 2 ? params[1] : jsEngine->NewValue(false)); |
| 530 callback(action, item); | 504 callback(action, item); |
| 531 } | 505 } |
| 532 | 506 |
| 533 void FilterEngine::ShowNotification(const ShowNotificationCallback& callback, | 507 void FilterEngine::ShowNotification(const ShowNotificationCallback& callback, |
| 534 const JsValueList& params) | 508 const JsValueList& params) |
| 535 { | 509 { |
| 536 if (params.size() < 1) | 510 if (params.size() < 1) |
| 537 return; | 511 return; |
| 538 | 512 |
| 539 if (!params[0]->IsObject()) | 513 if (!params[0]->IsObject()) |
| 540 { | 514 { |
| 541 return; | 515 return; |
| 542 } | 516 } |
| 543 callback(NotificationPtr(new Notification(std::move(*params[0])))); | 517 callback(NotificationPtr(new Notification(std::move(*params[0])))); |
| 544 } | 518 } |
| 545 | 519 |
| 546 | 520 |
| 547 int FilterEngine::CompareVersions(const std::string& v1, const std::string& v2) | 521 int FilterEngine::CompareVersions(const std::string& v1, const std::string& v2)
const |
| 548 { | 522 { |
| 549 JsValueList params; | 523 JsConstValueList params; |
| 550 params.push_back(jsEngine->NewValue(v1)); | 524 params.push_back(jsEngine->NewValue(v1)); |
| 551 params.push_back(jsEngine->NewValue(v2)); | 525 params.push_back(jsEngine->NewValue(v2)); |
| 552 JsValuePtr func = jsEngine->Evaluate("API.compareVersions"); | 526 JsValuePtr func = jsEngine->Evaluate("API.compareVersions"); |
| 553 return func->Call(params)->AsInt(); | 527 return func->Call(params)->AsInt(); |
| 554 } | 528 } |
| 555 | 529 |
| 556 FilterPtr FilterEngine::GetWhitelistingFilter(const std::string& url, | 530 FilterPtr FilterEngine::GetWhitelistingFilter(const std::string& url, |
| 557 ContentTypeMask contentTypeMask, const std::string& documentUrl) const | 531 ContentTypeMask contentTypeMask, const std::string& documentUrl) const |
| 558 { | 532 { |
| 559 FilterPtr match = Matches(url, contentTypeMask, documentUrl); | 533 FilterPtr match = Matches(url, contentTypeMask, documentUrl); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 581 FilterPtr filter = GetWhitelistingFilter(currentUrl, contentTypeMask, parent
Url); | 555 FilterPtr filter = GetWhitelistingFilter(currentUrl, contentTypeMask, parent
Url); |
| 582 if (filter) | 556 if (filter) |
| 583 { | 557 { |
| 584 return filter; | 558 return filter; |
| 585 } | 559 } |
| 586 currentUrl = parentUrl; | 560 currentUrl = parentUrl; |
| 587 } | 561 } |
| 588 while (urlIterator != documentUrls.end()); | 562 while (urlIterator != documentUrls.end()); |
| 589 return FilterPtr(); | 563 return FilterPtr(); |
| 590 } | 564 } |
| OLD | NEW |