Skip to content

Commit

Permalink
feat: Exposing methods required by capturing a hidden webContents
Browse files Browse the repository at this point in the history
  • Loading branch information
zeeker999 committed Jan 5, 2020
1 parent 1abd24a commit 0361991
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
28 changes: 28 additions & 0 deletions shell/browser/api/atom_api_web_contents.cc
Expand Up @@ -2215,6 +2215,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 rect arguments if they exist
args->GetNext(&size);
// get stay_hidden 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 stay_hidden 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();

Expand Down Expand Up @@ -2591,6 +2616,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",
Expand Down
3 changes: 3 additions & 0 deletions shell/browser/api/atom_api_web_contents.h
Expand Up @@ -181,6 +181,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);
Expand Down

0 comments on commit 0361991

Please sign in to comment.