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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/prerender/prerender_final_status.cc ('k') | content/browser/browsing_instance.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include "chrome/browser/prerender/prerender_manager.h" 5 #include "chrome/browser/prerender/prerender_manager.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <functional> 8 #include <functional>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 #include "chrome/common/prerender_types.h" 51 #include "chrome/common/prerender_types.h"
52 #include "content/public/browser/browser_thread.h" 52 #include "content/public/browser/browser_thread.h"
53 #include "content/public/browser/devtools_agent_host.h" 53 #include "content/public/browser/devtools_agent_host.h"
54 #include "content/public/browser/navigation_controller.h" 54 #include "content/public/browser/navigation_controller.h"
55 #include "content/public/browser/notification_service.h" 55 #include "content/public/browser/notification_service.h"
56 #include "content/public/browser/notification_source.h" 56 #include "content/public/browser/notification_source.h"
57 #include "content/public/browser/render_frame_host.h" 57 #include "content/public/browser/render_frame_host.h"
58 #include "content/public/browser/render_process_host.h" 58 #include "content/public/browser/render_process_host.h"
59 #include "content/public/browser/render_view_host.h" 59 #include "content/public/browser/render_view_host.h"
60 #include "content/public/browser/session_storage_namespace.h" 60 #include "content/public/browser/session_storage_namespace.h"
61 #include "content/public/browser/site_instance.h"
61 #include "content/public/browser/storage_partition.h" 62 #include "content/public/browser/storage_partition.h"
62 #include "content/public/browser/web_contents.h" 63 #include "content/public/browser/web_contents.h"
63 #include "content/public/browser/web_contents_delegate.h" 64 #include "content/public/browser/web_contents_delegate.h"
64 #include "content/public/common/url_constants.h" 65 #include "content/public/common/url_constants.h"
65 #include "extensions/common/constants.h" 66 #include "extensions/common/constants.h"
66 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" 67 #include "net/base/registry_controlled_domains/registry_controlled_domain.h"
67 #include "net/url_request/url_request_context.h" 68 #include "net/url_request/url_request_context.h"
68 #include "net/url_request/url_request_context_getter.h" 69 #include "net/url_request/url_request_context_getter.h"
69 70
70 using content::BrowserThread; 71 using content::BrowserThread;
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 final_status != FINAL_STATUS_TIMED_OUT && 122 final_status != FINAL_STATUS_TIMED_OUT &&
122 final_status != FINAL_STATUS_MANAGER_SHUTDOWN && 123 final_status != FINAL_STATUS_MANAGER_SHUTDOWN &&
123 final_status != FINAL_STATUS_PROFILE_DESTROYED && 124 final_status != FINAL_STATUS_PROFILE_DESTROYED &&
124 final_status != FINAL_STATUS_APP_TERMINATING && 125 final_status != FINAL_STATUS_APP_TERMINATING &&
125 final_status != FINAL_STATUS_WINDOW_OPENER && 126 final_status != FINAL_STATUS_WINDOW_OPENER &&
126 final_status != FINAL_STATUS_CACHE_OR_HISTORY_CLEARED && 127 final_status != FINAL_STATUS_CACHE_OR_HISTORY_CLEARED &&
127 final_status != FINAL_STATUS_CANCELLED && 128 final_status != FINAL_STATUS_CANCELLED &&
128 final_status != FINAL_STATUS_DEVTOOLS_ATTACHED && 129 final_status != FINAL_STATUS_DEVTOOLS_ATTACHED &&
129 final_status != FINAL_STATUS_CROSS_SITE_NAVIGATION_PENDING && 130 final_status != FINAL_STATUS_CROSS_SITE_NAVIGATION_PENDING &&
130 final_status != FINAL_STATUS_PAGE_BEING_CAPTURED && 131 final_status != FINAL_STATUS_PAGE_BEING_CAPTURED &&
131 final_status != FINAL_STATUS_NAVIGATION_UNCOMMITTED; 132 final_status != FINAL_STATUS_NAVIGATION_UNCOMMITTED &&
133 final_status != FINAL_STATUS_NON_EMPTY_BROWSING_INSTANCE;
132 } 134 }
133 135
134 void CheckIfCookiesExistForDomainResultOnUIThread( 136 void CheckIfCookiesExistForDomainResultOnUIThread(
135 const net::CookieMonster::HasCookiesForETLDP1Callback& callback, 137 const net::CookieMonster::HasCookiesForETLDP1Callback& callback,
136 bool cookies_exist) { 138 bool cookies_exist) {
137 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 139 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
138 callback.Run(cookies_exist); 140 callback.Run(cookies_exist);
139 } 141 }
140 142
141 void CheckIfCookiesExistForDomainResultOnIOThread( 143 void CheckIfCookiesExistForDomainResultOnIOThread(
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 // there is a pending entry, it may not commit. 532 // there is a pending entry, it may not commit.
531 // TODO(creis): If there is a pending navigation and no last committed 533 // TODO(creis): If there is a pending navigation and no last committed
532 // entry, we might be able to transfer the network request instead. 534 // entry, we might be able to transfer the network request instead.
533 if (!new_web_contents->GetController().CanPruneAllButLastCommitted()) { 535 if (!new_web_contents->GetController().CanPruneAllButLastCommitted()) {
534 // Abort this prerender so it is not used later. http://crbug.com/292121 536 // Abort this prerender so it is not used later. http://crbug.com/292121
535 prerender_data->contents()->Destroy(FINAL_STATUS_NAVIGATION_UNCOMMITTED); 537 prerender_data->contents()->Destroy(FINAL_STATUS_NAVIGATION_UNCOMMITTED);
536 return NULL; 538 return NULL;
537 } 539 }
538 } 540 }
539 541
542 // Do not swap if the target WebContents is not the only WebContents in its
543 // current BrowsingInstance.
544 if (web_contents->GetSiteInstance()->GetRelatedActiveContentsCount() != 1u) {
545 DCHECK_GT(
546 web_contents->GetSiteInstance()->GetRelatedActiveContentsCount(), 1u);
547 prerender_data->contents()->Destroy(
548 FINAL_STATUS_NON_EMPTY_BROWSING_INSTANCE);
549 return NULL;
550 }
551
540 // Do not use the prerendered version if there is an opener object. 552 // Do not use the prerendered version if there is an opener object.
541 if (web_contents->HasOpener()) { 553 if (web_contents->HasOpener()) {
542 prerender_data->contents()->Destroy(FINAL_STATUS_WINDOW_OPENER); 554 prerender_data->contents()->Destroy(FINAL_STATUS_WINDOW_OPENER);
543 return NULL; 555 return NULL;
544 } 556 }
545 557
546 // Do not swap in the prerender if the current WebContents is being captured. 558 // Do not swap in the prerender if the current WebContents is being captured.
547 if (web_contents->GetCapturerCount() > 0) { 559 if (web_contents->GetCapturerCount() > 0) {
548 prerender_data->contents()->Destroy(FINAL_STATUS_PAGE_BEING_CAPTURED); 560 prerender_data->contents()->Destroy(FINAL_STATUS_PAGE_BEING_CAPTURED);
549 return NULL; 561 return NULL;
(...skipping 1343 matching lines...) Expand 10 before | Expand all | Expand 10 after
1893 content::RenderProcessHost* host) { 1905 content::RenderProcessHost* host) {
1894 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 1906 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
1895 prerender_process_hosts_.erase(host); 1907 prerender_process_hosts_.erase(host);
1896 BrowserThread::PostTask( 1908 BrowserThread::PostTask(
1897 BrowserThread::IO, FROM_HERE, 1909 BrowserThread::IO, FROM_HERE,
1898 base::Bind(&PrerenderTracker::RemovePrerenderCookieStoreOnIOThread, 1910 base::Bind(&PrerenderTracker::RemovePrerenderCookieStoreOnIOThread,
1899 base::Unretained(prerender_tracker()), host->GetID(), false)); 1911 base::Unretained(prerender_tracker()), host->GetID(), false));
1900 } 1912 }
1901 1913
1902 } // namespace prerender 1914 } // namespace prerender
OLDNEW
« 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