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) {
auto title = entry ? entry->GetTitle() : base::string16();
bool explicit_set;
base::string16 final_title;
if (entry && entry->GetURL().SchemeIsFile() && title.empty()) {
final_title = base::UTF8ToUTF16(entry->GetURL().ExtractFileName());
bool explicit_set = true;
if (entry) {
auto title = entry->GetTitle();
auto url = entry->GetURL();
if (url.SchemeIsFile() && title.empty()) {
final_title = base::UTF8ToUTF16(url.ExtractFileName());
explicit_set = false;
} else {
base::TrimWhitespace(title, base::TRIM_ALL, &final_title);
explicit_set = true;
final_title = title;
}
}
Emit("page-title-updated", final_title, explicit_set);
}