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" |
| 12 #include "android_webview/native/permission/permission_request_handler.h" |
11 #include "base/android/jni_array.h" | 13 #include "base/android/jni_array.h" |
12 #include "base/android/jni_string.h" | 14 #include "base/android/jni_string.h" |
13 #include "base/android/scoped_java_ref.h" | 15 #include "base/android/scoped_java_ref.h" |
14 #include "base/lazy_instance.h" | 16 #include "base/lazy_instance.h" |
15 #include "base/message_loop/message_loop.h" | 17 #include "base/message_loop/message_loop.h" |
16 #include "base/strings/string_util.h" | 18 #include "base/strings/string_util.h" |
17 #include "content/public/browser/render_process_host.h" | 19 #include "content/public/browser/render_process_host.h" |
18 #include "content/public/browser/render_view_host.h" | 20 #include "content/public/browser/render_view_host.h" |
19 #include "content/public/browser/web_contents.h" | 21 #include "content/public/browser/web_contents.h" |
20 #include "content/public/common/file_chooser_params.h" | 22 #include "content/public/common/file_chooser_params.h" |
| 23 #include "content/public/common/media_stream_request.h" |
21 #include "jni/AwWebContentsDelegate_jni.h" | 24 #include "jni/AwWebContentsDelegate_jni.h" |
22 #include "ui/shell_dialogs/selected_file_info.h" | 25 #include "ui/shell_dialogs/selected_file_info.h" |
23 | 26 |
24 using base::android::AttachCurrentThread; | 27 using base::android::AttachCurrentThread; |
25 using base::android::ConvertUTF16ToJavaString; | 28 using base::android::ConvertUTF16ToJavaString; |
26 using base::android::ConvertUTF8ToJavaString; | 29 using base::android::ConvertUTF8ToJavaString; |
27 using base::android::ScopedJavaLocalRef; | 30 using base::android::ScopedJavaLocalRef; |
28 using content::FileChooserParams; | 31 using content::FileChooserParams; |
29 using content::WebContents; | 32 using content::WebContents; |
30 | 33 |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 | 184 |
182 void AwWebContentsDelegate::ActivateContents(WebContents* contents) { | 185 void AwWebContentsDelegate::ActivateContents(WebContents* contents) { |
183 JNIEnv* env = AttachCurrentThread(); | 186 JNIEnv* env = AttachCurrentThread(); |
184 | 187 |
185 ScopedJavaLocalRef<jobject> java_delegate = GetJavaDelegate(env); | 188 ScopedJavaLocalRef<jobject> java_delegate = GetJavaDelegate(env); |
186 if (java_delegate.obj()) { | 189 if (java_delegate.obj()) { |
187 Java_AwWebContentsDelegate_activateContents(env, java_delegate.obj()); | 190 Java_AwWebContentsDelegate_activateContents(env, java_delegate.obj()); |
188 } | 191 } |
189 } | 192 } |
190 | 193 |
| 194 void AwWebContentsDelegate::RequestMediaAccessPermission( |
| 195 WebContents* web_contents, |
| 196 const content::MediaStreamRequest& request, |
| 197 const content::MediaResponseCallback& callback) { |
| 198 AwContents* aw_contents = AwContents::FromWebContents(web_contents); |
| 199 if (!aw_contents) { |
| 200 callback.Run(content::MediaStreamDevices(), |
| 201 content::MEDIA_DEVICE_INVALID_STATE, |
| 202 scoped_ptr<content::MediaStreamUI>().Pass()); |
| 203 return; |
| 204 } |
| 205 aw_contents->GetPermissionRequestHandler()->SendRequest( |
| 206 scoped_ptr<AwPermissionRequestDelegate>( |
| 207 new MediaAccessPermissionRequest(request, callback))); |
| 208 } |
| 209 |
191 static void FilesSelectedInChooser( | 210 static void FilesSelectedInChooser( |
192 JNIEnv* env, jclass clazz, | 211 JNIEnv* env, jclass clazz, |
193 jint process_id, jint render_id, jint mode_flags, | 212 jint process_id, jint render_id, jint mode_flags, |
194 jobjectArray file_paths) { | 213 jobjectArray file_paths) { |
195 content::RenderViewHost* rvh = content::RenderViewHost::FromID(process_id, | 214 content::RenderViewHost* rvh = content::RenderViewHost::FromID(process_id, |
196 render_id); | 215 render_id); |
197 if (!rvh) | 216 if (!rvh) |
198 return; | 217 return; |
199 | 218 |
200 std::vector<std::string> file_path_str; | 219 std::vector<std::string> file_path_str; |
(...skipping 20 matching lines...) Expand all Loading... |
221 DVLOG(0) << "File Chooser result: mode = " << mode | 240 DVLOG(0) << "File Chooser result: mode = " << mode |
222 << ", file paths = " << JoinString(file_path_str, ":"); | 241 << ", file paths = " << JoinString(file_path_str, ":"); |
223 rvh->FilesSelectedInChooser(files, mode); | 242 rvh->FilesSelectedInChooser(files, mode); |
224 } | 243 } |
225 | 244 |
226 bool RegisterAwWebContentsDelegate(JNIEnv* env) { | 245 bool RegisterAwWebContentsDelegate(JNIEnv* env) { |
227 return RegisterNativesImpl(env); | 246 return RegisterNativesImpl(env); |
228 } | 247 } |
229 | 248 |
230 } // namespace android_webview | 249 } // namespace android_webview |
OLD | NEW |