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