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 void 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);
37 public void onDestroyContentVideoView() {
38 mAwContentsClient.onHideCustomView();
42 public View getVideoLoadingProgressView() {
43 return mAwContentsClient.getVideoLoadingProgressView();
47 private AwContentsClient mAwContentsClient;
48 private AwSettings mAwSettings;
50 public AwContentViewClient(AwContentsClient awContentsClient, AwSettings awSettings) {
51 mAwContentsClient = awContentsClient;
52 mAwSettings = awSettings;
56 public void onBackgroundColorChanged(int color) {
57 mAwContentsClient.onBackgroundColorChanged(color);
61 public void onStartContentIntent(Context context, String contentUrl) {
62 // Callback when detecting a click on a content link.
63 mAwContentsClient.shouldOverrideUrlLoading(contentUrl);
67 public void onUpdateTitle(String title) {
68 mAwContentsClient.onReceivedTitle(title);
72 public boolean shouldOverrideKeyEvent(KeyEvent event) {
73 return mAwContentsClient.shouldOverrideKeyEvent(event);
77 public final ContentVideoViewClient getContentVideoViewClient() {
78 return new AwContentVideoViewClient();
82 public boolean shouldBlockMediaRequest(String url) {
83 return mAwSettings != null ?
84 mAwSettings.getBlockNetworkLoads() && URLUtil.isNetworkUrl(url) : true;