package com.tencent.mm.plugin.webview;

import android.content.Intent;
import android.os.Bundle;
import com.tencent.matrix.trace.core.AppMethodBeat;
import com.tencent.mm.bp.d;
import com.tencent.mm.sdk.platformtools.aa;
import com.tencent.mm.sdk.platformtools.ab;
import com.tencent.mm.sdk.platformtools.ah;
import com.tencent.mm.ui.base.p;
import com.tencent.xweb.WebView;
import org.a.a;

public final class b {
    public p tipDialog;
    private final int uew = 0;
    private final int uex = 1;
    private final int uey = 2;

    public static boolean b(WebView webView) {
        AppMethodBeat.i(5619);
        if (webView.getX5WebViewExtension() == null) {
            AppMethodBeat.o(5619);
            return false;
        }
        boolean z;
        try {
            Bundle bundle = (Bundle) a.ep(webView.getX5WebViewExtension()).u("invokeMiscMethod", new Object[]{"supportTranslateWebSite", null}).object;
            if (bundle != null) {
                z = bundle.getBoolean("result");
                ab.i("MicroMsg.WebViewTranslateHelper", "supportTranslate %b", new Object[]{Boolean.valueOf(z)});
                AppMethodBeat.o(5619);
                return z;
            }
        } catch (Exception e) {
            ab.e("MicroMsg.WebViewTranslateHelper", "supportTranslateWebSite error %s", new Object[]{e.getMessage()});
        }
        z = false;
        ab.i("MicroMsg.WebViewTranslateHelper", "supportTranslate %b", new Object[]{Boolean.valueOf(z)});
        AppMethodBeat.o(5619);
        return z;
    }

    public static int a(WebView webView, boolean z) {
        AppMethodBeat.i(5620);
        if (webView == null || webView.getX5WebViewExtension() == null) {
            AppMethodBeat.o(5620);
            return 2;
        }
        int i;
        Bundle bundle = new Bundle();
        bundle.putString("destLanguage", aa.dor());
        if (z) {
            bundle.putBoolean("isFastOpen", true);
        } else {
            bundle.putBoolean("isFastOpen", false);
        }
        try {
            bundle = (Bundle) a.ep(webView.getX5WebViewExtension()).u("invokeMiscMethod", new Object[]{"detectTranslateWebSiteIsNeeded", bundle}).object;
            if (bundle != null) {
                i = bundle.getInt("errorCode", 2);
                ab.i("MicroMsg.WebViewTranslateHelper", "needTranslate errCode %d,languageCode %s", new Object[]{Integer.valueOf(i), r2});
                AppMethodBeat.o(5620);
                return i;
            }
        } catch (Exception e) {
            ab.e("MicroMsg.WebViewTranslateHelper", "detectTranslateWebSiteIsNeeded error %s", new Object[]{e.getMessage()});
        }
        i = 2;
        ab.i("MicroMsg.WebViewTranslateHelper", "needTranslate errCode %d,languageCode %s", new Object[]{Integer.valueOf(i), r2});
        AppMethodBeat.o(5620);
        return i;
    }

    static /* synthetic */ void adX(String str) {
        AppMethodBeat.i(5621);
        Intent intent = new Intent();
        intent.putExtra("rawUrl", str);
        intent.putExtra("hide_option_menu", true);
        intent.putExtra("translate_webview", true);
        d.b(ah.getContext(), "webview", ".ui.tools.WebViewUI", intent);
        AppMethodBeat.o(5621);
    }
}
