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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 #include "content/browser/dom_storage/dom_storage_context_wrapper.h" | 52 #include "content/browser/dom_storage/dom_storage_context_wrapper.h" |
53 #include "content/browser/dom_storage/session_storage_namespace_impl.h" | 53 #include "content/browser/dom_storage/session_storage_namespace_impl.h" |
54 #include "content/browser/frame_host/debug_urls.h" | 54 #include "content/browser/frame_host/debug_urls.h" |
55 #include "content/browser/frame_host/interstitial_page_impl.h" | 55 #include "content/browser/frame_host/interstitial_page_impl.h" |
56 #include "content/browser/frame_host/navigation_entry_impl.h" | 56 #include "content/browser/frame_host/navigation_entry_impl.h" |
57 #include "content/browser/frame_host/navigation_entry_screenshot_manager.h" | 57 #include "content/browser/frame_host/navigation_entry_screenshot_manager.h" |
58 #include "content/browser/frame_host/navigator.h" | 58 #include "content/browser/frame_host/navigator.h" |
59 #include "content/browser/renderer_host/render_view_host_impl.h" // Temporary | 59 #include "content/browser/renderer_host/render_view_host_impl.h" // Temporary |
60 #include "content/browser/site_instance_impl.h" | 60 #include "content/browser/site_instance_impl.h" |
61 #include "content/common/frame_messages.h" | 61 #include "content/common/frame_messages.h" |
| 62 #include "content/common/site_isolation_policy.h" |
62 #include "content/common/ssl_status_serialization.h" | 63 #include "content/common/ssl_status_serialization.h" |
63 #include "content/common/view_messages.h" | 64 #include "content/common/view_messages.h" |
64 #include "content/public/browser/browser_context.h" | 65 #include "content/public/browser/browser_context.h" |
65 #include "content/public/browser/content_browser_client.h" | 66 #include "content/public/browser/content_browser_client.h" |
66 #include "content/public/browser/invalidate_type.h" | 67 #include "content/public/browser/invalidate_type.h" |
67 #include "content/public/browser/navigation_details.h" | 68 #include "content/public/browser/navigation_details.h" |
68 #include "content/public/browser/notification_service.h" | 69 #include "content/public/browser/notification_service.h" |
69 #include "content/public/browser/notification_types.h" | 70 #include "content/public/browser/notification_types.h" |
70 #include "content/public/browser/render_widget_host.h" | 71 #include "content/public/browser/render_widget_host.h" |
71 #include "content/public/browser/render_widget_host_view.h" | 72 #include "content/public/browser/render_widget_host_view.h" |
72 #include "content/public/browser/storage_partition.h" | 73 #include "content/public/browser/storage_partition.h" |
73 #include "content/public/browser/user_metrics.h" | 74 #include "content/public/browser/user_metrics.h" |
74 #include "content/public/common/content_client.h" | 75 #include "content/public/common/content_client.h" |
75 #include "content/public/common/content_constants.h" | 76 #include "content/public/common/content_constants.h" |
76 #include "content/public/common/content_switches.h" | |
77 #include "media/base/mime_util.h" | 77 #include "media/base/mime_util.h" |
78 #include "net/base/escape.h" | 78 #include "net/base/escape.h" |
79 #include "net/base/net_util.h" | 79 #include "net/base/net_util.h" |
80 #include "skia/ext/platform_canvas.h" | 80 #include "skia/ext/platform_canvas.h" |
81 #include "url/url_constants.h" | 81 #include "url/url_constants.h" |
82 | 82 |
83 namespace content { | 83 namespace content { |
84 namespace { | 84 namespace { |
85 | 85 |
86 // Invoked when entries have been pruned, or removed. For example, if the | 86 // Invoked when entries have been pruned, or removed. For example, if the |
(...skipping 643 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
730 ? delegate_->GetFrameTree()->FindByID(params.frame_tree_node_id) | 730 ? delegate_->GetFrameTree()->FindByID(params.frame_tree_node_id) |
731 : delegate_->GetFrameTree()->FindByName(params.frame_name); | 731 : delegate_->GetFrameTree()->FindByName(params.frame_name); |
732 if (node && !node->IsMainFrame()) { | 732 if (node && !node->IsMainFrame()) { |
733 DCHECK(GetLastCommittedEntry()); | 733 DCHECK(GetLastCommittedEntry()); |
734 | 734 |
735 // Update the FTN ID to use below in case we found a named frame. | 735 // Update the FTN ID to use below in case we found a named frame. |
736 frame_tree_node_id = node->frame_tree_node_id(); | 736 frame_tree_node_id = node->frame_tree_node_id(); |
737 | 737 |
738 // In --site-per-process, create an identical NavigationEntry with a | 738 // In --site-per-process, create an identical NavigationEntry with a |
739 // new FrameNavigationEntry for the target subframe. | 739 // new FrameNavigationEntry for the target subframe. |
740 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 740 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { |
741 switches::kSitePerProcess)) { | |
742 entry = GetLastCommittedEntry()->Clone(); | 741 entry = GetLastCommittedEntry()->Clone(); |
743 entry->SetPageID(-1); | 742 entry->SetPageID(-1); |
744 entry->AddOrUpdateFrameEntry(node, -1, -1, nullptr, params.url, | 743 entry->AddOrUpdateFrameEntry(node, -1, -1, nullptr, params.url, |
745 params.referrer, PageState()); | 744 params.referrer, PageState()); |
746 } | 745 } |
747 } | 746 } |
748 } | 747 } |
749 | 748 |
750 // Otherwise, create a pending entry for the main frame. | 749 // Otherwise, create a pending entry for the main frame. |
751 if (!entry) { | 750 if (!entry) { |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
884 // We should not have a pending entry anymore. Clear it again in case any | 883 // We should not have a pending entry anymore. Clear it again in case any |
885 // error cases above forgot to do so. | 884 // error cases above forgot to do so. |
886 DiscardNonCommittedEntriesInternal(); | 885 DiscardNonCommittedEntriesInternal(); |
887 | 886 |
888 // All committed entries should have nonempty content state so WebKit doesn't | 887 // All committed entries should have nonempty content state so WebKit doesn't |
889 // get confused when we go back to them (see the function for details). | 888 // get confused when we go back to them (see the function for details). |
890 DCHECK(params.page_state.IsValid()); | 889 DCHECK(params.page_state.IsValid()); |
891 NavigationEntryImpl* active_entry = GetLastCommittedEntry(); | 890 NavigationEntryImpl* active_entry = GetLastCommittedEntry(); |
892 active_entry->SetTimestamp(timestamp); | 891 active_entry->SetTimestamp(timestamp); |
893 active_entry->SetHttpStatusCode(params.http_status_code); | 892 active_entry->SetHttpStatusCode(params.http_status_code); |
894 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 893 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { |
895 switches::kSitePerProcess)) { | |
896 // Update the frame-specific PageState. | 894 // Update the frame-specific PageState. |
897 FrameNavigationEntry* frame_entry = | 895 FrameNavigationEntry* frame_entry = |
898 active_entry->GetFrameEntry(rfh->frame_tree_node()); | 896 active_entry->GetFrameEntry(rfh->frame_tree_node()); |
899 frame_entry->set_page_state(params.page_state); | 897 frame_entry->set_page_state(params.page_state); |
900 } else { | 898 } else { |
901 active_entry->SetPageState(params.page_state); | 899 active_entry->SetPageState(params.page_state); |
902 } | 900 } |
903 active_entry->SetRedirectChain(params.redirects); | 901 active_entry->SetRedirectChain(params.redirects); |
904 | 902 |
905 // Use histogram to track memory impact of redirect chain because it's now | 903 // Use histogram to track memory impact of redirect chain because it's now |
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1216 ui::PAGE_TRANSITION_MANUAL_SUBFRAME)); | 1214 ui::PAGE_TRANSITION_MANUAL_SUBFRAME)); |
1217 | 1215 |
1218 // Manual subframe navigations just get the current entry cloned so the user | 1216 // Manual subframe navigations just get the current entry cloned so the user |
1219 // can go back or forward to it. The actual subframe information will be | 1217 // can go back or forward to it. The actual subframe information will be |
1220 // stored in the page state for each of those entries. This happens out of | 1218 // stored in the page state for each of those entries. This happens out of |
1221 // band with the actual navigations. | 1219 // band with the actual navigations. |
1222 DCHECK(GetLastCommittedEntry()) << "ClassifyNavigation should guarantee " | 1220 DCHECK(GetLastCommittedEntry()) << "ClassifyNavigation should guarantee " |
1223 << "that a last committed entry exists."; | 1221 << "that a last committed entry exists."; |
1224 | 1222 |
1225 scoped_ptr<NavigationEntryImpl> new_entry; | 1223 scoped_ptr<NavigationEntryImpl> new_entry; |
1226 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 1224 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { |
1227 switches::kSitePerProcess)) { | |
1228 // Make sure new_entry takes ownership of frame_entry in a scoped_refptr. | 1225 // Make sure new_entry takes ownership of frame_entry in a scoped_refptr. |
1229 FrameNavigationEntry* frame_entry = new FrameNavigationEntry( | 1226 FrameNavigationEntry* frame_entry = new FrameNavigationEntry( |
1230 rfh->frame_tree_node()->frame_tree_node_id(), | 1227 rfh->frame_tree_node()->frame_tree_node_id(), |
1231 params.item_sequence_number, params.document_sequence_number, | 1228 params.item_sequence_number, params.document_sequence_number, |
1232 rfh->GetSiteInstance(), params.url, params.referrer); | 1229 rfh->GetSiteInstance(), params.url, params.referrer); |
1233 new_entry = GetLastCommittedEntry()->CloneAndReplace(rfh->frame_tree_node(), | 1230 new_entry = GetLastCommittedEntry()->CloneAndReplace(rfh->frame_tree_node(), |
1234 frame_entry); | 1231 frame_entry); |
1235 CHECK(frame_entry->HasOneRef()); | 1232 CHECK(frame_entry->HasOneRef()); |
1236 } else { | 1233 } else { |
1237 new_entry = GetLastCommittedEntry()->Clone(); | 1234 new_entry = GetLastCommittedEntry()->Clone(); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1272 NOTREACHED() << "Unexpected main frame origin change on AUTO_SUBFRAME."; | 1269 NOTREACHED() << "Unexpected main frame origin change on AUTO_SUBFRAME."; |
1273 } | 1270 } |
1274 | 1271 |
1275 // TODO(creis): Update the FrameNavigationEntry in --site-per-process. | 1272 // TODO(creis): Update the FrameNavigationEntry in --site-per-process. |
1276 last_committed_entry_index_ = entry_index; | 1273 last_committed_entry_index_ = entry_index; |
1277 DiscardNonCommittedEntriesInternal(); | 1274 DiscardNonCommittedEntriesInternal(); |
1278 return true; | 1275 return true; |
1279 } | 1276 } |
1280 } | 1277 } |
1281 | 1278 |
1282 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 1279 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { |
1283 switches::kSitePerProcess)) { | |
1284 // This may be a "new auto" case where we add a new FrameNavigationEntry, or | 1280 // This may be a "new auto" case where we add a new FrameNavigationEntry, or |
1285 // it may be a "history auto" case where we update an existing one. | 1281 // it may be a "history auto" case where we update an existing one. |
1286 NavigationEntryImpl* last_committed = GetLastCommittedEntry(); | 1282 NavigationEntryImpl* last_committed = GetLastCommittedEntry(); |
1287 last_committed->AddOrUpdateFrameEntry( | 1283 last_committed->AddOrUpdateFrameEntry( |
1288 rfh->frame_tree_node(), params.item_sequence_number, | 1284 rfh->frame_tree_node(), params.item_sequence_number, |
1289 params.document_sequence_number, rfh->GetSiteInstance(), params.url, | 1285 params.document_sequence_number, rfh->GetSiteInstance(), params.url, |
1290 params.referrer, params.page_state); | 1286 params.referrer, params.page_state); |
1291 | 1287 |
1292 // Cross-process subframe navigations may leave a pending entry around. | 1288 // Cross-process subframe navigations may leave a pending entry around. |
1293 // Clear it if it's actually for the subframe. | 1289 // Clear it if it's actually for the subframe. |
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1737 } | 1733 } |
1738 | 1734 |
1739 bool NavigationControllerImpl::NavigateToPendingEntryInternal( | 1735 bool NavigationControllerImpl::NavigateToPendingEntryInternal( |
1740 ReloadType reload_type) { | 1736 ReloadType reload_type) { |
1741 DCHECK(pending_entry_); | 1737 DCHECK(pending_entry_); |
1742 FrameTreeNode* root = delegate_->GetFrameTree()->root(); | 1738 FrameTreeNode* root = delegate_->GetFrameTree()->root(); |
1743 | 1739 |
1744 // In default Chrome, there are no subframe FrameNavigationEntries. Either | 1740 // In default Chrome, there are no subframe FrameNavigationEntries. Either |
1745 // navigate the main frame or use the main frame's FrameNavigationEntry to | 1741 // navigate the main frame or use the main frame's FrameNavigationEntry to |
1746 // tell the indicated frame where to go. | 1742 // tell the indicated frame where to go. |
1747 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( | 1743 if (!SiteIsolationPolicy::UseSubframeNavigationEntries()) { |
1748 switches::kSitePerProcess)) { | |
1749 FrameNavigationEntry* frame_entry = GetPendingEntry()->GetFrameEntry(root); | 1744 FrameNavigationEntry* frame_entry = GetPendingEntry()->GetFrameEntry(root); |
1750 FrameTreeNode* frame = root; | 1745 FrameTreeNode* frame = root; |
1751 int ftn_id = GetPendingEntry()->frame_tree_node_id(); | 1746 int ftn_id = GetPendingEntry()->frame_tree_node_id(); |
1752 if (ftn_id != -1) { | 1747 if (ftn_id != -1) { |
1753 frame = delegate_->GetFrameTree()->FindByID(ftn_id); | 1748 frame = delegate_->GetFrameTree()->FindByID(ftn_id); |
1754 DCHECK(frame); | 1749 DCHECK(frame); |
1755 } | 1750 } |
1756 return frame->navigator()->NavigateToPendingEntry(frame, *frame_entry, | 1751 return frame->navigator()->NavigateToPendingEntry(frame, *frame_entry, |
1757 reload_type, false); | 1752 reload_type, false); |
1758 } | 1753 } |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1982 } | 1977 } |
1983 } | 1978 } |
1984 } | 1979 } |
1985 | 1980 |
1986 void NavigationControllerImpl::SetGetTimestampCallbackForTest( | 1981 void NavigationControllerImpl::SetGetTimestampCallbackForTest( |
1987 const base::Callback<base::Time()>& get_timestamp_callback) { | 1982 const base::Callback<base::Time()>& get_timestamp_callback) { |
1988 get_timestamp_callback_ = get_timestamp_callback; | 1983 get_timestamp_callback_ = get_timestamp_callback; |
1989 } | 1984 } |
1990 | 1985 |
1991 } // namespace content | 1986 } // namespace content |
OLD | NEW |