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

Side by Side 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: 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 AwContentViewClient extends ContentViewClient {
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 AwContentViewClient(AwContentsClient awContentsClient, AwSettings awS ettings) {
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 ?
mkosiba (inactive) 2013/11/07 11:12:10 FYI boolean expressions are evaluated LTR so: ret
96 mAwSettings.getBlockNetworkLoads() && URLUtil.isNetworkUrl(url) : true;
97 }
98 }
OLDNEW
« 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