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

Unified Diff: chrome/browser/prerender/prerender_manager.cc

Issue 257083002: Check BrowsingInstance before swapping prerenders. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 6 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/prerender/prerender_final_status.cc ('k') | content/browser/browsing_instance.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/prerender/prerender_manager.cc
diff --git a/chrome/browser/prerender/prerender_manager.cc b/chrome/browser/prerender/prerender_manager.cc
index 141afe7087f382ab75e01697c69965f8055b5117..9bcb739bfb23c64cb2f910da0f77fa956071859a 100644
--- a/chrome/browser/prerender/prerender_manager.cc
+++ b/chrome/browser/prerender/prerender_manager.cc
@@ -58,6 +58,7 @@
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/session_storage_namespace.h"
+#include "content/public/browser/site_instance.h"
#include "content/public/browser/storage_partition.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_delegate.h"
@@ -128,7 +129,8 @@ bool NeedMatchCompleteDummyForFinalStatus(FinalStatus final_status) {
final_status != FINAL_STATUS_DEVTOOLS_ATTACHED &&
final_status != FINAL_STATUS_CROSS_SITE_NAVIGATION_PENDING &&
final_status != FINAL_STATUS_PAGE_BEING_CAPTURED &&
- final_status != FINAL_STATUS_NAVIGATION_UNCOMMITTED;
+ final_status != FINAL_STATUS_NAVIGATION_UNCOMMITTED &&
+ final_status != FINAL_STATUS_NON_EMPTY_BROWSING_INSTANCE;
}
void CheckIfCookiesExistForDomainResultOnUIThread(
@@ -537,6 +539,16 @@ WebContents* PrerenderManager::SwapInternal(
}
}
+ // Do not swap if the target WebContents is not the only WebContents in its
+ // current BrowsingInstance.
+ if (web_contents->GetSiteInstance()->GetRelatedActiveContentsCount() != 1u) {
+ DCHECK_GT(
+ web_contents->GetSiteInstance()->GetRelatedActiveContentsCount(), 1u);
+ prerender_data->contents()->Destroy(
+ FINAL_STATUS_NON_EMPTY_BROWSING_INSTANCE);
+ return NULL;
+ }
+
// Do not use the prerendered version if there is an opener object.
if (web_contents->HasOpener()) {
prerender_data->contents()->Destroy(FINAL_STATUS_WINDOW_OPENER);
« no previous file with comments | « chrome/browser/prerender/prerender_final_status.cc ('k') | content/browser/browsing_instance.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698