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/android/hung_renderer_infobar_delegate.h" |
11 #include "chrome/browser/chrome_notification_types.h" | 12 #include "chrome/browser/chrome_notification_types.h" |
12 #include "chrome/browser/file_select_helper.h" | 13 #include "chrome/browser/file_select_helper.h" |
| 14 #include "chrome/browser/infobars/infobar_service.h" |
13 #include "chrome/browser/media/media_capture_devices_dispatcher.h" | 15 #include "chrome/browser/media/media_capture_devices_dispatcher.h" |
14 #include "chrome/browser/media/media_stream_capture_indicator.h" | 16 #include "chrome/browser/media/media_stream_capture_indicator.h" |
15 #include "chrome/browser/media/protected_media_identifier_permission_context.h" | 17 #include "chrome/browser/media/protected_media_identifier_permission_context.h" |
16 #include "chrome/browser/media/protected_media_identifier_permission_context_fac
tory.h" | 18 #include "chrome/browser/media/protected_media_identifier_permission_context_fac
tory.h" |
17 #include "chrome/browser/prerender/prerender_manager.h" | 19 #include "chrome/browser/prerender/prerender_manager.h" |
18 #include "chrome/browser/prerender/prerender_manager_factory.h" | 20 #include "chrome/browser/prerender/prerender_manager_factory.h" |
19 #include "chrome/browser/profiles/profile.h" | 21 #include "chrome/browser/profiles/profile.h" |
20 #include "chrome/browser/ui/android/bluetooth_chooser_android.h" | 22 #include "chrome/browser/ui/android/bluetooth_chooser_android.h" |
21 #include "chrome/browser/ui/blocked_content/popup_blocker_tab_helper.h" | 23 #include "chrome/browser/ui/blocked_content/popup_blocker_tab_helper.h" |
22 #include "chrome/browser/ui/browser_navigator.h" | 24 #include "chrome/browser/ui/browser_navigator.h" |
23 #include "chrome/browser/ui/find_bar/find_notification_details.h" | 25 #include "chrome/browser/ui/find_bar/find_notification_details.h" |
24 #include "chrome/browser/ui/find_bar/find_tab_helper.h" | 26 #include "chrome/browser/ui/find_bar/find_tab_helper.h" |
25 #include "chrome/browser/ui/tab_helpers.h" | 27 #include "chrome/browser/ui/tab_helpers.h" |
26 #include "chrome/common/chrome_switches.h" | 28 #include "chrome/common/chrome_switches.h" |
27 #include "components/app_modal/javascript_dialog_manager.h" | 29 #include "components/app_modal/javascript_dialog_manager.h" |
| 30 #include "components/infobars/core/infobar.h" |
28 #include "content/public/browser/notification_details.h" | 31 #include "content/public/browser/notification_details.h" |
29 #include "content/public/browser/notification_service.h" | 32 #include "content/public/browser/notification_service.h" |
30 #include "content/public/browser/notification_source.h" | 33 #include "content/public/browser/notification_source.h" |
31 #include "content/public/browser/render_process_host.h" | 34 #include "content/public/browser/render_process_host.h" |
32 #include "content/public/browser/render_view_host.h" | 35 #include "content/public/browser/render_view_host.h" |
33 #include "content/public/browser/web_contents.h" | 36 #include "content/public/browser/web_contents.h" |
34 #include "content/public/common/file_chooser_params.h" | 37 #include "content/public/common/file_chooser_params.h" |
35 #include "jni/ChromeWebContentsDelegateAndroid_jni.h" | 38 #include "jni/ChromeWebContentsDelegateAndroid_jni.h" |
36 #include "third_party/WebKit/public/web/WebWindowFeatures.h" | 39 #include "third_party/WebKit/public/web/WebWindowFeatures.h" |
37 #include "ui/gfx/geometry/rect.h" | 40 #include "ui/gfx/geometry/rect.h" |
(...skipping 27 matching lines...) Expand all Loading... |
65 const gfx::Rect& rect) { | 68 const gfx::Rect& rect) { |
66 return ScopedJavaLocalRef<jobject>( | 69 return ScopedJavaLocalRef<jobject>( |
67 Java_ChromeWebContentsDelegateAndroid_createRect( | 70 Java_ChromeWebContentsDelegateAndroid_createRect( |
68 env, | 71 env, |
69 static_cast<int>(rect.x()), | 72 static_cast<int>(rect.x()), |
70 static_cast<int>(rect.y()), | 73 static_cast<int>(rect.y()), |
71 static_cast<int>(rect.right()), | 74 static_cast<int>(rect.right()), |
72 static_cast<int>(rect.bottom()))); | 75 static_cast<int>(rect.bottom()))); |
73 } | 76 } |
74 | 77 |
| 78 infobars::InfoBar* FindHungRendererInfoBar(InfoBarService* infobar_service) { |
| 79 DCHECK(infobar_service); |
| 80 for (size_t i = 0; i < infobar_service->infobar_count(); ++i) { |
| 81 infobars::InfoBar* infobar = infobar_service->infobar_at(i); |
| 82 if (infobar->delegate()->AsHungRendererInfoBarDelegate()) |
| 83 return infobar; |
| 84 } |
| 85 return nullptr; |
| 86 } |
| 87 |
75 } // anonymous namespace | 88 } // anonymous namespace |
76 | 89 |
77 namespace chrome { | 90 namespace chrome { |
78 namespace android { | 91 namespace android { |
79 | 92 |
80 ChromeWebContentsDelegateAndroid::ChromeWebContentsDelegateAndroid(JNIEnv* env, | 93 ChromeWebContentsDelegateAndroid::ChromeWebContentsDelegateAndroid(JNIEnv* env, |
81 jobject obj) | 94 jobject obj) |
82 : WebContentsDelegateAndroid(env, obj) { | 95 : WebContentsDelegateAndroid(env, obj) { |
83 } | 96 } |
84 | 97 |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
379 | 392 |
380 if (was_blocked) | 393 if (was_blocked) |
381 *was_blocked = !handled; | 394 *was_blocked = !handled; |
382 if (!handled) | 395 if (!handled) |
383 delete new_contents; | 396 delete new_contents; |
384 } | 397 } |
385 | 398 |
386 } // namespace android | 399 } // namespace android |
387 } // namespace chrome | 400 } // namespace chrome |
388 | 401 |
| 402 void OnRendererUnresponsive(JNIEnv* env, |
| 403 const JavaParamRef<jclass>& clazz, |
| 404 const JavaParamRef<jobject>& java_web_contents) { |
| 405 content::WebContents* web_contents = |
| 406 content::WebContents::FromJavaWebContents(java_web_contents); |
| 407 InfoBarService* infobar_service = |
| 408 InfoBarService::FromWebContents(web_contents); |
| 409 DCHECK(!FindHungRendererInfoBar(infobar_service)); |
| 410 HungRendererInfoBarDelegate::Create(infobar_service, |
| 411 web_contents->GetRenderProcessHost()); |
| 412 } |
| 413 |
| 414 void OnRendererResponsive(JNIEnv* env, |
| 415 const JavaParamRef<jclass>& clazz, |
| 416 const JavaParamRef<jobject>& java_web_contents) { |
| 417 content::WebContents* web_contents = |
| 418 content::WebContents::FromJavaWebContents(java_web_contents); |
| 419 InfoBarService* infobar_service = |
| 420 InfoBarService::FromWebContents(web_contents); |
| 421 infobars::InfoBar* hung_renderer_infobar = |
| 422 FindHungRendererInfoBar(infobar_service); |
| 423 if (!hung_renderer_infobar) |
| 424 return; |
| 425 |
| 426 hung_renderer_infobar->delegate() |
| 427 ->AsHungRendererInfoBarDelegate() |
| 428 ->OnRendererResponsive(); |
| 429 infobar_service->RemoveInfoBar(hung_renderer_infobar); |
| 430 } |
| 431 |
389 jboolean IsCapturingAudio(JNIEnv* env, | 432 jboolean IsCapturingAudio(JNIEnv* env, |
390 const JavaParamRef<jclass>& clazz, | 433 const JavaParamRef<jclass>& clazz, |
391 const JavaParamRef<jobject>& java_web_contents) { | 434 const JavaParamRef<jobject>& java_web_contents) { |
392 content::WebContents* web_contents = | 435 content::WebContents* web_contents = |
393 content::WebContents::FromJavaWebContents(java_web_contents); | 436 content::WebContents::FromJavaWebContents(java_web_contents); |
394 scoped_refptr<MediaStreamCaptureIndicator> indicator = | 437 scoped_refptr<MediaStreamCaptureIndicator> indicator = |
395 MediaCaptureDevicesDispatcher::GetInstance()-> | 438 MediaCaptureDevicesDispatcher::GetInstance()-> |
396 GetMediaStreamCaptureIndicator(); | 439 GetMediaStreamCaptureIndicator(); |
397 return indicator->IsCapturingAudio(web_contents); | 440 return indicator->IsCapturingAudio(web_contents); |
398 } | 441 } |
399 | 442 |
400 jboolean IsCapturingVideo(JNIEnv* env, | 443 jboolean IsCapturingVideo(JNIEnv* env, |
401 const JavaParamRef<jclass>& clazz, | 444 const JavaParamRef<jclass>& clazz, |
402 const JavaParamRef<jobject>& java_web_contents) { | 445 const JavaParamRef<jobject>& java_web_contents) { |
403 content::WebContents* web_contents = | 446 content::WebContents* web_contents = |
404 content::WebContents::FromJavaWebContents(java_web_contents); | 447 content::WebContents::FromJavaWebContents(java_web_contents); |
405 scoped_refptr<MediaStreamCaptureIndicator> indicator = | 448 scoped_refptr<MediaStreamCaptureIndicator> indicator = |
406 MediaCaptureDevicesDispatcher::GetInstance()-> | 449 MediaCaptureDevicesDispatcher::GetInstance()-> |
407 GetMediaStreamCaptureIndicator(); | 450 GetMediaStreamCaptureIndicator(); |
408 return indicator->IsCapturingVideo(web_contents); | 451 return indicator->IsCapturingVideo(web_contents); |
409 } | 452 } |
OLD | NEW |