Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(42)

Side by Side Diff: content/browser/frame_host/navigation_controller_impl.cc

Issue 1208143002: Move existing kSitePerProcess checks to a policy-oracle object (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@swapped_out_cmdline_checks
Patch Set: Fix some includes Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 649 matching lines...) Expand 10 before | Expand all | Expand 10 after
736 ? delegate_->GetFrameTree()->FindByID(params.frame_tree_node_id) 736 ? delegate_->GetFrameTree()->FindByID(params.frame_tree_node_id)
737 : delegate_->GetFrameTree()->FindByName(params.frame_name); 737 : delegate_->GetFrameTree()->FindByName(params.frame_name);
738 if (node && !node->IsMainFrame()) { 738 if (node && !node->IsMainFrame()) {
739 DCHECK(GetLastCommittedEntry()); 739 DCHECK(GetLastCommittedEntry());
740 740
741 // Update the FTN ID to use below in case we found a named frame. 741 // Update the FTN ID to use below in case we found a named frame.
742 frame_tree_node_id = node->frame_tree_node_id(); 742 frame_tree_node_id = node->frame_tree_node_id();
743 743
744 // In --site-per-process, create an identical NavigationEntry with a 744 // In --site-per-process, create an identical NavigationEntry with a
745 // new FrameNavigationEntry for the target subframe. 745 // new FrameNavigationEntry for the target subframe.
746 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 746 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) {
747 switches::kSitePerProcess)) {
748 entry = GetLastCommittedEntry()->Clone(); 747 entry = GetLastCommittedEntry()->Clone();
749 entry->SetPageID(-1); 748 entry->SetPageID(-1);
750 entry->AddOrUpdateFrameEntry(node, -1, -1, nullptr, params.url, 749 entry->AddOrUpdateFrameEntry(node, -1, -1, nullptr, params.url,
751 params.referrer, PageState()); 750 params.referrer, PageState());
752 } 751 }
753 } 752 }
754 } 753 }
755 754
756 // Otherwise, create a pending entry for the main frame. 755 // Otherwise, create a pending entry for the main frame.
757 if (!entry) { 756 if (!entry) {
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
890 // We should not have a pending entry anymore. Clear it again in case any 889 // We should not have a pending entry anymore. Clear it again in case any
891 // error cases above forgot to do so. 890 // error cases above forgot to do so.
892 DiscardNonCommittedEntriesInternal(); 891 DiscardNonCommittedEntriesInternal();
893 892
894 // All committed entries should have nonempty content state so WebKit doesn't 893 // All committed entries should have nonempty content state so WebKit doesn't
895 // get confused when we go back to them (see the function for details). 894 // get confused when we go back to them (see the function for details).
896 DCHECK(params.page_state.IsValid()); 895 DCHECK(params.page_state.IsValid());
897 NavigationEntryImpl* active_entry = GetLastCommittedEntry(); 896 NavigationEntryImpl* active_entry = GetLastCommittedEntry();
898 active_entry->SetTimestamp(timestamp); 897 active_entry->SetTimestamp(timestamp);
899 active_entry->SetHttpStatusCode(params.http_status_code); 898 active_entry->SetHttpStatusCode(params.http_status_code);
900 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 899 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) {
901 switches::kSitePerProcess)) {
902 // Update the frame-specific PageState. 900 // Update the frame-specific PageState.
903 FrameNavigationEntry* frame_entry = 901 FrameNavigationEntry* frame_entry =
904 active_entry->GetFrameEntry(rfh->frame_tree_node()); 902 active_entry->GetFrameEntry(rfh->frame_tree_node());
905 frame_entry->set_page_state(params.page_state); 903 frame_entry->set_page_state(params.page_state);
906 } else { 904 } else {
907 active_entry->SetPageState(params.page_state); 905 active_entry->SetPageState(params.page_state);
908 } 906 }
909 active_entry->SetRedirectChain(params.redirects); 907 active_entry->SetRedirectChain(params.redirects);
910 908
911 // Use histogram to track memory impact of redirect chain because it's now 909 // 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
1222 ui::PAGE_TRANSITION_MANUAL_SUBFRAME)); 1220 ui::PAGE_TRANSITION_MANUAL_SUBFRAME));
1223 1221
1224 // Manual subframe navigations just get the current entry cloned so the user 1222 // Manual subframe navigations just get the current entry cloned so the user
1225 // can go back or forward to it. The actual subframe information will be 1223 // can go back or forward to it. The actual subframe information will be
1226 // stored in the page state for each of those entries. This happens out of 1224 // stored in the page state for each of those entries. This happens out of
1227 // band with the actual navigations. 1225 // band with the actual navigations.
1228 DCHECK(GetLastCommittedEntry()) << "ClassifyNavigation should guarantee " 1226 DCHECK(GetLastCommittedEntry()) << "ClassifyNavigation should guarantee "
1229 << "that a last committed entry exists."; 1227 << "that a last committed entry exists.";
1230 1228
1231 scoped_ptr<NavigationEntryImpl> new_entry; 1229 scoped_ptr<NavigationEntryImpl> new_entry;
1232 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 1230 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) {
1233 switches::kSitePerProcess)) {
1234 // Make sure new_entry takes ownership of frame_entry in a scoped_refptr. 1231 // Make sure new_entry takes ownership of frame_entry in a scoped_refptr.
1235 FrameNavigationEntry* frame_entry = new FrameNavigationEntry( 1232 FrameNavigationEntry* frame_entry = new FrameNavigationEntry(
1236 rfh->frame_tree_node()->frame_tree_node_id(), 1233 rfh->frame_tree_node()->frame_tree_node_id(),
1237 params.item_sequence_number, params.document_sequence_number, 1234 params.item_sequence_number, params.document_sequence_number,
1238 rfh->GetSiteInstance(), params.url, params.referrer); 1235 rfh->GetSiteInstance(), params.url, params.referrer);
1239 new_entry = GetLastCommittedEntry()->CloneAndReplace(rfh->frame_tree_node(), 1236 new_entry = GetLastCommittedEntry()->CloneAndReplace(rfh->frame_tree_node(),
1240 frame_entry); 1237 frame_entry);
1241 CHECK(frame_entry->HasOneRef()); 1238 CHECK(frame_entry->HasOneRef());
1242 } else { 1239 } else {
1243 new_entry = GetLastCommittedEntry()->Clone(); 1240 new_entry = GetLastCommittedEntry()->Clone();
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1278 NOTREACHED() << "Unexpected main frame origin change on AUTO_SUBFRAME."; 1275 NOTREACHED() << "Unexpected main frame origin change on AUTO_SUBFRAME.";
1279 } 1276 }
1280 1277
1281 // TODO(creis): Update the FrameNavigationEntry in --site-per-process. 1278 // TODO(creis): Update the FrameNavigationEntry in --site-per-process.
1282 last_committed_entry_index_ = entry_index; 1279 last_committed_entry_index_ = entry_index;
1283 DiscardNonCommittedEntriesInternal(); 1280 DiscardNonCommittedEntriesInternal();
1284 return true; 1281 return true;
1285 } 1282 }
1286 } 1283 }
1287 1284
1288 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 1285 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) {
1289 switches::kSitePerProcess)) {
1290 // This may be a "new auto" case where we add a new FrameNavigationEntry, or 1286 // This may be a "new auto" case where we add a new FrameNavigationEntry, or
1291 // it may be a "history auto" case where we update an existing one. 1287 // it may be a "history auto" case where we update an existing one.
1292 NavigationEntryImpl* last_committed = GetLastCommittedEntry(); 1288 NavigationEntryImpl* last_committed = GetLastCommittedEntry();
1293 last_committed->AddOrUpdateFrameEntry( 1289 last_committed->AddOrUpdateFrameEntry(
1294 rfh->frame_tree_node(), params.item_sequence_number, 1290 rfh->frame_tree_node(), params.item_sequence_number,
1295 params.document_sequence_number, rfh->GetSiteInstance(), params.url, 1291 params.document_sequence_number, rfh->GetSiteInstance(), params.url,
1296 params.referrer, params.page_state); 1292 params.referrer, params.page_state);
1297 1293
1298 // Cross-process subframe navigations may leave a pending entry around. 1294 // Cross-process subframe navigations may leave a pending entry around.
1299 // Clear it if it's actually for the subframe. 1295 // Clear it if it's actually for the subframe.
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after
1743 } 1739 }
1744 1740
1745 bool NavigationControllerImpl::NavigateToPendingEntryInternal( 1741 bool NavigationControllerImpl::NavigateToPendingEntryInternal(
1746 ReloadType reload_type) { 1742 ReloadType reload_type) {
1747 DCHECK(pending_entry_); 1743 DCHECK(pending_entry_);
1748 FrameTreeNode* root = delegate_->GetFrameTree()->root(); 1744 FrameTreeNode* root = delegate_->GetFrameTree()->root();
1749 1745
1750 // In default Chrome, there are no subframe FrameNavigationEntries. Either 1746 // In default Chrome, there are no subframe FrameNavigationEntries. Either
1751 // navigate the main frame or use the main frame's FrameNavigationEntry to 1747 // navigate the main frame or use the main frame's FrameNavigationEntry to
1752 // tell the indicated frame where to go. 1748 // tell the indicated frame where to go.
1753 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( 1749 if (!SiteIsolationPolicy::UseSubframeNavigationEntries()) {
1754 switches::kSitePerProcess)) {
1755 FrameNavigationEntry* frame_entry = GetPendingEntry()->GetFrameEntry(root); 1750 FrameNavigationEntry* frame_entry = GetPendingEntry()->GetFrameEntry(root);
1756 FrameTreeNode* frame = root; 1751 FrameTreeNode* frame = root;
1757 int ftn_id = GetPendingEntry()->frame_tree_node_id(); 1752 int ftn_id = GetPendingEntry()->frame_tree_node_id();
1758 if (ftn_id != -1) { 1753 if (ftn_id != -1) {
1759 frame = delegate_->GetFrameTree()->FindByID(ftn_id); 1754 frame = delegate_->GetFrameTree()->FindByID(ftn_id);
1760 DCHECK(frame); 1755 DCHECK(frame);
1761 } 1756 }
1762 return frame->navigator()->NavigateToPendingEntry(frame, *frame_entry, 1757 return frame->navigator()->NavigateToPendingEntry(frame, *frame_entry,
1763 reload_type, false); 1758 reload_type, false);
1764 } 1759 }
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
1988 } 1983 }
1989 } 1984 }
1990 } 1985 }
1991 1986
1992 void NavigationControllerImpl::SetGetTimestampCallbackForTest( 1987 void NavigationControllerImpl::SetGetTimestampCallbackForTest(
1993 const base::Callback<base::Time()>& get_timestamp_callback) { 1988 const base::Callback<base::Time()>& get_timestamp_callback) {
1994 get_timestamp_callback_ = get_timestamp_callback; 1989 get_timestamp_callback_ = get_timestamp_callback;
1995 } 1990 }
1996 1991
1997 } // namespace content 1992 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698