Add webContents.isFocused()

This commit is contained in:
Kevin Sawicki 2016-07-13 08:54:40 -07:00
parent 6d2e633c82
commit 7877fa7c0a
5 changed files with 43 additions and 0 deletions

View file

@ -789,6 +789,13 @@ WebContents::Type WebContents::GetType() const {
return type_;
}
#if !defined(OS_MACOSX)
bool WebContents::IsFocused() const {
auto view = web_contents()->GetRenderWidgetHostView();
return view && view->HasFocus();
}
#endif
bool WebContents::Equal(const WebContents* web_contents) const {
return GetID() == web_contents->GetID();
}
@ -1418,6 +1425,7 @@ void WebContents::BuildPrototype(v8::Isolate* isolate,
.SetMethod("showDefinitionForSelection",
&WebContents::ShowDefinitionForSelection)
.SetMethod("capturePage", &WebContents::CapturePage)
.SetMethod("isFocused", &WebContents::IsFocused)
.SetProperty("id", &WebContents::ID)
.SetProperty("session", &WebContents::Session)
.SetProperty("hostWebContents", &WebContents::HostWebContents)