| 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 "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/common/chrome_switches.h" | 10 #include "chrome/common/chrome_switches.h" |
| 11 #include "chrome/common/render_messages.h" | 11 #include "chrome/common/render_messages.h" |
| 12 #include "chrome/common/url_constants.h" | 12 #include "chrome/common/url_constants.h" |
| 13 #include "content/browser/content_browser_client.h" | 13 #include "content/browser/content_browser_client.h" |
| 14 #include "content/browser/renderer_host/render_view_host.h" | 14 #include "content/browser/renderer_host/render_view_host.h" |
| 15 #include "content/browser/renderer_host/render_view_host_delegate.h" | 15 #include "content/browser/renderer_host/render_view_host_delegate.h" |
| 16 #include "content/browser/renderer_host/render_view_host_factory.h" | 16 #include "content/browser/renderer_host/render_view_host_factory.h" |
| 17 #include "content/browser/renderer_host/render_widget_host_view.h" | 17 #include "content/browser/renderer_host/render_widget_host_view.h" |
| 18 #include "content/browser/site_instance.h" | 18 #include "content/browser/site_instance.h" |
| 19 #include "content/browser/tab_contents/navigation_controller.h" | 19 #include "content/browser/tab_contents/navigation_controller.h" |
| 20 #include "content/browser/tab_contents/navigation_entry.h" | 20 #include "content/browser/tab_contents/navigation_entry.h" |
| 21 #include "content/browser/tab_contents/tab_contents_view.h" | 21 #include "content/browser/tab_contents/tab_contents_view.h" |
| 22 #include "content/browser/webui/content_web_ui_client.h" |
| 22 #include "content/browser/webui/web_ui.h" | 23 #include "content/browser/webui/web_ui.h" |
| 23 #include "content/browser/webui/web_ui_factory.h" | 24 #include "content/common/content_client.h" |
| 24 #include "content/common/notification_service.h" | 25 #include "content/common/notification_service.h" |
| 25 #include "content/common/notification_type.h" | 26 #include "content/common/notification_type.h" |
| 26 #include "content/common/view_messages.h" | 27 #include "content/common/view_messages.h" |
| 27 | 28 |
| 28 namespace base { | 29 namespace base { |
| 29 class WaitableEvent; | 30 class WaitableEvent; |
| 30 } | 31 } |
| 31 | 32 |
| 32 RenderViewHostManager::RenderViewHostManager( | 33 RenderViewHostManager::RenderViewHostManager( |
| 33 RenderViewHostDelegate* render_view_delegate, | 34 RenderViewHostDelegate* render_view_delegate, |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 | 295 |
| 295 // Check for reasons to swap processes even if we are in a process model that | 296 // Check for reasons to swap processes even if we are in a process model that |
| 296 // doesn't usually swap (e.g., process-per-tab). | 297 // doesn't usually swap (e.g., process-per-tab). |
| 297 | 298 |
| 298 // For security, we should transition between processes when one is a Web UI | 299 // For security, we should transition between processes when one is a Web UI |
| 299 // page and one isn't. If there's no cur_entry, check the current RVH's | 300 // page and one isn't. If there's no cur_entry, check the current RVH's |
| 300 // site, which might already be committed to a Web UI URL (such as the NTP). | 301 // site, which might already be committed to a Web UI URL (such as the NTP). |
| 301 const GURL& current_url = (cur_entry) ? cur_entry->url() : | 302 const GURL& current_url = (cur_entry) ? cur_entry->url() : |
| 302 render_view_host_->site_instance()->site(); | 303 render_view_host_->site_instance()->site(); |
| 303 Profile* profile = delegate_->GetControllerForRenderManager().profile(); | 304 Profile* profile = delegate_->GetControllerForRenderManager().profile(); |
| 304 if (WebUIFactory::UseWebUIForURL(profile, current_url)) { | 305 const content::ContentWebUIClient* web_ui_client = |
| 306 content::GetContentClient()->web_ui(); |
| 307 if (web_ui_client->UseWebUIForURL(profile, current_url)) { |
| 305 // Force swap if it's not an acceptable URL for Web UI. | 308 // Force swap if it's not an acceptable URL for Web UI. |
| 306 if (!WebUIFactory::IsURLAcceptableForWebUI(profile, new_entry->url())) | 309 if (!web_ui_client->IsURLAcceptableForWebUI(profile, new_entry->url())) |
| 307 return true; | 310 return true; |
| 308 } else { | 311 } else { |
| 309 // Force swap if it's a Web UI URL. | 312 // Force swap if it's a Web UI URL. |
| 310 if (WebUIFactory::UseWebUIForURL(profile, new_entry->url())) | 313 if (web_ui_client->UseWebUIForURL(profile, new_entry->url())) |
| 311 return true; | 314 return true; |
| 312 } | 315 } |
| 313 | 316 |
| 314 if (!cur_entry) { | 317 if (!cur_entry) { |
| 315 // Always choose a new process when navigating to extension URLs. The | 318 // Always choose a new process when navigating to extension URLs. The |
| 316 // process grouping logic will combine all of a given extension's pages | 319 // process grouping logic will combine all of a given extension's pages |
| 317 // into the same process. | 320 // into the same process. |
| 318 if (new_entry->url().SchemeIs(chrome::kExtensionScheme)) | 321 if (new_entry->url().SchemeIs(chrome::kExtensionScheme)) |
| 319 return true; | 322 return true; |
| 320 | 323 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 377 // to compare against the current URL and not the SiteInstance's site. In | 380 // to compare against the current URL and not the SiteInstance's site. In |
| 378 // this case, there is no current URL, so comparing against the site is ok. | 381 // this case, there is no current URL, so comparing against the site is ok. |
| 379 // See additional comments below.) | 382 // See additional comments below.) |
| 380 if (curr_instance->HasRelatedSiteInstance(dest_url)) | 383 if (curr_instance->HasRelatedSiteInstance(dest_url)) |
| 381 return curr_instance->GetRelatedSiteInstance(dest_url); | 384 return curr_instance->GetRelatedSiteInstance(dest_url); |
| 382 | 385 |
| 383 // For extensions and Web UI URLs (such as the new tab page), we do not | 386 // For extensions and Web UI URLs (such as the new tab page), we do not |
| 384 // want to use the curr_instance if it has no site, since it will have a | 387 // want to use the curr_instance if it has no site, since it will have a |
| 385 // RenderProcessHost of TYPE_NORMAL. Create a new SiteInstance for this | 388 // RenderProcessHost of TYPE_NORMAL. Create a new SiteInstance for this |
| 386 // URL instead (with the correct process type). | 389 // URL instead (with the correct process type). |
| 387 if (WebUIFactory::UseWebUIForURL(profile, dest_url)) | 390 if (content::GetContentClient()->web_ui()-> |
| 391 UseWebUIForURL(profile, dest_url)) { |
| 388 return SiteInstance::CreateSiteInstanceForURL(profile, dest_url); | 392 return SiteInstance::CreateSiteInstanceForURL(profile, dest_url); |
| 393 } |
| 389 | 394 |
| 390 // Normally the "site" on the SiteInstance is set lazily when the load | 395 // Normally the "site" on the SiteInstance is set lazily when the load |
| 391 // actually commits. This is to support better process sharing in case | 396 // actually commits. This is to support better process sharing in case |
| 392 // the site redirects to some other site: we want to use the destination | 397 // the site redirects to some other site: we want to use the destination |
| 393 // site in the site instance. | 398 // site in the site instance. |
| 394 // | 399 // |
| 395 // In the case of session restore, as it loads all the pages immediately | 400 // In the case of session restore, as it loads all the pages immediately |
| 396 // we need to set the site first, otherwise after a restore none of the | 401 // we need to set the site first, otherwise after a restore none of the |
| 397 // pages would share renderers in process-per-site. | 402 // pages would share renderers in process-per-site. |
| 398 if (entry.restore_type() != NavigationEntry::RESTORE_NONE) | 403 if (entry.restore_type() != NavigationEntry::RESTORE_NONE) |
| (...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 719 Source<NavigationController>(&delegate_->GetControllerForRenderManager()), | 724 Source<NavigationController>(&delegate_->GetControllerForRenderManager()), |
| 720 Details<RenderViewHostSwitchedDetails>(&details)); | 725 Details<RenderViewHostSwitchedDetails>(&details)); |
| 721 | 726 |
| 722 // This will cause the old RenderViewHost to delete itself. | 727 // This will cause the old RenderViewHost to delete itself. |
| 723 old_render_view_host->Shutdown(); | 728 old_render_view_host->Shutdown(); |
| 724 | 729 |
| 725 // Let the task manager know that we've swapped RenderViewHosts, since it | 730 // Let the task manager know that we've swapped RenderViewHosts, since it |
| 726 // might need to update its process groupings. | 731 // might need to update its process groupings. |
| 727 delegate_->NotifySwappedFromRenderManager(); | 732 delegate_->NotifySwappedFromRenderManager(); |
| 728 } | 733 } |
| OLD | NEW |