diff --git a/atom/browser/api/atom_api_web_contents.cc b/atom/browser/api/atom_api_web_contents.cc index 120bfe52b3..60856d029b 100644 --- a/atom/browser/api/atom_api_web_contents.cc +++ b/atom/browser/api/atom_api_web_contents.cc @@ -1123,6 +1123,14 @@ const GURL& WebContents::GetURLAtIndex(int index) const { return GURL::EmptyGURL(); } +const base::string16 WebContents::GetTitleAtIndex(int index) const { + auto entry = web_contents()->GetController().GetEntryAtIndex(index); + if (entry) + return entry->GetTitle(); + else + return base::string16(); +} + // TODO(bridiver) there should be a more generic way // to set renderer preferences in general const std::string& WebContents::GetWebRTCIPHandlingPolicy() const { @@ -1710,6 +1718,7 @@ void WebContents::BuildPrototype(v8::Isolate* isolate, .SetMethod("canGoForward", &WebContents::CanGoForward) .SetMethod("canGoToOffset", &WebContents::CanGoToOffset) .SetMethod("getURLAtIndex", &WebContents::GetURLAtIndex) + .SetMethod("getTitleAtIndex", &WebContents::GetTitleAtIndex) .SetMethod("getEntryCount", &WebContents::GetEntryCount) .SetMethod("getCurrentEntryIndex", &WebContents::GetCurrentEntryIndex) .SetMethod("getLastCommittedEntryIndex", diff --git a/atom/browser/api/atom_api_web_contents.h b/atom/browser/api/atom_api_web_contents.h index de03c038dc..508c42363f 100644 --- a/atom/browser/api/atom_api_web_contents.h +++ b/atom/browser/api/atom_api_web_contents.h @@ -113,6 +113,7 @@ class WebContents : public mate::TrackableObject, bool CanGoForward() const; void GoToIndex(int index); const GURL& GetURLAtIndex(int index) const; + const base::string16 GetTitleAtIndex(int index) const; int GetCurrentEntryIndex() const; int GetLastCommittedEntryIndex() const; int GetEntryCount() const;