re-use title information from NavigationEntry

This commit is contained in:
deepak1556 2017-12-24 18:12:23 +05:30 committed by Aleksei Kuzmin
parent fa3d9d32ae
commit 1f2d229862

View file

@ -894,15 +894,17 @@ void WebContents::DidFinishNavigation(
} }
void WebContents::TitleWasSet(content::NavigationEntry* entry) { void WebContents::TitleWasSet(content::NavigationEntry* entry) {
auto title = entry ? entry->GetTitle() : base::string16();
bool explicit_set;
base::string16 final_title; base::string16 final_title;
if (entry && entry->GetURL().SchemeIsFile() && title.empty()) { bool explicit_set = true;
final_title = base::UTF8ToUTF16(entry->GetURL().ExtractFileName()); if (entry) {
explicit_set = false; auto title = entry->GetTitle();
} else { auto url = entry->GetURL();
base::TrimWhitespace(title, base::TRIM_ALL, &final_title); if (url.SchemeIsFile() && title.empty()) {
explicit_set = true; final_title = base::UTF8ToUTF16(url.ExtractFileName());
explicit_set = false;
} else {
final_title = title;
}
} }
Emit("page-title-updated", final_title, explicit_set); Emit("page-title-updated", final_title, explicit_set);
} }