1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 package org.chromium.android_webview;
7 import android.content.Context;
8 import android.view.KeyEvent;
9 import android.view.View;
10 import android.webkit.URLUtil;
11 import android.webkit.WebChromeClient;
13 import org.chromium.content.browser.ContentVideoView;
14 import org.chromium.content.browser.ContentVideoViewClient;
15 import org.chromium.content.browser.ContentViewClient;
18 * ContentViewClient implementation for WebView
20 public class AwContentViewClient extends ContentViewClient {
22 private class AwContentVideoViewClient implements ContentVideoViewClient {
24 public boolean onShowCustomView(View view) {
25 WebChromeClient.CustomViewCallback cb = new WebChromeClient.CustomViewCallback() {
27 public void onCustomViewHidden() {
28 ContentVideoView contentVideoView = ContentVideoView.getContentVideoView();
29 if (contentVideoView != null)
30 contentVideoView.exitFullscreen(false);
33 mAwContentsClient.onShowCustomView(view, cb);
38 public void onDestroyContentVideoView() {
39 mAwContentsClient.onHideCustomView();
43 public View getVideoLoadingProgressView() {
44 return mAwContentsClient.getVideoLoadingProgressView();
48 private AwContentsClient mAwContentsClient;
49 private AwSettings mAwSettings;
51 public AwContentViewClient(AwContentsClient awContentsClient, AwSettings awSettings) {
52 mAwContentsClient = awContentsClient;
53 mAwSettings = awSettings;
57 public void onBackgroundColorChanged(int color) {
58 mAwContentsClient.onBackgroundColorChanged(color);
62 public void onStartContentIntent(Context context, String contentUrl) {
63 // Callback when detecting a click on a content link.
64 mAwContentsClient.shouldOverrideUrlLoading(contentUrl);
68 public void onUpdateTitle(String title) {
69 mAwContentsClient.onReceivedTitle(title);
73 public boolean shouldOverrideKeyEvent(KeyEvent event) {
74 return mAwContentsClient.shouldOverrideKeyEvent(event);
78 public final ContentVideoViewClient getContentVideoViewClient() {
79 return new AwContentVideoViewClient();
83 public boolean shouldBlockMediaRequest(String url) {
84 return mAwSettings != null ?
85 mAwSettings.getBlockNetworkLoads() && URLUtil.isNetworkUrl(url) : true;