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 | 1219 |
1219 // If a transient entry was removed, the indices might have changed, so we | 1220 // If a transient entry was removed, the indices might have changed, so we |
1220 // have to query the entry index again. | 1221 // have to query the entry index again. |
1221 last_committed_entry_index_ = | 1222 last_committed_entry_index_ = |
1222 GetEntryIndexWithPageID(rfh->GetSiteInstance(), params.page_id); | 1223 GetEntryIndexWithPageID(rfh->GetSiteInstance(), params.page_id); |
1223 } | 1224 } |
1224 | 1225 |
1225 void NavigationControllerImpl::RendererDidNavigateNewSubframe( | 1226 void NavigationControllerImpl::RendererDidNavigateNewSubframe( |
1226 RenderFrameHost* rfh, | 1227 RenderFrameHost* rfh, |
1227 const FrameHostMsg_DidCommitProvisionalLoad_Params& params) { | 1228 const FrameHostMsg_DidCommitProvisionalLoad_Params& params) { |
1228 if (ui::PageTransitionCoreTypeIs(params.transition, | 1229 if (!ui::PageTransitionCoreTypeIs(params.transition, |
1229 ui::PAGE_TRANSITION_AUTO_SUBFRAME)) { | 1230 ui::PAGE_TRANSITION_MANUAL_SUBFRAME)) { |
1230 // This is not user-initiated. Ignore. | 1231 // There was a comment here that said, "This is not user-initiated. Ignore." |
| 1232 // But this makes no sense; non-user-initiated navigations should be |
| 1233 // determined to be of type NAVIGATION_TYPE_AUTO_SUBFRAME and sent to |
| 1234 // RendererDidNavigateAutoSubframe below. |
| 1235 // |
| 1236 // This if clause dates back to https://codereview.chromium.org/115919 and |
| 1237 // the handling of immediate redirects. TODO(avi): Is this still valid? I'm |
| 1238 // pretty sure that's there's nothing left of that code and that we should |
| 1239 // take this out. |
| 1240 // |
| 1241 // Except for cross-process iframes; this doesn't work yet for them. |
| 1242 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 1243 switches::kSitePerProcess)) { |
| 1244 NOTREACHED(); |
| 1245 } |
| 1246 |
1231 DiscardNonCommittedEntriesInternal(); | 1247 DiscardNonCommittedEntriesInternal(); |
1232 return; | 1248 return; |
1233 } | 1249 } |
1234 | 1250 |
1235 // Manual subframe navigations just get the current entry cloned so the user | 1251 // Manual subframe navigations just get the current entry cloned so the user |
1236 // can go back or forward to it. The actual subframe information will be | 1252 // can go back or forward to it. The actual subframe information will be |
1237 // stored in the page state for each of those entries. This happens out of | 1253 // stored in the page state for each of those entries. This happens out of |
1238 // band with the actual navigations. | 1254 // band with the actual navigations. |
1239 DCHECK(GetLastCommittedEntry()) << "ClassifyNavigation should guarantee " | 1255 DCHECK(GetLastCommittedEntry()) << "ClassifyNavigation should guarantee " |
1240 << "that a last committed entry exists."; | 1256 << "that a last committed entry exists."; |
1241 NavigationEntryImpl* new_entry = new NavigationEntryImpl( | 1257 NavigationEntryImpl* new_entry = new NavigationEntryImpl( |
1242 *NavigationEntryImpl::FromNavigationEntry(GetLastCommittedEntry())); | 1258 *NavigationEntryImpl::FromNavigationEntry(GetLastCommittedEntry())); |
1243 new_entry->SetPageID(params.page_id); | 1259 new_entry->SetPageID(params.page_id); |
1244 InsertOrReplaceEntry(new_entry, false); | 1260 InsertOrReplaceEntry(new_entry, false); |
1245 } | 1261 } |
1246 | 1262 |
1247 bool NavigationControllerImpl::RendererDidNavigateAutoSubframe( | 1263 bool NavigationControllerImpl::RendererDidNavigateAutoSubframe( |
1248 RenderFrameHost* rfh, | 1264 RenderFrameHost* rfh, |
1249 const FrameHostMsg_DidCommitProvisionalLoad_Params& params) { | 1265 const FrameHostMsg_DidCommitProvisionalLoad_Params& params) { |
| 1266 DCHECK(ui::PageTransitionCoreTypeIs(params.transition, |
| 1267 ui::PAGE_TRANSITION_AUTO_SUBFRAME)); |
| 1268 |
1250 // We're guaranteed to have a previously committed entry, and we now need to | 1269 // We're guaranteed to have a previously committed entry, and we now need to |
1251 // handle navigation inside of a subframe in it without creating a new entry. | 1270 // handle navigation inside of a subframe in it without creating a new entry. |
1252 DCHECK(GetLastCommittedEntry()); | 1271 DCHECK(GetLastCommittedEntry()); |
1253 | 1272 |
1254 // Handle the case where we're navigating back/forward to a previous subframe | 1273 // Handle the case where we're navigating back/forward to a previous subframe |
1255 // navigation entry. This is case "2." in NAV_AUTO_SUBFRAME comment in the | 1274 // navigation entry. This is case "2." in NAV_AUTO_SUBFRAME comment in the |
1256 // header file. In case "1." this will be a NOP. | 1275 // header file. In case "1." this will be a NOP. |
1257 int entry_index = GetEntryIndexWithPageID( | 1276 int entry_index = GetEntryIndexWithPageID( |
1258 rfh->GetSiteInstance(), | 1277 rfh->GetSiteInstance(), |
1259 params.page_id); | 1278 params.page_id); |
(...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1790 } | 1809 } |
1791 } | 1810 } |
1792 } | 1811 } |
1793 | 1812 |
1794 void NavigationControllerImpl::SetGetTimestampCallbackForTest( | 1813 void NavigationControllerImpl::SetGetTimestampCallbackForTest( |
1795 const base::Callback<base::Time()>& get_timestamp_callback) { | 1814 const base::Callback<base::Time()>& get_timestamp_callback) { |
1796 get_timestamp_callback_ = get_timestamp_callback; | 1815 get_timestamp_callback_ = get_timestamp_callback; |
1797 } | 1816 } |
1798 | 1817 |
1799 } // namespace content | 1818 } // namespace content |
OLD | NEW |