OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/frame_host/navigation_controller_impl.h" | 5 #include "content/browser/frame_host/navigation_controller_impl.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 894 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
905 details->http_status_code = params.http_status_code; | 905 details->http_status_code = params.http_status_code; |
906 NotifyNavigationEntryCommitted(details); | 906 NotifyNavigationEntryCommitted(details); |
907 | 907 |
908 return true; | 908 return true; |
909 } | 909 } |
910 | 910 |
911 NavigationType NavigationControllerImpl::ClassifyNavigation( | 911 NavigationType NavigationControllerImpl::ClassifyNavigation( |
912 RenderFrameHostImpl* rfh, | 912 RenderFrameHostImpl* rfh, |
913 const FrameHostMsg_DidCommitProvisionalLoad_Params& params) const { | 913 const FrameHostMsg_DidCommitProvisionalLoad_Params& params) const { |
914 if (params.page_id == -1) { | 914 if (params.page_id == -1) { |
915 // TODO(nasko, creis): An out-of-process child frame has no way of | 915 // TODO(nasko, creis): An out-of-process child frame has no way of knowing |
916 // knowing the page_id of its parent, so it is passing back -1. The | 916 // the page_id of its parent, so it is passing back -1. The semantics here |
917 // semantics here should be re-evaluated during session history refactor | 917 // should be re-evaluated during session history refactor (see |
918 // (see http://crbug.com/236848). For now, we assume this means the | 918 // http://crbug.com/236848 and in particular http://crbug.com/464014). For |
919 // child frame loaded and proceed. Note that this may do the wrong thing | 919 // now, we assume this means the child frame loaded and proceed. Note that |
920 // for cross-process AUTO_SUBFRAME navigations. | 920 // this may do the wrong thing for cross-process AUTO_SUBFRAME navigations. |
921 if (rfh->IsCrossProcessSubframe()) | 921 if (rfh->IsCrossProcessSubframe()) |
922 return NAVIGATION_TYPE_NEW_SUBFRAME; | 922 return NAVIGATION_TYPE_NEW_SUBFRAME; |
923 | 923 |
924 // The renderer generates the page IDs, and so if it gives us the invalid | 924 // The renderer generates the page IDs, and so if it gives us the invalid |
925 // page ID (-1) we know it didn't actually navigate. This happens in a few | 925 // page ID (-1) we know it didn't actually navigate. This happens in a few |
926 // cases: | 926 // cases: |
927 // | 927 // |
928 // - If a page makes a popup navigated to about blank, and then writes | 928 // - If a page makes a popup navigated to about blank, and then writes |
929 // stuff like a subframe navigated to a real page. We'll get the commit | 929 // stuff like a subframe navigated to a real page. We'll get the commit |
930 // for the subframe, but there won't be any commit for the outer page. | 930 // for the subframe, but there won't be any commit for the outer page. |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1018 DCHECK(GetLastCommittedEntry()); | 1018 DCHECK(GetLastCommittedEntry()); |
1019 return NAVIGATION_TYPE_AUTO_SUBFRAME; | 1019 return NAVIGATION_TYPE_AUTO_SUBFRAME; |
1020 } | 1020 } |
1021 | 1021 |
1022 // Anything below here we know is a main frame navigation. | 1022 // Anything below here we know is a main frame navigation. |
1023 if (pending_entry_ && | 1023 if (pending_entry_ && |
1024 !pending_entry_->is_renderer_initiated() && | 1024 !pending_entry_->is_renderer_initiated() && |
1025 existing_entry != pending_entry_ && | 1025 existing_entry != pending_entry_ && |
1026 pending_entry_->GetPageID() == -1 && | 1026 pending_entry_->GetPageID() == -1 && |
1027 existing_entry == GetLastCommittedEntry()) { | 1027 existing_entry == GetLastCommittedEntry()) { |
1028 // In this case, we have a pending entry for a URL but WebCore didn't do a | 1028 const std::vector<GURL>& existing_redirect_chain = |
1029 // new navigation. This happens when you press enter in the URL bar to | 1029 existing_entry->GetRedirectChain(); |
1030 // reload. We will create a pending entry, but WebKit will convert it to | 1030 |
1031 // a reload since it's the same page and not create a new entry for it | 1031 if (existing_entry->GetURL() == pending_entry_->GetURL() || |
1032 // (the user doesn't want to have a new back/forward entry when they do | 1032 (existing_redirect_chain.size() && |
1033 // this). If this matches the last committed entry, we want to just ignore | 1033 existing_redirect_chain[0] == pending_entry_->GetURL())) { |
1034 // the pending entry and go back to where we were (the "existing entry"). | 1034 // In this case, we have a pending entry for a URL but WebCore didn't do a |
1035 return NAVIGATION_TYPE_SAME_PAGE; | 1035 // new navigation. This happens when you press enter in the URL bar to |
| 1036 // reload. We will create a pending entry, but WebKit will convert it to |
| 1037 // a reload since it's the same page and not create a new entry for it |
| 1038 // (the user doesn't want to have a new back/forward entry when they do |
| 1039 // this). If this matches the last committed entry, we want to just ignore |
| 1040 // the pending entry and go back to where we were (the "existing entry"). |
| 1041 return NAVIGATION_TYPE_SAME_PAGE; |
| 1042 } |
1036 } | 1043 } |
1037 | 1044 |
1038 // Any toplevel navigations with the same base (minus the reference fragment) | 1045 // Any toplevel navigations with the same base (minus the reference fragment) |
1039 // are in-page navigations. We weeded out subframe navigations above. Most of | 1046 // are in-page navigations. We weeded out subframe navigations above. Most of |
1040 // the time this doesn't matter since WebKit doesn't tell us about subframe | 1047 // the time this doesn't matter since WebKit doesn't tell us about subframe |
1041 // navigations that don't actually navigate, but it can happen when there is | 1048 // navigations that don't actually navigate, but it can happen when there is |
1042 // an encoding override (it always sends a navigation request). | 1049 // an encoding override (it always sends a navigation request). |
1043 if (AreURLsInPageNavigation(existing_entry->GetURL(), params.url, | 1050 if (AreURLsInPageNavigation(existing_entry->GetURL(), params.url, |
1044 params.was_within_same_page, rfh)) { | 1051 params.was_within_same_page, rfh)) { |
1045 return NAVIGATION_TYPE_IN_PAGE; | 1052 return NAVIGATION_TYPE_IN_PAGE; |
(...skipping 801 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1847 } | 1854 } |
1848 } | 1855 } |
1849 } | 1856 } |
1850 | 1857 |
1851 void NavigationControllerImpl::SetGetTimestampCallbackForTest( | 1858 void NavigationControllerImpl::SetGetTimestampCallbackForTest( |
1852 const base::Callback<base::Time()>& get_timestamp_callback) { | 1859 const base::Callback<base::Time()>& get_timestamp_callback) { |
1853 get_timestamp_callback_ = get_timestamp_callback; | 1860 get_timestamp_callback_ = get_timestamp_callback; |
1854 } | 1861 } |
1855 | 1862 |
1856 } // namespace content | 1863 } // namespace content |
OLD | NEW |