| 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 /* | 5 /* |
| 6 * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. | 6 * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. |
| 7 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) | 7 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) |
| 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. | 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. |
| 9 * (http://www.torchmobile.com/) | 9 * (http://www.torchmobile.com/) |
| 10 * | 10 * |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 #include "content/public/browser/invalidate_type.h" | 65 #include "content/public/browser/invalidate_type.h" |
| 66 #include "content/public/browser/navigation_details.h" | 66 #include "content/public/browser/navigation_details.h" |
| 67 #include "content/public/browser/notification_service.h" | 67 #include "content/public/browser/notification_service.h" |
| 68 #include "content/public/browser/notification_types.h" | 68 #include "content/public/browser/notification_types.h" |
| 69 #include "content/public/browser/render_widget_host.h" | 69 #include "content/public/browser/render_widget_host.h" |
| 70 #include "content/public/browser/render_widget_host_view.h" | 70 #include "content/public/browser/render_widget_host_view.h" |
| 71 #include "content/public/browser/storage_partition.h" | 71 #include "content/public/browser/storage_partition.h" |
| 72 #include "content/public/browser/user_metrics.h" | 72 #include "content/public/browser/user_metrics.h" |
| 73 #include "content/public/common/content_client.h" | 73 #include "content/public/common/content_client.h" |
| 74 #include "content/public/common/content_constants.h" | 74 #include "content/public/common/content_constants.h" |
| 75 #include "content/public/common/content_switches.h" | 75 #include "content/public/common/site_isolation_policy.h" |
| 76 #include "media/base/mime_util.h" | 76 #include "media/base/mime_util.h" |
| 77 #include "net/base/escape.h" | 77 #include "net/base/escape.h" |
| 78 #include "net/base/net_util.h" | 78 #include "net/base/net_util.h" |
| 79 #include "skia/ext/platform_canvas.h" | 79 #include "skia/ext/platform_canvas.h" |
| 80 #include "url/url_constants.h" | 80 #include "url/url_constants.h" |
| 81 | 81 |
| 82 namespace content { | 82 namespace content { |
| 83 namespace { | 83 namespace { |
| 84 | 84 |
| 85 // Invoked when entries have been pruned, or removed. For example, if the | 85 // Invoked when entries have been pruned, or removed. For example, if the |
| (...skipping 660 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 746 ? delegate_->GetFrameTree()->FindByID(params.frame_tree_node_id) | 746 ? delegate_->GetFrameTree()->FindByID(params.frame_tree_node_id) |
| 747 : delegate_->GetFrameTree()->FindByName(params.frame_name); | 747 : delegate_->GetFrameTree()->FindByName(params.frame_name); |
| 748 if (node && !node->IsMainFrame()) { | 748 if (node && !node->IsMainFrame()) { |
| 749 DCHECK(GetLastCommittedEntry()); | 749 DCHECK(GetLastCommittedEntry()); |
| 750 | 750 |
| 751 // Update the FTN ID to use below in case we found a named frame. | 751 // Update the FTN ID to use below in case we found a named frame. |
| 752 frame_tree_node_id = node->frame_tree_node_id(); | 752 frame_tree_node_id = node->frame_tree_node_id(); |
| 753 | 753 |
| 754 // In --site-per-process, create an identical NavigationEntry with a | 754 // In --site-per-process, create an identical NavigationEntry with a |
| 755 // new FrameNavigationEntry for the target subframe. | 755 // new FrameNavigationEntry for the target subframe. |
| 756 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 756 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { |
| 757 switches::kSitePerProcess)) { | |
| 758 entry = GetLastCommittedEntry()->Clone(); | 757 entry = GetLastCommittedEntry()->Clone(); |
| 759 entry->SetPageID(-1); | 758 entry->SetPageID(-1); |
| 760 entry->AddOrUpdateFrameEntry(node, -1, -1, nullptr, params.url, | 759 entry->AddOrUpdateFrameEntry(node, -1, -1, nullptr, params.url, |
| 761 params.referrer, PageState()); | 760 params.referrer, PageState()); |
| 762 } | 761 } |
| 763 } | 762 } |
| 764 } | 763 } |
| 765 | 764 |
| 766 // Otherwise, create a pending entry for the main frame. | 765 // Otherwise, create a pending entry for the main frame. |
| 767 if (!entry) { | 766 if (!entry) { |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 902 // We should not have a pending entry anymore. Clear it again in case any | 901 // We should not have a pending entry anymore. Clear it again in case any |
| 903 // error cases above forgot to do so. | 902 // error cases above forgot to do so. |
| 904 DiscardNonCommittedEntriesInternal(); | 903 DiscardNonCommittedEntriesInternal(); |
| 905 | 904 |
| 906 // All committed entries should have nonempty content state so WebKit doesn't | 905 // All committed entries should have nonempty content state so WebKit doesn't |
| 907 // get confused when we go back to them (see the function for details). | 906 // get confused when we go back to them (see the function for details). |
| 908 DCHECK(params.page_state.IsValid()); | 907 DCHECK(params.page_state.IsValid()); |
| 909 NavigationEntryImpl* active_entry = GetLastCommittedEntry(); | 908 NavigationEntryImpl* active_entry = GetLastCommittedEntry(); |
| 910 active_entry->SetTimestamp(timestamp); | 909 active_entry->SetTimestamp(timestamp); |
| 911 active_entry->SetHttpStatusCode(params.http_status_code); | 910 active_entry->SetHttpStatusCode(params.http_status_code); |
| 912 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 911 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { |
| 913 switches::kSitePerProcess)) { | |
| 914 // Update the frame-specific PageState. | 912 // Update the frame-specific PageState. |
| 915 FrameNavigationEntry* frame_entry = | 913 FrameNavigationEntry* frame_entry = |
| 916 active_entry->GetFrameEntry(rfh->frame_tree_node()); | 914 active_entry->GetFrameEntry(rfh->frame_tree_node()); |
| 917 frame_entry->set_page_state(params.page_state); | 915 frame_entry->set_page_state(params.page_state); |
| 918 } else { | 916 } else { |
| 919 active_entry->SetPageState(params.page_state); | 917 active_entry->SetPageState(params.page_state); |
| 920 } | 918 } |
| 921 active_entry->SetRedirectChain(params.redirects); | 919 active_entry->SetRedirectChain(params.redirects); |
| 922 | 920 |
| 923 // Use histogram to track memory impact of redirect chain because it's now | 921 // Use histogram to track memory impact of redirect chain because it's now |
| (...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1283 // But this makes no sense; non-user-initiated navigations should be | 1281 // But this makes no sense; non-user-initiated navigations should be |
| 1284 // determined to be of type NAVIGATION_TYPE_AUTO_SUBFRAME and sent to | 1282 // determined to be of type NAVIGATION_TYPE_AUTO_SUBFRAME and sent to |
| 1285 // RendererDidNavigateAutoSubframe below. | 1283 // RendererDidNavigateAutoSubframe below. |
| 1286 // | 1284 // |
| 1287 // This if clause dates back to https://codereview.chromium.org/115919 and | 1285 // This if clause dates back to https://codereview.chromium.org/115919 and |
| 1288 // the handling of immediate redirects. TODO(avi): Is this still valid? I'm | 1286 // the handling of immediate redirects. TODO(avi): Is this still valid? I'm |
| 1289 // pretty sure that's there's nothing left of that code and that we should | 1287 // pretty sure that's there's nothing left of that code and that we should |
| 1290 // take this out. | 1288 // take this out. |
| 1291 // | 1289 // |
| 1292 // Except for cross-process iframes; this doesn't work yet for them. | 1290 // Except for cross-process iframes; this doesn't work yet for them. |
| 1293 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( | 1291 if (!SiteIsolationPolicy::AreCrossProcessFramesPossible()) { |
| 1294 switches::kSitePerProcess)) { | |
| 1295 NOTREACHED(); | 1292 NOTREACHED(); |
| 1296 } | 1293 } |
| 1297 | 1294 |
| 1298 DiscardNonCommittedEntriesInternal(); | 1295 DiscardNonCommittedEntriesInternal(); |
| 1299 return; | 1296 return; |
| 1300 } | 1297 } |
| 1301 | 1298 |
| 1302 // Manual subframe navigations just get the current entry cloned so the user | 1299 // Manual subframe navigations just get the current entry cloned so the user |
| 1303 // can go back or forward to it. The actual subframe information will be | 1300 // can go back or forward to it. The actual subframe information will be |
| 1304 // stored in the page state for each of those entries. This happens out of | 1301 // stored in the page state for each of those entries. This happens out of |
| 1305 // band with the actual navigations. | 1302 // band with the actual navigations. |
| 1306 DCHECK(GetLastCommittedEntry()) << "ClassifyNavigation should guarantee " | 1303 DCHECK(GetLastCommittedEntry()) << "ClassifyNavigation should guarantee " |
| 1307 << "that a last committed entry exists."; | 1304 << "that a last committed entry exists."; |
| 1308 | 1305 |
| 1309 scoped_ptr<NavigationEntryImpl> new_entry; | 1306 scoped_ptr<NavigationEntryImpl> new_entry; |
| 1310 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 1307 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { |
| 1311 switches::kSitePerProcess)) { | |
| 1312 // Make sure new_entry takes ownership of frame_entry in a scoped_refptr. | 1308 // Make sure new_entry takes ownership of frame_entry in a scoped_refptr. |
| 1313 FrameNavigationEntry* frame_entry = new FrameNavigationEntry( | 1309 FrameNavigationEntry* frame_entry = new FrameNavigationEntry( |
| 1314 rfh->frame_tree_node()->frame_tree_node_id(), | 1310 rfh->frame_tree_node()->frame_tree_node_id(), |
| 1315 params.item_sequence_number, params.document_sequence_number, | 1311 params.item_sequence_number, params.document_sequence_number, |
| 1316 rfh->GetSiteInstance(), params.url, params.referrer); | 1312 rfh->GetSiteInstance(), params.url, params.referrer); |
| 1317 new_entry = GetLastCommittedEntry()->CloneAndReplace(rfh->frame_tree_node(), | 1313 new_entry = GetLastCommittedEntry()->CloneAndReplace(rfh->frame_tree_node(), |
| 1318 frame_entry); | 1314 frame_entry); |
| 1319 CHECK(frame_entry->HasOneRef()); | 1315 CHECK(frame_entry->HasOneRef()); |
| 1320 } else { | 1316 } else { |
| 1321 new_entry = GetLastCommittedEntry()->Clone(); | 1317 new_entry = GetLastCommittedEntry()->Clone(); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1356 NOTREACHED() << "Unexpected main frame origin change on AUTO_SUBFRAME."; | 1352 NOTREACHED() << "Unexpected main frame origin change on AUTO_SUBFRAME."; |
| 1357 } | 1353 } |
| 1358 | 1354 |
| 1359 // TODO(creis): Update the FrameNavigationEntry in --site-per-process. | 1355 // TODO(creis): Update the FrameNavigationEntry in --site-per-process. |
| 1360 last_committed_entry_index_ = entry_index; | 1356 last_committed_entry_index_ = entry_index; |
| 1361 DiscardNonCommittedEntriesInternal(); | 1357 DiscardNonCommittedEntriesInternal(); |
| 1362 return true; | 1358 return true; |
| 1363 } | 1359 } |
| 1364 } | 1360 } |
| 1365 | 1361 |
| 1366 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 1362 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { |
| 1367 switches::kSitePerProcess)) { | |
| 1368 // This may be a "new auto" case where we add a new FrameNavigationEntry, or | 1363 // This may be a "new auto" case where we add a new FrameNavigationEntry, or |
| 1369 // it may be a "history auto" case where we update an existing one. | 1364 // it may be a "history auto" case where we update an existing one. |
| 1370 NavigationEntryImpl* last_committed = GetLastCommittedEntry(); | 1365 NavigationEntryImpl* last_committed = GetLastCommittedEntry(); |
| 1371 last_committed->AddOrUpdateFrameEntry( | 1366 last_committed->AddOrUpdateFrameEntry( |
| 1372 rfh->frame_tree_node(), params.item_sequence_number, | 1367 rfh->frame_tree_node(), params.item_sequence_number, |
| 1373 params.document_sequence_number, rfh->GetSiteInstance(), params.url, | 1368 params.document_sequence_number, rfh->GetSiteInstance(), params.url, |
| 1374 params.referrer, params.page_state); | 1369 params.referrer, params.page_state); |
| 1375 | 1370 |
| 1376 // Cross-process subframe navigations may leave a pending entry around. | 1371 // Cross-process subframe navigations may leave a pending entry around. |
| 1377 // Clear it if it's actually for the subframe. | 1372 // Clear it if it's actually for the subframe. |
| (...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1810 } | 1805 } |
| 1811 | 1806 |
| 1812 bool NavigationControllerImpl::NavigateToPendingEntryInternal( | 1807 bool NavigationControllerImpl::NavigateToPendingEntryInternal( |
| 1813 ReloadType reload_type) { | 1808 ReloadType reload_type) { |
| 1814 DCHECK(pending_entry_); | 1809 DCHECK(pending_entry_); |
| 1815 FrameTreeNode* root = delegate_->GetFrameTree()->root(); | 1810 FrameTreeNode* root = delegate_->GetFrameTree()->root(); |
| 1816 | 1811 |
| 1817 // In default Chrome, there are no subframe FrameNavigationEntries. Either | 1812 // In default Chrome, there are no subframe FrameNavigationEntries. Either |
| 1818 // navigate the main frame or use the main frame's FrameNavigationEntry to | 1813 // navigate the main frame or use the main frame's FrameNavigationEntry to |
| 1819 // tell the indicated frame where to go. | 1814 // tell the indicated frame where to go. |
| 1820 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( | 1815 if (!SiteIsolationPolicy::UseSubframeNavigationEntries()) { |
| 1821 switches::kSitePerProcess)) { | |
| 1822 FrameNavigationEntry* frame_entry = GetPendingEntry()->GetFrameEntry(root); | 1816 FrameNavigationEntry* frame_entry = GetPendingEntry()->GetFrameEntry(root); |
| 1823 FrameTreeNode* frame = root; | 1817 FrameTreeNode* frame = root; |
| 1824 int ftn_id = GetPendingEntry()->frame_tree_node_id(); | 1818 int ftn_id = GetPendingEntry()->frame_tree_node_id(); |
| 1825 if (ftn_id != -1) { | 1819 if (ftn_id != -1) { |
| 1826 frame = delegate_->GetFrameTree()->FindByID(ftn_id); | 1820 frame = delegate_->GetFrameTree()->FindByID(ftn_id); |
| 1827 DCHECK(frame); | 1821 DCHECK(frame); |
| 1828 } | 1822 } |
| 1829 return frame->navigator()->NavigateToPendingEntry(frame, *frame_entry, | 1823 return frame->navigator()->NavigateToPendingEntry(frame, *frame_entry, |
| 1830 reload_type, false); | 1824 reload_type, false); |
| 1831 } | 1825 } |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2055 } | 2049 } |
| 2056 } | 2050 } |
| 2057 } | 2051 } |
| 2058 | 2052 |
| 2059 void NavigationControllerImpl::SetGetTimestampCallbackForTest( | 2053 void NavigationControllerImpl::SetGetTimestampCallbackForTest( |
| 2060 const base::Callback<base::Time()>& get_timestamp_callback) { | 2054 const base::Callback<base::Time()>& get_timestamp_callback) { |
| 2061 get_timestamp_callback_ = get_timestamp_callback; | 2055 get_timestamp_callback_ = get_timestamp_callback; |
| 2062 } | 2056 } |
| 2063 | 2057 |
| 2064 } // namespace content | 2058 } // namespace content |
| OLD | NEW |