Index: chrome/browser/android/vr_shell/vr_shell.cc |
diff --git a/chrome/browser/android/vr_shell/vr_shell.cc b/chrome/browser/android/vr_shell/vr_shell.cc |
index 1917ddbef19bccb8195c63e9dc0a1d1bd400e840..9fe8304e000f01722a140f62c61a927ce864cd86 100644 |
--- a/chrome/browser/android/vr_shell/vr_shell.cc |
+++ b/chrome/browser/android/vr_shell/vr_shell.cc |
@@ -30,6 +30,8 @@ |
#include "chrome/browser/android/vr_shell/vr_shell_gl.h" |
#include "chrome/browser/android/vr_shell/vr_usage_monitor.h" |
#include "chrome/browser/android/vr_shell/vr_web_contents_observer.h" |
+#include "chrome/browser/media/webrtc/media_capture_devices_dispatcher.h" |
+#include "chrome/browser/media/webrtc/media_stream_capture_indicator.h" |
#include "content/public/browser/browser_thread.h" |
#include "content/public/browser/navigation_controller.h" |
#include "content/public/browser/render_view_host.h" |
@@ -61,6 +63,9 @@ namespace vr_shell { |
namespace { |
vr_shell::VrShell* g_instance; |
+constexpr base::TimeDelta poll_media_access_interval_ = |
+ base::TimeDelta::FromSecondsD(0.01); |
+ |
void SetIsInVR(content::WebContents* contents, bool is_in_vr) { |
if (contents && contents->GetRenderWidgetHostView()) |
contents->GetRenderWidgetHostView()->SetIsInVR(is_in_vr); |
@@ -177,6 +182,7 @@ bool RegisterVrShell(JNIEnv* env) { |
VrShell::~VrShell() { |
DVLOG(1) << __FUNCTION__ << "=" << this; |
+ poll_capturing_media_task_.Cancel(); |
if (gamepad_source_active_) { |
device::GamepadDataFetcherManager::GetInstance()->RemoveSourceFactory( |
device::GAMEPAD_SOURCE_GVR); |
@@ -512,11 +518,46 @@ void VrShell::OnVRVsyncProviderRequest( |
void VrShell::UpdateVSyncInterval(int64_t timebase_nanos, |
double interval_seconds) { |
+ PollMediaAccessFlag(); |
PostToGlThreadWhenReady(base::Bind(&VrShellGl::UpdateVSyncInterval, |
gl_thread_->GetVrShellGl(), timebase_nanos, |
interval_seconds)); |
} |
+void VrShell::PollMediaAccessFlag() { |
+ poll_capturing_media_task_.Cancel(); |
+ |
+ poll_capturing_media_task_.Reset( |
+ base::Bind(&VrShell::PollMediaAccessFlag, base::Unretained(this))); |
+ main_thread_task_runner_->PostDelayedTask( |
+ FROM_HERE, poll_capturing_media_task_.callback(), |
+ poll_media_access_interval_); |
+ |
+ scoped_refptr<MediaStreamCaptureIndicator> indicator = |
+ MediaCaptureDevicesDispatcher::GetInstance() |
+ ->GetMediaStreamCaptureIndicator(); |
+ bool is_capturing_audio = indicator->IsCapturingAudio(web_contents_); |
+ if (is_capturing_audio != is_capturing_audio_) |
+ PostToGlThreadWhenReady(base::Bind(&VrShellGl::SetAudioCapturingWarning, |
+ gl_thread_->GetVrShellGl(), |
+ is_capturing_audio)); |
+ is_capturing_audio_ = is_capturing_audio; |
+ |
+ bool is_capturing_video = indicator->IsCapturingVideo(web_contents_); |
+ if (is_capturing_video != is_capturing_video_) |
+ PostToGlThreadWhenReady(base::Bind(&VrShellGl::SetVideoCapturingWarning, |
+ gl_thread_->GetVrShellGl(), |
+ is_capturing_video)); |
+ is_capturing_video_ = is_capturing_video; |
+ |
+ bool is_capturing_screen = indicator->IsBeingMirrored(web_contents_); |
+ if (is_capturing_screen != is_capturing_screen_) |
+ PostToGlThreadWhenReady(base::Bind(&VrShellGl::SetScreenCapturingWarning, |
+ gl_thread_->GetVrShellGl(), |
+ is_capturing_screen)); |
+ is_capturing_screen_ = is_capturing_screen; |
+} |
+ |
void VrShell::SetContentCssSize(float width, float height, float dpr) { |
JNIEnv* env = base::android::AttachCurrentThread(); |
Java_VrShellImpl_setContentCssSize(env, j_vr_shell_.obj(), width, height, |