Chromium Code Reviews| 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 | |
| 220 && mAwContents.hasAccessedInitialDocument() | |
| 221 && mAwContents.getDidAttemptLoad()) { | |
|
Charlie Reis
2015/03/02 23:09:31
I don't think we need this, do we? It seems like
mnaganov (inactive)
2015/03/03 08:55:48
Indeed, my initial plan was to just use GetPending
| |
| 222 // Hint the client to show the last committed url, as it may be unsa fe to show | |
| 223 // the pending entry. | |
| 224 String url = mAwContents.getLastCommittedUrl(); | |
| 225 url = TextUtils.isEmpty(url) ? "about:blank" : url; | |
| 226 mContentsClient.onPageStarted(url); | |
| 227 mContentsClient.onLoadResource(url); | |
| 228 mContentsClient.onProgressChanged(100); | |
| 229 mContentsClient.onPageFinished(url); | |
| 230 } | |
| 231 } | |
| 232 | |
| 233 @Override | |
| 216 public void toggleFullscreenModeForTab(boolean enterFullscreen) { | 234 public void toggleFullscreenModeForTab(boolean enterFullscreen) { |
| 217 if (enterFullscreen) { | 235 if (enterFullscreen) { |
| 218 mContentViewClient.enterFullscreen(); | 236 mContentViewClient.enterFullscreen(); |
| 219 } else { | 237 } else { |
| 220 mContentViewClient.exitFullscreen(); | 238 mContentViewClient.exitFullscreen(); |
| 221 } | 239 } |
| 222 } | 240 } |
| 223 | 241 |
| 224 private static class GetDisplayNameTask extends AsyncTask<Void, Void, String []> { | 242 private static class GetDisplayNameTask extends AsyncTask<Void, Void, String []> { |
| 225 final int mProcessId; | 243 final int mProcessId; |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 256 * or an empty string otherwise. | 274 * or an empty string otherwise. |
| 257 */ | 275 */ |
| 258 private String resolveFileName(String filePath) { | 276 private String resolveFileName(String filePath) { |
| 259 if (mContentResolver == null || filePath == null) return ""; | 277 if (mContentResolver == null || filePath == null) return ""; |
| 260 Uri uri = Uri.parse(filePath); | 278 Uri uri = Uri.parse(filePath); |
| 261 return ContentUriUtils.getDisplayName( | 279 return ContentUriUtils.getDisplayName( |
| 262 uri, mContentResolver, MediaStore.MediaColumns.DISPLAY_NAME) ; | 280 uri, mContentResolver, MediaStore.MediaColumns.DISPLAY_NAME) ; |
| 263 } | 281 } |
| 264 } | 282 } |
| 265 } | 283 } |
| OLD | NEW |