Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/tab_contents/render_view_host_manager.h" | 5 #include "chrome/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 "chrome/browser/dom_ui/dom_ui.h" | 9 #include "chrome/browser/dom_ui/dom_ui.h" |
| 10 #include "chrome/browser/dom_ui/dom_ui_factory.h" | 10 #include "chrome/browser/dom_ui/dom_ui_factory.h" |
| (...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 270 CHECK(render_view_host_ != deleted_rvh); | 270 CHECK(render_view_host_ != deleted_rvh); |
| 271 CHECK(pending_render_view_host_ != deleted_rvh); | 271 CHECK(pending_render_view_host_ != deleted_rvh); |
| 272 } | 272 } |
| 273 | 273 |
| 274 bool RenderViewHostManager::ShouldTransitionCrossSite() { | 274 bool RenderViewHostManager::ShouldTransitionCrossSite() { |
| 275 // True if we are using process-per-site-instance (default) or | 275 // True if we are using process-per-site-instance (default) or |
| 276 // process-per-site (kProcessPerSite). | 276 // process-per-site (kProcessPerSite). |
| 277 return !CommandLine::ForCurrentProcess()->HasSwitch(switches::kProcessPerTab); | 277 return !CommandLine::ForCurrentProcess()->HasSwitch(switches::kProcessPerTab); |
| 278 } | 278 } |
| 279 | 279 |
| 280 bool RenderViewHostManager::ShouldSwapRenderViewsForNavigation( | 280 bool RenderViewHostManager::ShouldSwapProcessesForNavigation( |
| 281 const NavigationEntry* cur_entry, | 281 const NavigationEntry* cur_entry, |
| 282 const NavigationEntry* new_entry) const { | 282 const NavigationEntry* new_entry) const { |
| 283 if (!cur_entry || !new_entry) | 283 if (!cur_entry || !new_entry) |
| 284 return false; | 284 return false; |
| 285 | 285 |
| 286 // We can't switch a RenderView between view source and non-view source mode | 286 // We can't switch a RenderView between view source and non-view source mode |
| 287 // without screwing up the session history sometimes (when navigating between | 287 // without screwing up the session history sometimes (when navigating between |
| 288 // "view-source:http://foo.com/" and "http://foo.com/", WebKit doesn't treat | 288 // "view-source:http://foo.com/" and "http://foo.com/", WebKit doesn't treat |
| 289 // it as a new navigation). So require a view switch. | 289 // it as a new navigation). So require a view switch. |
| 290 if (cur_entry->IsViewSourceMode() != new_entry->IsViewSourceMode()) | 290 if (cur_entry->IsViewSourceMode() != new_entry->IsViewSourceMode()) |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 371 // script-based navigations, but for now, it could place some pages in a | 371 // script-based navigations, but for now, it could place some pages in a |
| 372 // new process unnecessarily. We should only hit this case if a page tries | 372 // new process unnecessarily. We should only hit this case if a page tries |
| 373 // to open a new tab to an interstitial-inducing URL, and then navigates | 373 // to open a new tab to an interstitial-inducing URL, and then navigates |
| 374 // the page to a different same-site URL. (This seems very unlikely in | 374 // the page to a different same-site URL. (This seems very unlikely in |
| 375 // practice.) | 375 // practice.) |
| 376 const GURL& current_url = (curr_entry) ? curr_entry->url() : | 376 const GURL& current_url = (curr_entry) ? curr_entry->url() : |
| 377 curr_instance->site(); | 377 curr_instance->site(); |
| 378 | 378 |
| 379 if (SiteInstance::IsSameWebSite(current_url, dest_url)) { | 379 if (SiteInstance::IsSameWebSite(current_url, dest_url)) { |
| 380 return curr_instance; | 380 return curr_instance; |
| 381 } else if (ShouldSwapProcessesForNavigation(curr_entry, &entry)) { | |
| 382 // When we're swapping, we need to force the site instance AND browsing | |
| 383 // instance to be new ones. This prevents some cases where we'll re-use | |
| 384 // processes opened from the New Tab Page because all NTP's have the same | |
| 385 // BrowsingInstance. | |
|
Charlie Reis
2009/04/16 22:00:56
I had trouble following the last sentence. Perhap
| |
| 386 return SiteInstance::CreateSiteInstance( | |
| 387 delegate_->GetControllerForRenderManager()->profile()); | |
| 381 } else { | 388 } else { |
| 382 // Start the new renderer in a new SiteInstance, but in the current | 389 // Start the new renderer in a new SiteInstance, but in the current |
| 383 // BrowsingInstance. It is important to immediately give this new | 390 // BrowsingInstance. It is important to immediately give this new |
| 384 // SiteInstance to a RenderViewHost (if it is different than our current | 391 // SiteInstance to a RenderViewHost (if it is different than our current |
| 385 // SiteInstance), so that it is ref counted. This will happen in | 392 // SiteInstance), so that it is ref counted. This will happen in |
| 386 // CreatePendingRenderView. | 393 // CreatePendingRenderView. |
| 387 return curr_instance->GetRelatedSiteInstance(dest_url); | 394 return curr_instance->GetRelatedSiteInstance(dest_url); |
| 388 } | 395 } |
| 389 } | 396 } |
| 390 | 397 |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 482 SiteInstance* curr_instance = render_view_host_->site_instance(); | 489 SiteInstance* curr_instance = render_view_host_->site_instance(); |
| 483 | 490 |
| 484 // Determine if we need a new SiteInstance for this entry. | 491 // Determine if we need a new SiteInstance for this entry. |
| 485 // Again, new_instance won't be deleted before the end of this method, so it | 492 // Again, new_instance won't be deleted before the end of this method, so it |
| 486 // is safe to use a normal pointer here. | 493 // is safe to use a normal pointer here. |
| 487 SiteInstance* new_instance = curr_instance; | 494 SiteInstance* new_instance = curr_instance; |
| 488 if (ShouldTransitionCrossSite()) | 495 if (ShouldTransitionCrossSite()) |
| 489 new_instance = GetSiteInstanceForEntry(entry, curr_instance); | 496 new_instance = GetSiteInstanceForEntry(entry, curr_instance); |
| 490 | 497 |
| 491 if (new_instance != curr_instance || | 498 if (new_instance != curr_instance || |
| 492 ShouldSwapRenderViewsForNavigation( | 499 ShouldSwapProcessesForNavigation( |
| 493 delegate_->GetLastCommittedNavigationEntryForRenderManager(), | 500 delegate_->GetLastCommittedNavigationEntryForRenderManager(), |
| 494 &entry)) { | 501 &entry)) { |
| 495 // New SiteInstance. | 502 // New SiteInstance. |
| 496 DCHECK(!cross_navigation_pending_); | 503 DCHECK(!cross_navigation_pending_); |
| 497 | 504 |
| 498 // Create a pending RVH and navigate it. | 505 // Create a pending RVH and navigate it. |
| 499 bool success = CreatePendingRenderView(new_instance); | 506 bool success = CreatePendingRenderView(new_instance); |
| 500 if (!success) | 507 if (!success) |
| 501 return NULL; | 508 return NULL; |
| 502 | 509 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 557 | 564 |
| 558 pending_dom_ui_.reset(); | 565 pending_dom_ui_.reset(); |
| 559 } | 566 } |
| 560 | 567 |
| 561 void RenderViewHostManager::CrossSiteNavigationCanceled() { | 568 void RenderViewHostManager::CrossSiteNavigationCanceled() { |
| 562 DCHECK(cross_navigation_pending_); | 569 DCHECK(cross_navigation_pending_); |
| 563 cross_navigation_pending_ = false; | 570 cross_navigation_pending_ = false; |
| 564 if (pending_render_view_host_) | 571 if (pending_render_view_host_) |
| 565 CancelPending(); | 572 CancelPending(); |
| 566 } | 573 } |
| OLD | NEW |