OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "content/browser/tab_contents/render_view_host_manager.h" | 5 #include "content/browser/tab_contents/render_view_host_manager.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "content/browser/renderer_host/render_view_host.h" | 9 #include "content/browser/renderer_host/render_view_host.h" |
10 #include "content/browser/renderer_host/render_view_host_delegate.h" | 10 #include "content/browser/renderer_host/render_view_host_delegate.h" |
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
384 // NOTE: This is only called when ShouldTransitionCrossSite is true. | 384 // NOTE: This is only called when ShouldTransitionCrossSite is true. |
385 | 385 |
386 const GURL& dest_url = entry.url(); | 386 const GURL& dest_url = entry.url(); |
387 NavigationController& controller = delegate_->GetControllerForRenderManager(); | 387 NavigationController& controller = delegate_->GetControllerForRenderManager(); |
388 content::BrowserContext* browser_context = controller.browser_context(); | 388 content::BrowserContext* browser_context = controller.browser_context(); |
389 | 389 |
390 // If the entry has an instance already we should use it, unless the URL | 390 // If the entry has an instance already we should use it, unless the URL |
391 // is part of an app that has been installed or uninstalled since the last | 391 // is part of an app that has been installed or uninstalled since the last |
392 // visit. | 392 // visit. |
393 if (entry.site_instance()) { | 393 if (entry.site_instance()) { |
394 if (entry.site_instance()->HasWrongProcessForURL(dest_url)) | 394 if (entry.site_instance()->HasWrongProcessForURL(dest_url)) { |
395 return curr_instance->GetRelatedSiteInstance(dest_url); | 395 // If we need to swap to a different SiteInstance, the new one should have |
396 else | 396 // the same max_page_id as the current one so that it identifies new vs |
397 return entry.site_instance(); | 397 // existing navigations correctly. We also need to update the entry's |
| 398 // SiteInstance, which we will do in TabContents::NavigateToEntry. |
| 399 SiteInstance* new_instance = |
| 400 curr_instance->GetRelatedSiteInstance(dest_url); |
| 401 new_instance->UpdateMaxPageID(curr_instance->max_page_id()); |
| 402 return new_instance; |
| 403 } |
| 404 return entry.site_instance(); |
398 } | 405 } |
399 | 406 |
400 // (UGLY) HEURISTIC, process-per-site only: | 407 // (UGLY) HEURISTIC, process-per-site only: |
401 // | 408 // |
402 // If this navigation is generated, then it probably corresponds to a search | 409 // If this navigation is generated, then it probably corresponds to a search |
403 // query. Given that search results typically lead to users navigating to | 410 // query. Given that search results typically lead to users navigating to |
404 // other sites, we don't really want to use the search engine hostname to | 411 // other sites, we don't really want to use the search engine hostname to |
405 // determine the site instance for this navigation. | 412 // determine the site instance for this navigation. |
406 // | 413 // |
407 // NOTE: This can be removed once we have a way to transition between | 414 // NOTE: This can be removed once we have a way to transition between |
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
802 } | 809 } |
803 } | 810 } |
804 | 811 |
805 bool RenderViewHostManager::IsSwappedOut(RenderViewHost* rvh) { | 812 bool RenderViewHostManager::IsSwappedOut(RenderViewHost* rvh) { |
806 if (!rvh->site_instance()) | 813 if (!rvh->site_instance()) |
807 return false; | 814 return false; |
808 | 815 |
809 return swapped_out_hosts_.find(rvh->site_instance()->id()) != | 816 return swapped_out_hosts_.find(rvh->site_instance()->id()) != |
810 swapped_out_hosts_.end(); | 817 swapped_out_hosts_.end(); |
811 } | 818 } |
OLD | NEW |