正在查看: Jurassic World v1.83.4 应用的 AirshipWebView.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Jurassic World v1.83.4 应用的 AirshipWebView.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.urbanairship.webkit;
import android.R;
import android.content.Context;
import android.content.res.TypedArray;
import android.net.Uri;
import android.util.AttributeSet;
import android.util.Base64;
import android.webkit.ValueCallback;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import androidx.webkit.WebSettingsCompat;
import androidx.webkit.WebViewCompat;
import androidx.webkit.WebViewFeature;
import com.microsoft.appcenter.Constants;
import com.urbanairship.Logger;
import com.urbanairship.util.ManifestUtils;
import java.util.Map;
public class AirshipWebView extends WebView {
private static final String CACHE_DIRECTORY = "urbanairship";
private String currentClientAuthRequestUrl;
private boolean isStartSafeBrowsingAttempted;
private WebViewClient webViewClient;
protected void initializeView() {
}
protected void populateCustomJavascriptInterfaces() {
}
public AirshipWebView(Context context) {
this(context, null);
}
public AirshipWebView(Context context, AttributeSet attrs) {
this(context, attrs, R.attr.webViewStyle);
}
public AirshipWebView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
this.isStartSafeBrowsingAttempted = false;
if (isInEditMode()) {
return;
}
init(context, attrs, defStyle, 0);
}
public AirshipWebView(Context context, AttributeSet attrs, int defStyle, int defResStyle) {
super(context, attrs, defStyle, defResStyle);
this.isStartSafeBrowsingAttempted = false;
if (isInEditMode()) {
return;
}
init(context, attrs, defStyle, defResStyle);
}
private void init(Context context, AttributeSet attrs, int defStyle, int defResStyle) {
WebSettings settings = getSettings();
settings.setDomStorageEnabled(true);
if (attrs != null) {
TypedArray obtainStyledAttributes = context.getTheme().obtainStyledAttributes(attrs, com.urbanairship.R.styleable.AirshipWebView, defStyle, defResStyle);
try {
settings.setMixedContentMode(obtainStyledAttributes.getInteger(com.urbanairship.R.styleable.AirshipWebView_mixed_content_mode, 2));
} finally {
obtainStyledAttributes.recycle();
}
}
settings.setAllowFileAccess(true);
settings.setJavaScriptEnabled(true);
settings.setCacheMode(-1);
if (ManifestUtils.shouldEnableLocalStorage()) {
Logger.verbose("Application contains metadata to enable local storage", new Object[0]);
settings.setDomStorageEnabled(true);
settings.setDatabaseEnabled(true);
}
initializeView();
populateCustomJavascriptInterfaces();
}
void m3305lambda$loadData$0$comurbanairshipwebkitAirshipWebView(String str, String str2, String str3) {
super.loadData(str, str2, str3);
}
@Override
public void loadData(final String data, final String mimeType, final String encoding) {
onPreLoad(new Runnable() {
@Override
public final void run() {
AirshipWebView.this.m3305lambda$loadData$0$comurbanairshipwebkitAirshipWebView(data, mimeType, encoding);
}
});
}
void m3306x6f0e94fd(String str, String str2, String str3, String str4, String str5) {
super.loadDataWithBaseURL(str, str2, str3, str4, str5);
}
@Override
public void loadDataWithBaseURL(final String baseUrl, final String data, final String mimeType, final String encoding, final String historyUrl) {
onPreLoad(new Runnable() {
@Override
public final void run() {
AirshipWebView.this.m3306x6f0e94fd(baseUrl, data, mimeType, encoding, historyUrl);
}
});
}
void m3307lambda$loadUrl$2$comurbanairshipwebkitAirshipWebView(String str) {
super.loadUrl(str);
}
@Override
public void loadUrl(final String url) {
onPreLoad(new Runnable() {
@Override
public final void run() {
AirshipWebView.this.m3307lambda$loadUrl$2$comurbanairshipwebkitAirshipWebView(url);
}
});
}
void m3308lambda$loadUrl$3$comurbanairshipwebkitAirshipWebView(String str, Map map) {
super.loadUrl(str, map);
}
@Override
public void loadUrl(final String url, final Map<String, String> additionalHttpHeaders) {
onPreLoad(new Runnable() {
@Override
public final void run() {
AirshipWebView.this.m3308lambda$loadUrl$3$comurbanairshipwebkitAirshipWebView(url, additionalHttpHeaders);
}
});
}
@Override
public void setWebViewClient(WebViewClient webViewClient) {
if (webViewClient != null && !(webViewClient instanceof AirshipWebViewClient)) {
Logger.warn("The web view client should extend AirshipWebViewClient to support Airship url overrides and triggering actions from.", new Object[0]);
}
this.webViewClient = webViewClient;
super.setWebViewClient(webViewClient);
}
protected void onPreLoad(final Runnable onReadyCallback) {
if (getWebViewClientCompat() == null) {
Logger.debug("No web view client set, setting a default AirshipWebViewClient for landing page view.", new Object[0]);
setWebViewClient(new AirshipWebViewClient());
}
if (this.currentClientAuthRequestUrl != null && getWebViewClientCompat() != null && (getWebViewClientCompat() instanceof AirshipWebViewClient)) {
((AirshipWebViewClient) getWebViewClientCompat()).removeAuthRequestCredentials(this.currentClientAuthRequestUrl);
this.currentClientAuthRequestUrl = null;
}
if (!this.isStartSafeBrowsingAttempted && shouldStartSafeBrowsing()) {
WebViewCompat.startSafeBrowsing(getContext().getApplicationContext(), new ValueCallback() {
@Override
public final void onReceiveValue(Object obj) {
AirshipWebView.this.m3309lambda$onPreLoad$4$comurbanairshipwebkitAirshipWebView(onReadyCallback, (Boolean) obj);
}
});
return;
}
Logger.debug("Unable to start Safe Browsing. Feature is not supported or disabled in the manifest.", new Object[0]);
this.isStartSafeBrowsingAttempted = true;
onReadyCallback.run();
}
void m3309lambda$onPreLoad$4$comurbanairshipwebkitAirshipWebView(Runnable runnable, Boolean bool) {
if (!bool.booleanValue()) {
Logger.debug("Unable to start Safe Browsing. Feature is not supported or disabled in the manifest.", new Object[0]);
}
this.isStartSafeBrowsingAttempted = true;
runnable.run();
}
WebViewClient getWebViewClientCompat() {
return this.webViewClient;
}
protected void setClientAuthRequest(String url, String username, String password) {
this.currentClientAuthRequestUrl = url;
if (getWebViewClientCompat() == null || !(getWebViewClientCompat() instanceof AirshipWebViewClient)) {
return;
}
AirshipWebViewClient airshipWebViewClient = (AirshipWebViewClient) getWebViewClientCompat();
String host = Uri.parse(url).getHost();
if (host != null) {
airshipWebViewClient.addAuthRequestCredentials(host, username, password);
}
}
protected String createBasicAuth(String userName, String password) {
return "Basic " + Base64.encodeToString((userName + Constants.COMMON_SCHEMA_PREFIX_SEPARATOR + password).getBytes(), 2);
}
private boolean shouldStartSafeBrowsing() {
return WebViewFeature.isFeatureSupported("START_SAFE_BROWSING") && WebViewFeature.isFeatureSupported("SAFE_BROWSING_ENABLE") && WebSettingsCompat.getSafeBrowsingEnabled(getSettings()) && ManifestUtils.isWebViewSafeBrowsingEnabled();
}
}