mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
2807829: Allow capturers to indicate if they want a WakeLock or not.
https://chromium-review.googlesource.com/c/chromium/src/+/2807829
This commit is contained in:
committed by
Samuel Attard
parent
c8a7225cac
commit
39f0c263d7
@@ -1313,19 +1313,21 @@ Captures a snapshot of the page within `rect`. Omitting `rect` will capture the
|
||||
Returns `Boolean` - Whether this page is being captured. It returns true when the capturer count
|
||||
is large then 0.
|
||||
|
||||
#### `contents.incrementCapturerCount([size, stayHidden])`
|
||||
#### `contents.incrementCapturerCount([size, stayHidden, stayAwake])`
|
||||
|
||||
* `size` [Size](structures/size.md) (optional) - The preferred size for the capturer.
|
||||
* `stayHidden` Boolean (optional) - Keep the page hidden instead of visible.
|
||||
* `stayAwake` Boolean (optional) - Keep the system awake instead of allowing it to sleep.
|
||||
|
||||
Increase the capturer count by one. The page is considered visible when its browser window is
|
||||
hidden and the capturer count is non-zero. If you would like the page to stay hidden, you should ensure that `stayHidden` is set to true.
|
||||
|
||||
This also affects the Page Visibility API.
|
||||
|
||||
#### `contents.decrementCapturerCount([stayHidden])`
|
||||
#### `contents.decrementCapturerCount([stayHidden, stayAwake])`
|
||||
|
||||
* `stayHidden` Boolean (optional) - Keep the page in hidden state instead of visible.
|
||||
* `stayAwake` Boolean (optional) - Keep the system awake instead of allowing it to sleep.
|
||||
|
||||
Decrease the capturer count by one. The page will be set to hidden or occluded state when its
|
||||
browser window is hidden or occluded and the capturer count reaches zero. If you want to
|
||||
|
||||
@@ -105,3 +105,4 @@ fix_route_mouse_event_navigations_through_the_web_contents_delegate.patch
|
||||
disable_unload_metrics.patch
|
||||
fix_add_check_for_sandbox_then_result.patch
|
||||
moves_background_color_setter_of_webview_to_blinks_webprefs_logic.patch
|
||||
fix_expose_decrementcapturercount_in_web_contents_impl.patch
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Shelley Vohr <shelley.vohr@gmail.com>
|
||||
Date: Fri, 9 Apr 2021 19:30:01 +0200
|
||||
Subject: fix: expose DecrementCapturerCount in web_contents_impl
|
||||
|
||||
This was made private in https://chromium-review.googlesource.com/c/chromium/src/+/2807829 but
|
||||
we invoke it in order to expose contents.decrementCapturerCount([stayHidden, stayAwake])
|
||||
to users. We should try to upstream this.
|
||||
|
||||
diff --git a/content/browser/web_contents/web_contents_impl.h b/content/browser/web_contents/web_contents_impl.h
|
||||
index 43b6f3bb996a296f6f6619eff60c84c2a1dc0da5..847403381e87d2bba3af254610347f4bf96b3c56 100644
|
||||
--- a/content/browser/web_contents/web_contents_impl.h
|
||||
+++ b/content/browser/web_contents/web_contents_impl.h
|
||||
@@ -394,6 +394,9 @@ class CONTENT_EXPORT WebContentsImpl : public WebContents,
|
||||
const gfx::Size& capture_size,
|
||||
bool stay_hidden,
|
||||
bool stay_awake) override WARN_UNUSED_RESULT;
|
||||
+ // Called when the base::ScopedClosureRunner returned by
|
||||
+ // IncrementCapturerCount() is destructed.
|
||||
+ void DecrementCapturerCount(bool stay_hidden, bool stay_awake) override;
|
||||
bool IsBeingCaptured() override;
|
||||
bool IsBeingVisiblyCaptured() override;
|
||||
bool IsAudioMuted() override;
|
||||
@@ -1707,10 +1710,6 @@ class CONTENT_EXPORT WebContentsImpl : public WebContents,
|
||||
// shown in the address bar), as opposed to one in for example a Prerender.
|
||||
bool IsPrimaryFrameTree(const FrameTree& frame_tree) const;
|
||||
|
||||
- // Called when the base::ScopedClosureRunner returned by
|
||||
- // IncrementCapturerCount() is destructed.
|
||||
- void DecrementCapturerCount(bool stay_hidden, bool stay_awake);
|
||||
-
|
||||
// Data for core operation ---------------------------------------------------
|
||||
|
||||
// Delegate for notifying our owner about stuff. Not owned by us.
|
||||
diff --git a/content/public/browser/web_contents.h b/content/public/browser/web_contents.h
|
||||
index 9d089057f886c7b6b10ded3c2b37f5580f3b67f7..517d5e18e064f23aebd3eed0e6c0a5e41a32c863 100644
|
||||
--- a/content/public/browser/web_contents.h
|
||||
+++ b/content/public/browser/web_contents.h
|
||||
@@ -570,6 +570,7 @@ class WebContents : public PageNavigator,
|
||||
const gfx::Size& capture_size,
|
||||
bool stay_hidden,
|
||||
bool stay_awake) WARN_UNUSED_RESULT = 0;
|
||||
+ virtual void DecrementCapturerCount(bool stay_hidden, bool stay_awake) = 0;
|
||||
|
||||
// Returns true if audio/screenshot/video is being captured by the embedder,
|
||||
// as indicated by calls to IncrementCapturerCount().
|
||||
@@ -2812,22 +2812,29 @@ v8::Local<v8::Promise> WebContents::CapturePage(gin::Arguments* args) {
|
||||
void WebContents::IncrementCapturerCount(gin::Arguments* args) {
|
||||
gfx::Size size;
|
||||
bool stay_hidden = false;
|
||||
bool stay_awake = false;
|
||||
|
||||
// get size arguments if they exist
|
||||
args->GetNext(&size);
|
||||
// get stayHidden arguments if they exist
|
||||
args->GetNext(&stay_hidden);
|
||||
// get stayAwake arguments if they exist
|
||||
args->GetNext(&stay_awake);
|
||||
|
||||
web_contents()->IncrementCapturerCount(size, stay_hidden);
|
||||
ignore_result(
|
||||
web_contents()->IncrementCapturerCount(size, stay_hidden, stay_awake));
|
||||
}
|
||||
|
||||
void WebContents::DecrementCapturerCount(gin::Arguments* args) {
|
||||
bool stay_hidden = false;
|
||||
bool stay_awake = false;
|
||||
|
||||
// get stayHidden arguments if they exist
|
||||
args->GetNext(&stay_hidden);
|
||||
// get stayAwake arguments if they exist
|
||||
args->GetNext(&stay_awake);
|
||||
|
||||
web_contents()->DecrementCapturerCount(stay_hidden);
|
||||
web_contents()->DecrementCapturerCount(stay_hidden, stay_awake);
|
||||
}
|
||||
|
||||
bool WebContents::IsBeingCaptured() {
|
||||
|
||||
Reference in New Issue
Block a user