Chromium Code Reviews| 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 037c2c70c39e1ef9dc42150bb16b0166df2ce78b..6ed846f55198668442522af00b7de9d90995fd9a 100644 |
| --- a/chrome/browser/android/vr_shell/vr_shell.cc |
| +++ b/chrome/browser/android/vr_shell/vr_shell.cc |
| @@ -317,6 +317,10 @@ void VrShell::OnTabListCreated(JNIEnv* env, |
| const JavaParamRef<jobject>& obj, |
| jobjectArray tabs, |
| jobjectArray incognito_tabs) { |
| + number_of_tabs_capturing_audio_ = 0; |
| + number_of_tabs_capturing_video_ = 0; |
| + number_of_tabs_capturing_screen_ = 0; |
| + |
| ProcessTabArray(env, tabs, false); |
| ProcessTabArray(env, incognito_tabs, true); |
| ui_->FlushTabList(); |
| @@ -329,6 +333,17 @@ void VrShell::ProcessTabArray(JNIEnv* env, jobjectArray tabs, bool incognito) { |
| TabAndroid* tab = |
| TabAndroid::GetNativeTab(env, JavaParamRef<jobject>(env, jtab)); |
| ui_->AppendToTabList(incognito, tab->GetAndroidId(), tab->GetTitle()); |
| + if (tab->web_contents() != web_contents_) { |
| + scoped_refptr<MediaStreamCaptureIndicator> indicator = |
| + MediaCaptureDevicesDispatcher::GetInstance() |
| + ->GetMediaStreamCaptureIndicator(); |
| + 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
|
| + number_of_tabs_capturing_audio_++; |
| + if (indicator->IsCapturingVideo(tab->web_contents())) |
| + number_of_tabs_capturing_video_++; |
| + if (indicator->IsBeingMirrored(tab->web_contents())) |
| + number_of_tabs_capturing_screen_++; |
| + } |
| } |
| } |
| @@ -574,18 +589,33 @@ void VrShell::PollMediaAccessFlag() { |
| MediaCaptureDevicesDispatcher::GetInstance() |
| ->GetMediaStreamCaptureIndicator(); |
| bool is_capturing_audio = indicator->IsCapturingAudio(web_contents_); |
| - if (is_capturing_audio != is_capturing_audio_) |
| - ui_->SetAudioCapturingIndicator(is_capturing_audio); |
| + if (is_capturing_audio != is_capturing_audio_) { |
| + 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.
|
| + if (number_of_tabs_capturing_audio_ > 0) |
| + ui_->SetAudioCapturingIndicator(true); |
| + else |
| + ui_->SetAudioCapturingIndicator(false); |
| + } |
| is_capturing_audio_ = is_capturing_audio; |
| bool is_capturing_video = indicator->IsCapturingVideo(web_contents_); |
| - if (is_capturing_video != is_capturing_video_) |
| - ui_->SetVideoCapturingIndicator(is_capturing_video); |
| + if (is_capturing_video != is_capturing_video_) { |
| + number_of_tabs_capturing_video_ += is_capturing_video ? 1 : -1; |
| + if (number_of_tabs_capturing_video_ > 0) |
| + ui_->SetVideoCapturingIndicator(true); |
| + else |
| + ui_->SetVideoCapturingIndicator(false); |
| + } |
| is_capturing_video_ = is_capturing_video; |
| bool is_capturing_screen = indicator->IsBeingMirrored(web_contents_); |
| - if (is_capturing_screen != is_capturing_screen_) |
| - ui_->SetScreenCapturingIndicator(is_capturing_screen); |
| + if (is_capturing_screen != is_capturing_screen_) { |
| + number_of_tabs_capturing_screen_ += is_capturing_screen ? 1 : -1; |
| + if (number_of_tabs_capturing_screen_ > 0) |
| + ui_->SetScreenCapturingIndicator(true); |
| + else |
| + ui_->SetScreenCapturingIndicator(false); |
| + } |
| is_capturing_screen_ = is_capturing_screen; |
| } |