Fixup browser to use WebView proxy
Has to escape out to WebViewClassic whenever it needs a hidden API.
Interdepends on https://android-git.corp.google.com/g/165608
Change-Id: Ic61dd7f57f75381864075605d5901f2688648cbd
diff --git a/src/com/android/browser/Tab.java b/src/com/android/browser/Tab.java
index b09e423..837ca47 100644
--- a/src/com/android/browser/Tab.java
+++ b/src/com/android/browser/Tab.java
@@ -64,6 +64,7 @@
import android.webkit.WebResourceResponse;
import android.webkit.WebStorage;
import android.webkit.WebView;
+import android.webkit.WebViewClassic;
import android.webkit.WebView.PictureListener;
import android.webkit.WebViewClient;
import android.widget.CheckBox;
@@ -1541,7 +1542,7 @@
// does a redirect after a period of time. The user could have
// switched to another tab while waiting for the download to start.
mMainView.setDownloadListener(mDownloadListener);
- mMainView.setWebBackForwardListClient(mWebBackForwardListClient);
+ getWebViewClassic().setWebBackForwardListClient(mWebBackForwardListClient);
TabControl tc = mWebViewController.getTabControl();
if (tc != null && tc.getOnThumbnailUpdatedListener() != null) {
mMainView.setPictureListener(this);
@@ -1565,7 +1566,7 @@
if (mMainView != null) {
dismissSubWindow();
// Make sure the embedded title bar isn't still attached
- mMainView.setEmbeddedTitleBar(null);
+ getWebViewClassic().setEmbeddedTitleBar(null);
// save the WebView to call destroy() after detach it from the tab
WebView webView = mMainView;
setWebView(null);
@@ -1778,6 +1779,15 @@
return mMainView;
}
+ /**
+ * Return the underlying WebViewClassic implementation. As with getWebView,
+ * this maybe null for background tabs.
+ * @return The main WebView of this tab.
+ */
+ WebViewClassic getWebViewClassic() {
+ return WebViewClassic.fromWebView(mMainView);
+ }
+
void setViewContainer(View container) {
mContainer = container;
}
@@ -2046,7 +2056,7 @@
SnapshotByteArrayOutputStream bos = new SnapshotByteArrayOutputStream();
try {
GZIPOutputStream stream = new GZIPOutputStream(bos);
- if (!mMainView.saveViewState(stream)) {
+ if (!getWebViewClassic().saveViewState(stream)) {
return null;
}
stream.flush();
@@ -2060,7 +2070,7 @@
values.put(Snapshots.TITLE, mCurrentState.mTitle);
values.put(Snapshots.URL, mCurrentState.mUrl);
values.put(Snapshots.VIEWSTATE, data);
- values.put(Snapshots.BACKGROUND, mMainView.getPageBackgroundColor());
+ values.put(Snapshots.BACKGROUND, getWebViewClassic().getPageBackgroundColor());
values.put(Snapshots.DATE_CREATED, System.currentTimeMillis());
values.put(Snapshots.FAVICON, compressBitmap(getFavicon()));
Bitmap screenshot = Controller.createScreenshot(mMainView,