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 882 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 893 details->http_status_code = params.http_status_code; | 893 details->http_status_code = params.http_status_code; |
| 894 NotifyNavigationEntryCommitted(details); | 894 NotifyNavigationEntryCommitted(details); |
| 895 | 895 |
| 896 return true; | 896 return true; |
| 897 } | 897 } |
| 898 | 898 |
| 899 NavigationType NavigationControllerImpl::ClassifyNavigation( | 899 NavigationType NavigationControllerImpl::ClassifyNavigation( |
| 900 RenderFrameHostImpl* rfh, | 900 RenderFrameHostImpl* rfh, |
| 901 const FrameHostMsg_DidCommitProvisionalLoad_Params& params) const { | 901 const FrameHostMsg_DidCommitProvisionalLoad_Params& params) const { |
| 902 if (params.page_id == -1) { | 902 if (params.page_id == -1) { |
| 903 // TODO(nasko, creis): An out-of-process child frame has no way of | 903 if (rfh->IsCrossProcessSubframe()) { |
| 904 // knowing the page_id of its parent, so it is passing back -1. The | 904 CHECK(!ui::PageTransitionIsMainFrame(params.transition)); |
|
Charlie Reis
2015/03/12 22:54:17
DCHECK. The renderer could be exploited or buggy
Nate Chapin
2015/03/13 21:48:35
Oops, I wasn't careful about this while testing an
| |
| 905 // semantics here should be re-evaluated during session history refactor | 905 if (ui::PageTransitionCoreTypeIs(params.transition, |
| 906 // (see http://crbug.com/236848). For now, we assume this means the | 906 ui::PAGE_TRANSITION_MANUAL_SUBFRAME)) { |
| 907 // child frame loaded and proceed. Note that this may do the wrong thing | 907 return NAVIGATION_TYPE_NEW_SUBFRAME; |
| 908 // for cross-process AUTO_SUBFRAME navigations. | 908 } else { |
| 909 if (rfh->IsCrossProcessSubframe()) | 909 return NAVIGATION_TYPE_AUTO_SUBFRAME; |
| 910 return NAVIGATION_TYPE_NEW_SUBFRAME; | 910 } |
| 911 } | |
| 911 | 912 |
| 912 // The renderer generates the page IDs, and so if it gives us the invalid | 913 // The renderer generates the page IDs, and so if it gives us the invalid |
| 913 // page ID (-1) we know it didn't actually navigate. This happens in a few | 914 // page ID (-1) we know it didn't actually navigate. This happens in a few |
| 914 // cases: | 915 // cases: |
| 915 // | 916 // |
| 916 // - If a page makes a popup navigated to about blank, and then writes | 917 // - If a page makes a popup navigated to about blank, and then writes |
| 917 // stuff like a subframe navigated to a real page. We'll get the commit | 918 // stuff like a subframe navigated to a real page. We'll get the commit |
| 918 // for the subframe, but there won't be any commit for the outer page. | 919 // for the subframe, but there won't be any commit for the outer page. |
| 919 // | 920 // |
| 920 // - We were also getting these for failed loads (for example, bug 21849). | 921 // - We were also getting these for failed loads (for example, bug 21849). |
| (...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1225 | 1226 |
| 1226 // If a transient entry was removed, the indices might have changed, so we | 1227 // If a transient entry was removed, the indices might have changed, so we |
| 1227 // have to query the entry index again. | 1228 // have to query the entry index again. |
| 1228 last_committed_entry_index_ = | 1229 last_committed_entry_index_ = |
| 1229 GetEntryIndexWithPageID(rfh->GetSiteInstance(), params.page_id); | 1230 GetEntryIndexWithPageID(rfh->GetSiteInstance(), params.page_id); |
| 1230 } | 1231 } |
| 1231 | 1232 |
| 1232 void NavigationControllerImpl::RendererDidNavigateNewSubframe( | 1233 void NavigationControllerImpl::RendererDidNavigateNewSubframe( |
| 1233 RenderFrameHostImpl* rfh, | 1234 RenderFrameHostImpl* rfh, |
| 1234 const FrameHostMsg_DidCommitProvisionalLoad_Params& params) { | 1235 const FrameHostMsg_DidCommitProvisionalLoad_Params& params) { |
| 1235 if (!ui::PageTransitionCoreTypeIs(params.transition, | 1236 DCHECK(ui::PageTransitionCoreTypeIs(params.transition, |
| 1236 ui::PAGE_TRANSITION_MANUAL_SUBFRAME)) { | 1237 ui::PAGE_TRANSITION_MANUAL_SUBFRAME)); |
| 1237 // There was a comment here that said, "This is not user-initiated. Ignore." | |
| 1238 // But this makes no sense; non-user-initiated navigations should be | |
| 1239 // determined to be of type NAVIGATION_TYPE_AUTO_SUBFRAME and sent to | |
| 1240 // RendererDidNavigateAutoSubframe below. | |
| 1241 // | |
| 1242 // This if clause dates back to https://codereview.chromium.org/115919 and | |
| 1243 // the handling of immediate redirects. TODO(avi): Is this still valid? I'm | |
| 1244 // pretty sure that's there's nothing left of that code and that we should | |
| 1245 // take this out. | |
| 1246 // | |
| 1247 // Except for cross-process iframes; this doesn't work yet for them. | |
| 1248 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( | |
| 1249 switches::kSitePerProcess)) { | |
| 1250 NOTREACHED(); | |
| 1251 } | |
| 1252 | |
| 1253 DiscardNonCommittedEntriesInternal(); | |
| 1254 return; | |
| 1255 } | |
| 1256 | 1238 |
| 1257 // Manual subframe navigations just get the current entry cloned so the user | 1239 // Manual subframe navigations just get the current entry cloned so the user |
| 1258 // can go back or forward to it. The actual subframe information will be | 1240 // can go back or forward to it. The actual subframe information will be |
| 1259 // stored in the page state for each of those entries. This happens out of | 1241 // stored in the page state for each of those entries. This happens out of |
| 1260 // band with the actual navigations. | 1242 // band with the actual navigations. |
| 1261 DCHECK(GetLastCommittedEntry()) << "ClassifyNavigation should guarantee " | 1243 DCHECK(GetLastCommittedEntry()) << "ClassifyNavigation should guarantee " |
| 1262 << "that a last committed entry exists."; | 1244 << "that a last committed entry exists."; |
| 1263 NavigationEntryImpl* new_entry = GetLastCommittedEntry()->Clone(); | 1245 NavigationEntryImpl* new_entry = GetLastCommittedEntry()->Clone(); |
| 1264 new_entry->SetPageID(params.page_id); | 1246 new_entry->SetPageID(params.page_id); |
| 1265 InsertOrReplaceEntry(new_entry, false); | 1247 InsertOrReplaceEntry(new_entry, false); |
| (...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1815 } | 1797 } |
| 1816 } | 1798 } |
| 1817 } | 1799 } |
| 1818 | 1800 |
| 1819 void NavigationControllerImpl::SetGetTimestampCallbackForTest( | 1801 void NavigationControllerImpl::SetGetTimestampCallbackForTest( |
| 1820 const base::Callback<base::Time()>& get_timestamp_callback) { | 1802 const base::Callback<base::Time()>& get_timestamp_callback) { |
| 1821 get_timestamp_callback_ = get_timestamp_callback; | 1803 get_timestamp_callback_ = get_timestamp_callback; |
| 1822 } | 1804 } |
| 1823 | 1805 |
| 1824 } // namespace content | 1806 } // namespace content |
| OLD | NEW |