Index: android_webview/java/src/org/chromium/android_webview/AwWebContentsDelegateAdapter.java |
diff --git a/android_webview/java/src/org/chromium/android_webview/AwWebContentsDelegateAdapter.java b/android_webview/java/src/org/chromium/android_webview/AwWebContentsDelegateAdapter.java |
index 0b888d30d3dbdeda968083b21d22595b2d293ba1..f94d3ed1a0d72fd52703faf12f58e39b3eb6a7b0 100644 |
--- a/android_webview/java/src/org/chromium/android_webview/AwWebContentsDelegateAdapter.java |
+++ b/android_webview/java/src/org/chromium/android_webview/AwWebContentsDelegateAdapter.java |
@@ -11,9 +11,12 @@ import android.os.Message; |
import android.util.Log; |
import android.view.KeyEvent; |
import android.webkit.ConsoleMessage; |
+import android.webkit.ValueCallback; |
import org.chromium.content.browser.ContentViewCore; |
+import java.util.concurrent.atomic.AtomicBoolean; |
+ |
/** |
* Adapts the AwWebContentsDelegate interface to the AwContentsClient interface. |
* This class also serves a secondary function of routing certain callbacks from the content layer |
@@ -86,14 +89,15 @@ class AwWebContentsDelegateAdapter extends AwWebContentsDelegate { |
@Override |
public void openNewTab(String url, boolean incognito) { |
- // TODO: implement |
+ // This is only called in chrome layers. |
+ assert false; |
} |
@Override |
public boolean addNewContents(int nativeSourceWebContents, int nativeWebContents, |
int disposition, Rect initialPosition, boolean userGesture) { |
- // TODO: implement |
- return false; |
+ // This is overridden native side; see the other addNewContents overload. |
+ throw new RuntimeException("Impossible"); |
} |
@Override |
@@ -136,6 +140,34 @@ class AwWebContentsDelegateAdapter extends AwWebContentsDelegate { |
} |
@Override |
+ public void runFileChooser(final int processId, final int renderId, final int mode_flags, |
+ String acceptTypes, String title, String defaultFilename, boolean capture) { |
+ AwContentsClient.FileChooserParams params = new AwContentsClient.FileChooserParams(); |
+ params.mode = mode_flags; |
+ params.acceptTypes = acceptTypes; |
+ params.title = title; |
+ params.defaultFilename = defaultFilename; |
+ params.capture = capture; |
+ |
+ // AtomicBoolen used only to allow mutation via final reference; it is only accesed on the |
+ // main thread. |
+ final AtomicBoolean completed = new AtomicBoolean(false); |
+ boolean ret = mContentsClient.showFileChooser(new ValueCallback<String[]>() { |
+ @Override |
+ public void onReceiveValue(String[] results) { |
+ if (completed.getAndSet(true)) { |
+ Log.w(TAG, "Ignroing spurious showFileChooser result"); |
mkosiba (inactive)
2013/07/29 10:59:03
same thing here - IMHO this should throw because i
joth
2013/08/03 19:01:05
Done.
|
+ return; |
+ } |
+ nativeFilesSelectedInChooser(processId, renderId, mode_flags, results); |
+ } |
+ }, params); |
+ if (!ret && !completed.getAndSet(true)) { |
mkosiba (inactive)
2013/07/29 10:59:03
ISTM we should throw some sort of exception the 3r
joth
2013/08/03 19:01:05
Done.
|
+ nativeFilesSelectedInChooser(processId, renderId, mode_flags, null); |
+ } |
+ } |
+ |
+ @Override |
public boolean addNewContents(boolean isDialog, boolean isUserGesture) { |
return mContentsClient.onCreateWindow(isDialog, isUserGesture); |
} |