feat: add osProcessId / name properties to webFrameMain (#26093)

* feat: add osProcessId / name properties to webFrameMain

* Update docs/api/web-frame-main.md

Co-authored-by: Jeremy Rose <jeremya@chromium.org>

Co-authored-by: Jeremy Rose <jeremya@chromium.org>
This commit is contained in:
Milan Burda 2020-10-26 04:03:34 +01:00 committed by GitHub
parent 30b5e15ddc
commit aa157c3f05
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 32 additions and 18 deletions

View file

@ -1590,18 +1590,6 @@ base::ProcessId WebContents::GetOSProcessID() const {
return base::GetProcId(process_handle);
}
base::ProcessId WebContents::GetOSProcessIdForFrame(
const std::string& name,
const std::string& document_url) const {
for (auto* frame : web_contents()->GetAllFrames()) {
if (frame->GetFrameName() == name &&
frame->GetLastCommittedURL().spec() == document_url) {
return base::GetProcId(frame->GetProcess()->GetProcess().Handle());
}
}
return base::kNullProcessId;
}
WebContents::Type WebContents::GetType() const {
return type_;
}
@ -2941,8 +2929,6 @@ v8::Local<v8::ObjectTemplate> WebContents::FillObjectTemplate(
&WebContents::SetBackgroundThrottling)
.SetMethod("getProcessId", &WebContents::GetProcessID)
.SetMethod("getOSProcessId", &WebContents::GetOSProcessID)
.SetMethod("_getOSProcessIdForFrame",
&WebContents::GetOSProcessIdForFrame)
.SetMethod("equal", &WebContents::Equal)
.SetMethod("_loadURL", &WebContents::LoadURL)
.SetMethod("downloadURL", &WebContents::DownloadURL)

View file

@ -209,8 +209,6 @@ class WebContents : public gin::Wrappable<WebContents>,
void SetBackgroundThrottling(bool allowed);
int GetProcessID() const;
base::ProcessId GetOSProcessID() const;
base::ProcessId GetOSProcessIdForFrame(const std::string& name,
const std::string& document_url) const;
Type GetType() const;
bool Equal(const WebContents* web_contents) const;
void LoadURL(const GURL& url, const gin_helper::Dictionary& options);

View file

@ -120,6 +120,20 @@ int WebFrameMain::FrameTreeNodeID(v8::Isolate* isolate) const {
return render_frame_->GetFrameTreeNodeId();
}
std::string WebFrameMain::Name(v8::Isolate* isolate) const {
if (!CheckRenderFrame())
return std::string();
return render_frame_->GetFrameName();
}
base::ProcessId WebFrameMain::OSProcessID(v8::Isolate* isolate) const {
if (!CheckRenderFrame())
return -1;
base::ProcessHandle process_handle =
render_frame_->GetProcess()->GetProcess().Handle();
return base::GetProcId(process_handle);
}
int WebFrameMain::ProcessID(v8::Isolate* isolate) const {
if (!CheckRenderFrame())
return -1;
@ -210,6 +224,8 @@ gin::ObjectTemplateBuilder WebFrameMain::GetObjectTemplateBuilder(
.SetMethod("executeJavaScript", &WebFrameMain::ExecuteJavaScript)
.SetMethod("reload", &WebFrameMain::Reload)
.SetProperty("frameTreeNodeId", &WebFrameMain::FrameTreeNodeID)
.SetProperty("name", &WebFrameMain::Name)
.SetProperty("osProcessId", &WebFrameMain::OSProcessID)
.SetProperty("processId", &WebFrameMain::ProcessID)
.SetProperty("routingId", &WebFrameMain::RoutingID)
.SetProperty("url", &WebFrameMain::URL)

View file

@ -9,6 +9,7 @@
#include <string>
#include <vector>
#include "base/process/process.h"
#include "gin/handle.h"
#include "gin/wrappable.h"
@ -68,6 +69,8 @@ class WebFrameMain : public gin::Wrappable<WebFrameMain> {
bool Reload(v8::Isolate* isolate);
int FrameTreeNodeID(v8::Isolate* isolate) const;
std::string Name(v8::Isolate* isolate) const;
base::ProcessId OSProcessID(v8::Isolate* isolate) const;
int ProcessID(v8::Isolate* isolate) const;
int RoutingID(v8::Isolate* isolate) const;
GURL URL(v8::Isolate* isolate) const;