QQ浏览器 v12.2.3.7053版本的 MD5 值为:8285ab3059e5c8b521a264dfbc5c3685

以下内容为反编译后的 WebPageFrame.java 源代码,内容仅作参考


package com.tencent.mtt.lightwindow;

import android.content.Context;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.WebResourceRequest;
import android.webkit.WebResourceResponse;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import com.huawei.hms.framework.common.ContainerUtils;
import com.tencent.common.manifest.AppManifest;
import com.tencent.common.threadpool.BrowserExecutorSupplier;
import com.tencent.mtt.R;
import com.tencent.mtt.base.nativeframework.NativeWebLongClickListener;
import com.tencent.mtt.base.skin.MttResources;
import com.tencent.mtt.base.webview.QBWebView;
import com.tencent.mtt.base.webview.WebExtension;
import com.tencent.mtt.base.webview.common.HitTestResult;
import com.tencent.mtt.base.webview.common.JsPromptResult;
import com.tencent.mtt.base.webview.common.JsResult;
import com.tencent.mtt.base.webview.common.QBBrowserClient;
import com.tencent.mtt.base.webview.common.QBWebChromeClient;
import com.tencent.mtt.base.webview.common.QBWebChromeClientExtension;
import com.tencent.mtt.base.webview.common.QBWebResourceRequest;
import com.tencent.mtt.base.webview.common.QBWebSettings;
import com.tencent.mtt.base.webview.common.QBWebViewClient;
import com.tencent.mtt.base.webview.extension.QBWebViewBackOrForwardChangeListener;
import com.tencent.mtt.base.wrapper.callback.IScrollListener;
import com.tencent.mtt.base.wrapper.extension.EmptyWebViewClientExtension;
import com.tencent.mtt.base.wrapper.extension.IBrowserClient;
import com.tencent.mtt.base.wrapper.extension.IQBSelection;
import com.tencent.mtt.base.wrapper.extension.IQQBrowserSettings;
import com.tencent.mtt.browser.WebEngine;
import com.tencent.mtt.browser.x5.drawable.X5LogoDrawable;
import com.tencent.mtt.lightwindow.framwork.IPageCtrl;
import com.tencent.mtt.lightwindow.framwork.WindowController;
import com.tencent.mtt.log.plugin.useraction.WebActionListener;
import com.tencent.mtt.support.utils.ViewCompat;
import com.tencent.mtt.view.addressbar.progress.ProgressBarView;
import com.tencent.mtt.view.addressbar.progress.ProgressCalculator;
import com.tencent.mtt.view.common.QBImageView;
import com.tencent.mtt.view.layout.QBFrameLayout;
import com.tencent.mtt.view.layout.QBLinearLayout;
import java.util.HashMap;
import qb.a.f;

public class WebPageFrame extends QBFrameLayout implements WebEngine.WebCoreStateObserver, IPageCtrl {

    public QBWebView f67000a;

    public String f67001b;

    ProgressBarView f67002c;

    ProgressCalculator f67003d;
    boolean e;
    boolean f;
    boolean g;
    QBLinearLayout h;
    QBImageView i;
    QBAdDownloadListener j;
    private QBWebViewClient k;
    private QBWebChromeClient l;
    private IBrowserClient m;
    private String n;
    private boolean o;
    private Bundle p;
    private boolean q;
    private QBWebViewBackOrForwardChangeListener r;
    private WindowController s;
    private WebPageLoadingCallback t;

    public interface WebPageLoadingCallback {
        void a(int i);

        void i();
    }

    public WebPageFrame(WindowController windowController, boolean z, boolean z2) {
        super(windowController.getContainer());
        this.f67001b = null;
        this.f67002c = null;
        this.f67003d = null;
        this.e = false;
        this.f = true;
        this.g = false;
        this.o = false;
        this.h = null;
        this.i = null;
        this.q = true;
        this.r = null;
        this.s = windowController;
        this.f = z;
        this.g = z2;
        setLayoutParams(new ViewGroup.LayoutParams(-1, -1));
    }

