| 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.text.TextUtils; |
| 14 import android.util.Log; | 15 import android.util.Log; |
| 15 import android.view.KeyEvent; | 16 import android.view.KeyEvent; |
| 16 import android.view.View; | 17 import android.view.View; |
| 17 import android.webkit.ConsoleMessage; | 18 import android.webkit.ConsoleMessage; |
| 18 import android.webkit.ValueCallback; | 19 import android.webkit.ValueCallback; |
| 19 | 20 |
| 20 import org.chromium.base.ContentUriUtils; | 21 import org.chromium.base.ContentUriUtils; |
| 21 import org.chromium.base.ThreadUtils; | 22 import org.chromium.base.ThreadUtils; |
| 23 import org.chromium.content_public.browser.InvalidateTypes; |
| 22 | 24 |
| 23 /** | 25 /** |
| 24 * Adapts the AwWebContentsDelegate interface to the AwContentsClient interface. | 26 * Adapts the AwWebContentsDelegate interface to the AwContentsClient interface. |
| 25 * This class also serves a secondary function of routing certain callbacks from
the content layer | 27 * This class also serves a secondary function of routing certain callbacks from
the content layer |
| 26 * to specific listener interfaces. | 28 * to specific listener interfaces. |
| 27 */ | 29 */ |
| 28 class AwWebContentsDelegateAdapter extends AwWebContentsDelegate { | 30 class AwWebContentsDelegateAdapter extends AwWebContentsDelegate { |
| 29 private static final String TAG = "AwWebContentsDelegateAdapter"; | 31 private static final String TAG = "AwWebContentsDelegateAdapter"; |
| 30 | 32 |
| 31 private final AwContents mAwContents; | 33 private final AwContents mAwContents; |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 public boolean addNewContents(boolean isDialog, boolean isUserGesture) { | 208 public boolean addNewContents(boolean isDialog, boolean isUserGesture) { |
| 207 return mContentsClient.onCreateWindow(isDialog, isUserGesture); | 209 return mContentsClient.onCreateWindow(isDialog, isUserGesture); |
| 208 } | 210 } |
| 209 | 211 |
| 210 @Override | 212 @Override |
| 211 public void activateContents() { | 213 public void activateContents() { |
| 212 mContentsClient.onRequestFocus(); | 214 mContentsClient.onRequestFocus(); |
| 213 } | 215 } |
| 214 | 216 |
| 215 @Override | 217 @Override |
| 218 public void navigationStateChanged(int flags) { |
| 219 if ((flags & InvalidateTypes.URL) != 0 && mAwContents.hasAccessedInitial
Document()) { |
| 220 // Hint the client to show the last committed url, as it may be unsa
fe to show |
| 221 // the pending entry. |
| 222 String url = mAwContents.getLastCommittedUrl(); |
| 223 url = TextUtils.isEmpty(url) ? "about:blank" : url; |
| 224 mContentsClient.onPageStarted(url); |
| 225 mContentsClient.onLoadResource(url); |
| 226 mContentsClient.onProgressChanged(100); |
| 227 mContentsClient.onPageFinished(url); |
| 228 } |
| 229 } |
| 230 |
| 231 @Override |
| 216 public void toggleFullscreenModeForTab(boolean enterFullscreen) { | 232 public void toggleFullscreenModeForTab(boolean enterFullscreen) { |
| 217 if (enterFullscreen) { | 233 if (enterFullscreen) { |
| 218 mContentViewClient.enterFullscreen(); | 234 mContentViewClient.enterFullscreen(); |
| 219 } else { | 235 } else { |
| 220 mContentViewClient.exitFullscreen(); | 236 mContentViewClient.exitFullscreen(); |
| 221 } | 237 } |
| 222 } | 238 } |
| 223 | 239 |
| 224 private static class GetDisplayNameTask extends AsyncTask<Void, Void, String
[]> { | 240 private static class GetDisplayNameTask extends AsyncTask<Void, Void, String
[]> { |
| 225 final int mProcessId; | 241 final int mProcessId; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 256 * or an empty string otherwise. | 272 * or an empty string otherwise. |
| 257 */ | 273 */ |
| 258 private String resolveFileName(String filePath) { | 274 private String resolveFileName(String filePath) { |
| 259 if (mContentResolver == null || filePath == null) return ""; | 275 if (mContentResolver == null || filePath == null) return ""; |
| 260 Uri uri = Uri.parse(filePath); | 276 Uri uri = Uri.parse(filePath); |
| 261 return ContentUriUtils.getDisplayName( | 277 return ContentUriUtils.getDisplayName( |
| 262 uri, mContentResolver, MediaStore.MediaColumns.DISPLAY_NAME)
; | 278 uri, mContentResolver, MediaStore.MediaColumns.DISPLAY_NAME)
; |
| 263 } | 279 } |
| 264 } | 280 } |
| 265 } | 281 } |
| OLD | NEW |