summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/com/android/browser/Controller.java4
-rw-r--r--src/com/android/browser/PreloadController.java2
-rw-r--r--src/com/android/browser/Tab.java4
-rw-r--r--src/com/android/browser/UploadHandler.java58
-rw-r--r--src/com/android/browser/WebViewController.java2
-rw-r--r--tests/src/com/android/browser/TestWebChromeClient.java4
6 files changed, 36 insertions, 38 deletions
diff --git a/src/com/android/browser/Controller.java b/src/com/android/browser/Controller.java
index fdad0d8..0ffb4be 100644
--- a/src/com/android/browser/Controller.java
+++ b/src/com/android/browser/Controller.java
@@ -1964,9 +1964,9 @@ public class Controller
}
// file chooser
- public void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType) {
+ public void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType, String capture) {
mUploadHandler = new UploadHandler(this);
- mUploadHandler.openFileChooser(uploadMsg, acceptType);
+ mUploadHandler.openFileChooser(uploadMsg, acceptType, capture);
}
// thumbnails
diff --git a/src/com/android/browser/PreloadController.java b/src/com/android/browser/PreloadController.java
index 5de5be0..0efe119 100644
--- a/src/com/android/browser/PreloadController.java
+++ b/src/com/android/browser/PreloadController.java
@@ -214,7 +214,7 @@ public class PreloadController implements WebViewController {
}
@Override
- public void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType) {
+ public void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType, String capture) {
if (LOGD_ENABLED) Log.d(LOGTAG, "openFileChooser()");
}
diff --git a/src/com/android/browser/Tab.java b/src/com/android/browser/Tab.java
index cfbd88a..9b5a675 100644
--- a/src/com/android/browser/Tab.java
+++ b/src/com/android/browser/Tab.java
@@ -1234,9 +1234,9 @@ class Tab implements PictureListener {
}
@Override
- public void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType) {
+ public void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType, String capture) {
if (mInForeground) {
- mWebViewController.openFileChooser(uploadMsg, acceptType);
+ mWebViewController.openFileChooser(uploadMsg, acceptType, capture);
} else {
uploadMsg.onReceiveValue(null);
}
diff --git a/src/com/android/browser/UploadHandler.java b/src/com/android/browser/UploadHandler.java
index 5947e4a..a9560bb 100644
--- a/src/com/android/browser/UploadHandler.java
+++ b/src/com/android/browser/UploadHandler.java
@@ -90,7 +90,7 @@ public class UploadHandler {
mCaughtActivityNotFoundException = false;
}
- void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType) {
+ void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType, String capture) {
final String imageMimeType = "image/*";
final String videoMimeType = "video/*";
@@ -102,8 +102,8 @@ public class UploadHandler {
final String mediaSourceValueMicrophone = "microphone";
// According to the spec, media source can be 'filesystem' or 'camera' or 'camcorder'
- // or 'microphone'.
- String mediaSource = "";
+ // or 'microphone' and the default value should be 'filesystem'.
+ String mediaSource = mediaSourceValueFileSystem;
if (mUploadMessage != null) {
// Already a file picker operation in progress.
@@ -116,12 +116,22 @@ public class UploadHandler {
String params[] = acceptType.split(";");
String mimeType = params[0];
- for (String p : params) {
- String[] keyValue = p.split("=");
- if (keyValue.length == 2) {
- // Process key=value parameters.
- if (mediaSourceKey.equals(keyValue[0])) {
- mediaSource = keyValue[1];
+ if (capture.length() > 0) {
+ mediaSource = capture;
+ }
+
+ if (capture.equals(mediaSourceValueFileSystem)) {
+ // To maintain backwards compatibility with the previous implementation
+ // of the media capture API, if the value of the 'capture' attribute is
+ // "filesystem", we should examine the accept-type for a MIME type that
+ // may specify a different capture value.
+ for (String p : params) {
+ String[] keyValue = p.split("=");
+ if (keyValue.length == 2) {
+ // Process key=value parameters.
+ if (mediaSourceKey.equals(keyValue[0])) {
+ mediaSource = keyValue[1];
+ }
}
}
}
@@ -135,14 +145,10 @@ public class UploadHandler {
// camera directly.
startActivity(createCameraIntent());
return;
- } else if (mediaSource.equals(mediaSourceValueFileSystem)) {
- // Specified 'image/*' and requested the filesystem, so go ahead and launch an
- // OPENABLE intent.
- startActivity(createOpenableIntent(imageMimeType));
- return;
} else {
- // Specified just 'image/*', so launch an intent for both the Camera and image/*
- // OPENABLE.
+ // Specified just 'image/*', capture=filesystem, or an invalid capture parameter.
+ // In all these cases we show a traditional picker filetered on accept type
+ // so launch an intent for both the Camera and image/* OPENABLE.
Intent chooser = createChooserIntent(createCameraIntent());
chooser.putExtra(Intent.EXTRA_INTENT, createOpenableIntent(imageMimeType));
startActivity(chooser);
@@ -154,14 +160,10 @@ public class UploadHandler {
// camcorder directly.
startActivity(createCamcorderIntent());
return;
- } else if (mediaSource.equals(mediaSourceValueFileSystem)) {
- // Specified 'video/*' and requested the filesystem, so go ahead and launch an
- // an OPENABLE intent.
- startActivity(createOpenableIntent(videoMimeType));
- return;
- } else {
- // Specified just 'video/*', so go ahead and launch an intent for both camcorder and
- // video/* OPENABLE.
+ } else {
+ // Specified just 'video/*', capture=filesystem or an invalid capture parameter.
+ // In all these cases we show an intent for the traditional file picker, filtered
+ // on accept type so launch an intent for both camcorder and video/* OPENABLE.
Intent chooser = createChooserIntent(createCamcorderIntent());
chooser.putExtra(Intent.EXTRA_INTENT, createOpenableIntent(videoMimeType));
startActivity(chooser);
@@ -173,13 +175,9 @@ public class UploadHandler {
// recorder.
startActivity(createSoundRecorderIntent());
return;
- } else if (mediaSource.equals(mediaSourceValueFileSystem)) {
- // Specified 'audio/*' and requested filesystem, so go ahead and launch an
- // OPENABLE intent.
- startActivity(createOpenableIntent(audioMimeType));
- return;
} else {
- // Specified just 'audio/*', so go ahead and launch an intent for both the sound
+ // Specified just 'audio/*', capture=filesystem of an invalid capture parameter.
+ // In all these cases so go ahead and launch an intent for both the sound
// recorder and audio/* OPENABLE.
Intent chooser = createChooserIntent(createSoundRecorderIntent());
chooser.putExtra(Intent.EXTRA_INTENT, createOpenableIntent(audioMimeType));
diff --git a/src/com/android/browser/WebViewController.java b/src/com/android/browser/WebViewController.java
index 20027e0..30eec4f 100644
--- a/src/com/android/browser/WebViewController.java
+++ b/src/com/android/browser/WebViewController.java
@@ -97,7 +97,7 @@ public interface WebViewController {
void onUpdatedSecurityState(Tab tab);
- void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType);
+ void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType, String capture);
void endActionMode();
diff --git a/tests/src/com/android/browser/TestWebChromeClient.java b/tests/src/com/android/browser/TestWebChromeClient.java
index dd84b3a..e876902 100644
--- a/tests/src/com/android/browser/TestWebChromeClient.java
+++ b/tests/src/com/android/browser/TestWebChromeClient.java
@@ -197,7 +197,7 @@ abstract class TestWebChromeClient extends WebChromeClient {
/** {@inheritDoc} */
@Override
- public void openFileChooser(ValueCallback<Uri> uploadFile, String acceptType) {
- mWrappedClient.openFileChooser(uploadFile, acceptType);
+ public void openFileChooser(ValueCallback<Uri> uploadFile, String acceptType, String capture) {
+ mWrappedClient.openFileChooser(uploadFile, acceptType, capture);
}
}