| 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 "chrome/browser/android/chrome_web_contents_delegate_android.h" | 5 #include "chrome/browser/android/chrome_web_contents_delegate_android.h" |
| 6 | 6 |
| 7 #include "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
| 8 #include "base/android/jni_string.h" | 8 #include "base/android/jni_string.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "chrome/browser/android/feature_utilities.h" | 10 #include "chrome/browser/android/feature_utilities.h" |
| 11 #include "chrome/browser/chrome_notification_types.h" | 11 #include "chrome/browser/chrome_notification_types.h" |
| 12 #include "chrome/browser/file_select_helper.h" | 12 #include "chrome/browser/file_select_helper.h" |
| 13 #include "chrome/browser/media/media_capture_devices_dispatcher.h" | 13 #include "chrome/browser/media/media_capture_devices_dispatcher.h" |
| 14 #include "chrome/browser/media/media_stream_capture_indicator.h" | 14 #include "chrome/browser/media/media_stream_capture_indicator.h" |
| 15 #include "chrome/browser/media/protected_media_identifier_permission_context.h" | 15 #include "chrome/browser/media/protected_media_identifier_permission_context.h" |
| 16 #include "chrome/browser/media/protected_media_identifier_permission_context_fac
tory.h" | 16 #include "chrome/browser/media/protected_media_identifier_permission_context_fac
tory.h" |
| 17 #include "chrome/browser/prerender/prerender_manager.h" | 17 #include "chrome/browser/prerender/prerender_manager.h" |
| 18 #include "chrome/browser/prerender/prerender_manager_factory.h" | 18 #include "chrome/browser/prerender/prerender_manager_factory.h" |
| 19 #include "chrome/browser/profiles/profile.h" | 19 #include "chrome/browser/profiles/profile.h" |
| 20 #include "chrome/browser/ui/blocked_content/popup_blocker_tab_helper.h" | 20 #include "chrome/browser/ui/blocked_content/popup_blocker_tab_helper.h" |
| 21 #include "chrome/browser/ui/browser_navigator.h" | 21 #include "chrome/browser/ui/browser_navigator.h" |
| 22 #include "chrome/browser/ui/find_bar/find_notification_details.h" | 22 #include "chrome/browser/ui/find_bar/find_notification_details.h" |
| 23 #include "chrome/browser/ui/find_bar/find_tab_helper.h" | 23 #include "chrome/browser/ui/find_bar/find_tab_helper.h" |
| 24 #include "chrome/browser/ui/tab_helpers.h" | 24 #include "chrome/browser/ui/tab_helpers.h" |
| 25 #include "chrome/common/chrome_switches.h" | 25 #include "chrome/common/chrome_switches.h" |
| 26 #include "components/app_modal/javascript_dialog_manager.h" | 26 #include "components/app_modal/javascript_dialog_manager.h" |
| 27 #include "content/public/browser/android/media_controls_delegate.h" |
| 27 #include "content/public/browser/notification_details.h" | 28 #include "content/public/browser/notification_details.h" |
| 28 #include "content/public/browser/notification_service.h" | 29 #include "content/public/browser/notification_service.h" |
| 29 #include "content/public/browser/notification_source.h" | 30 #include "content/public/browser/notification_source.h" |
| 30 #include "content/public/browser/render_process_host.h" | 31 #include "content/public/browser/render_process_host.h" |
| 31 #include "content/public/browser/render_view_host.h" | 32 #include "content/public/browser/render_view_host.h" |
| 32 #include "content/public/browser/web_contents.h" | 33 #include "content/public/browser/web_contents.h" |
| 33 #include "content/public/common/file_chooser_params.h" | 34 #include "content/public/common/file_chooser_params.h" |
| 34 #include "jni/ChromeWebContentsDelegateAndroid_jni.h" | 35 #include "jni/ChromeWebContentsDelegateAndroid_jni.h" |
| 35 #include "third_party/WebKit/public/web/WebWindowFeatures.h" | 36 #include "third_party/WebKit/public/web/WebWindowFeatures.h" |
| 36 #include "ui/gfx/geometry/rect.h" | 37 #include "ui/gfx/geometry/rect.h" |
| (...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 345 NULL, | 346 NULL, |
| 346 user_gesture); | 347 user_gesture); |
| 347 } | 348 } |
| 348 | 349 |
| 349 if (was_blocked) | 350 if (was_blocked) |
| 350 *was_blocked = !handled; | 351 *was_blocked = !handled; |
| 351 if (!handled) | 352 if (!handled) |
| 352 delete new_contents; | 353 delete new_contents; |
| 353 } | 354 } |
| 354 | 355 |
| 356 |
| 357 void ChromeWebContentsDelegateAndroid::UpdateMediaControls( |
| 358 WebContents* web_contents) { |
| 359 DCHECK(web_contents); |
| 360 |
| 361 JNIEnv* env = AttachCurrentThread(); |
| 362 ScopedJavaLocalRef<jobject> obj = GetJavaDelegate(env); |
| 363 if (obj.is_null()) |
| 364 return; |
| 365 |
| 366 content::MediaControlsDelegate* delegate = |
| 367 web_contents->GetMediaControlsDelegate(); |
| 368 jboolean jis_controllable = delegate->IsControllable(); |
| 369 jboolean jis_paused = delegate->IsPaused(); |
| 370 Java_ChromeWebContentsDelegateAndroid_updateMediaControls( |
| 371 env, obj.obj(), jis_controllable, jis_paused); |
| 372 } |
| 373 |
| 355 } // namespace android | 374 } // namespace android |
| 356 } // namespace chrome | 375 } // namespace chrome |
| 357 | 376 |
| 358 jboolean IsCapturingAudio(JNIEnv* env, | 377 jboolean IsCapturingAudio(JNIEnv* env, |
| 359 jclass clazz, | 378 jclass clazz, |
| 360 jobject java_web_contents) { | 379 jobject java_web_contents) { |
| 361 content::WebContents* web_contents = | 380 content::WebContents* web_contents = |
| 362 content::WebContents::FromJavaWebContents(java_web_contents); | 381 content::WebContents::FromJavaWebContents(java_web_contents); |
| 363 scoped_refptr<MediaStreamCaptureIndicator> indicator = | 382 scoped_refptr<MediaStreamCaptureIndicator> indicator = |
| 364 MediaCaptureDevicesDispatcher::GetInstance()-> | 383 MediaCaptureDevicesDispatcher::GetInstance()-> |
| (...skipping 12 matching lines...) Expand all Loading... |
| 377 return indicator->IsCapturingVideo(web_contents); | 396 return indicator->IsCapturingVideo(web_contents); |
| 378 } | 397 } |
| 379 | 398 |
| 380 jboolean HasAudibleAudio(JNIEnv* env, | 399 jboolean HasAudibleAudio(JNIEnv* env, |
| 381 jclass clazz, | 400 jclass clazz, |
| 382 jobject java_web_contents) { | 401 jobject java_web_contents) { |
| 383 content::WebContents* web_contents = | 402 content::WebContents* web_contents = |
| 384 content::WebContents::FromJavaWebContents(java_web_contents); | 403 content::WebContents::FromJavaWebContents(java_web_contents); |
| 385 return web_contents->WasRecentlyAudible(); | 404 return web_contents->WasRecentlyAudible(); |
| 386 } | 405 } |
| 406 |
| 407 void OnMediaControlsPause( |
| 408 JNIEnv* env, jclass clazz, jobject java_web_contents) { |
| 409 content::WebContents* web_contents = |
| 410 content::WebContents::FromJavaWebContents(java_web_contents); |
| 411 content::MediaControlsDelegate* delegate = |
| 412 web_contents->GetMediaControlsDelegate(); |
| 413 if (delegate) |
| 414 delegate->OnControlsPause(); |
| 415 } |
| 416 |
| 417 void OnMediaControlsResume( |
| 418 JNIEnv* env, jclass clazz, jobject java_web_contents) { |
| 419 content::WebContents* web_contents = |
| 420 content::WebContents::FromJavaWebContents(java_web_contents); |
| 421 content::MediaControlsDelegate* delegate = |
| 422 web_contents->GetMediaControlsDelegate(); |
| 423 if (delegate) |
| 424 delegate->OnControlsResume(); |
| 425 } |
| OLD | NEW |