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 #include "android_webview/native/aw_web_contents_delegate.h" | 5 #include "android_webview/native/aw_web_contents_delegate.h" |
6 | 6 |
7 #include "android_webview/browser/aw_javascript_dialog_manager.h" | 7 #include "android_webview/browser/aw_javascript_dialog_manager.h" |
8 #include "android_webview/browser/find_helper.h" | 8 #include "android_webview/browser/find_helper.h" |
9 #include "android_webview/native/aw_contents.h" | 9 #include "android_webview/native/aw_contents.h" |
10 #include "android_webview/native/aw_contents_io_thread_client_impl.h" | 10 #include "android_webview/native/aw_contents_io_thread_client_impl.h" |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 | 223 |
224 bool AwWebContentsDelegate::IsFullscreenForTabOrPending( | 224 bool AwWebContentsDelegate::IsFullscreenForTabOrPending( |
225 const content::WebContents* web_contents) const { | 225 const content::WebContents* web_contents) const { |
226 return is_fullscreen_; | 226 return is_fullscreen_; |
227 } | 227 } |
228 | 228 |
229 | 229 |
230 static void FilesSelectedInChooser( | 230 static void FilesSelectedInChooser( |
231 JNIEnv* env, jclass clazz, | 231 JNIEnv* env, jclass clazz, |
232 jint process_id, jint render_id, jint mode_flags, | 232 jint process_id, jint render_id, jint mode_flags, |
233 jobjectArray file_paths) { | 233 jobjectArray file_paths, jobjectArray display_names) { |
234 content::RenderViewHost* rvh = content::RenderViewHost::FromID(process_id, | 234 content::RenderViewHost* rvh = content::RenderViewHost::FromID(process_id, |
235 render_id); | 235 render_id); |
236 if (!rvh) | 236 if (!rvh) |
237 return; | 237 return; |
238 | 238 |
239 std::vector<std::string> file_path_str; | 239 std::vector<std::string> file_path_str; |
| 240 std::vector<std::string> display_name_str; |
240 // Note file_paths maybe NULL, but this will just yield a zero-length vector. | 241 // Note file_paths maybe NULL, but this will just yield a zero-length vector. |
241 base::android::AppendJavaStringArrayToStringVector(env, file_paths, | 242 base::android::AppendJavaStringArrayToStringVector(env, file_paths, |
242 &file_path_str); | 243 &file_path_str); |
| 244 base::android::AppendJavaStringArrayToStringVector(env, display_names, |
| 245 &display_name_str); |
243 std::vector<ui::SelectedFileInfo> files; | 246 std::vector<ui::SelectedFileInfo> files; |
244 files.reserve(file_path_str.size()); | 247 files.reserve(file_path_str.size()); |
245 for (size_t i = 0; i < file_path_str.size(); ++i) { | 248 for (size_t i = 0; i < file_path_str.size(); ++i) { |
246 GURL url(file_path_str[i]); | 249 GURL url(file_path_str[i]); |
247 if (!url.is_valid()) | 250 if (!url.is_valid()) |
248 continue; | 251 continue; |
249 base::FilePath path(url.SchemeIsFile() ? url.path() : file_path_str[i]); | 252 base::FilePath path(url.SchemeIsFile() ? url.path() : file_path_str[i]); |
250 files.push_back(ui::SelectedFileInfo(path, base::FilePath())); | 253 ui::SelectedFileInfo file_info(path, base::FilePath()); |
| 254 if (!display_name_str[i].empty()) |
| 255 file_info.display_name = display_name_str[i]; |
| 256 files.push_back(file_info); |
251 } | 257 } |
252 FileChooserParams::Mode mode; | 258 FileChooserParams::Mode mode; |
253 if (mode_flags & kFileChooserModeOpenFolder) { | 259 if (mode_flags & kFileChooserModeOpenFolder) { |
254 mode = FileChooserParams::UploadFolder; | 260 mode = FileChooserParams::UploadFolder; |
255 } else if (mode_flags & kFileChooserModeOpenMultiple) { | 261 } else if (mode_flags & kFileChooserModeOpenMultiple) { |
256 mode = FileChooserParams::OpenMultiple; | 262 mode = FileChooserParams::OpenMultiple; |
257 } else { | 263 } else { |
258 mode = FileChooserParams::Open; | 264 mode = FileChooserParams::Open; |
259 } | 265 } |
260 DVLOG(0) << "File Chooser result: mode = " << mode | 266 DVLOG(0) << "File Chooser result: mode = " << mode |
261 << ", file paths = " << JoinString(file_path_str, ":"); | 267 << ", file paths = " << JoinString(file_path_str, ":"); |
262 rvh->FilesSelectedInChooser(files, mode); | 268 rvh->FilesSelectedInChooser(files, mode); |
263 } | 269 } |
264 | 270 |
265 bool RegisterAwWebContentsDelegate(JNIEnv* env) { | 271 bool RegisterAwWebContentsDelegate(JNIEnv* env) { |
266 return RegisterNativesImpl(env); | 272 return RegisterNativesImpl(env); |
267 } | 273 } |
268 | 274 |
269 } // namespace android_webview | 275 } // namespace android_webview |
OLD | NEW |