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

Side by Side Diff: content/browser/web_contents/web_contents_impl.cc

Issue 78443005: New Tab: fix tab title flickering. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments. Created 7 years 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 | Annotate | Revision Log
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/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
(...skipping 738 matching lines...) Expand 10 before | Expand all | Expand 10 after
749 return title; 749 return title;
750 } 750 }
751 } 751 }
752 752
753 // We use the title for the last committed entry rather than a pending 753 // We use the title for the last committed entry rather than a pending
754 // navigation entry. For example, when the user types in a URL, we want to 754 // navigation entry. For example, when the user types in a URL, we want to
755 // keep the old page's title until the new load has committed and we get a new 755 // keep the old page's title until the new load has committed and we get a new
756 // title. 756 // title.
757 entry = controller_.GetLastCommittedEntry(); 757 entry = controller_.GetLastCommittedEntry();
758 758
759 // We make an exception for initial navigations, because we can have a 759 // We make an exception for initial navigations.
760 // committed entry for an initial navigation when doing a history navigation 760 if (controller_.IsInitialNavigation()) {
761 // in a new tab, such as Ctrl+Back. 761 // We only want to use the title from the visible entry in one of two cases:
762 if (entry && controller_.IsInitialNavigation()) 762 // 1. There's already a committed entry for an initial navigation, in which
763 entry = controller_.GetVisibleEntry(); 763 // case we are doing a history navigation in a new tab (e.g., Ctrl+Back).
764 // 2. The pending entry has been explicitly assigned a title to display.
765 //
766 // If there's no last committed entry and no assigned title, we should fall
767 // back to |page_title_when_no_navigation_entry_| rather than showing the
768 // URL.
769 if (entry ||
770 (controller_.GetVisibleEntry() &&
771 !controller_.GetVisibleEntry()->GetTitle().empty())) {
772 entry = controller_.GetVisibleEntry();
773 }
774 }
764 775
765 if (entry) { 776 if (entry) {
766 return entry->GetTitleForDisplay(accept_languages); 777 return entry->GetTitleForDisplay(accept_languages);
767 } 778 }
768 779
769 // |page_title_when_no_navigation_entry_| is finally used 780 // |page_title_when_no_navigation_entry_| is finally used
770 // if no title cannot be retrieved. 781 // if no title cannot be retrieved.
771 return page_title_when_no_navigation_entry_; 782 return page_title_when_no_navigation_entry_;
772 } 783 }
773 784
(...skipping 2909 matching lines...) Expand 10 before | Expand all | Expand 10 after
3683 } 3694 }
3684 3695
3685 void WebContentsImpl::OnFrameRemoved( 3696 void WebContentsImpl::OnFrameRemoved(
3686 RenderViewHostImpl* render_view_host, 3697 RenderViewHostImpl* render_view_host,
3687 int64 frame_id) { 3698 int64 frame_id) {
3688 FOR_EACH_OBSERVER(WebContentsObserver, observers_, 3699 FOR_EACH_OBSERVER(WebContentsObserver, observers_,
3689 FrameDetached(render_view_host, frame_id)); 3700 FrameDetached(render_view_host, frame_id));
3690 } 3701 }
3691 3702
3692 } // namespace content 3703 } // namespace content
OLDNEW
« no previous file with comments | « chrome/browser/ui/search/search_tab_helper_unittest.cc ('k') | content/browser/web_contents/web_contents_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698