    public void a(QBWebView qBWebView, String str) {
        if (this.e) {
            this.f67003d.a((byte) 1);
        }
        if (this.h.getVisibility() != 8) {
            this.h.setVisibility(8);
        }
    }

    private View g() {
        this.f67002c = new ProgressBarView(getContext(), this.f);
        this.f67002c.setLayoutParams(new ViewGroup.LayoutParams(-1, this.f67002c.getProcessHeight()));
        this.f67003d = new ProgressCalculator();
        this.f67003d.a(this.f67002c);
        this.f67003d.a(100, false);
        this.f67002c.setProcessBarCalculator(this.f67003d);
        return this.f67002c;
    }

    public boolean h() {
        HitTestResult hitTestResult;
        QBWebView qBWebView = this.f67000a;
        if (qBWebView == null || (hitTestResult = qBWebView.getHitTestResult()) == null) {
            return false;
        }
        QBWebView qBWebView2 = this.f67000a;
        if (qBWebView2 != null) {
            qBWebView2.enterSelectionMode(false, 10);
        }
        QBWebView qBWebView3 = this.f67000a;
        if (qBWebView3 == null) {
            return true;
        }
        IQBSelection selection = qBWebView3.getSelection();
        this.f67000a.setHitReslutType(hitTestResult);
        if (selection == null) {
            return true;
        }
        selection.setHitType(hitTestResult);
        selection.g();
        return true;
    }

