feat: Exposing methods required by capturing a hidden webContents (#21679)
This commit is contained in:
Родитель
8103ded33e
Коммит
852b8693bd
|
@ -1225,6 +1225,29 @@ Returns `Promise<NativeImage>` - Resolves with a [NativeImage](native-image.md)
|
|||
|
||||
Captures a snapshot of the page within `rect`. Omitting `rect` will capture the whole visible page.
|
||||
|
||||
#### `contents.isBeingCaptured()`
|
||||
|
||||
Returns `Boolean` - Whether this page is being captured. It returns true when the capturer count
|
||||
is large then 0.
|
||||
|
||||
#### `contents.incrementCapturerCount([size, stayHidden])`
|
||||
|
||||
* `size` [Size](structures/size.md) (optional) - The perferred size for the capturer.
|
||||
* `stayHidden` Boolean (optional) - Keep the page hidden instead of visible.
|
||||
|
||||
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])`
|
||||
|
||||
* `stayHidden` Boolean (optional) - Keep the page in hidden state instead of visible.
|
||||
|
||||
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
|
||||
decrease the hidden capturer count instead you should set `stayHidden` to true.
|
||||
|
||||
#### `contents.getPrinters()`
|
||||
|
||||
Get the system printer list.
|
||||
|
|
|
@ -2222,6 +2222,31 @@ v8::Local<v8::Promise> WebContents::CapturePage(gin_helper::Arguments* args) {
|
|||
return handle;
|
||||
}
|
||||
|
||||
void WebContents::IncrementCapturerCount(gin_helper::Arguments* args) {
|
||||
gfx::Size size;
|
||||
bool stay_hidden = false;
|
||||
|
||||
// get size arguments if they exist
|
||||
args->GetNext(&size);
|
||||
// get stayHidden arguments if they exist
|
||||
args->GetNext(&stay_hidden);
|
||||
|
||||
web_contents()->IncrementCapturerCount(size, stay_hidden);
|
||||
}
|
||||
|
||||
void WebContents::DecrementCapturerCount(gin_helper::Arguments* args) {
|
||||
bool stay_hidden = false;
|
||||
|
||||
// get stayHidden arguments if they exist
|
||||
args->GetNext(&stay_hidden);
|
||||
|
||||
web_contents()->DecrementCapturerCount(stay_hidden);
|
||||
}
|
||||
|
||||
bool WebContents::IsBeingCaptured() {
|
||||
return web_contents()->IsBeingCaptured();
|
||||
}
|
||||
|
||||
void WebContents::OnCursorChange(const content::WebCursor& cursor) {
|
||||
const content::CursorInfo& info = cursor.info();
|
||||
|
||||
|
@ -2598,6 +2623,9 @@ void WebContents::BuildPrototype(v8::Isolate* isolate,
|
|||
.SetMethod("setEmbedder", &WebContents::SetEmbedder)
|
||||
.SetMethod("setDevToolsWebContents", &WebContents::SetDevToolsWebContents)
|
||||
.SetMethod("getNativeView", &WebContents::GetNativeView)
|
||||
.SetMethod("incrementCapturerCount", &WebContents::IncrementCapturerCount)
|
||||
.SetMethod("decrementCapturerCount", &WebContents::DecrementCapturerCount)
|
||||
.SetMethod("isBeingCaptured", &WebContents::IsBeingCaptured)
|
||||
.SetMethod("setWebRTCIPHandlingPolicy",
|
||||
&WebContents::SetWebRTCIPHandlingPolicy)
|
||||
.SetMethod("getWebRTCIPHandlingPolicy",
|
||||
|
|
|
@ -185,6 +185,9 @@ class WebContents : public gin_helper::TrackableObject<WebContents>,
|
|||
void SetEmbedder(const WebContents* embedder);
|
||||
void SetDevToolsWebContents(const WebContents* devtools);
|
||||
v8::Local<v8::Value> GetNativeView() const;
|
||||
void IncrementCapturerCount(gin_helper::Arguments* args);
|
||||
void DecrementCapturerCount(gin_helper::Arguments* args);
|
||||
bool IsBeingCaptured();
|
||||
|
||||
#if BUILDFLAG(ENABLE_PRINTING)
|
||||
void Print(gin_helper::Arguments* args);
|
||||
|
|
Загрузка…
Ссылка в новой задаче