summaryrefslogtreecommitdiffstats
path: root/src/com/android/browser
diff options
context:
space:
mode:
authorBen Murdoch <benm@google.com>2012-01-11 10:56:43 +0000
committerBen Murdoch <benm@google.com>2012-04-13 14:03:56 +0100
commit8cad413fe902010140cf20aad47c2f4e7a51f8d2 (patch)
tree105ee0228d351fa1d27c681846e2a229017e7452 /src/com/android/browser
parent981bd08923014c7208f7b59fbe6a00db90c24e22 (diff)
downloadpackages_apps_Browser-8cad413fe902010140cf20aad47c2f4e7a51f8d2.tar.gz
packages_apps_Browser-8cad413fe902010140cf20aad47c2f4e7a51f8d2.tar.bz2
packages_apps_Browser-8cad413fe902010140cf20aad47c2f4e7a51f8d2.zip
Add support for HTML Media Capture "capture" attribute.
Receive the value for the new "capture" attribute on HTML file pickers, and do the right thing with it. Requires changes in WebKit (I0a921be31fda79a43c05da4fe22d9c808d92709c) and the framework (I494adc1274ca21ce8fe52a6c7b6b758217927e66). Bug: 5771207 Change-Id: I38dfe2df043fdba1388384dbd3b5370737eb38e5
Diffstat (limited to 'src/com/android/browser')
-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
5 files changed, 34 insertions, 36 deletions
diff --git a/src/com/android/browser/Controller.java b/src/com/android/browser/Controller.java
index fdad0d8d0..0ffb4be75 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 5de5be0af..0efe119be 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 cfbd88a31..9b5a67579 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 5947e4a72..a9560bb50 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 20027e004..30eec4f12 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();