Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(247)

Side by Side Diff: chrome/browser/android/chrome_web_contents_delegate_android.cc

Issue 1159113006: [Android] A prototype of the interactive media notification. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added browser tests Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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::ShowMediaControls(
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_paused = delegate->IsPaused();
mlamouri (slow - plz ping) 2015/06/18 16:43:22 If I understand correctly, the only reason why you
whywhat 2015/06/19 16:00:34 So why would you want to split Show and Update? Th
mlamouri (slow - plz ping) 2015/06/22 14:34:17 What would you think of having UpdateMediaControls
whywhat 2015/06/23 19:39:10 Per offline discussion we agreed that there're two
369 Java_ChromeWebContentsDelegateAndroid_showMediaControls(
370 env, obj.obj(), jis_paused);
371 }
372
373 void ChromeWebContentsDelegateAndroid::HideMediaControls(
374 WebContents* web_contents) {
375 DCHECK(web_contents);
376
377 JNIEnv* env = AttachCurrentThread();
378 ScopedJavaLocalRef<jobject> obj = GetJavaDelegate(env);
379 if (obj.is_null())
380 return;
381
382 Java_ChromeWebContentsDelegateAndroid_hideMediaControls(env, obj.obj());
383 }
384
355 } // namespace android 385 } // namespace android
356 } // namespace chrome 386 } // namespace chrome
357 387
358 jboolean IsCapturingAudio(JNIEnv* env, 388 jboolean IsCapturingAudio(JNIEnv* env,
359 jclass clazz, 389 jclass clazz,
360 jobject java_web_contents) { 390 jobject java_web_contents) {
361 content::WebContents* web_contents = 391 content::WebContents* web_contents =
362 content::WebContents::FromJavaWebContents(java_web_contents); 392 content::WebContents::FromJavaWebContents(java_web_contents);
363 scoped_refptr<MediaStreamCaptureIndicator> indicator = 393 scoped_refptr<MediaStreamCaptureIndicator> indicator =
364 MediaCaptureDevicesDispatcher::GetInstance()-> 394 MediaCaptureDevicesDispatcher::GetInstance()->
(...skipping 12 matching lines...) Expand all
377 return indicator->IsCapturingVideo(web_contents); 407 return indicator->IsCapturingVideo(web_contents);
378 } 408 }
379 409
380 jboolean HasAudibleAudio(JNIEnv* env, 410 jboolean HasAudibleAudio(JNIEnv* env,
381 jclass clazz, 411 jclass clazz,
382 jobject java_web_contents) { 412 jobject java_web_contents) {
383 content::WebContents* web_contents = 413 content::WebContents* web_contents =
384 content::WebContents::FromJavaWebContents(java_web_contents); 414 content::WebContents::FromJavaWebContents(java_web_contents);
385 return web_contents->WasRecentlyAudible(); 415 return web_contents->WasRecentlyAudible();
386 } 416 }
417
418 void OnMediaControlsPause(
419 JNIEnv* env, jclass clazz, jobject java_web_contents) {
420 content::WebContents* web_contents =
421 content::WebContents::FromJavaWebContents(java_web_contents);
422 content::MediaControlsDelegate* delegate =
423 web_contents->GetMediaControlsDelegate();
424 if (delegate)
425 delegate->OnControlsPause();
426 }
427
428 void OnMediaControlsResume(
429 JNIEnv* env, jclass clazz, jobject java_web_contents) {
430 content::WebContents* web_contents =
431 content::WebContents::FromJavaWebContents(java_web_contents);
432 content::MediaControlsDelegate* delegate =
433 web_contents->GetMediaControlsDelegate();
434 if (delegate)
435 delegate->OnControlsResume();
436 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698