static jobject GetOrigins(JNIEnv* env, jobject obj) { Vector<RefPtr<WebCore::SecurityOrigin> > coreOrigins; WebCore::DatabaseTracker::tracker().origins(coreOrigins); Vector<WebCore::KURL> manifestUrls; if (WebCore::cacheStorage().manifestURLs(&manifestUrls)) { int size = manifestUrls.size(); for (int i = 0; i < size; ++i) { RefPtr<WebCore::SecurityOrigin> manifestOrigin = WebCore::SecurityOrigin::create(manifestUrls[i]); if (manifestOrigin.get() == 0) continue; coreOrigins.append(manifestOrigin); } } jclass setClass = env->FindClass("java/util/HashSet"); jmethodID cid = env->GetMethodID(setClass, "<init>", "()V"); jmethodID mid = env->GetMethodID(setClass, "add", "(Ljava/lang/Object;)Z"); jobject set = env->NewObject(setClass, cid); for (unsigned i = 0; i < coreOrigins.size(); ++i) { WebCore::SecurityOrigin* origin = coreOrigins[i].get(); WebCore::String url = origin->toString(); jstring jUrl = env->NewString(url.characters(), url.length()); env->CallBooleanMethod(set, mid, jUrl); env->DeleteLocalRef(jUrl); } return set; }
static String combinedSecurityOriginIdentifier(const WebCore::SecurityOrigin& openingOrigin, const WebCore::SecurityOrigin& mainFrameOrigin) { StringBuilder stringBuilder; String originString = openingOrigin.toString(); if (originString == "null") return String(); stringBuilder.append(originString); stringBuilder.append("_"); originString = mainFrameOrigin.toString(); if (originString == "null") return String(); stringBuilder.append(originString); return stringBuilder.toString(); }