OLD | NEW |
---|---|
(Empty) | |
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. | |
4 | |
5 package org.chromium.android_webview; | |
6 | |
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; | |
12 | |
13 import org.chromium.content.browser.ContentVideoView; | |
14 import org.chromium.content.browser.ContentVideoViewClient; | |
15 import org.chromium.content.browser.ContentVideoViewControls; | |
16 import org.chromium.content.browser.ContentViewClient; | |
17 | |
18 /** | |
19 * ContentViewClient implementation for WebView | |
20 */ | |
21 public class AwContentsViewClient extends ContentViewClient { | |
joth
2013/11/05 23:00:47
nit: no 's'
AwContentViewClient
(it is true it's
| |
22 | |
23 private class AwContentVideoViewClient implements ContentVideoViewClient { | |
24 @Override | |
25 public void onShowCustomView(View view) { | |
26 WebChromeClient.CustomViewCallback cb = new WebChromeClient.CustomVi ewCallback() { | |
27 @Override | |
28 public void onCustomViewHidden() { | |
29 ContentVideoView contentVideoView = ContentVideoView.getCont entVideoView(); | |
30 if (contentVideoView != null) | |
31 contentVideoView.exitFullscreen(false); | |
32 } | |
33 }; | |
34 mAwContentsClient.onShowCustomView(view, cb); | |
35 } | |
36 | |
37 @Override | |
38 public void onDestroyContentVideoView() { | |
39 mAwContentsClient.onHideCustomView(); | |
40 } | |
41 | |
42 @Override | |
43 public View getVideoLoadingProgressView() { | |
44 return mAwContentsClient.getVideoLoadingProgressView(); | |
45 } | |
46 | |
47 @Override | |
48 public ContentVideoViewControls createControls() { | |
49 return null; | |
50 } | |
51 } | |
52 | |
53 private AwContentsClient mAwContentsClient; | |
54 private AwSettings mAwSettings; | |
55 | |
56 public AwContentsViewClient(AwContentsClient awContentsClient, AwSettings aw Settings) { | |
57 mAwContentsClient = awContentsClient; | |
58 mAwSettings = awSettings; | |
59 } | |
60 | |
61 @Override | |
62 public void onBackgroundColorChanged(int color) { | |
63 mAwContentsClient.onBackgroundColorChanged(color); | |
64 } | |
65 | |
66 @Override | |
67 public void onStartContentIntent(Context context, String contentUrl) { | |
68 // Callback when detecting a click on a content link. | |
69 mAwContentsClient.shouldOverrideUrlLoading(contentUrl); | |
70 } | |
71 | |
72 @Override | |
73 public void onRendererCrash(boolean crashedWhileOomProtected) { | |
74 // This is not possible so long as the webview is run single process! | |
75 throw new RuntimeException("Renderer crash reported."); | |
76 } | |
77 | |
78 @Override | |
79 public void onUpdateTitle(String title) { | |
80 mAwContentsClient.onReceivedTitle(title); | |
81 } | |
82 | |
83 @Override | |
84 public boolean shouldOverrideKeyEvent(KeyEvent event) { | |
85 return mAwContentsClient.shouldOverrideKeyEvent(event); | |
86 } | |
87 | |
88 @Override | |
89 final public ContentVideoViewClient getContentVideoViewClient() { | |
90 return new AwContentVideoViewClient(); | |
91 } | |
92 | |
93 @Override | |
94 public boolean shouldBlockMediaRequest(String url) { | |
95 return mAwSettings != null ? | |
96 mAwSettings.getBlockNetworkLoads() && URLUtil.isNetworkUrl(url) : true; | |
97 } | |
98 } | |
OLD | NEW |