    protected QBWebView a(Context context) {
        this.f67000a = new QBWebView(context) {
            @Override
            protected void onDetachedFromWindow() {
                super.onDetachedFromWindow();
                if (WebPageFrame.this.q) {
                    destroy();
                }
            }

            @Override
            public void onWindowVisibilityChanged(int i) {
                super.onWindowVisibilityChanged(i);
                if (i == 8) {
                    deactive();
                } else if (i == 0) {
                    active();
                }
            }
        };
        WebExtension webExtension = (WebExtension) AppManifest.getInstance().queryExtension(WebExtension.class, null);
        if (webExtension != null) {
            webExtension.onLightPageInjectJsApi(this.f67000a);
        }
        this.f67000a.setLayoutParams(new ViewGroup.LayoutParams(-1, -1));
        this.f67000a.setWebViewClientExtension(new EmptyWebViewClientExtension() {
            @Override
            public boolean a() {
                if (WebPageFrame.this.o) {
                    return WebPageFrame.this.h();
                }
                return false;
            }

            @Override
            public void m() {
                try {
                    WebPageFrame.this.p.getString("windowType");
                    WebPageFrame.this.p.getString("PosID");
                    WebPageFrame.this.p.getString("ChannelID");
                    String string = WebPageFrame.this.p.getString("openqbtime");
                    if (TextUtils.isEmpty(string)) {
                        return;
                    }
                    int i = ((System.currentTimeMillis() - Long.parseLong(string)) > 0L ? 1 : ((System.currentTimeMillis() - Long.parseLong(string)) == 0L ? 0 : -1));
                } catch (Exception unused) {
                }
            }
        });
        this.f67000a.setQBWebViewClient(new QBWebViewClient() {
            @Override
            public void onPageFinished(QBWebView qBWebView, String str) {
                if (WebPageFrame.this.k != null) {
                    WebPageFrame.this.k.onPageFinished(qBWebView, str);
                } else {
                    super.onPageFinished(qBWebView, str);
                }
                if (WebPageFrame.this.s != null) {
                    WebPageFrame.this.s.onPageFinished(qBWebView, str);
                }
                WebPageFrame.this.a(qBWebView, str);
            }

            @Override
            public void onPageStarted(QBWebView qBWebView, String str, Bitmap bitmap) {
                if (WebPageFrame.this.k != null) {
                    WebPageFrame.this.k.onPageStarted(qBWebView, str, bitmap);
                } else {
                    super.onPageStarted(qBWebView, str, bitmap);
                }
                if (WebPageFrame.this.e) {
                    WebPageFrame.this.f67003d.a((byte) 0);
                }
            }

            @Override
            public WebResourceResponse shouldInterceptRequest(QBWebView qBWebView, WebResourceRequest webResourceRequest) {
                return WebPageFrame.this.k != null ? WebPageFrame.this.k.shouldInterceptRequest(qBWebView, webResourceRequest) : super.shouldInterceptRequest(qBWebView, webResourceRequest);
            }

            @Override
            public WebResourceResponse shouldInterceptRequest(QBWebView qBWebView, String str) {
                return WebPageFrame.this.k != null ? WebPageFrame.this.k.shouldInterceptRequest(qBWebView, str) : super.shouldInterceptRequest(qBWebView, str);
            }

            @Override
            public boolean shouldOverrideUrlLoading(QBWebView qBWebView, QBWebResourceRequest qBWebResourceRequest) {
                return WebPageFrame.this.k != null ? WebPageFrame.this.k.shouldOverrideUrlLoading(qBWebView, qBWebResourceRequest) : super.shouldOverrideUrlLoading(qBWebView, qBWebResourceRequest);
            }

            @Override
            public boolean shouldOverrideUrlLoading(QBWebView qBWebView, String str) {
                return WebPageFrame.this.k != null ? WebPageFrame.this.k.shouldOverrideUrlLoading(qBWebView, str) : super.shouldOverrideUrlLoading(qBWebView, str);
            }
        });
        this.f67000a.setQBWebChromeClient(new QBWebChromeClient() {
            @Override
            public void onCloseWindow(QBWebView qBWebView) {
                super.onCloseWindow(qBWebView);
                if (WebPageFrame.this.s != null) {
                    WebPageFrame.this.s.closeWindow();
                }
            }

            @Override
            public boolean onJsAlert(QBWebView qBWebView, String str, String str2, JsResult jsResult) {
                return WebPageFrame.this.l != null ? WebPageFrame.this.l.onJsAlert(qBWebView, str, str2, jsResult) : super.onJsAlert(qBWebView, str, str2, jsResult);
            }

            @Override
            public boolean onJsConfirm(QBWebView qBWebView, String str, String str2, JsResult jsResult) {
                return WebPageFrame.this.l != null ? WebPageFrame.this.l.onJsConfirm(qBWebView, str, str2, jsResult) : super.onJsConfirm(qBWebView, str, str2, jsResult);
            }

            @Override
            public boolean onJsPrompt(QBWebView qBWebView, String str, String str2, String str3, JsPromptResult jsPromptResult) {
                return WebPageFrame.this.l != null ? WebPageFrame.this.l.onJsPrompt(qBWebView, str, str2, str3, jsPromptResult) : super.onJsPrompt(qBWebView, str, str2, str3, jsPromptResult);
            }

            @Override
            public void onProgressChanged(QBWebView qBWebView, int i) {
                super.onProgressChanged(qBWebView, i);
                if (i >= 100) {
                    WebPageFrame.this.a(qBWebView, qBWebView.getUrl());
                }
                if (WebPageFrame.this.t != null) {
                    WebPageFrame.this.t.a(i);
                }
            }

            @Override
            public void onReceivedTitle(QBWebView qBWebView, String str) {
                if (WebPageFrame.this.l != null) {
                    WebPageFrame.this.l.onReceivedTitle(qBWebView, str);
                } else {
                    super.onReceivedTitle(qBWebView, str);
                }
            }
        });
        this.f67000a.setQQBrowserClient(new QBBrowserClient());
        this.j = new QBAdDownloadListener(this.f67000a, this.f67001b);
        this.j.a(true);
        this.f67000a.setDownloadListener(this.j);
        this.f67000a.getQBSettings().o(true);
        QBWebView qBWebView = this.f67000a;
        qBWebView.setWebChromeClientExtension(new QBWebChromeClientExtension(qBWebView, WebExtension.PageMode.SIMPLE_PAGE, new NativeWebLongClickListener(this.f67000a)));
        this.f67000a.setX5WebViewOnScrollListener(new IScrollListener() {

            private boolean f67010b = false;

            @Override
            public boolean onOverScroll(int i, int i2, int i3, int i4, int i5, int i6, int i7, int i8, boolean z) {
                if (!this.f67010b && WebPageFrame.this.s != null) {
                    if (i6 - i4 <= i2 && i2 > 0) {
                        this.f67010b = true;
                        WebPageFrame.this.s.onOverScroll();
                    }
                }
                return true;
            }
        });
        QBWebView qBWebView2 = this.f67000a;
        if (qBWebView2 != null) {
            QBWebSettings qBSettings = qBWebView2.getQBSettings();
            if (qBSettings != null) {
                qBSettings.f(true);
                qBSettings.k(true);
                qBSettings.c(true);
                qBSettings.a(true);
                qBSettings.m(true);
                qBSettings.n(false);
            }
            IQQBrowserSettings qQBrowserSettings = this.f67000a.getQQBrowserSettings();
            if (qQBrowserSettings != null) {
                String str = this.n;
                if (str == null) {
                    str = "";
                }
                qQBrowserSettings.a(str);
            }
            this.f67000a.setVerticalScrollBarEnabled(false);
            this.f67000a.setOverScrollParams(QBWebView.OVER_SCROLL_NEVER, 0, 0, QBWebView.OVER_SCROLL_ALWAYS, 1073741823, 0, null, new X5LogoDrawable(this.f67000a, true, this.f), new X5LogoDrawable(this.f67000a, false, this.f));
        } else {
            qBWebView2.enableLongClick(false);
        }
        if (this.f) {
            this.f67000a.switchSkin();
        } else {
            this.f67000a.switchSkin(false);
        }
        this.f67000a.setBackOrForwardChangeListener(this.r);
        return this.f67000a;
    }

