Chromium Code Reviews| 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()) || |
|
Charlie Reis
2015/04/13 23:45:41
It would help to have a test showing why this is t
Avi (use Gerrit)
2015/04/14 02:00:43
There's a test where if you navigate to url1 that
Charlie Reis
2015/04/15 17:43:08
Acknowledged.
| |
| 1034 // the pending entry and go back to where we were (the "existing entry"). | 1034 existing_entry->GetURL() == pending_entry_->GetVirtualURL()) { |
|
Charlie Reis
2015/04/13 23:45:40
Why are we comparing GetURL() and GetVirtualURL()
Avi (use Gerrit)
2015/04/14 02:00:43
To cover SAME_PAGE for view-source:
Charlie Reis
2015/04/15 17:43:08
Sorry, I still don't understand this one. I just
Avi (use Gerrit)
2015/04/15 19:14:16
I remember putting this line in for a test, but I
Charlie Reis
2015/04/15 19:57:36
Ok, thanks. Let me know if you find the case it m
| |
| 1035 return NAVIGATION_TYPE_SAME_PAGE; | 1035 // In this case, we have a pending entry for a URL but WebCore didn't do a |
| 1036 // new navigation. This happens when you press enter in the URL bar to | |
| 1037 // reload. We will create a pending entry, but WebKit will convert it to | |
| 1038 // a reload since it's the same page and not create a new entry for it | |
| 1039 // (the user doesn't want to have a new back/forward entry when they do | |
| 1040 // this). If this matches the last committed entry, we want to just ignore | |
| 1041 // the pending entry and go back to where we were (the "existing entry"). | |
| 1042 return NAVIGATION_TYPE_SAME_PAGE; | |
| 1043 } | |
| 1036 } | 1044 } |
| 1037 | 1045 |
| 1038 // Any toplevel navigations with the same base (minus the reference fragment) | 1046 // Any toplevel navigations with the same base (minus the reference fragment) |
| 1039 // are in-page navigations. We weeded out subframe navigations above. Most of | 1047 // 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 | 1048 // 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 | 1049 // navigations that don't actually navigate, but it can happen when there is |
| 1042 // an encoding override (it always sends a navigation request). | 1050 // an encoding override (it always sends a navigation request). |
| 1043 if (AreURLsInPageNavigation(existing_entry->GetURL(), params.url, | 1051 if (AreURLsInPageNavigation(existing_entry->GetURL(), params.url, |
| 1044 params.was_within_same_page, rfh)) { | 1052 params.was_within_same_page, rfh)) { |
| 1045 return NAVIGATION_TYPE_IN_PAGE; | 1053 return NAVIGATION_TYPE_IN_PAGE; |
| (...skipping 801 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1847 } | 1855 } |
| 1848 } | 1856 } |
| 1849 } | 1857 } |
| 1850 | 1858 |
| 1851 void NavigationControllerImpl::SetGetTimestampCallbackForTest( | 1859 void NavigationControllerImpl::SetGetTimestampCallbackForTest( |
| 1852 const base::Callback<base::Time()>& get_timestamp_callback) { | 1860 const base::Callback<base::Time()>& get_timestamp_callback) { |
| 1853 get_timestamp_callback_ = get_timestamp_callback; | 1861 get_timestamp_callback_ = get_timestamp_callback; |
| 1854 } | 1862 } |
| 1855 | 1863 |
| 1856 } // namespace content | 1864 } // namespace content |
| OLD | NEW |