| OLD | NEW |
| 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 "content/browser/web_contents/render_view_host_manager.h" | 5 #include "content/browser/web_contents/render_view_host_manager.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "content/browser/debugger/devtools_manager_impl.h" | 11 #include "content/browser/debugger/devtools_manager_impl.h" |
| 12 #include "content/browser/renderer_host/render_process_host_impl.h" | 12 #include "content/browser/renderer_host/render_process_host_impl.h" |
| 13 #include "content/browser/renderer_host/render_view_host_factory.h" | 13 #include "content/browser/renderer_host/render_view_host_factory.h" |
| 14 #include "content/browser/renderer_host/render_view_host_impl.h" | 14 #include "content/browser/renderer_host/render_view_host_impl.h" |
| 15 #include "content/browser/site_instance_impl.h" | 15 #include "content/browser/site_instance_impl.h" |
| 16 #include "content/browser/web_contents/navigation_controller_impl.h" | 16 #include "content/browser/web_contents/navigation_controller_impl.h" |
| 17 #include "content/browser/web_contents/navigation_entry_impl.h" | 17 #include "content/browser/web_contents/navigation_entry_impl.h" |
| 18 #include "content/browser/webui/web_ui_impl.h" | 18 #include "content/browser/webui/web_ui_impl.h" |
| 19 #include "content/common/view_messages.h" | 19 #include "content/common/view_messages.h" |
| 20 #include "content/port/browser/render_widget_host_view_port.h" | 20 #include "content/port/browser/render_widget_host_view_port.h" |
| 21 #include "content/public/browser/content_browser_client.h" | 21 #include "content/public/browser/content_browser_client.h" |
| 22 #include "content/public/browser/notification_service.h" | 22 #include "content/public/browser/notification_service.h" |
| 23 #include "content/public/browser/notification_types.h" | 23 #include "content/public/browser/notification_types.h" |
| 24 #include "content/public/browser/web_contents_view.h" | 24 #include "content/public/browser/web_contents_view.h" |
| 25 #include "content/public/browser/web_ui_controller.h" | 25 #include "content/public/browser/web_ui_controller.h" |
| 26 #include "content/public/browser/web_ui_controller_factory.h" | 26 #include "content/public/browser/web_ui_controller_factory.h" |
| 27 #include "content/public/common/content_switches.h" | 27 #include "content/public/common/content_switches.h" |
| 28 #include "content/public/common/url_constants.h" | 28 #include "content/public/common/url_constants.h" |
| 29 | 29 |
| 30 using content::NavigationController; | 30 namespace content { |
| 31 using content::NavigationControllerImpl; | |
| 32 using content::NavigationEntry; | |
| 33 using content::NavigationEntryImpl; | |
| 34 using content::RenderProcessHost; | |
| 35 using content::RenderProcessHostImpl; | |
| 36 using content::RenderViewHost; | |
| 37 using content::RenderViewHostFactory; | |
| 38 using content::RenderViewHostImpl; | |
| 39 using content::RenderWidgetHostView; | |
| 40 using content::RenderWidgetHostViewPort; | |
| 41 using content::SiteInstance; | |
| 42 using content::WebUIControllerFactory; | |
| 43 using content::WebUIImpl; | |
| 44 | 31 |
| 45 RenderViewHostManager::RenderViewHostManager( | 32 RenderViewHostManager::RenderViewHostManager( |
| 46 content::RenderViewHostDelegate* render_view_delegate, | 33 RenderViewHostDelegate* render_view_delegate, |
| 47 content::RenderWidgetHostDelegate* render_widget_delegate, | 34 RenderWidgetHostDelegate* render_widget_delegate, |
| 48 Delegate* delegate) | 35 Delegate* delegate) |
| 49 : delegate_(delegate), | 36 : delegate_(delegate), |
| 50 cross_navigation_pending_(false), | 37 cross_navigation_pending_(false), |
| 51 render_view_delegate_(render_view_delegate), | 38 render_view_delegate_(render_view_delegate), |
| 52 render_widget_delegate_(render_widget_delegate), | 39 render_widget_delegate_(render_widget_delegate), |
| 53 render_view_host_(NULL), | 40 render_view_host_(NULL), |
| 54 pending_render_view_host_(NULL), | 41 pending_render_view_host_(NULL), |
| 55 interstitial_page_(NULL) { | 42 interstitial_page_(NULL) { |
| 56 } | 43 } |
| 57 | 44 |
| 58 RenderViewHostManager::~RenderViewHostManager() { | 45 RenderViewHostManager::~RenderViewHostManager() { |
| 59 if (pending_render_view_host_) | 46 if (pending_render_view_host_) |
| 60 CancelPending(); | 47 CancelPending(); |
| 61 | 48 |
| 62 // We should always have a main RenderViewHost except in some tests. | 49 // We should always have a main RenderViewHost except in some tests. |
| 63 RenderViewHostImpl* render_view_host = render_view_host_; | 50 RenderViewHostImpl* render_view_host = render_view_host_; |
| 64 render_view_host_ = NULL; | 51 render_view_host_ = NULL; |
| 65 if (render_view_host) | 52 if (render_view_host) |
| 66 render_view_host->Shutdown(); | 53 render_view_host->Shutdown(); |
| 67 | 54 |
| 68 // Shut down any swapped out RenderViewHosts. | 55 // Shut down any swapped out RenderViewHosts. |
| 69 for (RenderViewHostMap::iterator iter = swapped_out_hosts_.begin(); | 56 for (RenderViewHostMap::iterator iter = swapped_out_hosts_.begin(); |
| 70 iter != swapped_out_hosts_.end(); | 57 iter != swapped_out_hosts_.end(); |
| 71 ++iter) { | 58 ++iter) { |
| 72 iter->second->Shutdown(); | 59 iter->second->Shutdown(); |
| 73 } | 60 } |
| 74 } | 61 } |
| 75 | 62 |
| 76 void RenderViewHostManager::Init(content::BrowserContext* browser_context, | 63 void RenderViewHostManager::Init(BrowserContext* browser_context, |
| 77 SiteInstance* site_instance, | 64 SiteInstance* site_instance, |
| 78 int routing_id) { | 65 int routing_id) { |
| 79 // Create a RenderViewHost, once we have an instance. It is important to | 66 // Create a RenderViewHost, once we have an instance. It is important to |
| 80 // immediately give this SiteInstance to a RenderViewHost so that it is | 67 // immediately give this SiteInstance to a RenderViewHost so that it is |
| 81 // ref counted. | 68 // ref counted. |
| 82 if (!site_instance) | 69 if (!site_instance) |
| 83 site_instance = SiteInstance::Create(browser_context); | 70 site_instance = SiteInstance::Create(browser_context); |
| 84 render_view_host_ = static_cast<RenderViewHostImpl*>( | 71 render_view_host_ = static_cast<RenderViewHostImpl*>( |
| 85 RenderViewHostFactory::Create( | 72 RenderViewHostFactory::Create( |
| 86 site_instance, render_view_delegate_, render_widget_delegate_, | 73 site_instance, render_view_delegate_, render_widget_delegate_, |
| 87 routing_id, false, delegate_-> | 74 routing_id, false, delegate_-> |
| 88 GetControllerForRenderManager().GetSessionStorageNamespace( | 75 GetControllerForRenderManager().GetSessionStorageNamespace( |
| 89 site_instance))); | 76 site_instance))); |
| 90 | 77 |
| 91 // Keep track of renderer processes as they start to shut down. | 78 // Keep track of renderer processes as they start to shut down. |
| 92 registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_CLOSING, | 79 registrar_.Add(this, NOTIFICATION_RENDERER_PROCESS_CLOSING, |
| 93 content::NotificationService::AllSources()); | 80 NotificationService::AllSources()); |
| 94 } | 81 } |
| 95 | 82 |
| 96 RenderViewHostImpl* RenderViewHostManager::current_host() const { | 83 RenderViewHostImpl* RenderViewHostManager::current_host() const { |
| 97 return render_view_host_; | 84 return render_view_host_; |
| 98 } | 85 } |
| 99 | 86 |
| 100 RenderViewHostImpl* RenderViewHostManager::pending_render_view_host() const { | 87 RenderViewHostImpl* RenderViewHostManager::pending_render_view_host() const { |
| 101 return pending_render_view_host_; | 88 return pending_render_view_host_; |
| 102 } | 89 } |
| 103 | 90 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 // on it later. | 124 // on it later. |
| 138 if (dest_render_view_host != render_view_host_ && | 125 if (dest_render_view_host != render_view_host_ && |
| 139 dest_render_view_host->GetView()) { | 126 dest_render_view_host->GetView()) { |
| 140 dest_render_view_host->GetView()->Hide(); | 127 dest_render_view_host->GetView()->Hide(); |
| 141 } else { | 128 } else { |
| 142 // This is our primary renderer, notify here as we won't be calling | 129 // This is our primary renderer, notify here as we won't be calling |
| 143 // CommitPending (which does the notify). | 130 // CommitPending (which does the notify). |
| 144 RenderViewHost* null_rvh = NULL; | 131 RenderViewHost* null_rvh = NULL; |
| 145 std::pair<RenderViewHost*, RenderViewHost*> details = | 132 std::pair<RenderViewHost*, RenderViewHost*> details = |
| 146 std::make_pair(null_rvh, render_view_host_); | 133 std::make_pair(null_rvh, render_view_host_); |
| 147 content::NotificationService::current()->Notify( | 134 NotificationService::current()->Notify( |
| 148 content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED, | 135 NOTIFICATION_RENDER_VIEW_HOST_CHANGED, |
| 149 content::Source<NavigationController>( | 136 Source<NavigationController>( |
| 150 &delegate_->GetControllerForRenderManager()), | 137 &delegate_->GetControllerForRenderManager()), |
| 151 content::Details<std::pair<RenderViewHost*, RenderViewHost*> >( | 138 Details<std::pair<RenderViewHost*, RenderViewHost*> >( |
| 152 &details)); | 139 &details)); |
| 153 } | 140 } |
| 154 } | 141 } |
| 155 | 142 |
| 156 return dest_render_view_host; | 143 return dest_render_view_host; |
| 157 } | 144 } |
| 158 | 145 |
| 159 void RenderViewHostManager::Stop() { | 146 void RenderViewHostManager::Stop() { |
| 160 render_view_host_->Stop(); | 147 render_view_host_->Stop(); |
| 161 | 148 |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 373 // ResourceDispatcherHost has told us to run the onunload handler, which | 360 // ResourceDispatcherHost has told us to run the onunload handler, which |
| 374 // means it is not a download or unsafe page, and we are going to perform the | 361 // means it is not a download or unsafe page, and we are going to perform the |
| 375 // navigation. Thus, we no longer need to remember that the RenderViewHost | 362 // navigation. Thus, we no longer need to remember that the RenderViewHost |
| 376 // is part of a pending cross-site request. | 363 // is part of a pending cross-site request. |
| 377 pending_render_view_host_->SetHasPendingCrossSiteRequest(false, | 364 pending_render_view_host_->SetHasPendingCrossSiteRequest(false, |
| 378 new_request_id); | 365 new_request_id); |
| 379 } | 366 } |
| 380 | 367 |
| 381 void RenderViewHostManager::Observe( | 368 void RenderViewHostManager::Observe( |
| 382 int type, | 369 int type, |
| 383 const content::NotificationSource& source, | 370 const NotificationSource& source, |
| 384 const content::NotificationDetails& details) { | 371 const NotificationDetails& details) { |
| 385 switch (type) { | 372 switch (type) { |
| 386 case content::NOTIFICATION_RENDERER_PROCESS_CLOSING: | 373 case NOTIFICATION_RENDERER_PROCESS_CLOSING: |
| 387 RendererProcessClosing( | 374 RendererProcessClosing( |
| 388 content::Source<RenderProcessHost>(source).ptr()); | 375 Source<RenderProcessHost>(source).ptr()); |
| 389 break; | 376 break; |
| 390 | 377 |
| 391 default: | 378 default: |
| 392 NOTREACHED(); | 379 NOTREACHED(); |
| 393 } | 380 } |
| 394 } | 381 } |
| 395 | 382 |
| 396 bool RenderViewHostManager::ShouldTransitionCrossSite() { | 383 bool RenderViewHostManager::ShouldTransitionCrossSite() { |
| 397 // True if we are using process-per-site-instance (default) or | 384 // True if we are using process-per-site-instance (default) or |
| 398 // process-per-site (kProcessPerSite). | 385 // process-per-site (kProcessPerSite). |
| 399 return !CommandLine::ForCurrentProcess()->HasSwitch(switches::kProcessPerTab); | 386 return !CommandLine::ForCurrentProcess()->HasSwitch(switches::kProcessPerTab); |
| 400 } | 387 } |
| 401 | 388 |
| 402 bool RenderViewHostManager::ShouldSwapProcessesForNavigation( | 389 bool RenderViewHostManager::ShouldSwapProcessesForNavigation( |
| 403 const NavigationEntry* curr_entry, | 390 const NavigationEntry* curr_entry, |
| 404 const NavigationEntryImpl* new_entry) const { | 391 const NavigationEntryImpl* new_entry) const { |
| 405 DCHECK(new_entry); | 392 DCHECK(new_entry); |
| 406 | 393 |
| 407 // Check for reasons to swap processes even if we are in a process model that | 394 // Check for reasons to swap processes even if we are in a process model that |
| 408 // doesn't usually swap (e.g., process-per-tab). | 395 // doesn't usually swap (e.g., process-per-tab). |
| 409 | 396 |
| 410 // For security, we should transition between processes when one is a Web UI | 397 // For security, we should transition between processes when one is a Web UI |
| 411 // page and one isn't. If there's no curr_entry, check the current RVH's | 398 // page and one isn't. If there's no curr_entry, check the current RVH's |
| 412 // site, which might already be committed to a Web UI URL (such as the NTP). | 399 // site, which might already be committed to a Web UI URL (such as the NTP). |
| 413 const GURL& current_url = (curr_entry) ? curr_entry->GetURL() : | 400 const GURL& current_url = (curr_entry) ? curr_entry->GetURL() : |
| 414 render_view_host_->GetSiteInstance()->GetSiteURL(); | 401 render_view_host_->GetSiteInstance()->GetSiteURL(); |
| 415 content::BrowserContext* browser_context = | 402 BrowserContext* browser_context = |
| 416 delegate_->GetControllerForRenderManager().GetBrowserContext(); | 403 delegate_->GetControllerForRenderManager().GetBrowserContext(); |
| 417 const WebUIControllerFactory* web_ui_factory = | 404 const WebUIControllerFactory* web_ui_factory = |
| 418 content::GetContentClient()->browser()->GetWebUIControllerFactory(); | 405 GetContentClient()->browser()->GetWebUIControllerFactory(); |
| 419 if (web_ui_factory) { | 406 if (web_ui_factory) { |
| 420 if (web_ui_factory->UseWebUIForURL(browser_context, current_url)) { | 407 if (web_ui_factory->UseWebUIForURL(browser_context, current_url)) { |
| 421 // Force swap if it's not an acceptable URL for Web UI. | 408 // Force swap if it's not an acceptable URL for Web UI. |
| 422 // Here, data URLs are never allowed. | 409 // Here, data URLs are never allowed. |
| 423 if (!web_ui_factory->IsURLAcceptableForWebUI(browser_context, | 410 if (!web_ui_factory->IsURLAcceptableForWebUI(browser_context, |
| 424 new_entry->GetURL(), false)) | 411 new_entry->GetURL(), false)) |
| 425 return true; | 412 return true; |
| 426 } else { | 413 } else { |
| 427 // Force swap if it's a Web UI URL. | 414 // Force swap if it's a Web UI URL. |
| 428 if (web_ui_factory->UseWebUIForURL(browser_context, new_entry->GetURL())) | 415 if (web_ui_factory->UseWebUIForURL(browser_context, new_entry->GetURL())) |
| 429 return true; | 416 return true; |
| 430 } | 417 } |
| 431 } | 418 } |
| 432 | 419 |
| 433 if (content::GetContentClient()->browser()->ShouldSwapProcessesForNavigation( | 420 if (GetContentClient()->browser()->ShouldSwapProcessesForNavigation( |
| 434 curr_entry ? curr_entry->GetURL() : GURL(), new_entry->GetURL())) { | 421 curr_entry ? curr_entry->GetURL() : GURL(), new_entry->GetURL())) { |
| 435 return true; | 422 return true; |
| 436 } | 423 } |
| 437 | 424 |
| 438 if (!curr_entry) | 425 if (!curr_entry) |
| 439 return false; | 426 return false; |
| 440 | 427 |
| 441 // We can't switch a RenderView between view source and non-view source mode | 428 // We can't switch a RenderView between view source and non-view source mode |
| 442 // without screwing up the session history sometimes (when navigating between | 429 // without screwing up the session history sometimes (when navigating between |
| 443 // "view-source:http://foo.com/" and "http://foo.com/", WebKit doesn't treat | 430 // "view-source:http://foo.com/" and "http://foo.com/", WebKit doesn't treat |
| 444 // it as a new navigation). So require a view switch. | 431 // it as a new navigation). So require a view switch. |
| 445 if (curr_entry->IsViewSourceMode() != new_entry->IsViewSourceMode()) | 432 if (curr_entry->IsViewSourceMode() != new_entry->IsViewSourceMode()) |
| 446 return true; | 433 return true; |
| 447 | 434 |
| 448 return false; | 435 return false; |
| 449 } | 436 } |
| 450 | 437 |
| 451 bool RenderViewHostManager::ShouldReuseWebUI( | 438 bool RenderViewHostManager::ShouldReuseWebUI( |
| 452 const NavigationEntry* curr_entry, | 439 const NavigationEntry* curr_entry, |
| 453 const NavigationEntryImpl* new_entry) const { | 440 const NavigationEntryImpl* new_entry) const { |
| 454 NavigationControllerImpl& controller = | 441 NavigationControllerImpl& controller = |
| 455 delegate_->GetControllerForRenderManager(); | 442 delegate_->GetControllerForRenderManager(); |
| 456 WebUIControllerFactory* factory = | 443 WebUIControllerFactory* factory = |
| 457 content::GetContentClient()->browser()->GetWebUIControllerFactory(); | 444 GetContentClient()->browser()->GetWebUIControllerFactory(); |
| 458 return curr_entry && web_ui_.get() && | 445 return curr_entry && web_ui_.get() && |
| 459 (factory->GetWebUIType(controller.GetBrowserContext(), | 446 (factory->GetWebUIType(controller.GetBrowserContext(), |
| 460 curr_entry->GetURL()) == | 447 curr_entry->GetURL()) == |
| 461 factory->GetWebUIType(controller.GetBrowserContext(), | 448 factory->GetWebUIType(controller.GetBrowserContext(), |
| 462 new_entry->GetURL())); | 449 new_entry->GetURL())); |
| 463 } | 450 } |
| 464 | 451 |
| 465 SiteInstance* RenderViewHostManager::GetSiteInstanceForEntry( | 452 SiteInstance* RenderViewHostManager::GetSiteInstanceForEntry( |
| 466 const NavigationEntryImpl& entry, | 453 const NavigationEntryImpl& entry, |
| 467 SiteInstance* curr_instance) { | 454 SiteInstance* curr_instance) { |
| 468 // NOTE: This is only called when ShouldTransitionCrossSite is true. | 455 // NOTE: This is only called when ShouldTransitionCrossSite is true. |
| 469 | 456 |
| 470 const GURL& dest_url = entry.GetURL(); | 457 const GURL& dest_url = entry.GetURL(); |
| 471 NavigationControllerImpl& controller = | 458 NavigationControllerImpl& controller = |
| 472 delegate_->GetControllerForRenderManager(); | 459 delegate_->GetControllerForRenderManager(); |
| 473 content::BrowserContext* browser_context = controller.GetBrowserContext(); | 460 BrowserContext* browser_context = controller.GetBrowserContext(); |
| 474 | 461 |
| 475 // If the entry has an instance already we should use it. | 462 // If the entry has an instance already we should use it. |
| 476 if (entry.site_instance()) | 463 if (entry.site_instance()) |
| 477 return entry.site_instance(); | 464 return entry.site_instance(); |
| 478 | 465 |
| 479 // (UGLY) HEURISTIC, process-per-site only: | 466 // (UGLY) HEURISTIC, process-per-site only: |
| 480 // | 467 // |
| 481 // If this navigation is generated, then it probably corresponds to a search | 468 // If this navigation is generated, then it probably corresponds to a search |
| 482 // query. Given that search results typically lead to users navigating to | 469 // query. Given that search results typically lead to users navigating to |
| 483 // other sites, we don't really want to use the search engine hostname to | 470 // other sites, we don't really want to use the search engine hostname to |
| 484 // determine the site instance for this navigation. | 471 // determine the site instance for this navigation. |
| 485 // | 472 // |
| 486 // NOTE: This can be removed once we have a way to transition between | 473 // NOTE: This can be removed once we have a way to transition between |
| 487 // RenderViews in response to a link click. | 474 // RenderViews in response to a link click. |
| 488 // | 475 // |
| 489 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kProcessPerSite) && | 476 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kProcessPerSite) && |
| 490 entry.GetTransitionType() == content::PAGE_TRANSITION_GENERATED) | 477 entry.GetTransitionType() == PAGE_TRANSITION_GENERATED) |
| 491 return curr_instance; | 478 return curr_instance; |
| 492 | 479 |
| 493 SiteInstanceImpl* curr_site_instance = | 480 SiteInstanceImpl* curr_site_instance = |
| 494 static_cast<SiteInstanceImpl*>(curr_instance); | 481 static_cast<SiteInstanceImpl*>(curr_instance); |
| 495 | 482 |
| 496 // If we haven't used our SiteInstance (and thus RVH) yet, then we can use it | 483 // If we haven't used our SiteInstance (and thus RVH) yet, then we can use it |
| 497 // for this entry. We won't commit the SiteInstance to this site until the | 484 // for this entry. We won't commit the SiteInstance to this site until the |
| 498 // navigation commits (in DidNavigate), unless the navigation entry was | 485 // navigation commits (in DidNavigate), unless the navigation entry was |
| 499 // restored or it's a Web UI as described below. | 486 // restored or it's a Web UI as described below. |
| 500 if (!curr_site_instance->HasSite()) { | 487 if (!curr_site_instance->HasSite()) { |
| (...skipping 27 matching lines...) Expand all Loading... |
| 528 // View-source URLs must use a new SiteInstance and BrowsingInstance. | 515 // View-source URLs must use a new SiteInstance and BrowsingInstance. |
| 529 // TODO(nasko): This is the same condition as later in the function. This | 516 // TODO(nasko): This is the same condition as later in the function. This |
| 530 // should be taken into account when refactoring this method as part of | 517 // should be taken into account when refactoring this method as part of |
| 531 // http://crbug.com/123007. | 518 // http://crbug.com/123007. |
| 532 if (entry.IsViewSourceMode()) | 519 if (entry.IsViewSourceMode()) |
| 533 return SiteInstance::CreateForURL(browser_context, dest_url); | 520 return SiteInstance::CreateForURL(browser_context, dest_url); |
| 534 | 521 |
| 535 // If we are navigating from a blank SiteInstance to a WebUI, make sure we | 522 // If we are navigating from a blank SiteInstance to a WebUI, make sure we |
| 536 // create a new SiteInstance. | 523 // create a new SiteInstance. |
| 537 const WebUIControllerFactory* web_ui_factory = | 524 const WebUIControllerFactory* web_ui_factory = |
| 538 content::GetContentClient()->browser()->GetWebUIControllerFactory(); | 525 GetContentClient()->browser()->GetWebUIControllerFactory(); |
| 539 if (web_ui_factory && | 526 if (web_ui_factory && |
| 540 web_ui_factory->UseWebUIForURL(browser_context, dest_url)) { | 527 web_ui_factory->UseWebUIForURL(browser_context, dest_url)) { |
| 541 return SiteInstance::CreateForURL(browser_context, dest_url); | 528 return SiteInstance::CreateForURL(browser_context, dest_url); |
| 542 } | 529 } |
| 543 | 530 |
| 544 // Normally the "site" on the SiteInstance is set lazily when the load | 531 // Normally the "site" on the SiteInstance is set lazily when the load |
| 545 // actually commits. This is to support better process sharing in case | 532 // actually commits. This is to support better process sharing in case |
| 546 // the site redirects to some other site: we want to use the destination | 533 // the site redirects to some other site: we want to use the destination |
| 547 // site in the site instance. | 534 // site in the site instance. |
| 548 // | 535 // |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 734 // Make sure the size is up to date. (Fix for bug 1079768.) | 721 // Make sure the size is up to date. (Fix for bug 1079768.) |
| 735 delegate_->UpdateRenderViewSizeForRenderManager(); | 722 delegate_->UpdateRenderViewSizeForRenderManager(); |
| 736 | 723 |
| 737 if (will_focus_location_bar) | 724 if (will_focus_location_bar) |
| 738 delegate_->SetFocusToLocationBar(false); | 725 delegate_->SetFocusToLocationBar(false); |
| 739 else if (focus_render_view && render_view_host_->GetView()) | 726 else if (focus_render_view && render_view_host_->GetView()) |
| 740 RenderWidgetHostViewPort::FromRWHV(render_view_host_->GetView())->Focus(); | 727 RenderWidgetHostViewPort::FromRWHV(render_view_host_->GetView())->Focus(); |
| 741 | 728 |
| 742 std::pair<RenderViewHost*, RenderViewHost*> details = | 729 std::pair<RenderViewHost*, RenderViewHost*> details = |
| 743 std::make_pair(old_render_view_host, render_view_host_); | 730 std::make_pair(old_render_view_host, render_view_host_); |
| 744 content::NotificationService::current()->Notify( | 731 NotificationService::current()->Notify( |
| 745 content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED, | 732 NOTIFICATION_RENDER_VIEW_HOST_CHANGED, |
| 746 content::Source<NavigationController>( | 733 Source<NavigationController>( |
| 747 &delegate_->GetControllerForRenderManager()), | 734 &delegate_->GetControllerForRenderManager()), |
| 748 content::Details<std::pair<RenderViewHost*, RenderViewHost*> >(&details)); | 735 Details<std::pair<RenderViewHost*, RenderViewHost*> >(&details)); |
| 749 | 736 |
| 750 // If the pending view was on the swapped out list, we can remove it. | 737 // If the pending view was on the swapped out list, we can remove it. |
| 751 swapped_out_hosts_.erase(render_view_host_->GetSiteInstance()->GetId()); | 738 swapped_out_hosts_.erase(render_view_host_->GetSiteInstance()->GetId()); |
| 752 | 739 |
| 753 // If the old RVH is live, we are swapping it out and should keep track of it | 740 // If the old RVH is live, we are swapping it out and should keep track of it |
| 754 // in case we navigate back to it. | 741 // in case we navigate back to it. |
| 755 if (old_render_view_host->IsRenderViewLive()) { | 742 if (old_render_view_host->IsRenderViewLive()) { |
| 756 DCHECK(old_render_view_host->is_swapped_out()); | 743 DCHECK(old_render_view_host->is_swapped_out()); |
| 757 // Temp fix for http://crbug.com/90867 until we do a better cleanup to make | 744 // Temp fix for http://crbug.com/90867 until we do a better cleanup to make |
| 758 // sure we don't get different rvh instances for the same site instance | 745 // sure we don't get different rvh instances for the same site instance |
| (...skipping 29 matching lines...) Expand all Loading... |
| 788 } | 775 } |
| 789 | 776 |
| 790 // render_view_host_ will not be deleted before the end of this method, so we | 777 // render_view_host_ will not be deleted before the end of this method, so we |
| 791 // don't have to worry about this SiteInstance's ref count dropping to zero. | 778 // don't have to worry about this SiteInstance's ref count dropping to zero. |
| 792 SiteInstance* curr_instance = render_view_host_->GetSiteInstance(); | 779 SiteInstance* curr_instance = render_view_host_->GetSiteInstance(); |
| 793 | 780 |
| 794 // Determine if we need a new SiteInstance for this entry. | 781 // Determine if we need a new SiteInstance for this entry. |
| 795 // Again, new_instance won't be deleted before the end of this method, so it | 782 // Again, new_instance won't be deleted before the end of this method, so it |
| 796 // is safe to use a normal pointer here. | 783 // is safe to use a normal pointer here. |
| 797 SiteInstance* new_instance = curr_instance; | 784 SiteInstance* new_instance = curr_instance; |
| 798 const content::NavigationEntry* curr_entry = | 785 const NavigationEntry* curr_entry = |
| 799 delegate_->GetLastCommittedNavigationEntryForRenderManager(); | 786 delegate_->GetLastCommittedNavigationEntryForRenderManager(); |
| 800 bool is_guest_scheme = curr_instance->GetSiteURL().SchemeIs( | 787 bool is_guest_scheme = curr_instance->GetSiteURL().SchemeIs( |
| 801 chrome::kGuestScheme); | 788 chrome::kGuestScheme); |
| 802 bool force_swap = ShouldSwapProcessesForNavigation(curr_entry, &entry); | 789 bool force_swap = ShouldSwapProcessesForNavigation(curr_entry, &entry); |
| 803 if (!is_guest_scheme && (ShouldTransitionCrossSite() || force_swap)) | 790 if (!is_guest_scheme && (ShouldTransitionCrossSite() || force_swap)) |
| 804 new_instance = GetSiteInstanceForEntry(entry, curr_instance); | 791 new_instance = GetSiteInstanceForEntry(entry, curr_instance); |
| 805 | 792 |
| 806 if (!is_guest_scheme && (new_instance != curr_instance || force_swap)) { | 793 if (!is_guest_scheme && (new_instance != curr_instance || force_swap)) { |
| 807 // New SiteInstance. | 794 // New SiteInstance. |
| 808 DCHECK(!cross_navigation_pending_); | 795 DCHECK(!cross_navigation_pending_); |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 899 // Same SiteInstance can be used. Navigate render_view_host_ if we are not | 886 // Same SiteInstance can be used. Navigate render_view_host_ if we are not |
| 900 // cross navigating. | 887 // cross navigating. |
| 901 DCHECK(!cross_navigation_pending_); | 888 DCHECK(!cross_navigation_pending_); |
| 902 return render_view_host_; | 889 return render_view_host_; |
| 903 } | 890 } |
| 904 | 891 |
| 905 void RenderViewHostManager::CancelPending() { | 892 void RenderViewHostManager::CancelPending() { |
| 906 RenderViewHostImpl* pending_render_view_host = pending_render_view_host_; | 893 RenderViewHostImpl* pending_render_view_host = pending_render_view_host_; |
| 907 pending_render_view_host_ = NULL; | 894 pending_render_view_host_ = NULL; |
| 908 | 895 |
| 909 content::DevToolsManagerImpl::GetInstance()->OnCancelPendingNavigation( | 896 DevToolsManagerImpl::GetInstance()->OnCancelPendingNavigation( |
| 910 pending_render_view_host, | 897 pending_render_view_host, |
| 911 render_view_host_); | 898 render_view_host_); |
| 912 | 899 |
| 913 // We no longer need to prevent the process from exiting. | 900 // We no longer need to prevent the process from exiting. |
| 914 pending_render_view_host->GetProcess()->RemovePendingView(); | 901 pending_render_view_host->GetProcess()->RemovePendingView(); |
| 915 | 902 |
| 916 // The pending RVH may already be on the swapped out list if we started to | 903 // The pending RVH may already be on the swapped out list if we started to |
| 917 // swap it back in and then canceled. If so, make sure it gets swapped out | 904 // swap it back in and then canceled. If so, make sure it gets swapped out |
| 918 // again. If it's not on the swapped out list (e.g., aborting a pending | 905 // again. If it's not on the swapped out list (e.g., aborting a pending |
| 919 // load), then it's safe to shut down. | 906 // load), then it's safe to shut down. |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 970 } | 957 } |
| 971 | 958 |
| 972 RenderViewHostImpl* RenderViewHostManager::GetSwappedOutRenderViewHost( | 959 RenderViewHostImpl* RenderViewHostManager::GetSwappedOutRenderViewHost( |
| 973 SiteInstance* instance) { | 960 SiteInstance* instance) { |
| 974 RenderViewHostMap::iterator iter = swapped_out_hosts_.find(instance->GetId()); | 961 RenderViewHostMap::iterator iter = swapped_out_hosts_.find(instance->GetId()); |
| 975 if (iter != swapped_out_hosts_.end()) | 962 if (iter != swapped_out_hosts_.end()) |
| 976 return iter->second; | 963 return iter->second; |
| 977 | 964 |
| 978 return NULL; | 965 return NULL; |
| 979 } | 966 } |
| 967 |
| 968 } // namespace content |
| OLD | NEW |