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

Side by Side Diff: ui/android/java/src/org/chromium/ui/SelectFileDialog.java

Issue 46303005: Fix chrome upload with content uri (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: addressing comments Created 7 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 153
154 // Broadcast to the media scanner that there's a new photo on the de vice so it will 154 // Broadcast to the media scanner that there's a new photo on the de vice so it will
155 // show up right away in the gallery (rather than waiting until the next time the media 155 // show up right away in the gallery (rather than waiting until the next time the media
156 // scanner runs). 156 // scanner runs).
157 window.sendBroadcast(new Intent( 157 window.sendBroadcast(new Intent(
158 Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, mCameraOutputUri)); 158 Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, mCameraOutputUri));
159 } else { 159 } else {
160 // We get back a content:// URI from the system if the user picked a file from the 160 // We get back a content:// URI from the system if the user picked a file from the
161 // gallery. The ContentView has functionality that will convert that content:// URI to 161 // gallery. The ContentView has functionality that will convert that content:// URI to
162 // a file path on disk that Chromium understands. 162 // a file path on disk that Chromium understands.
163 Cursor c = contentResolver.query(results.getData(), 163 if (results.getScheme() != null
164 new String[] { MediaStore.MediaColumns.DATA }, null, null, n ull); 164 && results.getScheme().equals(ContentResolver.SCHEME_CONTENT )) {
165 if (c != null) { 165 nativeOnFileSelected(mNativeSelectFileDialog, results.getData(). toString());
166 if (c.getCount() == 1) { 166 success = true;
167 c.moveToFirst();
168 String path = c.getString(0);
169 if (path != null) {
170 // Not all providers support the MediaStore.DATA column. For example,
171 // Gallery3D (com.android.gallery3d.provider) does not s upport it for
172 // Picasa Web Album images.
173 nativeOnFileSelected(mNativeSelectFileDialog, path);
174 success = true;
175 }
176 }
177 c.close();
178 } 167 }
179 } 168 }
180 if (!success) { 169 if (!success) {
181 onFileNotSelected(); 170 onFileNotSelected();
182 window.showError(R.string.opening_file_error); 171 window.showError(R.string.opening_file_error);
183 } 172 }
184 } 173 }
185 174
186 private void onFileNotSelected() { 175 private void onFileNotSelected() {
187 nativeOnFileNotSelected(mNativeSelectFileDialog); 176 nativeOnFileNotSelected(mNativeSelectFileDialog);
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 228
240 @CalledByNative 229 @CalledByNative
241 private static SelectFileDialog create(int nativeSelectFileDialog) { 230 private static SelectFileDialog create(int nativeSelectFileDialog) {
242 return new SelectFileDialog(nativeSelectFileDialog); 231 return new SelectFileDialog(nativeSelectFileDialog);
243 } 232 }
244 233
245 private native void nativeOnFileSelected(int nativeSelectFileDialogImpl, 234 private native void nativeOnFileSelected(int nativeSelectFileDialogImpl,
246 String filePath); 235 String filePath);
247 private native void nativeOnFileNotSelected(int nativeSelectFileDialogImpl); 236 private native void nativeOnFileNotSelected(int nativeSelectFileDialogImpl);
248 } 237 }
OLDNEW
« net/base/file_stream_context.cc ('K') | « net/base/file_stream_context.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698