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 19 matching lines...) Expand all Loading... | |
30 #include "content/public/browser/invalidate_type.h" | 30 #include "content/public/browser/invalidate_type.h" |
31 #include "content/public/browser/navigation_details.h" | 31 #include "content/public/browser/navigation_details.h" |
32 #include "content/public/browser/notification_service.h" | 32 #include "content/public/browser/notification_service.h" |
33 #include "content/public/browser/notification_types.h" | 33 #include "content/public/browser/notification_types.h" |
34 #include "content/public/browser/render_widget_host.h" | 34 #include "content/public/browser/render_widget_host.h" |
35 #include "content/public/browser/render_widget_host_view.h" | 35 #include "content/public/browser/render_widget_host_view.h" |
36 #include "content/public/browser/storage_partition.h" | 36 #include "content/public/browser/storage_partition.h" |
37 #include "content/public/browser/user_metrics.h" | 37 #include "content/public/browser/user_metrics.h" |
38 #include "content/public/common/content_client.h" | 38 #include "content/public/common/content_client.h" |
39 #include "content/public/common/content_constants.h" | 39 #include "content/public/common/content_constants.h" |
40 #include "content/public/common/content_switches.h" | |
40 #include "net/base/escape.h" | 41 #include "net/base/escape.h" |
41 #include "net/base/mime_util.h" | 42 #include "net/base/mime_util.h" |
42 #include "net/base/net_util.h" | 43 #include "net/base/net_util.h" |
43 #include "skia/ext/platform_canvas.h" | 44 #include "skia/ext/platform_canvas.h" |
44 #include "url/url_constants.h" | 45 #include "url/url_constants.h" |
45 | 46 |
46 namespace content { | 47 namespace content { |
47 namespace { | 48 namespace { |
48 | 49 |
49 // Invoked when entries have been pruned, or removed. For example, if the | 50 // Invoked when entries have been pruned, or removed. For example, if the |
(...skipping 1168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1218 // have to query the entry index again. | 1219 // have to query the entry index again. |
1219 last_committed_entry_index_ = | 1220 last_committed_entry_index_ = |
1220 GetEntryIndexWithPageID(rfh->GetSiteInstance(), params.page_id); | 1221 GetEntryIndexWithPageID(rfh->GetSiteInstance(), params.page_id); |
1221 } | 1222 } |
1222 | 1223 |
1223 void NavigationControllerImpl::RendererDidNavigateNewSubframe( | 1224 void NavigationControllerImpl::RendererDidNavigateNewSubframe( |
1224 RenderFrameHost* rfh, | 1225 RenderFrameHost* rfh, |
1225 const FrameHostMsg_DidCommitProvisionalLoad_Params& params) { | 1226 const FrameHostMsg_DidCommitProvisionalLoad_Params& params) { |
1226 if (ui::PageTransitionCoreTypeIs(params.transition, | 1227 if (ui::PageTransitionCoreTypeIs(params.transition, |
1227 ui::PAGE_TRANSITION_AUTO_SUBFRAME)) { | 1228 ui::PAGE_TRANSITION_AUTO_SUBFRAME)) { |
1228 // This is not user-initiated. Ignore. | 1229 // There was a comment here that said, "This is not user-initiated. Ignore." |
1230 // But this makes no sense; non-user-initiated navigations should be | |
1231 // determined to be of type NAVIGATION_TYPE_AUTO_SUBFRAME and sent to | |
1232 // RendererDidNavigateAutoSubframe below. | |
1233 // | |
1234 // This if clause dates back to https://codereview.chromium.org/115919 and | |
1235 // the handling of immediate redirects. TODO(avi): Is this still valid? I'm | |
1236 // pretty sure that's there's nothing left of that code and that we should | |
1237 // take this out. | |
1238 // | |
1239 // Except for cross-process iframes; this doesn't work yet for them. | |
1240 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( | |
1241 switches::kSitePerProcess)) { | |
1242 NOTREACHED(); | |
1243 } | |
1244 | |
1229 DiscardNonCommittedEntriesInternal(); | 1245 DiscardNonCommittedEntriesInternal(); |
1230 return; | 1246 return; |
1231 } | 1247 } |
1232 | 1248 |
1233 // Manual subframe navigations just get the current entry cloned so the user | 1249 // Manual subframe navigations just get the current entry cloned so the user |
1234 // can go back or forward to it. The actual subframe information will be | 1250 // can go back or forward to it. The actual subframe information will be |
1235 // stored in the page state for each of those entries. This happens out of | 1251 // stored in the page state for each of those entries. This happens out of |
1236 // band with the actual navigations. | 1252 // band with the actual navigations. |
1237 DCHECK(GetLastCommittedEntry()) << "ClassifyNavigation should guarantee " | 1253 DCHECK(GetLastCommittedEntry()) << "ClassifyNavigation should guarantee " |
1238 << "that a last committed entry exists."; | 1254 << "that a last committed entry exists."; |
1239 NavigationEntryImpl* new_entry = new NavigationEntryImpl( | 1255 NavigationEntryImpl* new_entry = new NavigationEntryImpl( |
1240 *NavigationEntryImpl::FromNavigationEntry(GetLastCommittedEntry())); | 1256 *NavigationEntryImpl::FromNavigationEntry(GetLastCommittedEntry())); |
1241 new_entry->SetPageID(params.page_id); | 1257 new_entry->SetPageID(params.page_id); |
1242 InsertOrReplaceEntry(new_entry, false); | 1258 InsertOrReplaceEntry(new_entry, false); |
1243 } | 1259 } |
1244 | 1260 |
1245 bool NavigationControllerImpl::RendererDidNavigateAutoSubframe( | 1261 bool NavigationControllerImpl::RendererDidNavigateAutoSubframe( |
1246 RenderFrameHost* rfh, | 1262 RenderFrameHost* rfh, |
1247 const FrameHostMsg_DidCommitProvisionalLoad_Params& params) { | 1263 const FrameHostMsg_DidCommitProvisionalLoad_Params& params) { |
1264 DCHECK(ui::PageTransitionCoreTypeIs(params.transition, | |
1265 ui::PAGE_TRANSITION_AUTO_SUBFRAME)); | |
Avi (use Gerrit)
2015/02/09 22:20:50
Note that this fails on the reload tests because i
Charlie Reis
2015/02/09 22:33:03
It certainly seems strange for this check to fail
| |
1266 | |
1248 // We're guaranteed to have a previously committed entry, and we now need to | 1267 // We're guaranteed to have a previously committed entry, and we now need to |
1249 // handle navigation inside of a subframe in it without creating a new entry. | 1268 // handle navigation inside of a subframe in it without creating a new entry. |
1250 DCHECK(GetLastCommittedEntry()); | 1269 DCHECK(GetLastCommittedEntry()); |
1251 | 1270 |
1252 // Handle the case where we're navigating back/forward to a previous subframe | 1271 // Handle the case where we're navigating back/forward to a previous subframe |
1253 // navigation entry. This is case "2." in NAV_AUTO_SUBFRAME comment in the | 1272 // navigation entry. This is case "2." in NAV_AUTO_SUBFRAME comment in the |
1254 // header file. In case "1." this will be a NOP. | 1273 // header file. In case "1." this will be a NOP. |
1255 int entry_index = GetEntryIndexWithPageID( | 1274 int entry_index = GetEntryIndexWithPageID( |
1256 rfh->GetSiteInstance(), | 1275 rfh->GetSiteInstance(), |
1257 params.page_id); | 1276 params.page_id); |
(...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1787 } | 1806 } |
1788 } | 1807 } |
1789 } | 1808 } |
1790 | 1809 |
1791 void NavigationControllerImpl::SetGetTimestampCallbackForTest( | 1810 void NavigationControllerImpl::SetGetTimestampCallbackForTest( |
1792 const base::Callback<base::Time()>& get_timestamp_callback) { | 1811 const base::Callback<base::Time()>& get_timestamp_callback) { |
1793 get_timestamp_callback_ = get_timestamp_callback; | 1812 get_timestamp_callback_ = get_timestamp_callback; |
1794 } | 1813 } |
1795 | 1814 |
1796 } // namespace content | 1815 } // namespace content |
OLD | NEW |