electron/patches/chromium/desktop_media_list.patch

119 строки
5.9 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: deepak1556 <hop2deep@gmail.com>
Date: Thu, 18 Oct 2018 17:07:01 -0700
Subject: desktop_media_list.patch
* Use our grit resources instead of the chrome ones.
* Disabled WindowCaptureMacV2 feature for https://github.com/electron/electron/pull/30507
* Ensure "OnRefreshComplete()" even if there are no items in the list
diff --git a/chrome/browser/media/webrtc/desktop_media_list.h b/chrome/browser/media/webrtc/desktop_media_list.h
index 2892ec2c97b6a49b696f155780900e5c4654b051..c559ad5e07344281e61148eff3b63a131144fed2 100644
--- a/chrome/browser/media/webrtc/desktop_media_list.h
+++ b/chrome/browser/media/webrtc/desktop_media_list.h
@@ -107,7 +107,8 @@ class DesktopMediaList {
// once per DesktopMediaList instance. It should not be called after
// StartUpdating(), and StartUpdating() should not be called until |callback|
// has been called.
- virtual void Update(UpdateCallback callback) = 0;
+ virtual void Update(UpdateCallback callback,
+ bool refresh_thumbnails = false) = 0;
virtual int GetSourceCount() const = 0;
virtual const Source& GetSource(int index) const = 0;
diff --git a/chrome/browser/media/webrtc/desktop_media_list_base.cc b/chrome/browser/media/webrtc/desktop_media_list_base.cc
index c49e83d5ea1e8425156f0be482ec9061544db9bd..549e5a3a900c8aca83e64ea000a13e8377d28227 100644
--- a/chrome/browser/media/webrtc/desktop_media_list_base.cc
+++ b/chrome/browser/media/webrtc/desktop_media_list_base.cc
@@ -69,12 +69,12 @@ void DesktopMediaListBase::StartUpdating(DesktopMediaListObserver* observer) {
Refresh(true);
}
-void DesktopMediaListBase::Update(UpdateCallback callback) {
+void DesktopMediaListBase::Update(UpdateCallback callback, bool refresh_thumbnails) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
DCHECK(sources_.empty());
DCHECK(!refresh_callback_);
refresh_callback_ = std::move(callback);
- Refresh(false);
+ Refresh(refresh_thumbnails);
}
int DesktopMediaListBase::GetSourceCount() const {
diff --git a/chrome/browser/media/webrtc/desktop_media_list_base.h b/chrome/browser/media/webrtc/desktop_media_list_base.h
index 202cfa1df6a540fb6e13ef06b43bdabba5535599..94ed6bf35606fe22c4c58cbb4ed6668f84247d52 100644
--- a/chrome/browser/media/webrtc/desktop_media_list_base.h
+++ b/chrome/browser/media/webrtc/desktop_media_list_base.h
@@ -39,7 +39,7 @@ class DesktopMediaListBase : public DesktopMediaList {
void SetThumbnailSize(const gfx::Size& thumbnail_size) override;
void SetViewDialogWindowId(content::DesktopMediaID dialog_id) override;
void StartUpdating(DesktopMediaListObserver* observer) override;
- void Update(UpdateCallback callback) override;
+ void Update(UpdateCallback callback, bool refresh_thumbnails) override;
int GetSourceCount() const override;
const Source& GetSource(int index) const override;
DesktopMediaList::Type GetMediaListType() const override;
diff --git a/chrome/browser/media/webrtc/fake_desktop_media_list.cc b/chrome/browser/media/webrtc/fake_desktop_media_list.cc
index 1b977da7ff9e2ac86ce131da0dd0c6f3b6a69448..f94b818d3de71cb9a5521186611452c086d56608 100644
--- a/chrome/browser/media/webrtc/fake_desktop_media_list.cc
+++ b/chrome/browser/media/webrtc/fake_desktop_media_list.cc
@@ -79,7 +79,8 @@ void FakeDesktopMediaList::StartUpdating(DesktopMediaListObserver* observer) {
thumbnail_ = gfx::ImageSkia::CreateFrom1xBitmap(bitmap);
}
-void FakeDesktopMediaList::Update(UpdateCallback callback) {
+void FakeDesktopMediaList::Update(UpdateCallback callback,
+ bool refresh_thumbnails) {
std::move(callback).Run();
}
diff --git a/chrome/browser/media/webrtc/fake_desktop_media_list.h b/chrome/browser/media/webrtc/fake_desktop_media_list.h
index 33ca7a53dfb6d2c9e3a33f0065a3acd806e82e01..9fdf2e8ff0056ff407015b914c6b03eb6e25e0e4 100644
--- a/chrome/browser/media/webrtc/fake_desktop_media_list.h
+++ b/chrome/browser/media/webrtc/fake_desktop_media_list.h
@@ -40,7 +40,8 @@ class FakeDesktopMediaList : public DesktopMediaList {
void SetThumbnailSize(const gfx::Size& thumbnail_size) override;
void SetViewDialogWindowId(content::DesktopMediaID dialog_id) override;
void StartUpdating(DesktopMediaListObserver* observer) override;
- void Update(UpdateCallback callback) override;
+ void Update(UpdateCallback callback,
+ bool refresh_thumbnails = false) override;
int GetSourceCount() const override;
const Source& GetSource(int index) const override;
DesktopMediaList::Type GetMediaListType() const override;
diff --git a/chrome/browser/media/webrtc/native_desktop_media_list.cc b/chrome/browser/media/webrtc/native_desktop_media_list.cc
index 4da983eee1abad065dd8a76a7efd308ef5897a09..5c34fda5db161ad1e563a953995bfe06f902b53f 100644
--- a/chrome/browser/media/webrtc/native_desktop_media_list.cc
+++ b/chrome/browser/media/webrtc/native_desktop_media_list.cc
@@ -142,7 +142,7 @@ BOOL CALLBACK AllHwndCollector(HWND hwnd, LPARAM param) {
#if BUILDFLAG(IS_MAC)
BASE_FEATURE(kWindowCaptureMacV2,
"WindowCaptureMacV2",
- base::FEATURE_ENABLED_BY_DEFAULT);
+ base::FEATURE_DISABLED_BY_DEFAULT);
#endif
} // namespace
@@ -452,6 +452,9 @@ void NativeDesktopMediaList::Worker::RefreshNextThumbnail() {
FROM_HERE,
base::BindOnce(&NativeDesktopMediaList::UpdateNativeThumbnailsFinished,
media_list_));
+
+ // This call is necessary to release underlying OS screen capture mechanisms.
+ capturer_.reset();
}
void NativeDesktopMediaList::Worker::OnCaptureResult(
@@ -824,6 +827,11 @@ void NativeDesktopMediaList::RefreshForVizFrameSinkWindows(
FROM_HERE, base::BindOnce(&Worker::RefreshThumbnails,
base::Unretained(worker_.get()),
std::move(native_ids), thumbnail_size_));
+ } else {
+#if defined(USE_AURA)
+ pending_native_thumbnail_capture_ = true;
+#endif
+ UpdateNativeThumbnailsFinished();
}
}