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/memory/ptr_util.h" |
17 #include "base/message_loop/message_loop.h" | 18 #include "base/message_loop/message_loop.h" |
18 #include "base/strings/string_util.h" | 19 #include "base/strings/string_util.h" |
19 #include "base/strings/utf_string_conversions.h" | 20 #include "base/strings/utf_string_conversions.h" |
20 #include "content/public/browser/render_process_host.h" | 21 #include "content/public/browser/render_process_host.h" |
21 #include "content/public/browser/render_view_host.h" | 22 #include "content/public/browser/render_view_host.h" |
22 #include "content/public/browser/render_widget_host.h" | 23 #include "content/public/browser/render_widget_host.h" |
23 #include "content/public/browser/web_contents.h" | 24 #include "content/public/browser/web_contents.h" |
24 #include "content/public/common/file_chooser_file_info.h" | 25 #include "content/public/common/file_chooser_file_info.h" |
25 #include "content/public/common/file_chooser_params.h" | 26 #include "content/public/common/file_chooser_params.h" |
26 #include "content/public/common/media_stream_request.h" | 27 #include "content/public/common/media_stream_request.h" |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 java_delegate.obj(), is_dialog, user_gesture); | 142 java_delegate.obj(), is_dialog, user_gesture); |
142 } | 143 } |
143 | 144 |
144 if (create_popup) { | 145 if (create_popup) { |
145 // The embedder would like to display the popup and we will receive | 146 // The embedder would like to display the popup and we will receive |
146 // a callback from them later with an AwContents to use to display | 147 // a callback from them later with an AwContents to use to display |
147 // it. The source AwContents takes ownership of the new WebContents | 148 // it. The source AwContents takes ownership of the new WebContents |
148 // until then, and when the callback is made we will swap the WebContents | 149 // until then, and when the callback is made we will swap the WebContents |
149 // out into the new AwContents. | 150 // out into the new AwContents. |
150 AwContents::FromWebContents(source)->SetPendingWebContentsForPopup( | 151 AwContents::FromWebContents(source)->SetPendingWebContentsForPopup( |
151 make_scoped_ptr(new_contents)); | 152 base::WrapUnique(new_contents)); |
152 // Hide the WebContents for the pop up now, we will show it again | 153 // Hide the WebContents for the pop up now, we will show it again |
153 // when the user calls us back with an AwContents to use to show it. | 154 // when the user calls us back with an AwContents to use to show it. |
154 new_contents->WasHidden(); | 155 new_contents->WasHidden(); |
155 } else { | 156 } else { |
156 // The embedder has forgone their chance to display this popup | 157 // The embedder has forgone their chance to display this popup |
157 // window, so we're done with the WebContents now. We use | 158 // window, so we're done with the WebContents now. We use |
158 // DeleteSoon as WebContentsImpl may call methods on |new_contents| | 159 // DeleteSoon as WebContentsImpl may call methods on |new_contents| |
159 // after this method returns. | 160 // after this method returns. |
160 base::MessageLoop::current()->DeleteSoon(FROM_HERE, new_contents); | 161 base::MessageLoop::current()->DeleteSoon(FROM_HERE, new_contents); |
161 } | 162 } |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 } | 227 } |
227 | 228 |
228 void AwWebContentsDelegate::RequestMediaAccessPermission( | 229 void AwWebContentsDelegate::RequestMediaAccessPermission( |
229 WebContents* web_contents, | 230 WebContents* web_contents, |
230 const content::MediaStreamRequest& request, | 231 const content::MediaStreamRequest& request, |
231 const content::MediaResponseCallback& callback) { | 232 const content::MediaResponseCallback& callback) { |
232 AwContents* aw_contents = AwContents::FromWebContents(web_contents); | 233 AwContents* aw_contents = AwContents::FromWebContents(web_contents); |
233 if (!aw_contents) { | 234 if (!aw_contents) { |
234 callback.Run(content::MediaStreamDevices(), | 235 callback.Run(content::MediaStreamDevices(), |
235 content::MEDIA_DEVICE_FAILED_DUE_TO_SHUTDOWN, | 236 content::MEDIA_DEVICE_FAILED_DUE_TO_SHUTDOWN, |
236 scoped_ptr<content::MediaStreamUI>()); | 237 std::unique_ptr<content::MediaStreamUI>()); |
237 return; | 238 return; |
238 } | 239 } |
239 aw_contents->GetPermissionRequestHandler()->SendRequest( | 240 aw_contents->GetPermissionRequestHandler()->SendRequest( |
240 scoped_ptr<AwPermissionRequestDelegate>( | 241 std::unique_ptr<AwPermissionRequestDelegate>( |
241 new MediaAccessPermissionRequest(request, callback))); | 242 new MediaAccessPermissionRequest(request, callback))); |
242 } | 243 } |
243 | 244 |
244 void AwWebContentsDelegate::EnterFullscreenModeForTab( | 245 void AwWebContentsDelegate::EnterFullscreenModeForTab( |
245 content::WebContents* web_contents, const GURL& origin) { | 246 content::WebContents* web_contents, const GURL& origin) { |
246 WebContentsDelegateAndroid::EnterFullscreenModeForTab(web_contents, origin); | 247 WebContentsDelegateAndroid::EnterFullscreenModeForTab(web_contents, origin); |
247 is_fullscreen_ = true; | 248 is_fullscreen_ = true; |
248 web_contents->GetRenderViewHost()->GetWidget()->WasResized(); | 249 web_contents->GetRenderViewHost()->GetWidget()->WasResized(); |
249 } | 250 } |
250 | 251 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
308 DVLOG(0) << "File Chooser result: mode = " << mode | 309 DVLOG(0) << "File Chooser result: mode = " << mode |
309 << ", file paths = " << base::JoinString(file_path_str, ":"); | 310 << ", file paths = " << base::JoinString(file_path_str, ":"); |
310 rvh->FilesSelectedInChooser(files, mode); | 311 rvh->FilesSelectedInChooser(files, mode); |
311 } | 312 } |
312 | 313 |
313 bool RegisterAwWebContentsDelegate(JNIEnv* env) { | 314 bool RegisterAwWebContentsDelegate(JNIEnv* env) { |
314 return RegisterNativesImpl(env); | 315 return RegisterNativesImpl(env); |
315 } | 316 } |
316 | 317 |
317 } // namespace android_webview | 318 } // namespace android_webview |
OLD | NEW |