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

Unified Diff: android_webview/java/src/org/chromium/android_webview/AwContentViewClient.java

Issue 52463004: Block media loading when AwSettings.setBlockNetworkLoads is true. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: disable failed test Created 7 years, 1 month 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 | android_webview/java/src/org/chromium/android_webview/AwContents.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: android_webview/java/src/org/chromium/android_webview/AwContentViewClient.java
diff --git a/android_webview/java/src/org/chromium/android_webview/AwContentViewClient.java b/android_webview/java/src/org/chromium/android_webview/AwContentViewClient.java
new file mode 100644
index 0000000000000000000000000000000000000000..eda0e979cdd909f6331a99cd12c36fb68ddd2cfa
--- /dev/null
+++ b/android_webview/java/src/org/chromium/android_webview/AwContentViewClient.java
@@ -0,0 +1,92 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.chromium.android_webview;
+
+import android.content.Context;
+import android.view.KeyEvent;
+import android.view.View;
+import android.webkit.URLUtil;
+import android.webkit.WebChromeClient;
+
+import org.chromium.content.browser.ContentVideoView;
+import org.chromium.content.browser.ContentVideoViewClient;
+import org.chromium.content.browser.ContentVideoViewControls;
+import org.chromium.content.browser.ContentViewClient;
+
+/**
+ * ContentViewClient implementation for WebView
+ */
+public class AwContentViewClient extends ContentViewClient {
+
+ private class AwContentVideoViewClient implements ContentVideoViewClient {
+ @Override
+ public void onShowCustomView(View view) {
+ WebChromeClient.CustomViewCallback cb = new WebChromeClient.CustomViewCallback() {
+ @Override
+ public void onCustomViewHidden() {
+ ContentVideoView contentVideoView = ContentVideoView.getContentVideoView();
+ if (contentVideoView != null)
+ contentVideoView.exitFullscreen(false);
+ }
+ };
+ mAwContentsClient.onShowCustomView(view, cb);
+ }
+
+ @Override
+ public void onDestroyContentVideoView() {
+ mAwContentsClient.onHideCustomView();
+ }
+
+ @Override
+ public View getVideoLoadingProgressView() {
+ return mAwContentsClient.getVideoLoadingProgressView();
+ }
+
+ @Override
+ public ContentVideoViewControls createControls() {
+ return null;
+ }
+ }
+
+ private AwContentsClient mAwContentsClient;
+ private AwSettings mAwSettings;
+
+ public AwContentViewClient(AwContentsClient awContentsClient, AwSettings awSettings) {
+ mAwContentsClient = awContentsClient;
+ mAwSettings = awSettings;
+ }
+
+ @Override
+ public void onBackgroundColorChanged(int color) {
+ mAwContentsClient.onBackgroundColorChanged(color);
+ }
+
+ @Override
+ public void onStartContentIntent(Context context, String contentUrl) {
+ // Callback when detecting a click on a content link.
+ mAwContentsClient.shouldOverrideUrlLoading(contentUrl);
+ }
+
+ @Override
+ public void onUpdateTitle(String title) {
+ mAwContentsClient.onReceivedTitle(title);
+ }
+
+ @Override
+ public boolean shouldOverrideKeyEvent(KeyEvent event) {
+ return mAwContentsClient.shouldOverrideKeyEvent(event);
+ }
+
+ @Override
+ final public ContentVideoViewClient getContentVideoViewClient() {
+ return new AwContentVideoViewClient();
+ }
+
+ @Override
+ public boolean shouldBlockMediaRequest(String url) {
+ return mAwSettings != null ?
+ mAwSettings.getBlockNetworkLoads() && URLUtil.isNetworkUrl(url) : true;
+ }
+}
« no previous file with comments | « no previous file | android_webview/java/src/org/chromium/android_webview/AwContents.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698