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" |
11 #include "android_webview/native/permission/media_access_permission_request.h" | 11 #include "android_webview/native/permission/media_access_permission_request.h" |
12 #include "android_webview/native/permission/permission_request_handler.h" | 12 #include "android_webview/native/permission/permission_request_handler.h" |
13 #include "base/android/jni_array.h" | 13 #include "base/android/jni_array.h" |
14 #include "base/android/jni_string.h" | 14 #include "base/android/jni_string.h" |
15 #include "base/android/scoped_java_ref.h" | 15 #include "base/android/scoped_java_ref.h" |
16 #include "base/lazy_instance.h" | 16 #include "base/lazy_instance.h" |
17 #include "base/message_loop/message_loop.h" | 17 #include "base/message_loop/message_loop.h" |
18 #include "base/strings/string_util.h" | 18 #include "base/strings/string_util.h" |
19 #include "base/strings/utf_string_conversions.h" | |
20 #include "content/public/browser/render_process_host.h" | 19 #include "content/public/browser/render_process_host.h" |
21 #include "content/public/browser/render_view_host.h" | 20 #include "content/public/browser/render_view_host.h" |
22 #include "content/public/browser/web_contents.h" | 21 #include "content/public/browser/web_contents.h" |
23 #include "content/public/common/file_chooser_file_info.h" | 22 #include "content/public/common/file_chooser_file_info.h" |
24 #include "content/public/common/file_chooser_params.h" | 23 #include "content/public/common/file_chooser_params.h" |
25 #include "content/public/common/media_stream_request.h" | 24 #include "content/public/common/media_stream_request.h" |
26 #include "jni/AwWebContentsDelegate_jni.h" | 25 #include "jni/AwWebContentsDelegate_jni.h" |
27 #include "net/base/escape.h" | 26 #include "net/base/escape.h" |
28 | 27 |
29 using base::android::AttachCurrentThread; | 28 using base::android::AttachCurrentThread; |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 return; | 107 return; |
109 } else { | 108 } else { |
110 DCHECK_EQ(FileChooserParams::Open, params.mode); | 109 DCHECK_EQ(FileChooserParams::Open, params.mode); |
111 } | 110 } |
112 Java_AwWebContentsDelegate_runFileChooser(env, | 111 Java_AwWebContentsDelegate_runFileChooser(env, |
113 java_delegate.obj(), | 112 java_delegate.obj(), |
114 web_contents->GetRenderProcessHost()->GetID(), | 113 web_contents->GetRenderProcessHost()->GetID(), |
115 web_contents->GetRenderViewHost()->GetRoutingID(), | 114 web_contents->GetRenderViewHost()->GetRoutingID(), |
116 mode_flags, | 115 mode_flags, |
117 ConvertUTF16ToJavaString(env, | 116 ConvertUTF16ToJavaString(env, |
118 base::JoinString(params.accept_types, base::ASCIIToUTF16(","))).obj(), | 117 JoinString(params.accept_types, ',')).obj(), |
119 params.title.empty() ? NULL : | 118 params.title.empty() ? NULL : |
120 ConvertUTF16ToJavaString(env, params.title).obj(), | 119 ConvertUTF16ToJavaString(env, params.title).obj(), |
121 params.default_file_name.empty() ? NULL : | 120 params.default_file_name.empty() ? NULL : |
122 ConvertUTF8ToJavaString(env, params.default_file_name.value()).obj(), | 121 ConvertUTF8ToJavaString(env, params.default_file_name.value()).obj(), |
123 params.capture); | 122 params.capture); |
124 } | 123 } |
125 | 124 |
126 void AwWebContentsDelegate::AddNewContents(WebContents* source, | 125 void AwWebContentsDelegate::AddNewContents(WebContents* source, |
127 WebContents* new_contents, | 126 WebContents* new_contents, |
128 WindowOpenDisposition disposition, | 127 WindowOpenDisposition disposition, |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 } | 286 } |
288 FileChooserParams::Mode mode; | 287 FileChooserParams::Mode mode; |
289 if (mode_flags & kFileChooserModeOpenFolder) { | 288 if (mode_flags & kFileChooserModeOpenFolder) { |
290 mode = FileChooserParams::UploadFolder; | 289 mode = FileChooserParams::UploadFolder; |
291 } else if (mode_flags & kFileChooserModeOpenMultiple) { | 290 } else if (mode_flags & kFileChooserModeOpenMultiple) { |
292 mode = FileChooserParams::OpenMultiple; | 291 mode = FileChooserParams::OpenMultiple; |
293 } else { | 292 } else { |
294 mode = FileChooserParams::Open; | 293 mode = FileChooserParams::Open; |
295 } | 294 } |
296 DVLOG(0) << "File Chooser result: mode = " << mode | 295 DVLOG(0) << "File Chooser result: mode = " << mode |
297 << ", file paths = " << base::JoinString(file_path_str, ":"); | 296 << ", file paths = " << JoinString(file_path_str, ":"); |
298 rvh->FilesSelectedInChooser(files, mode); | 297 rvh->FilesSelectedInChooser(files, mode); |
299 } | 298 } |
300 | 299 |
301 bool RegisterAwWebContentsDelegate(JNIEnv* env) { | 300 bool RegisterAwWebContentsDelegate(JNIEnv* env) { |
302 return RegisterNativesImpl(env); | 301 return RegisterNativesImpl(env); |
303 } | 302 } |
304 | 303 |
305 } // namespace android_webview | 304 } // namespace android_webview |
OLD | NEW |