Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(355)

Unified Diff: ui/android/java/src/org/chromium/ui/SelectFileDialog.java

Issue 14758008: Update the HTML Media Capture implementation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Build fix attempt. Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/renderer/render_view_impl.cc ('k') | ui/shell_dialogs/select_file_dialog_android.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/android/java/src/org/chromium/ui/SelectFileDialog.java
diff --git a/ui/android/java/src/org/chromium/ui/SelectFileDialog.java b/ui/android/java/src/org/chromium/ui/SelectFileDialog.java
index 85e355dd1f4041a2d4eb688f5a333fc420c004b6..8c7501241870bb4e48460afd5f48949057782ade 100644
--- a/ui/android/java/src/org/chromium/ui/SelectFileDialog.java
+++ b/ui/android/java/src/org/chromium/ui/SelectFileDialog.java
@@ -11,6 +11,7 @@ import android.database.Cursor;
import android.net.Uri;
import android.os.Environment;
import android.provider.MediaStore;
+import android.text.TextUtils;
import java.io.File;
import java.util.ArrayList;
@@ -34,15 +35,11 @@ class SelectFileDialog implements WindowAndroid.IntentCallback{
private static final String ALL_VIDEO_TYPES = VIDEO_TYPE + "*";
private static final String ALL_AUDIO_TYPES = AUDIO_TYPE + "*";
private static final String ANY_TYPES = "*/*";
- private static final String CAPTURE_CAMERA = "camera";
- private static final String CAPTURE_CAMCORDER = "camcorder";
- private static final String CAPTURE_MICROPHONE = "microphone";
- private static final String CAPTURE_FILESYSTEM = "filesystem";
private static final String CAPTURE_IMAGE_DIRECTORY = "browser-photos";
private final int mNativeSelectFileDialog;
private List<String> mFileTypes;
- private String mCapture; // May be null if no capture parameter was set.
+ private boolean mCapture;
private Uri mCameraOutputUri;
private SelectFileDialog(int nativeSelectFileDialog) {
@@ -56,7 +53,7 @@ class SelectFileDialog implements WindowAndroid.IntentCallback{
* @param window The WindowAndroid that can show intents
*/
@CalledByNative
- private void selectFile(String[] fileTypes, String capture, WindowAndroid window) {
+ private void selectFile(String[] fileTypes, boolean capture, WindowAndroid window) {
mFileTypes = new ArrayList<String>(Arrays.asList(fileTypes));
mCapture = capture;
@@ -69,9 +66,9 @@ class SelectFileDialog implements WindowAndroid.IntentCallback{
MediaStore.Audio.Media.RECORD_SOUND_ACTION);
String lowMemoryError = window.getContext().getString(R.string.low_memory_error);
- // Quick check - if a capture parameter other than filesystem (the default) is specified we
- // should just launch the appropriate intent. Otherwise build up a chooser based on the
- // accept type and then display that to the user.
+ // Quick check - if the |capture| parameter is set and |fileTypes| has the appropriate MIME
+ // type, we should just launch the appropriate intent. Otherwise build up a chooser based on
+ // the accept type and then display that to the user.
if (captureCamera()) {
if (window.showIntent(camera, this, lowMemoryError)) return;
} else if (captureCamcorder()) {
@@ -215,22 +212,20 @@ class SelectFileDialog implements WindowAndroid.IntentCallback{
return shouldShowTypes(ALL_AUDIO_TYPES, AUDIO_TYPE);
}
+ private boolean acceptsSpecificType(String type) {
+ return mFileTypes.size() == 1 && TextUtils.equals(mFileTypes.get(0), type);
+ }
+
private boolean captureCamera() {
- return shouldShowImageTypes() && mCapture != null && mCapture.startsWith(CAPTURE_CAMERA);
+ return mCapture && acceptsSpecificType(ALL_IMAGE_TYPES);
}
private boolean captureCamcorder() {
- return shouldShowVideoTypes() && mCapture != null &&
- mCapture.startsWith(CAPTURE_CAMCORDER);
+ return mCapture && acceptsSpecificType(ALL_VIDEO_TYPES);
}
private boolean captureMicrophone() {
- return shouldShowAudioTypes() && mCapture != null &&
- mCapture.startsWith(CAPTURE_MICROPHONE);
- }
-
- private boolean captureFilesystem() {
- return mCapture != null && mCapture.startsWith(CAPTURE_FILESYSTEM);
+ return mCapture && acceptsSpecificType(ALL_AUDIO_TYPES);
}
private boolean acceptSpecificType(String accept) {
« no previous file with comments | « content/renderer/render_view_impl.cc ('k') | ui/shell_dialogs/select_file_dialog_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698