    public WebPageFrame a(Bundle bundle) {
        this.p = bundle;
        return this;
    }

    public WebPageFrame a(QBWebChromeClient qBWebChromeClient) {
        this.l = qBWebChromeClient;
        return this;
    }

    public WebPageFrame a(QBWebViewClient qBWebViewClient) {
        this.k = qBWebViewClient;
        return this;
    }

    public WebPageFrame a(IBrowserClient iBrowserClient) {
        this.m = iBrowserClient;
        return this;
    }

    public WebPageFrame a(String str) {
        this.f67001b = str;
        return this;
    }

    public WebPageFrame a(boolean z) {
        this.e = z;
        return this;
    }

    @Override
    public void a() {
        QBWebView qBWebView = this.f67000a;
        if (qBWebView == null || !qBWebView.canGoBack()) {
            return;
        }
        this.f67000a.goBack();
    }

    @Override
    public void b() {
        QBWebView qBWebView = this.f67000a;
        if (qBWebView == null || !qBWebView.canGoForward()) {
            return;
        }
        this.f67000a.goForward();
    }

    @Override
    public boolean c() {
        QBWebView qBWebView = this.f67000a;
        return qBWebView != null && qBWebView.canGoBack();
    }

    @Override
    public boolean d() {
        QBWebView qBWebView = this.f67000a;
        return qBWebView != null && qBWebView.canGoForward();
    }

