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.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; | 22 import org.chromium.content.browser.ContentVideoView; |
| 23 import org.chromium.content.browser.ContentViewCore; | 23 import org.chromium.content_public.browser.WebContents; |
| 24 | 24 |
| 25 /** | 25 /** |
| 26 * Adapts the AwWebContentsDelegate interface to the AwContentsClient interface. | 26 * Adapts the AwWebContentsDelegate interface to the AwContentsClient interface. |
| 27 * 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 |
| 28 * to specific listener interfaces. | 28 * to specific listener interfaces. |
| 29 */ | 29 */ |
| 30 class AwWebContentsDelegateAdapter extends AwWebContentsDelegate { | 30 class AwWebContentsDelegateAdapter extends AwWebContentsDelegate { |
| 31 private static final String TAG = "AwWebContentsDelegateAdapter"; | 31 private static final String TAG = "AwWebContentsDelegateAdapter"; |
| 32 | 32 |
| 33 final AwContentsClient mContentsClient; | 33 final AwContentsClient mContentsClient; |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 128 // This is only called in chrome layers. | 128 // This is only called in chrome layers. |
| 129 assert false; | 129 assert false; |
| 130 } | 130 } |
| 131 | 131 |
| 132 @Override | 132 @Override |
| 133 public void closeContents() { | 133 public void closeContents() { |
| 134 mContentsClient.onCloseWindow(); | 134 mContentsClient.onCloseWindow(); |
| 135 } | 135 } |
| 136 | 136 |
| 137 @Override | 137 @Override |
| 138 public void showRepostFormWarningDialog(final ContentViewCore contentViewCor e) { | 138 public void showRepostFormWarningDialog(final WebContents webContents) { |
| 139 // TODO(mkosiba) We should be using something akin to the JsResultReceiv er as the | 139 // TODO(mkosiba) We should be using something akin to the JsResultReceiv er as the |
| 140 // callback parameter (instead of ContentViewCore) and implement a way o f converting | 140 // callback parameter (instead of ContentViewCore) and implement a way o f converting |
| 141 // that to a pair of messages. | 141 // that to a pair of messages. |
| 142 final int msgContinuePendingReload = 1; | 142 final int msgContinuePendingReload = 1; |
| 143 final int msgCancelPendingReload = 2; | 143 final int msgCancelPendingReload = 2; |
| 144 | 144 |
| 145 // TODO(sgurun) Remember the URL to cancel the reload behavior | 145 // TODO(sgurun) Remember the URL to cancel the reload behavior |
| 146 // if it is different than the most recent NavigationController entry. | 146 // if it is different than the most recent NavigationController entry. |
| 147 final Handler handler = new Handler(ThreadUtils.getUiThreadLooper()) { | 147 final Handler handler = new Handler(ThreadUtils.getUiThreadLooper()) { |
| 148 @Override | 148 @Override |
| 149 public void handleMessage(Message msg) { | 149 public void handleMessage(Message msg) { |
| 150 if (contentViewCore.getWebContents() == null) return; | 150 if (webContents == null) return; |
|
boliu
2014/10/09 17:10:04
This isn't the same check anymore.
This was meant
AKVT
2014/10/11 10:51:59
Done.
| |
| 151 | 151 |
| 152 switch(msg.what) { | 152 switch(msg.what) { |
| 153 case msgContinuePendingReload: { | 153 case msgContinuePendingReload: { |
| 154 contentViewCore.getWebContents().getNavigationController () | 154 webContents.getNavigationController().continuePendingRel oad(); |
| 155 .continuePendingReload(); | |
| 156 break; | 155 break; |
| 157 } | 156 } |
| 158 case msgCancelPendingReload: { | 157 case msgCancelPendingReload: { |
| 159 contentViewCore.getWebContents().getNavigationController () | 158 webContents.getNavigationController().cancelPendingReloa d(); |
| 160 .cancelPendingReload(); | |
| 161 break; | 159 break; |
| 162 } | 160 } |
| 163 default: | 161 default: |
| 164 throw new IllegalStateException( | 162 throw new IllegalStateException( |
| 165 "WebContentsDelegateAdapter: unhandled message " + msg.what); | 163 "WebContentsDelegateAdapter: unhandled message " + msg.what); |
| 166 } | 164 } |
| 167 } | 165 } |
| 168 }; | 166 }; |
| 169 | 167 |
| 170 Message resend = handler.obtainMessage(msgContinuePendingReload); | 168 Message resend = handler.obtainMessage(msgContinuePendingReload); |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 255 * or an empty string otherwise. | 253 * or an empty string otherwise. |
| 256 */ | 254 */ |
| 257 private String resolveFileName(String filePath) { | 255 private String resolveFileName(String filePath) { |
| 258 if (mContentResolver == null || filePath == null) return ""; | 256 if (mContentResolver == null || filePath == null) return ""; |
| 259 Uri uri = Uri.parse(filePath); | 257 Uri uri = Uri.parse(filePath); |
| 260 return ContentUriUtils.getDisplayName( | 258 return ContentUriUtils.getDisplayName( |
| 261 uri, mContentResolver, MediaStore.MediaColumns.DISPLAY_NAME) ; | 259 uri, mContentResolver, MediaStore.MediaColumns.DISPLAY_NAME) ; |
| 262 } | 260 } |
| 263 } | 261 } |
| 264 } | 262 } |
| OLD | NEW |