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

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

Issue 2902813003: VR: keep track of all pages that are recording audio/video/screen (Closed)
Patch Set: Created 3 years, 7 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
« no previous file with comments | « chrome/browser/android/vr_shell/vr_shell.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/vr_shell/vr_shell.h" 5 #include "chrome/browser/android/vr_shell/vr_shell.h"
6 6
7 #include <android/native_window_jni.h> 7 #include <android/native_window_jni.h>
8 8
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 void VrShell::OnLoadProgressChanged(JNIEnv* env, 310 void VrShell::OnLoadProgressChanged(JNIEnv* env,
311 const JavaParamRef<jobject>& obj, 311 const JavaParamRef<jobject>& obj,
312 double progress) { 312 double progress) {
313 ui_->SetLoadProgress(progress); 313 ui_->SetLoadProgress(progress);
314 } 314 }
315 315
316 void VrShell::OnTabListCreated(JNIEnv* env, 316 void VrShell::OnTabListCreated(JNIEnv* env,
317 const JavaParamRef<jobject>& obj, 317 const JavaParamRef<jobject>& obj,
318 jobjectArray tabs, 318 jobjectArray tabs,
319 jobjectArray incognito_tabs) { 319 jobjectArray incognito_tabs) {
320 number_of_tabs_capturing_audio_ = 0;
321 number_of_tabs_capturing_video_ = 0;
322 number_of_tabs_capturing_screen_ = 0;
323
320 ProcessTabArray(env, tabs, false); 324 ProcessTabArray(env, tabs, false);
321 ProcessTabArray(env, incognito_tabs, true); 325 ProcessTabArray(env, incognito_tabs, true);
322 ui_->FlushTabList(); 326 ui_->FlushTabList();
323 } 327 }
324 328
325 void VrShell::ProcessTabArray(JNIEnv* env, jobjectArray tabs, bool incognito) { 329 void VrShell::ProcessTabArray(JNIEnv* env, jobjectArray tabs, bool incognito) {
326 size_t len = env->GetArrayLength(tabs); 330 size_t len = env->GetArrayLength(tabs);
327 for (size_t i = 0; i < len; ++i) { 331 for (size_t i = 0; i < len; ++i) {
328 jobject jtab = env->GetObjectArrayElement(tabs, i); 332 jobject jtab = env->GetObjectArrayElement(tabs, i);
329 TabAndroid* tab = 333 TabAndroid* tab =
330 TabAndroid::GetNativeTab(env, JavaParamRef<jobject>(env, jtab)); 334 TabAndroid::GetNativeTab(env, JavaParamRef<jobject>(env, jtab));
331 ui_->AppendToTabList(incognito, tab->GetAndroidId(), tab->GetTitle()); 335 ui_->AppendToTabList(incognito, tab->GetAndroidId(), tab->GetTitle());
336 if (tab->web_contents() != web_contents_) {
337 scoped_refptr<MediaStreamCaptureIndicator> indicator =
338 MediaCaptureDevicesDispatcher::GetInstance()
339 ->GetMediaStreamCaptureIndicator();
340 if (indicator->IsCapturingAudio(tab->web_contents()))
cjgrant 2017/05/23 20:38:18 If this method is reliable enough to use with othe
asimjour1 2017/05/23 20:49:19 Current tab can change its current state. So we ha
cjgrant 2017/05/24 13:56:25 A few more questions: - Can a background tab ever
asimjour1 2017/05/25 14:38:37 I moved the code from here, and check all tabs eve
341 number_of_tabs_capturing_audio_++;
342 if (indicator->IsCapturingVideo(tab->web_contents()))
343 number_of_tabs_capturing_video_++;
344 if (indicator->IsBeingMirrored(tab->web_contents()))
345 number_of_tabs_capturing_screen_++;
346 }
332 } 347 }
333 } 348 }
334 349
335 void VrShell::OnTabUpdated(JNIEnv* env, 350 void VrShell::OnTabUpdated(JNIEnv* env,
336 const JavaParamRef<jobject>& obj, 351 const JavaParamRef<jobject>& obj,
337 jboolean incognito, 352 jboolean incognito,
338 jint id, 353 jint id,
339 jstring jtitle) { 354 jstring jtitle) {
340 std::string title; 355 std::string title;
341 base::android::ConvertJavaStringToUTF8(env, jtitle, &title); 356 base::android::ConvertJavaStringToUTF8(env, jtitle, &title);
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
567 poll_capturing_media_task_.Reset( 582 poll_capturing_media_task_.Reset(
568 base::Bind(&VrShell::PollMediaAccessFlag, base::Unretained(this))); 583 base::Bind(&VrShell::PollMediaAccessFlag, base::Unretained(this)));
569 main_thread_task_runner_->PostDelayedTask( 584 main_thread_task_runner_->PostDelayedTask(
570 FROM_HERE, poll_capturing_media_task_.callback(), 585 FROM_HERE, poll_capturing_media_task_.callback(),
571 poll_media_access_interval_); 586 poll_media_access_interval_);
572 587
573 scoped_refptr<MediaStreamCaptureIndicator> indicator = 588 scoped_refptr<MediaStreamCaptureIndicator> indicator =
574 MediaCaptureDevicesDispatcher::GetInstance() 589 MediaCaptureDevicesDispatcher::GetInstance()
575 ->GetMediaStreamCaptureIndicator(); 590 ->GetMediaStreamCaptureIndicator();
576 bool is_capturing_audio = indicator->IsCapturingAudio(web_contents_); 591 bool is_capturing_audio = indicator->IsCapturingAudio(web_contents_);
577 if (is_capturing_audio != is_capturing_audio_) 592 if (is_capturing_audio != is_capturing_audio_) {
578 ui_->SetAudioCapturingIndicator(is_capturing_audio); 593 number_of_tabs_capturing_audio_ += is_capturing_audio ? 1 : -1;
cjgrant 2017/05/24 13:56:25 style guide prefers "num_tabs_capturing_audio_" (a
asimjour1 2017/05/25 14:38:37 Done.
594 if (number_of_tabs_capturing_audio_ > 0)
595 ui_->SetAudioCapturingIndicator(true);
596 else
597 ui_->SetAudioCapturingIndicator(false);
598 }
579 is_capturing_audio_ = is_capturing_audio; 599 is_capturing_audio_ = is_capturing_audio;
580 600
581 bool is_capturing_video = indicator->IsCapturingVideo(web_contents_); 601 bool is_capturing_video = indicator->IsCapturingVideo(web_contents_);
582 if (is_capturing_video != is_capturing_video_) 602 if (is_capturing_video != is_capturing_video_) {
583 ui_->SetVideoCapturingIndicator(is_capturing_video); 603 number_of_tabs_capturing_video_ += is_capturing_video ? 1 : -1;
604 if (number_of_tabs_capturing_video_ > 0)
605 ui_->SetVideoCapturingIndicator(true);
606 else
607 ui_->SetVideoCapturingIndicator(false);
608 }
584 is_capturing_video_ = is_capturing_video; 609 is_capturing_video_ = is_capturing_video;
585 610
586 bool is_capturing_screen = indicator->IsBeingMirrored(web_contents_); 611 bool is_capturing_screen = indicator->IsBeingMirrored(web_contents_);
587 if (is_capturing_screen != is_capturing_screen_) 612 if (is_capturing_screen != is_capturing_screen_) {
588 ui_->SetScreenCapturingIndicator(is_capturing_screen); 613 number_of_tabs_capturing_screen_ += is_capturing_screen ? 1 : -1;
614 if (number_of_tabs_capturing_screen_ > 0)
615 ui_->SetScreenCapturingIndicator(true);
616 else
617 ui_->SetScreenCapturingIndicator(false);
618 }
589 is_capturing_screen_ = is_capturing_screen; 619 is_capturing_screen_ = is_capturing_screen;
590 } 620 }
591 621
592 void VrShell::SetContentCssSize(float width, float height, float dpr) { 622 void VrShell::SetContentCssSize(float width, float height, float dpr) {
593 JNIEnv* env = base::android::AttachCurrentThread(); 623 JNIEnv* env = base::android::AttachCurrentThread();
594 Java_VrShellImpl_setContentCssSize(env, j_vr_shell_.obj(), width, height, 624 Java_VrShellImpl_setContentCssSize(env, j_vr_shell_.obj(), width, height,
595 dpr); 625 dpr);
596 } 626 }
597 627
598 void VrShell::ProcessContentGesture( 628 void VrShell::ProcessContentGesture(
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
643 jlong gvr_api, 673 jlong gvr_api,
644 jboolean reprojected_rendering) { 674 jboolean reprojected_rendering) {
645 return reinterpret_cast<intptr_t>(new VrShell( 675 return reinterpret_cast<intptr_t>(new VrShell(
646 env, obj, reinterpret_cast<ui::WindowAndroid*>(window_android), 676 env, obj, reinterpret_cast<ui::WindowAndroid*>(window_android),
647 for_web_vr, in_cct, 677 for_web_vr, in_cct,
648 VrShellDelegate::GetNativeVrShellDelegate(env, delegate), 678 VrShellDelegate::GetNativeVrShellDelegate(env, delegate),
649 reinterpret_cast<gvr_context*>(gvr_api), reprojected_rendering)); 679 reinterpret_cast<gvr_context*>(gvr_api), reprojected_rendering));
650 } 680 }
651 681
652 } // namespace vr_shell 682 } // namespace vr_shell
OLDNEW
« no previous file with comments | « chrome/browser/android/vr_shell/vr_shell.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698