    public void e() {
        if (this.f67000a == null) {
            this.h = new QBLinearLayout(getContext(), this.f);
            if (this.f) {
                this.h.setBackgroundNormalIds(0, R.color.theme_common_logo_bkg);
            } else {
                this.h.setBackgroundResource(R.color.theme_common_logo_bkg);
            }
            this.h.setGravity(17);
            ViewCompat.a((View) this.h, 0.99f);
            addView(this.h, new FrameLayout.LayoutParams(-1, -1));
            this.i = new QBImageView(getContext(), this.f);
            this.i.setScaleType(ImageView.ScaleType.FIT_XY);
            if (this.f) {
                this.i.setImageNormalIds(R.drawable.common_icon_logo);
            } else {
                this.i.setBackgroundResource(R.drawable.common_icon_logo);
            }
            int g = MttResources.g(f.aM);
            this.h.addView(this.i, new LinearLayout.LayoutParams(g, g));
            if (this.e) {
                addView(g());
                this.f67003d.a((byte) 0);
            }
            if (!this.g || WebEngine.e().g()) {
                onWebCorePrepared();
            } else {
                WebEngine.e().a(this);
                BrowserExecutorSupplier.postForIoTasks(new BrowserExecutorSupplier.BackgroundRunable() {
                    @Override
                    public void doRun() {
                        WebEngine.e().load();
                    }
                });
            }
        }
    }

    public void f() {
        this.o = true;
    }

    @Override
    public String getTitle() {
        QBWebView qBWebView = this.f67000a;
        return qBWebView != null ? qBWebView.getTitle() : "";
    }

    @Override
    public String getUrl() {
        QBWebView qBWebView = this.f67000a;
        return qBWebView != null ? qBWebView.getUrl() : "";
    }

    public String getWebTitle() {
        QBWebView qBWebView = this.f67000a;
        return qBWebView != null ? qBWebView.getTitle() : "";
    }

    public String getWebUrl() {
        QBWebView qBWebView = this.f67000a;
        return qBWebView != null ? qBWebView.getUrl() : "";
    }

    @Override
    public void onWebCorePrepared() {
        HashMap hashMap;
        WebPageLoadingCallback webPageLoadingCallback;
        QBWebView qBWebView;
        String str;
        String[] split;
        a(getContext());
        addView(this.f67000a, 0);
        WebActionListener.b(this.f67000a);
        Bundle bundle = this.p;
        if (bundle != null) {
            String string = bundle.getString("extra_header");
            if (!TextUtils.isEmpty(string) && (split = string.split(ContainerUtils.FIELD_DELIMITER)) != null) {
                hashMap = new HashMap();
                for (String str2 : split) {
                    String[] split2 = str2.split(ContainerUtils.KEY_VALUE_DELIMITER, 2);
                    if (split2.length == 2) {
                        hashMap.put(split2[0], split2[1]);
                    }
                }
                webPageLoadingCallback = this.t;
                if (webPageLoadingCallback != null) {
                    webPageLoadingCallback.i();
                }
                if (!TextUtils.isEmpty(this.f67001b)) {
                    qBWebView = this.f67000a;
                    str = "https://www.qq.com";
                } else if (hashMap != null && hashMap.size() != 0) {
                    this.f67000a.loadUrl(this.f67001b, hashMap);
                    return;
                } else {
                    qBWebView = this.f67000a;
                    str = this.f67001b;
                }
                qBWebView.loadUrl(str);
            }
        }
        hashMap = null;
        webPageLoadingCallback = this.t;
        if (webPageLoadingCallback != null) {
        }
        if (!TextUtils.isEmpty(this.f67001b)) {
        }
        qBWebView.loadUrl(str);
    }

    public void setAutoDestroy(boolean z) {
        this.q = z;
    }

    @Override
    public void setOnBackForwardChangeListener(QBWebViewBackOrForwardChangeListener qBWebViewBackOrForwardChangeListener) {
        this.r = qBWebViewBackOrForwardChangeListener;
        QBWebView qBWebView = this.f67000a;
        if (qBWebView != null) {
            qBWebView.setBackOrForwardChangeListener(this.r);
        }
    }

    public void setOverrideUrl(String str) {
        QBAdDownloadListener qBAdDownloadListener = this.j;
        if (qBAdDownloadListener != null) {
            qBAdDownloadListener.a(str);
        }
    }

    public void setWebPageLoadingCallback(WebPageLoadingCallback webPageLoadingCallback) {
        this.t = webPageLoadingCallback;
    }
}