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 | |
206 // AwPermissionRequest owns the MediaAccessPermissionRequest. | |
207 scoped_refptr<AwPermissionRequest> permission_request = | |
208 new AwPermissionRequest(new MediaAccessPermissionRequest(request, | |
209 callback)); | |
210 aw_contents->GetPermissionRequestHandler()->SendRequest(permission_request); | |
mkosiba (inactive)
2014/04/17 10:34:06
could the PermissionRequestHandler be a member of
michaelbai
2014/04/22 20:53:51
Considering about the geolocation implementation,
mkosiba (inactive)
2014/04/23 18:04:40
ok. thanks for the explanation!
| |
211 } | |
212 | |
191 static void FilesSelectedInChooser( | 213 static void FilesSelectedInChooser( |
192 JNIEnv* env, jclass clazz, | 214 JNIEnv* env, jclass clazz, |
193 jint process_id, jint render_id, jint mode_flags, | 215 jint process_id, jint render_id, jint mode_flags, |
194 jobjectArray file_paths) { | 216 jobjectArray file_paths) { |
195 content::RenderViewHost* rvh = content::RenderViewHost::FromID(process_id, | 217 content::RenderViewHost* rvh = content::RenderViewHost::FromID(process_id, |
196 render_id); | 218 render_id); |
197 if (!rvh) | 219 if (!rvh) |
198 return; | 220 return; |
199 | 221 |
200 std::vector<std::string> file_path_str; | 222 std::vector<std::string> file_path_str; |
(...skipping 20 matching lines...) Expand all Loading... | |
221 DVLOG(0) << "File Chooser result: mode = " << mode | 243 DVLOG(0) << "File Chooser result: mode = " << mode |
222 << ", file paths = " << JoinString(file_path_str, ":"); | 244 << ", file paths = " << JoinString(file_path_str, ":"); |
223 rvh->FilesSelectedInChooser(files, mode); | 245 rvh->FilesSelectedInChooser(files, mode); |
224 } | 246 } |
225 | 247 |
226 bool RegisterAwWebContentsDelegate(JNIEnv* env) { | 248 bool RegisterAwWebContentsDelegate(JNIEnv* env) { |
227 return RegisterNativesImpl(env); | 249 return RegisterNativesImpl(env); |
228 } | 250 } |
229 | 251 |
230 } // namespace android_webview | 252 } // namespace android_webview |
OLD | NEW |