Add OS process id to web-contents

This commit is contained in:
Alexandre Lachèze 2017-04-18 12:31:20 +02:00
parent 0c1d60381d
commit f375e8a7db
2 changed files with 9 additions and 0 deletions

View file

@ -46,6 +46,7 @@
#include "chrome/browser/printing/print_preview_message_handler.h" #include "chrome/browser/printing/print_preview_message_handler.h"
#include "chrome/browser/printing/print_view_manager_basic.h" #include "chrome/browser/printing/print_view_manager_basic.h"
#include "chrome/browser/ssl/security_state_tab_helper.h" #include "chrome/browser/ssl/security_state_tab_helper.h"
#include "base/process/process_handle.h"
#include "content/browser/frame_host/navigation_entry_impl.h" #include "content/browser/frame_host/navigation_entry_impl.h"
#include "content/browser/renderer_host/render_widget_host_impl.h" #include "content/browser/renderer_host/render_widget_host_impl.h"
#include "content/browser/web_contents/web_contents_impl.h" #include "content/browser/web_contents/web_contents_impl.h"
@ -77,6 +78,7 @@
#include "third_party/WebKit/public/web/WebFindOptions.h" #include "third_party/WebKit/public/web/WebFindOptions.h"
#include "ui/display/screen.h" #include "ui/display/screen.h"
#if !defined(OS_MACOSX) #if !defined(OS_MACOSX)
#include "ui/aura/window.h" #include "ui/aura/window.h"
#endif #endif
@ -959,6 +961,11 @@ int WebContents::GetProcessID() const {
return web_contents()->GetRenderProcessHost()->GetID(); return web_contents()->GetRenderProcessHost()->GetID();
} }
int WebContents::GetOSProcessID() const {
auto process_handle = web_contents()->GetRenderProcessHost()->GetHandle();
return base::GetProcId(process_handle);
}
WebContents::Type WebContents::GetType() const { WebContents::Type WebContents::GetType() const {
return type_; return type_;
} }
@ -1708,6 +1715,7 @@ void WebContents::BuildPrototype(v8::Isolate* isolate,
.MakeDestroyable() .MakeDestroyable()
.SetMethod("getId", &WebContents::GetID) .SetMethod("getId", &WebContents::GetID)
.SetMethod("getProcessId", &WebContents::GetProcessID) .SetMethod("getProcessId", &WebContents::GetProcessID)
.SetMethod("getOSProcessId", &WebContents::GetOSProcessID)
.SetMethod("equal", &WebContents::Equal) .SetMethod("equal", &WebContents::Equal)
.SetMethod("_loadURL", &WebContents::LoadURL) .SetMethod("_loadURL", &WebContents::LoadURL)
.SetMethod("downloadURL", &WebContents::DownloadURL) .SetMethod("downloadURL", &WebContents::DownloadURL)

View file

@ -82,6 +82,7 @@ class WebContents : public mate::TrackableObject<WebContents>,
int64_t GetID() const; int64_t GetID() const;
int GetProcessID() const; int GetProcessID() const;
int GetOSProcessID() const;
Type GetType() const; Type GetType() const;
bool Equal(const WebContents* web_contents) const; bool Equal(const WebContents* web_contents) const;
void LoadURL(const GURL& url, const mate::Dictionary& options); void LoadURL(const GURL& url, const mate::Dictionary& options);