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

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

Issue 2023013002: Prevent renderer kills for in-page navigations on subframes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update tests and fix, clean up. Created 4 years, 6 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 1358 matching lines...) Expand 10 before | Expand all | Expand 10 after
1369 // However, due to reloads, even identical urls are *not* guaranteed to be 1369 // However, due to reloads, even identical urls are *not* guaranteed to be
1370 // in-page navigations, we have to trust the renderer almost entirely. 1370 // in-page navigations, we have to trust the renderer almost entirely.
1371 // The one thing we do know is that cross-origin navigations will *never* be 1371 // The one thing we do know is that cross-origin navigations will *never* be
1372 // in-page. Therefore, trust the renderer if the URLs are on the same origin, 1372 // in-page. Therefore, trust the renderer if the URLs are on the same origin,
1373 // and assume the renderer is malicious if a cross-origin navigation claims to 1373 // and assume the renderer is malicious if a cross-origin navigation claims to
1374 // be in-page. 1374 // be in-page.
1375 bool NavigationControllerImpl::IsURLInPageNavigation( 1375 bool NavigationControllerImpl::IsURLInPageNavigation(
1376 const GURL& url, 1376 const GURL& url,
1377 bool renderer_says_in_page, 1377 bool renderer_says_in_page,
1378 RenderFrameHost* rfh) const { 1378 RenderFrameHost* rfh) const {
1379 RenderFrameHostImpl* rfhi = static_cast<RenderFrameHostImpl*>(rfh);
1379 GURL last_committed_url; 1380 GURL last_committed_url;
1380 if (rfh->GetParent()) { 1381 if (rfh->GetParent()) {
1381 last_committed_url = rfh->GetLastCommittedURL(); 1382 last_committed_url = rfhi->frame_tree_node()->current_url();
Charlie Reis 2016/06/03 19:20:35 This is wrong after a process swap, when the newly
Avi (use Gerrit) 2016/06/03 20:26:57 Interesting; worthy of a comment why we don't do i
Charlie Reis 2016/06/03 20:53:28 Good idea. Done.
1382 } else { 1383 } else {
1383 NavigationEntry* last_committed = GetLastCommittedEntry(); 1384 NavigationEntry* last_committed = GetLastCommittedEntry();
1384 // There must be a last-committed entry to compare URLs to. TODO(avi): When 1385 // There must be a last-committed entry to compare URLs to. TODO(avi): When
1385 // might Blink say that a navigation is in-page yet there be no last- 1386 // might Blink say that a navigation is in-page yet there be no last-
1386 // committed entry? 1387 // committed entry?
1387 if (!last_committed) 1388 if (!last_committed)
1388 return false; 1389 return false;
1389 last_committed_url = last_committed->GetURL(); 1390 last_committed_url = last_committed->GetURL();
1390 } 1391 }
1391 1392
1392 WebPreferences prefs = rfh->GetRenderViewHost()->GetWebkitPreferences(); 1393 WebPreferences prefs = rfh->GetRenderViewHost()->GetWebkitPreferences();
1393 const url::Origin& committed_origin = static_cast<RenderFrameHostImpl*>(rfh) 1394 const url::Origin& committed_origin =
1394 ->frame_tree_node() 1395 rfhi->frame_tree_node()->current_origin();
1395 ->current_origin();
1396 bool is_same_origin = last_committed_url.is_empty() || 1396 bool is_same_origin = last_committed_url.is_empty() ||
1397 // TODO(japhet): We should only permit navigations 1397 // TODO(japhet): We should only permit navigations
1398 // originating from about:blank to be in-page if the 1398 // originating from about:blank to be in-page if the
1399 // about:blank is the first document that frame loaded. 1399 // about:blank is the first document that frame loaded.
1400 // We don't have sufficient information to identify 1400 // We don't have sufficient information to identify
1401 // that case at the moment, so always allow about:blank 1401 // that case at the moment, so always allow about:blank
1402 // for now. 1402 // for now.
1403 last_committed_url == GURL(url::kAboutBlankURL) || 1403 last_committed_url == GURL(url::kAboutBlankURL) ||
1404 last_committed_url.GetOrigin() == url.GetOrigin() || 1404 last_committed_url.GetOrigin() == url.GetOrigin() ||
1405 !prefs.web_security_enabled || 1405 !prefs.web_security_enabled ||
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after
1847 return success; 1847 return success;
1848 } 1848 }
1849 1849
1850 void NavigationControllerImpl::FindFramesToNavigate( 1850 void NavigationControllerImpl::FindFramesToNavigate(
1851 FrameTreeNode* frame, 1851 FrameTreeNode* frame,
1852 FrameLoadVector* same_document_loads, 1852 FrameLoadVector* same_document_loads,
1853 FrameLoadVector* different_document_loads) { 1853 FrameLoadVector* different_document_loads) {
1854 DCHECK(pending_entry_); 1854 DCHECK(pending_entry_);
1855 DCHECK_GE(last_committed_entry_index_, 0); 1855 DCHECK_GE(last_committed_entry_index_, 0);
1856 FrameNavigationEntry* new_item = pending_entry_->GetFrameEntry(frame); 1856 FrameNavigationEntry* new_item = pending_entry_->GetFrameEntry(frame);
1857 // TODO(creis): Store the last committed FrameNavigationEntry to use here,
1858 // rather than assuming the NavigationEntry has up to date info on subframes.
Charlie Reis 2016/06/03 19:20:35 I decided to punt this for another CL, since it wi
1857 FrameNavigationEntry* old_item = 1859 FrameNavigationEntry* old_item =
1858 GetLastCommittedEntry()->GetFrameEntry(frame); 1860 GetLastCommittedEntry()->GetFrameEntry(frame);
1859 if (!new_item) 1861 if (!new_item)
1860 return; 1862 return;
1861 1863
1862 // Schedule a load in this frame if the new item isn't for the same item 1864 // Schedule a load in this frame if the new item isn't for the same item
1863 // sequence number in the same SiteInstance. Newly restored items may not have 1865 // sequence number in the same SiteInstance. Newly restored items may not have
1864 // a SiteInstance yet, in which case it will be assigned on first commit. 1866 // a SiteInstance yet, in which case it will be assigned on first commit.
1865 if (!old_item || 1867 if (!old_item ||
1866 new_item->item_sequence_number() != old_item->item_sequence_number() || 1868 new_item->item_sequence_number() != old_item->item_sequence_number() ||
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
2060 } 2062 }
2061 } 2063 }
2062 } 2064 }
2063 2065
2064 void NavigationControllerImpl::SetGetTimestampCallbackForTest( 2066 void NavigationControllerImpl::SetGetTimestampCallbackForTest(
2065 const base::Callback<base::Time()>& get_timestamp_callback) { 2067 const base::Callback<base::Time()>& get_timestamp_callback) {
2066 get_timestamp_callback_ = get_timestamp_callback; 2068 get_timestamp_callback_ = get_timestamp_callback;
2067 } 2069 }
2068 2070
2069 } // namespace content 2071 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698