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

Side by Side Diff: jni/abpEngine.cpp

Issue 5172657418928128: Determine the frame structure (Closed)
Patch Set: Created Nov. 23, 2013, 12:03 a.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 /* 1 /*
2 * This file is part of Adblock Plus <http://adblockplus.org/>, 2 * This file is part of Adblock Plus <http://adblockplus.org/>,
3 * Copyright (C) 2006-2013 Eyeo GmbH 3 * Copyright (C) 2006-2013 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 23 matching lines...) Expand all
34 jstring sdkVersion, jstring locale, jboolean developmentBuild); 34 jstring sdkVersion, jstring locale, jboolean developmentBuild);
35 JNIEXPORT void JNICALL Java_org_adblockplus_android_ABPEngine_release(JNIEnv * pEnv, jobject); 35 JNIEXPORT void JNICALL Java_org_adblockplus_android_ABPEngine_release(JNIEnv * pEnv, jobject);
36 JNIEXPORT jboolean JNICALL Java_org_adblockplus_android_ABPEngine_isFirstRun(J NIEnv *pEnv, jobject); 36 JNIEXPORT jboolean JNICALL Java_org_adblockplus_android_ABPEngine_isFirstRun(J NIEnv *pEnv, jobject);
37 JNIEXPORT jobjectArray JNICALL Java_org_adblockplus_android_ABPEngine_getListe dSubscriptions(JNIEnv *pEnv, jobject); 37 JNIEXPORT jobjectArray JNICALL Java_org_adblockplus_android_ABPEngine_getListe dSubscriptions(JNIEnv *pEnv, jobject);
38 JNIEXPORT jobjectArray JNICALL Java_org_adblockplus_android_ABPEngine_getRecom mendedSubscriptions(JNIEnv *pEnv, jobject); 38 JNIEXPORT jobjectArray JNICALL Java_org_adblockplus_android_ABPEngine_getRecom mendedSubscriptions(JNIEnv *pEnv, jobject);
39 JNIEXPORT void JNICALL Java_org_adblockplus_android_ABPEngine_addSubscription( JNIEnv *pEnv, jobject, jstring url); 39 JNIEXPORT void JNICALL Java_org_adblockplus_android_ABPEngine_addSubscription( JNIEnv *pEnv, jobject, jstring url);
40 JNIEXPORT void JNICALL Java_org_adblockplus_android_ABPEngine_removeSubscripti on(JNIEnv *pEnv, jobject, jstring url); 40 JNIEXPORT void JNICALL Java_org_adblockplus_android_ABPEngine_removeSubscripti on(JNIEnv *pEnv, jobject, jstring url);
41 JNIEXPORT void JNICALL Java_org_adblockplus_android_ABPEngine_refreshSubscript ion(JNIEnv *pEnv, jobject, jstring url); 41 JNIEXPORT void JNICALL Java_org_adblockplus_android_ABPEngine_refreshSubscript ion(JNIEnv *pEnv, jobject, jstring url);
42 JNIEXPORT void JNICALL Java_org_adblockplus_android_ABPEngine_actualizeSubscri ptionStatus(JNIEnv *pEnv, jobject, jstring url); 42 JNIEXPORT void JNICALL Java_org_adblockplus_android_ABPEngine_actualizeSubscri ptionStatus(JNIEnv *pEnv, jobject, jstring url);
43 JNIEXPORT void JNICALL Java_org_adblockplus_android_ABPEngine_setAcceptableAds Enabled(JNIEnv *pEnv, jobject, jboolean enabled); 43 JNIEXPORT void JNICALL Java_org_adblockplus_android_ABPEngine_setAcceptableAds Enabled(JNIEnv *pEnv, jobject, jboolean enabled);
44 JNIEXPORT jboolean JNICALL Java_org_adblockplus_android_ABPEngine_matches(JNIE nv *pEnv, jobject, jstring url, jstring contentType, jstring documentUrl); 44 JNIEXPORT jboolean JNICALL Java_org_adblockplus_android_ABPEngine_matches(
45 JNIEnv *pEnv, jobject, jstring url, jstring contentType, jobjectArray docume ntUrls);
45 JNIEXPORT jobjectArray JNICALL Java_org_adblockplus_android_ABPEngine_getSelec torsForDomain(JNIEnv *pEnv, jobject, jstring domain); 46 JNIEXPORT jobjectArray JNICALL Java_org_adblockplus_android_ABPEngine_getSelec torsForDomain(JNIEnv *pEnv, jobject, jstring domain);
46 JNIEXPORT void JNICALL Java_org_adblockplus_android_ABPEngine_checkUpdates(JNI Env *pEnv, jobject); 47 JNIEXPORT void JNICALL Java_org_adblockplus_android_ABPEngine_checkUpdates(JNI Env *pEnv, jobject);
47 }; 48 };
48 49
49 jobjectArray subscriptionsAsJavaArray(JNIEnv *pEnv, std::vector<AdblockPlus::Sub scriptionPtr> subscriptions) 50 jobjectArray subscriptionsAsJavaArray(JNIEnv *pEnv, std::vector<AdblockPlus::Sub scriptionPtr> subscriptions)
50 { 51 {
51 D(D_WARN, "subscriptionsAsJavaArray()"); 52 D(D_WARN, "subscriptionsAsJavaArray()");
52 static jclass cls = reinterpret_cast<jclass>(pEnv->NewGlobalRef(pEnv->FindClas s("org/adblockplus/android/Subscription"))); 53 static jclass cls = reinterpret_cast<jclass>(pEnv->NewGlobalRef(pEnv->FindClas s("org/adblockplus/android/Subscription")));
53 static jmethodID cid = pEnv->GetMethodID(cls, "<init>", "()V"); 54 static jmethodID cid = pEnv->GetMethodID(cls, "<init>", "()V");
54 static jfieldID ftitle = pEnv->GetFieldID(cls, "title", "Ljava/lang/String;"); 55 static jfieldID ftitle = pEnv->GetFieldID(cls, "title", "Ljava/lang/String;");
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after
448 catch (const std::exception& e) 449 catch (const std::exception& e)
449 { 450 {
450 ThrowJavaException(pEnv, e); 451 ThrowJavaException(pEnv, e);
451 } 452 }
452 catch (...) 453 catch (...)
453 { 454 {
454 ThrowJavaException(pEnv); 455 ThrowJavaException(pEnv);
455 } 456 }
456 } 457 }
457 458
458 JNIEXPORT jboolean JNICALL Java_org_adblockplus_android_ABPEngine_matches(JNIEnv *pEnv, jobject, jstring url, jstring contentType, jstring documentUrl) 459 JNIEXPORT jboolean JNICALL Java_org_adblockplus_android_ABPEngine_matches(
460 JNIEnv *pEnv, jobject, jstring url, jstring contentType, jobjectArray document Urls)
459 { 461 {
460 try 462 try
461 { 463 {
462 const std::string surl = GetString(pEnv, url); 464 const std::string surl = GetString(pEnv, url);
463 const std::string stype = GetString(pEnv, contentType); 465 const std::string stype = GetString(pEnv, contentType);
464 const std::string sdoc = GetString(pEnv, documentUrl); 466 const int documentUrlsLength = pEnv->GetArrayLength(documentUrls);
467 std::vector<std::string> sdocumentUrls;
468 for(int i = 0; i < documentUrlsLength; i++)
469 {
470 jstring documentUrl = static_cast<jstring>(pEnv->GetObjectArrayElement(do cumentUrls, i));
471 sdocumentUrls.push_back(GetString(pEnv, documentUrl));
472 }
465 473
466 AdblockPlus::FilterPtr filter = filterEngine->Matches(surl, stype, sdoc); 474 AdblockPlus::FilterPtr filter = filterEngine->Matches(surl, stype, sdocument Urls);
467 475
468 if (! filter) 476 if (! filter)
469 return JNI_FALSE; 477 return JNI_FALSE;
470 478
471 // hack: if there is no referrer block only if filter is domain-specific 479 // hack: if there is no referrer, block only if filter is domain-specific
472 // (to re-enable in-app ads blocking, proposed on 12.11.2012 Monday meeting) 480 // (to re-enable in-app ads blocking, proposed on 12.11.2012 Monday meeting)
473 // documentUrl contains the referrer (Android application special case) 481 // (documentUrls contains the referrers on Android)
474 if (sdoc.empty() && (filter->GetProperty("text")->AsString()).find("||") != std::string::npos) 482 if (!sdocumentUrls.size() &&
483 (filter->GetProperty("text")->AsString()).find("||") != std::string::npo s)
475 return JNI_FALSE; 484 return JNI_FALSE;
476 485
477 return filter->GetType() == AdblockPlus::Filter::TYPE_EXCEPTION ? JNI_FALSE : JNI_TRUE; 486 return filter->GetType() == AdblockPlus::Filter::TYPE_EXCEPTION ? JNI_FALSE : JNI_TRUE;
478 } 487 }
479 catch (const std::exception& e) 488 catch (const std::exception& e)
480 { 489 {
481 ThrowJavaException(pEnv, e); 490 ThrowJavaException(pEnv, e);
482 } 491 }
483 catch (...) 492 catch (...)
484 { 493 {
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
531 } 540 }
532 catch (const std::exception& e) 541 catch (const std::exception& e)
533 { 542 {
534 ThrowJavaException(pEnv, e); 543 ThrowJavaException(pEnv, e);
535 } 544 }
536 catch (...) 545 catch (...)
537 { 546 {
538 ThrowJavaException(pEnv); 547 ThrowJavaException(pEnv);
539 } 548 }
540 } 549 }
OLDNEW
« no previous file with comments | « no previous file | src/org/adblockplus/android/ABPEngine.java » ('j') | src/org/adblockplus/android/AdblockPlus.java » ('J')

Powered by Google App Engine
This is Rietveld