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

Side by Side 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, 2 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/web_contents/web_contents_impl.h" 5 #include "content/browser/web_contents/web_contents_impl.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
(...skipping 928 matching lines...) Expand 10 before | Expand all | Expand 10 after
939 return title; 939 return title;
940 } 940 }
941 } 941 }
942 942
943 // We use the title for the last committed entry rather than a pending 943 // We use the title for the last committed entry rather than a pending
944 // navigation entry. For example, when the user types in a URL, we want to 944 // navigation entry. For example, when the user types in a URL, we want to
945 // keep the old page's title until the new load has committed and we get a new 945 // keep the old page's title until the new load has committed and we get a new
946 // title. 946 // title.
947 entry = controller_.GetLastCommittedEntry(); 947 entry = controller_.GetLastCommittedEntry();
948 948
949 // We make an exception for initial navigations. 949 // We make an exception for initial navigations. We only want to use the title
950 if (controller_.IsInitialNavigation()) { 950 // from the visible entry if:
951 // We only want to use the title from the visible entry in one of two cases: 951 // 1. The pending entry has been explicitly assigned a title to display.
952 // 1. There's already a committed entry for an initial navigation, in which 952 // 2. The user is doing a history navigation in a new tab (e.g., Ctrl+Back),
953 // case we are doing a history navigation in a new tab (e.g., Ctrl+Back). 953 // which case there is a pending entry index other than -1.
954 // 2. The pending entry has been explicitly assigned a title to display. 954 //
955 // 955 // Otherwise, we want to stick with the last committed entry's title during
956 // If there's no last committed entry and no assigned title, we should fall 956 // new navigations, which have pending entries at index -1 with no title.
957 // back to |page_title_when_no_navigation_entry_| rather than showing the 957 if (controller_.IsInitialNavigation() &&
958 // URL. 958 ((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
959 if (entry || 959 !controller_.GetVisibleEntry()->GetTitle().empty()) ||
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
960 (controller_.GetVisibleEntry() && 960 controller_.GetPendingEntryIndex() != -1)) {
961 !controller_.GetVisibleEntry()->GetTitle().empty())) { 961 entry = controller_.GetVisibleEntry();
962 entry = controller_.GetVisibleEntry();
963 }
964 } 962 }
965 963
966 if (entry) { 964 if (entry) {
967 return entry->GetTitleForDisplay(accept_languages); 965 return entry->GetTitleForDisplay(accept_languages);
968 } 966 }
969 967
970 // |page_title_when_no_navigation_entry_| is finally used 968 // |page_title_when_no_navigation_entry_| is finally used
971 // if no title cannot be retrieved. 969 // if no title cannot be retrieved.
972 return page_title_when_no_navigation_entry_; 970 return page_title_when_no_navigation_entry_;
973 } 971 }
(...skipping 3667 matching lines...) Expand 10 before | Expand all | Expand 10 after
4641 return NULL; 4639 return NULL;
4642 } 4640 }
4643 4641
4644 void WebContentsImpl::SetForceDisableOverscrollContent(bool force_disable) { 4642 void WebContentsImpl::SetForceDisableOverscrollContent(bool force_disable) {
4645 force_disable_overscroll_content_ = force_disable; 4643 force_disable_overscroll_content_ = force_disable;
4646 if (view_) 4644 if (view_)
4647 view_->SetOverscrollControllerEnabled(CanOverscrollContent()); 4645 view_->SetOverscrollControllerEnabled(CanOverscrollContent());
4648 } 4646 }
4649 4647
4650 } // namespace content 4648 } // namespace content
OLDNEW
« 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