diff --git a/atom/browser/api/atom_api_web_contents.cc b/atom/browser/api/atom_api_web_contents.cc index a9538167519b..4c76f5349eb5 100644 --- a/atom/browser/api/atom_api_web_contents.cc +++ b/atom/browser/api/atom_api_web_contents.cc @@ -240,6 +240,11 @@ void WebContents::DidNavigateMainFrame( Emit("did-navigate-to-different-page"); } +void WebContents::TitleWasSet(content::NavigationEntry* entry, + bool explicit_set) { + Emit("page-title-set", entry->GetTitle(), explicit_set); +} + bool WebContents::OnMessageReceived(const IPC::Message& message) { bool handled = true; IPC_BEGIN_MESSAGE_MAP(WebContents, message) diff --git a/atom/browser/api/atom_api_web_contents.h b/atom/browser/api/atom_api_web_contents.h index d570078d4c34..8e0d12801a9a 100644 --- a/atom/browser/api/atom_api_web_contents.h +++ b/atom/browser/api/atom_api_web_contents.h @@ -172,6 +172,7 @@ class WebContents : public mate::EventEmitter, void WebContentsDestroyed() override; void NavigationEntryCommitted( const content::LoadCommittedDetails& load_details) override; + void TitleWasSet(content::NavigationEntry* entry, bool explicit_set) override; // content::BrowserPluginGuestDelegate: void DidAttach(int guest_proxy_routing_id) final; diff --git a/atom/browser/lib/guest-view-manager.coffee b/atom/browser/lib/guest-view-manager.coffee index d3ab506a0242..b7caac22ac6d 100644 --- a/atom/browser/lib/guest-view-manager.coffee +++ b/atom/browser/lib/guest-view-manager.coffee @@ -14,6 +14,7 @@ supportedWebViewEvents = [ 'close' 'crashed' 'destroyed' + 'page-title-set' ] nextInstanceId = 0 diff --git a/atom/renderer/lib/web-view/guest-view-internal.coffee b/atom/renderer/lib/web-view/guest-view-internal.coffee index 99401784f599..f150615b937a 100644 --- a/atom/renderer/lib/web-view/guest-view-internal.coffee +++ b/atom/renderer/lib/web-view/guest-view-internal.coffee @@ -15,6 +15,7 @@ WEB_VIEW_EVENTS = 'close': [] 'crashed': [] 'destroyed': [] + 'page-title-set': ['title', 'explicitSet'] dispatchEvent = (webView, event, args...) -> throw new Error("Unkown event #{event}") unless WEB_VIEW_EVENTS[event]? diff --git a/docs/api/web-view-tag.md b/docs/api/web-view-tag.md index 40ccf1f174a6..b1fdf6449e90 100644 --- a/docs/api/web-view-tag.md +++ b/docs/api/web-view-tag.md @@ -310,6 +310,14 @@ Corresponds to the points in time when the spinner of the tab stops spinning. Fired when a redirect was received while requesting a resource. +### page-title-set + +* `title` String +* `explicitSet` Boolean + +Fired when page ttile is set during navigation. `explicitSet` is false when title is synthesised from file +url. + ### console-message * `level` Integer diff --git a/spec/fixtures/pages/a.html b/spec/fixtures/pages/a.html index 6889ce235b99..a471ad292d87 100644 --- a/spec/fixtures/pages/a.html +++ b/spec/fixtures/pages/a.html @@ -2,6 +2,7 @@