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" |
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
399 const NavigationEntryImpl* new_entry) const { | 399 const NavigationEntryImpl* new_entry) const { |
400 DCHECK(new_entry); | 400 DCHECK(new_entry); |
401 | 401 |
402 // Check for reasons to swap processes even if we are in a process model that | 402 // Check for reasons to swap processes even if we are in a process model that |
403 // doesn't usually swap (e.g., process-per-tab). | 403 // doesn't usually swap (e.g., process-per-tab). |
404 | 404 |
405 // For security, we should transition between processes when one is a Web UI | 405 // For security, we should transition between processes when one is a Web UI |
406 // page and one isn't. If there's no curr_entry, check the current RVH's | 406 // page and one isn't. If there's no curr_entry, check the current RVH's |
407 // site, which might already be committed to a Web UI URL (such as the NTP). | 407 // site, which might already be committed to a Web UI URL (such as the NTP). |
408 const GURL& current_url = (curr_entry) ? curr_entry->GetURL() : | 408 const GURL& current_url = (curr_entry) ? curr_entry->GetURL() : |
409 render_view_host_->GetSiteInstance()->GetSite(); | 409 render_view_host_->GetSiteInstance()->GetSiteURL(); |
410 content::BrowserContext* browser_context = | 410 content::BrowserContext* browser_context = |
411 delegate_->GetControllerForRenderManager().GetBrowserContext(); | 411 delegate_->GetControllerForRenderManager().GetBrowserContext(); |
412 const WebUIControllerFactory* web_ui_factory = | 412 const WebUIControllerFactory* web_ui_factory = |
413 content::GetContentClient()->browser()->GetWebUIControllerFactory(); | 413 content::GetContentClient()->browser()->GetWebUIControllerFactory(); |
414 if (web_ui_factory) { | 414 if (web_ui_factory) { |
415 if (web_ui_factory->UseWebUIForURL(browser_context, current_url)) { | 415 if (web_ui_factory->UseWebUIForURL(browser_context, current_url)) { |
416 // Force swap if it's not an acceptable URL for Web UI. | 416 // Force swap if it's not an acceptable URL for Web UI. |
417 // Here, data URLs are never allowed. | 417 // Here, data URLs are never allowed. |
418 if (!web_ui_factory->IsURLAcceptableForWebUI(browser_context, | 418 if (!web_ui_factory->IsURLAcceptableForWebUI(browser_context, |
419 new_entry->GetURL(), false)) | 419 new_entry->GetURL(), false)) |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
570 // has a site), then we must have been opened from another tab. We want | 570 // has a site), then we must have been opened from another tab. We want |
571 // to compare against the URL of the page that opened us, but we can't | 571 // to compare against the URL of the page that opened us, but we can't |
572 // get to it directly. The best we can do is check against the site of | 572 // get to it directly. The best we can do is check against the site of |
573 // the SiteInstance. This will be correct when we intercept links and | 573 // the SiteInstance. This will be correct when we intercept links and |
574 // script-based navigations, but for now, it could place some pages in a | 574 // script-based navigations, but for now, it could place some pages in a |
575 // new process unnecessarily. We should only hit this case if a page tries | 575 // new process unnecessarily. We should only hit this case if a page tries |
576 // to open a new tab to an interstitial-inducing URL, and then navigates | 576 // to open a new tab to an interstitial-inducing URL, and then navigates |
577 // the page to a different same-site URL. (This seems very unlikely in | 577 // the page to a different same-site URL. (This seems very unlikely in |
578 // practice.) | 578 // practice.) |
579 const GURL& current_url = (curr_entry) ? curr_entry->GetURL() : | 579 const GURL& current_url = (curr_entry) ? curr_entry->GetURL() : |
580 curr_instance->GetSite(); | 580 curr_instance->GetSiteURL(); |
581 | 581 |
582 // View-source URLs must use a new SiteInstance and BrowsingInstance. | 582 // View-source URLs must use a new SiteInstance and BrowsingInstance. |
583 // TODO(creis): Refactor this method so this duplicated code isn't needed. | 583 // TODO(creis): Refactor this method so this duplicated code isn't needed. |
584 // See http://crbug.com/123007. | 584 // See http://crbug.com/123007. |
585 if (curr_entry && | 585 if (curr_entry && |
586 curr_entry->IsViewSourceMode() != entry.IsViewSourceMode()) { | 586 curr_entry->IsViewSourceMode() != entry.IsViewSourceMode()) { |
587 return SiteInstance::CreateForURL(browser_context, dest_url); | 587 return SiteInstance::CreateForURL(browser_context, dest_url); |
588 } | 588 } |
589 | 589 |
590 // Use the current SiteInstance for same site navigations, as long as the | 590 // Use the current SiteInstance for same site navigations, as long as the |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
791 // render_view_host_ will not be deleted before the end of this method, so we | 791 // render_view_host_ will not be deleted before the end of this method, so we |
792 // don't have to worry about this SiteInstance's ref count dropping to zero. | 792 // don't have to worry about this SiteInstance's ref count dropping to zero. |
793 SiteInstance* curr_instance = render_view_host_->GetSiteInstance(); | 793 SiteInstance* curr_instance = render_view_host_->GetSiteInstance(); |
794 | 794 |
795 // Determine if we need a new SiteInstance for this entry. | 795 // Determine if we need a new SiteInstance for this entry. |
796 // Again, new_instance won't be deleted before the end of this method, so it | 796 // Again, new_instance won't be deleted before the end of this method, so it |
797 // is safe to use a normal pointer here. | 797 // is safe to use a normal pointer here. |
798 SiteInstance* new_instance = curr_instance; | 798 SiteInstance* new_instance = curr_instance; |
799 const content::NavigationEntry* curr_entry = | 799 const content::NavigationEntry* curr_entry = |
800 delegate_->GetLastCommittedNavigationEntryForRenderManager(); | 800 delegate_->GetLastCommittedNavigationEntryForRenderManager(); |
801 bool is_guest_scheme = curr_instance->GetSite().SchemeIs( | 801 bool is_guest_scheme = curr_instance->GetSiteURL().SchemeIs( |
802 chrome::kGuestScheme); | 802 chrome::kGuestScheme); |
803 bool force_swap = ShouldSwapProcessesForNavigation(curr_entry, &entry); | 803 bool force_swap = ShouldSwapProcessesForNavigation(curr_entry, &entry); |
804 if (!is_guest_scheme && (ShouldTransitionCrossSite() || force_swap)) | 804 if (!is_guest_scheme && (ShouldTransitionCrossSite() || force_swap)) |
805 new_instance = GetSiteInstanceForEntry(entry, curr_instance); | 805 new_instance = GetSiteInstanceForEntry(entry, curr_instance); |
806 | 806 |
807 if (!is_guest_scheme && (new_instance != curr_instance || force_swap)) { | 807 if (!is_guest_scheme && (new_instance != curr_instance || force_swap)) { |
808 // New SiteInstance. | 808 // New SiteInstance. |
809 DCHECK(!cross_navigation_pending_); | 809 DCHECK(!cross_navigation_pending_); |
810 | 810 |
811 // This will possibly create (set to NULL) a Web UI object for the pending | 811 // This will possibly create (set to NULL) a Web UI object for the pending |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
971 } | 971 } |
972 | 972 |
973 RenderViewHostImpl* RenderViewHostManager::GetSwappedOutRenderViewHost( | 973 RenderViewHostImpl* RenderViewHostManager::GetSwappedOutRenderViewHost( |
974 SiteInstance* instance) { | 974 SiteInstance* instance) { |
975 RenderViewHostMap::iterator iter = swapped_out_hosts_.find(instance->GetId()); | 975 RenderViewHostMap::iterator iter = swapped_out_hosts_.find(instance->GetId()); |
976 if (iter != swapped_out_hosts_.end()) | 976 if (iter != swapped_out_hosts_.end()) |
977 return iter->second; | 977 return iter->second; |
978 | 978 |
979 return NULL; | 979 return NULL; |
980 } | 980 } |
OLD | NEW |