fix: check screen capture permissions in desktopCapturer
(#43271)
fix: check screen capture permissions in desktopCapturer Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
This commit is contained in:
parent
c3a7f0001c
commit
10dd33c16e
2 changed files with 24 additions and 8 deletions
|
@ -41,6 +41,10 @@
|
||||||
#include "ui/gfx/x/randr.h"
|
#include "ui/gfx/x/randr.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if BUILDFLAG(IS_MAC)
|
||||||
|
#include "ui/base/cocoa/permissions_utils.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#if BUILDFLAG(IS_LINUX)
|
#if BUILDFLAG(IS_LINUX)
|
||||||
// Private function in ui/base/x/x11_display_util.cc
|
// Private function in ui/base/x/x11_display_util.cc
|
||||||
base::flat_map<x11::RandR::Output, int> GetMonitors(
|
base::flat_map<x11::RandR::Output, int> GetMonitors(
|
||||||
|
@ -304,6 +308,13 @@ void DesktopCapturer::StartHandling(bool capture_window,
|
||||||
capture_window_ = capture_window;
|
capture_window_ = capture_window;
|
||||||
capture_screen_ = capture_screen;
|
capture_screen_ = capture_screen;
|
||||||
|
|
||||||
|
#if BUILDFLAG(IS_MAC)
|
||||||
|
if (!ui::TryPromptUserForScreenCapture()) {
|
||||||
|
HandleFailure();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
{
|
{
|
||||||
// Initialize the source list.
|
// Initialize the source list.
|
||||||
// Apply the new thumbnail size and restart capture.
|
// Apply the new thumbnail size and restart capture.
|
||||||
|
@ -455,21 +466,25 @@ void DesktopCapturer::UpdateSourcesList(DesktopMediaList* list) {
|
||||||
std::back_inserter(captured_sources_));
|
std::back_inserter(captured_sources_));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!capture_window_ && !capture_screen_) {
|
if (!capture_window_ && !capture_screen_)
|
||||||
v8::Isolate* isolate = JavascriptEnvironment::GetIsolate();
|
HandleSuccess();
|
||||||
v8::HandleScope scope(isolate);
|
}
|
||||||
gin_helper::CallMethod(this, "_onfinished", captured_sources_);
|
|
||||||
|
|
||||||
screen_capturer_.reset();
|
void DesktopCapturer::HandleSuccess() {
|
||||||
window_capturer_.reset();
|
v8::Isolate* isolate = JavascriptEnvironment::GetIsolate();
|
||||||
|
v8::HandleScope scope(isolate);
|
||||||
|
gin_helper::CallMethod(this, "_onfinished", captured_sources_);
|
||||||
|
|
||||||
Unpin();
|
screen_capturer_.reset();
|
||||||
}
|
window_capturer_.reset();
|
||||||
|
|
||||||
|
Unpin();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DesktopCapturer::HandleFailure() {
|
void DesktopCapturer::HandleFailure() {
|
||||||
v8::Isolate* isolate = JavascriptEnvironment::GetIsolate();
|
v8::Isolate* isolate = JavascriptEnvironment::GetIsolate();
|
||||||
v8::HandleScope scope(isolate);
|
v8::HandleScope scope(isolate);
|
||||||
|
|
||||||
gin_helper::CallMethod(this, "_onerror", "Failed to get sources.");
|
gin_helper::CallMethod(this, "_onerror", "Failed to get sources.");
|
||||||
|
|
||||||
screen_capturer_.reset();
|
screen_capturer_.reset();
|
||||||
|
|
|
@ -90,6 +90,7 @@ class DesktopCapturer : public gin::Wrappable<DesktopCapturer>,
|
||||||
|
|
||||||
void UpdateSourcesList(DesktopMediaList* list);
|
void UpdateSourcesList(DesktopMediaList* list);
|
||||||
void HandleFailure();
|
void HandleFailure();
|
||||||
|
void HandleSuccess();
|
||||||
|
|
||||||
std::unique_ptr<DesktopListListener> window_listener_;
|
std::unique_ptr<DesktopListListener> window_listener_;
|
||||||
std::unique_ptr<DesktopListListener> screen_listener_;
|
std::unique_ptr<DesktopListListener> screen_listener_;
|
||||||
|
|
Loading…
Reference in a new issue