Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(128)

Unified Diff: android_webview/tools/system_webview_shell/apk/src/org/chromium/webview_shell/WebViewBrowserActivity.java

Issue 1990743003: Support fullscreen in webview shell. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Cope with the possibibility that onShowCustomView and onHideCustomView calls might not be paired Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: android_webview/tools/system_webview_shell/apk/src/org/chromium/webview_shell/WebViewBrowserActivity.java
diff --git a/android_webview/tools/system_webview_shell/apk/src/org/chromium/webview_shell/WebViewBrowserActivity.java b/android_webview/tools/system_webview_shell/apk/src/org/chromium/webview_shell/WebViewBrowserActivity.java
index 456343de9b70e627c2f2f99c087d70fdebf318cd..f029d86c99a6ea35d4e3ea5c224a4f95a4df2f2c 100644
--- a/android_webview/tools/system_webview_shell/apk/src/org/chromium/webview_shell/WebViewBrowserActivity.java
+++ b/android_webview/tools/system_webview_shell/apk/src/org/chromium/webview_shell/WebViewBrowserActivity.java
@@ -21,12 +21,14 @@ import android.os.Bundle;
import android.provider.Browser;
import android.util.SparseArray;
+import android.view.Gravity;
import android.view.KeyEvent;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnKeyListener;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
+import android.view.WindowManager;
import android.view.inputmethod.InputMethodManager;
import android.webkit.GeolocationPermissions;
@@ -37,6 +39,7 @@ import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.EditText;
+import android.widget.FrameLayout;
import android.widget.PopupMenu;
import android.widget.TextView;
@@ -88,6 +91,7 @@ public class WebViewBrowserActivity extends Activity implements PopupMenu.OnMenu
private EditText mUrlBar;
private WebView mWebView;
+ private View mFullscreenView;
private String mWebViewVersion;
// Each time we make a request, store it here with an int key. onRequestPermissionsResult will
@@ -247,6 +251,28 @@ public class WebViewBrowserActivity extends Activity implements PopupMenu.OnMenu
public void onPermissionRequest(PermissionRequest request) {
WebViewBrowserActivity.this.requestPermissionsForPage(request);
}
+
+ @Override
+ public void onShowCustomView(View view, WebChromeClient.CustomViewCallback callback) {
+ if (mFullscreenView != null) {
+ ((ViewGroup) mFullscreenView.getParent()).removeView(mFullscreenView);
+ }
+ mFullscreenView = view;
+ getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
+ getWindow().addContentView(mFullscreenView,
+ new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
+ ViewGroup.LayoutParams.MATCH_PARENT, Gravity.CENTER));
+ }
+
+ @Override
+ public void onHideCustomView() {
+ if (mFullscreenView == null) {
+ return;
+ }
+ getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
+ ((ViewGroup) mFullscreenView.getParent()).removeView(mFullscreenView);
+ mFullscreenView = null;
+ }
});
mWebView = webview;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698