Chomp v9.11版本的 MD5 值为:86ab69d1e20ec410efefb0967588d151
以下内容为反编译后的 MraidJsBridge.java 源代码,内容仅作参考
package com.smaato.sdk.richmedia.mraid.bridge;
import a.a;
import android.net.Uri;
import android.webkit.WebView;
import com.smaato.sdk.core.log.LogDomain;
import com.smaato.sdk.core.log.Logger;
import com.smaato.sdk.core.util.Objects;
import com.smaato.sdk.core.util.TextUtils;
import com.smaato.sdk.core.util.collections.Maps;
import com.smaato.sdk.richmedia.mraid.MraidUtils;
import j6.g;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
public final class MraidJsBridge {
private final Map<String, MraidCommandHandler> handlers = Collections.synchronizedMap(new HashMap());
private final Logger logger;
private final WebView webView;
public MraidJsBridge(WebView webView, Logger logger) {
this.webView = (WebView) Objects.requireNonNull(webView);
this.logger = (Logger) Objects.requireNonNull(logger);
}
private void fireNativeCallCompleteEvent() {
runScript("window.mraidbridge.nativeCallComplete();");
}
private Map<String, String> getQueryParamMap(Uri uri) {
HashMap hashMap = new HashMap();
for (String str : uri.getQueryParameterNames()) {
String queryParameter = uri.getQueryParameter(str);
if (queryParameter != null) {
hashMap.put(str, queryParameter);
}
}
return Maps.toImmutableMap(hashMap);
}
private void handleCommand(String str, Map<String, String> map, boolean z10) {
MraidCommandHandler mraidCommandHandler = this.handlers.get(str);
if (mraidCommandHandler == null) {
this.logger.debug(LogDomain.MRAID, a.j("A handler for command \"", str, "\" is not registered"), new Object[0]);
} else {
mraidCommandHandler.handle(map, z10);
}
}
public void lambda$handleMraidUrl$0(Uri uri, boolean z10, String str) {
handleCommand(str, getQueryParamMap(uri), z10);
}
public void addCommandHandler(String str, MraidCommandHandler mraidCommandHandler) {
if (TextUtils.isEmpty(str)) {
return;
}
this.handlers.put(str, mraidCommandHandler);
}
public void fireReadyEvent() {
runScript("window.mraidbridge.fireReadyEvent();");
}
public void handleMraidUrl(String str, boolean z10) {
Uri parse = Uri.parse(str);
Objects.onNotNull(parse.getHost(), new com.smaato.sdk.core.mvvm.view.a(this, parse, z10));
fireNativeCallCompleteEvent();
}
public void runScript(String str) {
this.logger.info(LogDomain.MRAID, g.h("Running script: ", str), new Object[0]);
this.webView.loadUrl(MraidUtils.format("javascript:%s", str));
}
}