Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(913)

Unified Diff: content/browser/web_contents/web_contents_impl.cc

Issue 1372133002: Don't rely on |entry| being null in initial title logic. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | content/browser/web_contents/web_contents_impl_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/web_contents/web_contents_impl.cc
diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc
index 1ee7a7dc3807794f0707f36abbef980e1c51da21..9b53030c2e68f7da57b9334373d903d50b6ded33 100644
--- a/content/browser/web_contents/web_contents_impl.cc
+++ b/content/browser/web_contents/web_contents_impl.cc
@@ -946,21 +946,19 @@ const base::string16& WebContentsImpl::GetTitle() const {
// title.
entry = controller_.GetLastCommittedEntry();
- // We make an exception for initial navigations.
- if (controller_.IsInitialNavigation()) {
- // We only want to use the title from the visible entry in one of two cases:
- // 1. There's already a committed entry for an initial navigation, in which
- // case we are doing a history navigation in a new tab (e.g., Ctrl+Back).
- // 2. The pending entry has been explicitly assigned a title to display.
- //
- // If there's no last committed entry and no assigned title, we should fall
- // back to |page_title_when_no_navigation_entry_| rather than showing the
- // URL.
- if (entry ||
Avi (use Gerrit) 2015/09/28 19:11:39 I'm not sure what this was supposed to mean. How c
Charlie Reis 2015/09/28 19:21:41 I thought the same at first glance, but there's ac
- (controller_.GetVisibleEntry() &&
- !controller_.GetVisibleEntry()->GetTitle().empty())) {
- entry = controller_.GetVisibleEntry();
- }
+ // We make an exception for initial navigations. We only want to use the title
+ // from the visible entry if:
+ // 1. The pending entry has been explicitly assigned a title to display.
+ // 2. The user is doing a history navigation in a new tab (e.g., Ctrl+Back),
+ // which case there is a pending entry index other than -1.
+ //
+ // Otherwise, we want to stick with the last committed entry's title during
+ // new navigations, which have pending entries at index -1 with no title.
+ if (controller_.IsInitialNavigation() &&
+ ((controller_.GetVisibleEntry() &&
Charlie Reis 2015/09/28 18:18:43 Note: I'll be able to remove this line once we alw
Avi (use Gerrit) 2015/09/28 19:11:39 Will you then (please) also kill WebContentsImpl::
Charlie Reis 2015/09/28 19:21:41 Yep! There's a lot of cruft like that on the chop
+ !controller_.GetVisibleEntry()->GetTitle().empty()) ||
+ controller_.GetPendingEntryIndex() != -1)) {
+ entry = controller_.GetVisibleEntry();
}
if (entry) {
« no previous file with comments | « no previous file | content/browser/web_contents/web_contents_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698