package com.tencent.mm.plugin.webview.ui.tools.widget;

import android.content.Context;
import android.util.AttributeSet;
import com.tencent.matrix.trace.core.AppMethodBeat;
import com.tencent.mm.plugin.webview.ui.tools.jsapi.d;
import com.tencent.mm.pluginsdk.ui.tools.u;
import com.tencent.mm.ui.widget.MMWebView;
import com.tencent.xweb.s;
import com.tencent.ytcommon.BuildConfig;

public class MMWebViewWithJsApi extends MMWebView {
    private k uJK;
    private boolean uJL;

    static /* synthetic */ void fu(Context context) {
        AppMethodBeat.i(10036);
        il(context);
        AppMethodBeat.o(10036);
    }

    public MMWebViewWithJsApi(Context context) {
        this(context, null);
    }

    public MMWebViewWithJsApi(Context context, AttributeSet attributeSet) {
        this(context, attributeSet, 0);
    }

    public MMWebViewWithJsApi(Context context, AttributeSet attributeSet, int i) {
        super(context, attributeSet, i);
        AppMethodBeat.i(10030);
        this.uJL = true;
        dKG();
        getSettings().setJavaScriptEnabled(true);
        getSettings().dUj();
        setWebChromeClient(new i(this));
        setWebViewClient(new k(this));
        String userAgentString = getSettings().getUserAgentString();
        if (!u.akj(userAgentString)) {
            getSettings().setUserAgentString(u.bh(getContext(), userAgentString));
        }
        AppMethodBeat.o(10030);
    }

    public d getJsapi() {
        if (this.uJK != null) {
            return this.uJK.uDd;
        }
        return null;
    }

    public void setWebViewClient(s sVar) {
        AppMethodBeat.i(10031);
        super.setWebViewClient(sVar);
        if (sVar instanceof k) {
            this.uJK = (k) sVar;
            AppMethodBeat.o(10031);
            return;
        }
        this.uJK = null;
        AppMethodBeat.o(10031);
    }

    public void setCleanOnDetached(boolean z) {
        this.uJL = z;
    }

    /* Access modifiers changed, original: protected */
    public void onDetachedFromWindow() {
        AppMethodBeat.i(10032);
        super.onDetachedFromWindow();
        if (this.uJK != null && this.uJL) {
            this.uJK.cleanup();
        }
        AppMethodBeat.o(10032);
    }

    public void loadData(String str, String str2, String str3) {
        AppMethodBeat.i(10033);
        if (this.uJK != null) {
            this.uJK.of(true);
            this.uJK.agc(BuildConfig.FLAVOR);
        }
        super.loadData(str, str2, str3);
        AppMethodBeat.o(10033);
    }

    public void loadDataWithBaseURL(String str, String str2, String str3, String str4, String str5) {
        AppMethodBeat.i(10034);
        if (this.uJK != null) {
            this.uJK.of(true);
            this.uJK.agc(BuildConfig.FLAVOR);
        }
        super.loadDataWithBaseURL(str, str2, str3, str4, str5);
        AppMethodBeat.o(10034);
    }

    /* JADX WARNING: Missing block: B:3:0x0015, code skipped:
            if (r3.uJK.agc(r4) == false) goto L_0x0017;
     */
    public void loadUrl(java.lang.String r4) {
        /*
        r3 = this;
        r2 = 10035; // 0x2733 float:1.4062E-41 double:4.958E-320;
        com.tencent.matrix.trace.core.AppMethodBeat.i(r2);
        r0 = r3.uJK;
        if (r0 == 0) goto L_0x0017;
    L_0x0009:
        r0 = r3.uJK;
        r1 = 0;
        r0.of(r1);
        r0 = r3.uJK;
        r0 = r0.agc(r4);
        if (r0 != 0) goto L_0x001a;
    L_0x0017:
        super.loadUrl(r4);
    L_0x001a:
        com.tencent.matrix.trace.core.AppMethodBeat.o(r2);
        return;
        */
        throw new UnsupportedOperationException("Method not decompiled: com.tencent.mm.plugin.webview.ui.tools.widget.MMWebViewWithJsApi.loadUrl(java.lang.String):void");
    }
}
