Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: content/browser/frame_host/render_frame_host_manager.cc

Issue 659293002: Make sure new render is used when navigating away from about:blank in WebUI renderer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Final nit fixes Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | content/browser/frame_host/render_frame_host_manager_browsertest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/frame_host/render_frame_host_manager.h" 5 #include "content/browser/frame_host/render_frame_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/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
(...skipping 672 matching lines...) Expand 10 before | Expand all | Expand 10 after
683 BrowserContext* browser_context = 683 BrowserContext* browser_context =
684 delegate_->GetControllerForRenderManager().GetBrowserContext(); 684 delegate_->GetControllerForRenderManager().GetBrowserContext();
685 685
686 // Don't force a new BrowsingInstance for debug URLs that are handled in the 686 // Don't force a new BrowsingInstance for debug URLs that are handled in the
687 // renderer process, like javascript: or chrome://crash. 687 // renderer process, like javascript: or chrome://crash.
688 if (IsRendererDebugURL(new_effective_url)) 688 if (IsRendererDebugURL(new_effective_url))
689 return false; 689 return false;
690 690
691 // For security, we should transition between processes when one is a Web UI 691 // For security, we should transition between processes when one is a Web UI
692 // page and one isn't. 692 // page and one isn't.
693 if (WebUIControllerFactoryRegistry::GetInstance()->UseWebUIForURL( 693 if (ChildProcessSecurityPolicyImpl::GetInstance()->HasWebUIBindings(
694 render_frame_host_->GetProcess()->GetID()) ||
695 WebUIControllerFactoryRegistry::GetInstance()->UseWebUIForURL(
694 browser_context, current_effective_url)) { 696 browser_context, current_effective_url)) {
695 // If so, force a swap if destination is not an acceptable URL for Web UI. 697 // If so, force a swap if destination is not an acceptable URL for Web UI.
696 // Here, data URLs are never allowed. 698 // Here, data URLs are never allowed.
697 if (!WebUIControllerFactoryRegistry::GetInstance()->IsURLAcceptableForWebUI( 699 if (!WebUIControllerFactoryRegistry::GetInstance()->IsURLAcceptableForWebUI(
698 browser_context, new_effective_url)) { 700 browser_context, new_effective_url)) {
699 return true; 701 return true;
700 } 702 }
701 } else { 703 } else {
702 // Force a swap if it's a Web UI URL. 704 // Force a swap if it's a Web UI URL.
703 if (WebUIControllerFactoryRegistry::GetInstance()->UseWebUIForURL( 705 if (WebUIControllerFactoryRegistry::GetInstance()->UseWebUIForURL(
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
740 SiteInstance* RenderFrameHostManager::GetSiteInstanceForNavigation( 742 SiteInstance* RenderFrameHostManager::GetSiteInstanceForNavigation(
741 const GURL& dest_url, 743 const GURL& dest_url,
742 SiteInstance* dest_instance, 744 SiteInstance* dest_instance,
743 ui::PageTransition dest_transition, 745 ui::PageTransition dest_transition,
744 bool dest_is_restore, 746 bool dest_is_restore,
745 bool dest_is_view_source_mode) { 747 bool dest_is_view_source_mode) {
746 SiteInstance* current_instance = render_frame_host_->GetSiteInstance(); 748 SiteInstance* current_instance = render_frame_host_->GetSiteInstance();
747 SiteInstance* new_instance = current_instance; 749 SiteInstance* new_instance = current_instance;
748 750
749 // We do not currently swap processes for navigations in webview tag guests. 751 // We do not currently swap processes for navigations in webview tag guests.
750 bool is_guest_scheme = current_instance->GetSiteURL().SchemeIs(kGuestScheme); 752 if (current_instance->GetSiteURL().SchemeIs(kGuestScheme))
753 return current_instance;
751 754
752 // Determine if we need a new BrowsingInstance for this entry. If true, this 755 // Determine if we need a new BrowsingInstance for this entry. If true, this
753 // implies that it will get a new SiteInstance (and likely process), and that 756 // implies that it will get a new SiteInstance (and likely process), and that
754 // other tabs in the current BrowsingInstance will be unable to script it. 757 // other tabs in the current BrowsingInstance will be unable to script it.
755 // This is used for cases that require a process swap even in the 758 // This is used for cases that require a process swap even in the
756 // process-per-tab model, such as WebUI pages. 759 // process-per-tab model, such as WebUI pages.
757 // TODO(clamy): Remove the dependency on the current entry. 760 // TODO(clamy): Remove the dependency on the current entry.
758 const NavigationEntry* current_entry = 761 const NavigationEntry* current_entry =
759 delegate_->GetLastCommittedNavigationEntryForRenderManager(); 762 delegate_->GetLastCommittedNavigationEntryForRenderManager();
760 BrowserContext* browser_context = 763 BrowserContext* browser_context =
761 delegate_->GetControllerForRenderManager().GetBrowserContext(); 764 delegate_->GetControllerForRenderManager().GetBrowserContext();
762 const GURL& current_effective_url = current_entry ? 765 const GURL& current_effective_url = current_entry ?
763 SiteInstanceImpl::GetEffectiveURL(browser_context, 766 SiteInstanceImpl::GetEffectiveURL(browser_context,
764 current_entry->GetURL()) : 767 current_entry->GetURL()) :
765 render_frame_host_->GetSiteInstance()->GetSiteURL(); 768 render_frame_host_->GetSiteInstance()->GetSiteURL();
766 bool current_is_view_source_mode = current_entry ? 769 bool current_is_view_source_mode = current_entry ?
767 current_entry->IsViewSourceMode() : dest_is_view_source_mode; 770 current_entry->IsViewSourceMode() : dest_is_view_source_mode;
768 bool force_swap = !is_guest_scheme && 771 bool force_swap = ShouldSwapBrowsingInstancesForNavigation(
769 ShouldSwapBrowsingInstancesForNavigation( 772 current_effective_url,
770 current_effective_url, 773 current_is_view_source_mode,
771 current_is_view_source_mode, 774 dest_instance,
772 dest_instance, 775 SiteInstanceImpl::GetEffectiveURL(browser_context, dest_url),
773 SiteInstanceImpl::GetEffectiveURL(browser_context, dest_url), 776 dest_is_view_source_mode);
774 dest_is_view_source_mode); 777 if (ShouldTransitionCrossSite() || force_swap) {
775 if (!is_guest_scheme && (ShouldTransitionCrossSite() || force_swap)) {
776 new_instance = GetSiteInstanceForURL( 778 new_instance = GetSiteInstanceForURL(
777 dest_url, 779 dest_url,
778 dest_instance, 780 dest_instance,
779 dest_transition, 781 dest_transition,
780 dest_is_restore, 782 dest_is_restore,
781 dest_is_view_source_mode, 783 dest_is_view_source_mode,
782 current_instance, 784 current_instance,
783 force_swap); 785 force_swap);
784 } 786 }
785 787
(...skipping 808 matching lines...) Expand 10 before | Expand all | Expand 10 after
1594 void RenderFrameHostManager::DeleteRenderFrameProxyHost( 1596 void RenderFrameHostManager::DeleteRenderFrameProxyHost(
1595 SiteInstance* instance) { 1597 SiteInstance* instance) {
1596 RenderFrameProxyHostMap::iterator iter = proxy_hosts_.find(instance->GetId()); 1598 RenderFrameProxyHostMap::iterator iter = proxy_hosts_.find(instance->GetId());
1597 if (iter != proxy_hosts_.end()) { 1599 if (iter != proxy_hosts_.end()) {
1598 delete iter->second; 1600 delete iter->second;
1599 proxy_hosts_.erase(iter); 1601 proxy_hosts_.erase(iter);
1600 } 1602 }
1601 } 1603 }
1602 1604
1603 } // namespace content 1605 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/browser/frame_host/render_frame_host_manager_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698