OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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.ui; | 5 package org.chromium.ui; |
6 | 6 |
7 import android.app.Activity; | 7 import android.app.Activity; |
8 import android.content.ContentResolver; | 8 import android.content.ContentResolver; |
9 import android.content.Intent; | 9 import android.content.Intent; |
10 import android.database.Cursor; | 10 import android.database.Cursor; |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 | 82 |
83 Intent getContentIntent = new Intent(Intent.ACTION_GET_CONTENT); | 83 Intent getContentIntent = new Intent(Intent.ACTION_GET_CONTENT); |
84 getContentIntent.addCategory(Intent.CATEGORY_OPENABLE); | 84 getContentIntent.addCategory(Intent.CATEGORY_OPENABLE); |
85 ArrayList<Intent> extraIntents = new ArrayList<Intent>(); | 85 ArrayList<Intent> extraIntents = new ArrayList<Intent>(); |
86 if (!noSpecificType()) { | 86 if (!noSpecificType()) { |
87 // Create a chooser based on the accept type that was specified in t
he webpage. Note | 87 // Create a chooser based on the accept type that was specified in t
he webpage. Note |
88 // that if the web page specified multiple accept types, we will hav
e built a generic | 88 // that if the web page specified multiple accept types, we will hav
e built a generic |
89 // chooser above. | 89 // chooser above. |
90 if (shouldShowImageTypes()) { | 90 if (shouldShowImageTypes()) { |
91 extraIntents.add(camera); | 91 extraIntents.add(camera); |
92 getContentIntent.setType("image/*"); | 92 getContentIntent.setType(ALL_IMAGE_TYPES); |
93 } else if (shouldShowVideoTypes()) { | 93 } else if (shouldShowVideoTypes()) { |
94 extraIntents.add(camcorder); | 94 extraIntents.add(camcorder); |
95 getContentIntent.setType("video/*"); | 95 getContentIntent.setType(ALL_VIDEO_TYPES); |
96 } else if (shouldShowAudioTypes()) { | 96 } else if (shouldShowAudioTypes()) { |
97 extraIntents.add(soundRecorder); | 97 extraIntents.add(soundRecorder); |
98 getContentIntent.setType("audio/*"); | 98 getContentIntent.setType(ALL_AUDIO_TYPES); |
99 } | 99 } |
100 } | 100 } |
101 | 101 |
102 if (extraIntents.isEmpty()) { | 102 if (extraIntents.isEmpty()) { |
103 // We couldn't resolve an accept type, so fallback to a generic choo
ser. | 103 // We couldn't resolve an accept type, so fallback to a generic choo
ser. |
104 getContentIntent.setType("*/*"); | 104 getContentIntent.setType(ANY_TYPES); |
105 extraIntents.add(camera); | 105 extraIntents.add(camera); |
106 extraIntents.add(camcorder); | 106 extraIntents.add(camcorder); |
107 extraIntents.add(soundRecorder); | 107 extraIntents.add(soundRecorder); |
108 } | 108 } |
109 | 109 |
110 chooser.putExtra(Intent.EXTRA_INITIAL_INTENTS, | 110 chooser.putExtra(Intent.EXTRA_INITIAL_INTENTS, |
111 extraIntents.toArray(new Intent[] { })); | 111 extraIntents.toArray(new Intent[] { })); |
112 | 112 |
113 chooser.putExtra(Intent.EXTRA_INTENT, getContentIntent); | 113 chooser.putExtra(Intent.EXTRA_INTENT, getContentIntent); |
114 | 114 |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 | 244 |
245 @CalledByNative | 245 @CalledByNative |
246 private static SelectFileDialog create(int nativeSelectFileDialog) { | 246 private static SelectFileDialog create(int nativeSelectFileDialog) { |
247 return new SelectFileDialog(nativeSelectFileDialog); | 247 return new SelectFileDialog(nativeSelectFileDialog); |
248 } | 248 } |
249 | 249 |
250 private native void nativeOnFileSelected(int nativeSelectFileDialogImpl, | 250 private native void nativeOnFileSelected(int nativeSelectFileDialogImpl, |
251 String filePath); | 251 String filePath); |
252 private native void nativeOnFileNotSelected(int nativeSelectFileDialogImpl); | 252 private native void nativeOnFileNotSelected(int nativeSelectFileDialogImpl); |
253 } | 253 } |
OLD | NEW |