From 4666879f94a6f3238ed76181460e7306ab09cbfe Mon Sep 17 00:00:00 2001 From: Samuel Attard Date: Mon, 18 Dec 2017 11:19:21 +1100 Subject: [PATCH] WebContentsObserver no longer provides explicit_set, we can calculate it --- atom/browser/api/atom_api_web_contents.cc | 11 +++++++++-- atom/browser/api/atom_api_web_contents.h | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/atom/browser/api/atom_api_web_contents.cc b/atom/browser/api/atom_api_web_contents.cc index 38740abd0452..b15a160bd1d9 100644 --- a/atom/browser/api/atom_api_web_contents.cc +++ b/atom/browser/api/atom_api_web_contents.cc @@ -893,9 +893,16 @@ void WebContents::DidFinishNavigation( } } -void WebContents::TitleWasSet(content::NavigationEntry* entry, - bool explicit_set) { +void WebContents::TitleWasSet(content::NavigationEntry* entry) { auto title = entry ? entry->GetTitle() : base::string16(); + bool explicit_set; + if (entry && entry->GetURL().SchemeIsFile() && title.empty()) { + final_title = base::UTF8ToUTF16(entry->GetURL().ExtractFileName()); + explicit_set = false; + } else { + base::TrimWhitespace(title, base::TRIM_ALL, &final_title); + explicit_set = true; + } Emit("page-title-updated", title, explicit_set); } diff --git a/atom/browser/api/atom_api_web_contents.h b/atom/browser/api/atom_api_web_contents.h index 5cd710149190..00e4b5a84a13 100644 --- a/atom/browser/api/atom_api_web_contents.h +++ b/atom/browser/api/atom_api_web_contents.h @@ -361,7 +361,7 @@ class WebContents : public mate::TrackableObject, void WebContentsDestroyed() override; void NavigationEntryCommitted( const content::LoadCommittedDetails& load_details) override; - void TitleWasSet(content::NavigationEntry* entry, bool explicit_set) override; + void TitleWasSet(content::NavigationEntry* entry) override; void DidUpdateFaviconURL( const std::vector& urls) override; void PluginCrashed(const base::FilePath& plugin_path,