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

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

Issue 13846007: Allow showing pending URL for new tab navigations, but only if safe. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « content/browser/web_contents/web_contents_impl.h ('k') | content/common/view_messages.h » ('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/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 691 matching lines...) Expand 10 before | Expand all | Expand 10 after
702 const NavigationControllerImpl& WebContentsImpl::GetController() const { 702 const NavigationControllerImpl& WebContentsImpl::GetController() const {
703 return controller_; 703 return controller_;
704 } 704 }
705 705
706 BrowserContext* WebContentsImpl::GetBrowserContext() const { 706 BrowserContext* WebContentsImpl::GetBrowserContext() const {
707 return controller_.GetBrowserContext(); 707 return controller_.GetBrowserContext();
708 } 708 }
709 709
710 const GURL& WebContentsImpl::GetURL() const { 710 const GURL& WebContentsImpl::GetURL() const {
711 // We may not have a navigation entry yet 711 // We may not have a navigation entry yet
712 NavigationEntry* entry = controller_.GetActiveEntry(); 712 NavigationEntry* entry = controller_.GetVisibleEntry();
713 return entry ? entry->GetVirtualURL() : GURL::EmptyGURL(); 713 return entry ? entry->GetVirtualURL() : GURL::EmptyGURL();
714 } 714 }
715 715
716 WebContentsDelegate* WebContentsImpl::GetDelegate() { 716 WebContentsDelegate* WebContentsImpl::GetDelegate() {
717 return delegate_; 717 return delegate_;
718 } 718 }
719 719
720 void WebContentsImpl::SetDelegate(WebContentsDelegate* delegate) { 720 void WebContentsImpl::SetDelegate(WebContentsDelegate* delegate) {
721 // TODO(cbentzel): remove this debugging code? 721 // TODO(cbentzel): remove this debugging code?
722 if (delegate == delegate_) 722 if (delegate == delegate_)
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
848 std::string accept_languages = 848 std::string accept_languages =
849 GetContentClient()->browser()->GetAcceptLangs( 849 GetContentClient()->browser()->GetAcceptLangs(
850 GetBrowserContext()); 850 GetBrowserContext());
851 if (entry) { 851 if (entry) {
852 return entry->GetTitleForDisplay(accept_languages); 852 return entry->GetTitleForDisplay(accept_languages);
853 } 853 }
854 WebUI* our_web_ui = render_manager_.pending_web_ui() ? 854 WebUI* our_web_ui = render_manager_.pending_web_ui() ?
855 render_manager_.pending_web_ui() : render_manager_.web_ui(); 855 render_manager_.pending_web_ui() : render_manager_.web_ui();
856 if (our_web_ui) { 856 if (our_web_ui) {
857 // Don't override the title in view source mode. 857 // Don't override the title in view source mode.
858 entry = controller_.GetActiveEntry(); 858 entry = controller_.GetVisibleEntry();
859 if (!(entry && entry->IsViewSourceMode())) { 859 if (!(entry && entry->IsViewSourceMode())) {
860 // Give the Web UI the chance to override our title. 860 // Give the Web UI the chance to override our title.
861 const string16& title = our_web_ui->GetOverriddenTitle(); 861 const string16& title = our_web_ui->GetOverriddenTitle();
862 if (!title.empty()) 862 if (!title.empty())
863 return title; 863 return title;
864 } 864 }
865 } 865 }
866 866
867 // We use the title for the last committed entry rather than a pending 867 // We use the title for the last committed entry rather than a pending
868 // navigation entry. For example, when the user types in a URL, we want to 868 // navigation entry. For example, when the user types in a URL, we want to
869 // keep the old page's title until the new load has committed and we get a new 869 // keep the old page's title until the new load has committed and we get a new
870 // title. 870 // title.
871 entry = controller_.GetLastCommittedEntry(); 871 entry = controller_.GetLastCommittedEntry();
872
873 // We make an exception for initial navigations, because we can have a
874 // committed entry for an initial navigation when doing a history navigation
875 // in a new tab, such as Ctrl+Back.
876 if (entry && controller_.IsInitialNavigation())
877 entry = controller_.GetVisibleEntry();
878
872 if (entry) { 879 if (entry) {
873 return entry->GetTitleForDisplay(accept_languages); 880 return entry->GetTitleForDisplay(accept_languages);
874 } 881 }
875 882
876 // |page_title_when_no_navigation_entry_| is finally used 883 // |page_title_when_no_navigation_entry_| is finally used
877 // if no title cannot be retrieved. 884 // if no title cannot be retrieved.
878 return page_title_when_no_navigation_entry_; 885 return page_title_when_no_navigation_entry_;
879 } 886 }
880 887
881 int32 WebContentsImpl::GetMaxPageID() { 888 int32 WebContentsImpl::GetMaxPageID() {
(...skipping 1082 matching lines...) Expand 10 before | Expand all | Expand 10 after
1964 bool is_error_page = (url.spec() == kUnreachableWebDataURL); 1971 bool is_error_page = (url.spec() == kUnreachableWebDataURL);
1965 bool is_iframe_srcdoc = (url.spec() == chrome::kAboutSrcDocURL); 1972 bool is_iframe_srcdoc = (url.spec() == chrome::kAboutSrcDocURL);
1966 GURL validated_url(url); 1973 GURL validated_url(url);
1967 RenderProcessHost* render_process_host = 1974 RenderProcessHost* render_process_host =
1968 render_view_host->GetProcess(); 1975 render_view_host->GetProcess();
1969 RenderViewHost::FilterURL(render_process_host, false, &validated_url); 1976 RenderViewHost::FilterURL(render_process_host, false, &validated_url);
1970 1977
1971 if (is_main_frame) 1978 if (is_main_frame)
1972 DidChangeLoadProgress(0); 1979 DidChangeLoadProgress(0);
1973 1980
1981 // Create a pending entry for this provisional load (if none exists) using the
1982 // current SiteInstance, and ensure the address bar updates accordingly.
1983 // We don't know the referrer or extra headers at this point, but the referrer
1984 // will be set properly upon commit.
1985 if (is_main_frame && !controller_.GetPendingEntry()) {
1986 NavigationEntryImpl* entry = NavigationEntryImpl::FromNavigationEntry(
1987 controller_.CreateNavigationEntry(validated_url,
1988 content::Referrer(),
1989 content::PAGE_TRANSITION_LINK,
1990 true /* is_renderer_initiated */,
1991 std::string(), GetBrowserContext()));
1992 entry->set_site_instance(
1993 static_cast<SiteInstanceImpl*>(GetSiteInstance()));
1994 controller_.SetPendingEntry(entry);
1995 NotifyNavigationStateChanged(content::INVALIDATE_TYPE_URL);
1996 }
1997
1974 // Notify observers about the start of the provisional load. 1998 // Notify observers about the start of the provisional load.
1975 FOR_EACH_OBSERVER(WebContentsObserver, observers_, 1999 FOR_EACH_OBSERVER(WebContentsObserver, observers_,
1976 DidStartProvisionalLoadForFrame(frame_id, parent_frame_id, 2000 DidStartProvisionalLoadForFrame(frame_id, parent_frame_id,
1977 is_main_frame, validated_url, is_error_page, 2001 is_main_frame, validated_url, is_error_page,
1978 is_iframe_srcdoc, render_view_host)); 2002 is_iframe_srcdoc, render_view_host));
1979 2003
1980 if (is_main_frame) { 2004 if (is_main_frame) {
1981 // Notify observers about the provisional change in the main frame URL. 2005 // Notify observers about the provisional change in the main frame URL.
1982 FOR_EACH_OBSERVER(WebContentsObserver, observers_, 2006 FOR_EACH_OBSERVER(WebContentsObserver, observers_,
1983 ProvisionalChangeToMainFrameUrl(validated_url, 2007 ProvisionalChangeToMainFrameUrl(validated_url,
(...skipping 919 matching lines...) Expand 10 before | Expand all | Expand 10 after
2903 // Notify all swapped out RenderViewHosts for this tab. This is important 2927 // Notify all swapped out RenderViewHosts for this tab. This is important
2904 // in case we go back to them, or if another window in those processes tries 2928 // in case we go back to them, or if another window in those processes tries
2905 // to access window.opener. 2929 // to access window.opener.
2906 render_manager_.DidDisownOpener(rvh); 2930 render_manager_.DidDisownOpener(rvh);
2907 } 2931 }
2908 2932
2909 void WebContentsImpl::DidUpdateFrameTree(RenderViewHost* rvh) { 2933 void WebContentsImpl::DidUpdateFrameTree(RenderViewHost* rvh) {
2910 render_manager_.DidUpdateFrameTree(rvh); 2934 render_manager_.DidUpdateFrameTree(rvh);
2911 } 2935 }
2912 2936
2937 void WebContentsImpl::DidAccessInitialDocument() {
2938 // Update the URL display.
2939 NotifyNavigationStateChanged(content::INVALIDATE_TYPE_URL);
2940 }
2941
2913 void WebContentsImpl::DocumentAvailableInMainFrame( 2942 void WebContentsImpl::DocumentAvailableInMainFrame(
2914 RenderViewHost* render_view_host) { 2943 RenderViewHost* render_view_host) {
2915 FOR_EACH_OBSERVER(WebContentsObserver, observers_, 2944 FOR_EACH_OBSERVER(WebContentsObserver, observers_,
2916 DocumentAvailableInMainFrame()); 2945 DocumentAvailableInMainFrame());
2917 } 2946 }
2918 2947
2919 void WebContentsImpl::DocumentOnLoadCompletedInMainFrame( 2948 void WebContentsImpl::DocumentOnLoadCompletedInMainFrame(
2920 RenderViewHost* render_view_host, 2949 RenderViewHost* render_view_host,
2921 int32 page_id) { 2950 int32 page_id) {
2922 NotificationService::current()->Notify( 2951 NotificationService::current()->Notify(
(...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after
3413 } 3442 }
3414 3443
3415 BrowserPluginGuestManager* 3444 BrowserPluginGuestManager*
3416 WebContentsImpl::GetBrowserPluginGuestManager() const { 3445 WebContentsImpl::GetBrowserPluginGuestManager() const {
3417 return static_cast<BrowserPluginGuestManager*>( 3446 return static_cast<BrowserPluginGuestManager*>(
3418 GetBrowserContext()->GetUserData( 3447 GetBrowserContext()->GetUserData(
3419 browser_plugin::kBrowserPluginGuestManagerKeyName)); 3448 browser_plugin::kBrowserPluginGuestManagerKeyName));
3420 } 3449 }
3421 3450
3422 } // namespace content 3451 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/web_contents/web_contents_impl.h ('k') | content/common/view_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698