Commit 196185bb authored by Marina Ciocea's avatar Marina Ciocea Committed by Commit Bot

Display tab capture status icon on the shared tab.

Register the shared tab with MediaStreamCaptureIndicator, to indicate
that the shared tab is being captured.

Bug: 980110
Change-Id: Ib81567f59ae9d978e57ebd481fb7ac41dd207e18
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1796671Reviewed-by: default avatarGuido Urdaneta <guidou@chromium.org>
Commit-Queue: Marina Ciocea <marinaciocea@chromium.org>
Cr-Commit-Position: refs/heads/master@{#695652}
parent 713a74a5
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "chrome/browser/infobars/infobar_service.h" #include "chrome/browser/infobars/infobar_service.h"
#include "chrome/browser/media/webrtc/media_capture_devices_dispatcher.h"
#include "chrome/browser/profiles/profile_manager.h" #include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_finder.h" #include "chrome/browser/ui/browser_finder.h"
...@@ -104,7 +105,7 @@ std::unique_ptr<TabSharingUI> TabSharingUI::Create( ...@@ -104,7 +105,7 @@ std::unique_ptr<TabSharingUI> TabSharingUI::Create(
TabSharingUIViews::TabSharingUIViews(const content::DesktopMediaID& media_id, TabSharingUIViews::TabSharingUIViews(const content::DesktopMediaID& media_id,
base::string16 app_name) base::string16 app_name)
: app_name_(std::move(app_name)) { : shared_tab_media_id_(media_id), app_name_(std::move(app_name)) {
shared_tab_ = content::WebContents::FromRenderFrameHost( shared_tab_ = content::WebContents::FromRenderFrameHost(
content::RenderFrameHost::FromID( content::RenderFrameHost::FromID(
media_id.web_contents_id.render_process_id, media_id.web_contents_id.render_process_id,
...@@ -126,6 +127,7 @@ gfx::NativeViewId TabSharingUIViews::OnStarted( ...@@ -126,6 +127,7 @@ gfx::NativeViewId TabSharingUIViews::OnStarted(
stop_callback_ = std::move(stop_callback); stop_callback_ = std::move(stop_callback);
CreateInfobarsForAllTabs(); CreateInfobarsForAllTabs();
SetContentsBorderVisible(shared_tab_, true); SetContentsBorderVisible(shared_tab_, true);
CreateTabCaptureIndicator();
return 0; return 0;
} }
...@@ -265,3 +267,14 @@ void TabSharingUIViews::RemoveInfobarsForAllTabs() { ...@@ -265,3 +267,14 @@ void TabSharingUIViews::RemoveInfobarsForAllTabs() {
infobars_.clear(); infobars_.clear();
} }
void TabSharingUIViews::CreateTabCaptureIndicator() {
const blink::MediaStreamDevice device(
blink::mojom::MediaStreamType::GUM_TAB_VIDEO_CAPTURE,
shared_tab_media_id_.ToString(), std::string());
tab_capture_indicator_ui_ = MediaCaptureDevicesDispatcher::GetInstance()
->GetMediaStreamCaptureIndicator()
->RegisterMediaStream(shared_tab_, {device});
tab_capture_indicator_ui_->OnStarted(
base::OnceClosure(), content::MediaStreamUI::SourceCallback());
}
...@@ -74,11 +74,15 @@ class TabSharingUIViews : public TabSharingUI, ...@@ -74,11 +74,15 @@ class TabSharingUIViews : public TabSharingUI,
void CreateInfobarForWebContents(content::WebContents* contents); void CreateInfobarForWebContents(content::WebContents* contents);
void RemoveInfobarsForAllTabs(); void RemoveInfobarsForAllTabs();
void CreateTabCaptureIndicator();
std::map<content::WebContents*, infobars::InfoBar*> infobars_; std::map<content::WebContents*, infobars::InfoBar*> infobars_;
content::DesktopMediaID shared_tab_media_id_;
const base::string16 app_name_; const base::string16 app_name_;
content::WebContents* shared_tab_; content::WebContents* shared_tab_;
base::string16 shared_tab_name_; base::string16 shared_tab_name_;
Profile* profile_; Profile* profile_;
std::unique_ptr<content::MediaStreamUI> tab_capture_indicator_ui_;
content::MediaStreamUI::SourceCallback source_callback_; content::MediaStreamUI::SourceCallback source_callback_;
base::OnceClosure stop_callback_; base::OnceClosure stop_callback_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment