OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 package org.chromium.android_webview; | 5 package org.chromium.android_webview; |
6 | 6 |
7 import android.content.ContentResolver; | 7 import android.content.ContentResolver; |
8 import android.content.Context; | 8 import android.content.Context; |
9 import android.net.Uri; | 9 import android.net.Uri; |
10 import android.os.AsyncTask; | 10 import android.os.AsyncTask; |
11 import android.os.Handler; | 11 import android.os.Handler; |
12 import android.os.Message; | 12 import android.os.Message; |
13 import android.provider.MediaStore; | 13 import android.provider.MediaStore; |
14 import android.util.Log; | 14 import android.util.Log; |
15 import android.view.KeyEvent; | 15 import android.view.KeyEvent; |
16 import android.view.View; | 16 import android.view.View; |
17 import android.webkit.ConsoleMessage; | 17 import android.webkit.ConsoleMessage; |
18 import android.webkit.ValueCallback; | 18 import android.webkit.ValueCallback; |
19 | 19 |
20 import org.chromium.base.ContentUriUtils; | 20 import org.chromium.base.ContentUriUtils; |
21 import org.chromium.base.ThreadUtils; | 21 import org.chromium.base.ThreadUtils; |
22 import org.chromium.content.browser.ContentVideoView; | |
23 | 22 |
24 /** | 23 /** |
25 * Adapts the AwWebContentsDelegate interface to the AwContentsClient interface. | 24 * Adapts the AwWebContentsDelegate interface to the AwContentsClient interface. |
26 * This class also serves a secondary function of routing certain callbacks from
the content layer | 25 * This class also serves a secondary function of routing certain callbacks from
the content layer |
27 * to specific listener interfaces. | 26 * to specific listener interfaces. |
28 */ | 27 */ |
29 class AwWebContentsDelegateAdapter extends AwWebContentsDelegate { | 28 class AwWebContentsDelegateAdapter extends AwWebContentsDelegate { |
30 private static final String TAG = "AwWebContentsDelegateAdapter"; | 29 private static final String TAG = "AwWebContentsDelegateAdapter"; |
31 | 30 |
32 final AwContents mAwContents; | 31 private final AwContents mAwContents; |
33 final AwContentsClient mContentsClient; | 32 private final AwContentsClient mContentsClient; |
34 View mContainerView; | 33 private final AwContentViewClient mContentViewClient; |
35 final Context mContext; | 34 private final Context mContext; |
| 35 private View mContainerView; |
36 | 36 |
37 public AwWebContentsDelegateAdapter(AwContents awContents, AwContentsClient
contentsClient, | 37 public AwWebContentsDelegateAdapter(AwContents awContents, AwContentsClient
contentsClient, |
38 View containerView, Context context) { | 38 AwContentViewClient contentViewClient, Context context, View contain
erView) { |
39 mAwContents = awContents; | 39 mAwContents = awContents; |
40 mContentsClient = contentsClient; | 40 mContentsClient = contentsClient; |
| 41 mContentViewClient = contentViewClient; |
| 42 mContext = context; |
41 setContainerView(containerView); | 43 setContainerView(containerView); |
42 mContext = context; | |
43 } | 44 } |
44 | 45 |
45 public void setContainerView(View containerView) { | 46 public void setContainerView(View containerView) { |
46 mContainerView = containerView; | 47 mContainerView = containerView; |
47 } | 48 } |
48 | 49 |
49 @Override | 50 @Override |
50 public void onLoadProgressChanged(int progress) { | 51 public void onLoadProgressChanged(int progress) { |
51 mContentsClient.onProgressChanged(progress); | 52 mContentsClient.onProgressChanged(progress); |
52 } | 53 } |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 return mContentsClient.onCreateWindow(isDialog, isUserGesture); | 207 return mContentsClient.onCreateWindow(isDialog, isUserGesture); |
207 } | 208 } |
208 | 209 |
209 @Override | 210 @Override |
210 public void activateContents() { | 211 public void activateContents() { |
211 mContentsClient.onRequestFocus(); | 212 mContentsClient.onRequestFocus(); |
212 } | 213 } |
213 | 214 |
214 @Override | 215 @Override |
215 public void toggleFullscreenModeForTab(boolean enterFullscreen) { | 216 public void toggleFullscreenModeForTab(boolean enterFullscreen) { |
216 if (!enterFullscreen) { | 217 if (enterFullscreen) { |
217 ContentVideoView videoView = ContentVideoView.getContentVideoView(); | 218 mContentViewClient.enterFullscreen(); |
218 if (videoView != null) videoView.exitFullscreen(false); | 219 } else { |
| 220 mContentViewClient.exitFullscreen(); |
219 } | 221 } |
220 } | 222 } |
221 | 223 |
222 private static class GetDisplayNameTask extends AsyncTask<Void, Void, String
[]> { | 224 private static class GetDisplayNameTask extends AsyncTask<Void, Void, String
[]> { |
223 final int mProcessId; | 225 final int mProcessId; |
224 final int mRenderId; | 226 final int mRenderId; |
225 final int mModeFlags; | 227 final int mModeFlags; |
226 final String[] mFilePaths; | 228 final String[] mFilePaths; |
227 final ContentResolver mContentResolver; | 229 final ContentResolver mContentResolver; |
228 | 230 |
(...skipping 25 matching lines...) Expand all Loading... |
254 * or an empty string otherwise. | 256 * or an empty string otherwise. |
255 */ | 257 */ |
256 private String resolveFileName(String filePath) { | 258 private String resolveFileName(String filePath) { |
257 if (mContentResolver == null || filePath == null) return ""; | 259 if (mContentResolver == null || filePath == null) return ""; |
258 Uri uri = Uri.parse(filePath); | 260 Uri uri = Uri.parse(filePath); |
259 return ContentUriUtils.getDisplayName( | 261 return ContentUriUtils.getDisplayName( |
260 uri, mContentResolver, MediaStore.MediaColumns.DISPLAY_NAME)
; | 262 uri, mContentResolver, MediaStore.MediaColumns.DISPLAY_NAME)
; |
261 } | 263 } |
262 } | 264 } |
263 } | 265 } |
OLD | NEW |