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

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: Moved the implementation to the better places pointed out and addressed other comments. 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
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 18 matching lines...) Expand all
29 #include "content/browser/webui/web_ui_impl.h" 29 #include "content/browser/webui/web_ui_impl.h"
30 #include "content/common/frame_messages.h" 30 #include "content/common/frame_messages.h"
31 #include "content/common/view_messages.h" 31 #include "content/common/view_messages.h"
32 #include "content/public/browser/content_browser_client.h" 32 #include "content/public/browser/content_browser_client.h"
33 #include "content/public/browser/notification_service.h" 33 #include "content/public/browser/notification_service.h"
34 #include "content/public/browser/notification_types.h" 34 #include "content/public/browser/notification_types.h"
35 #include "content/public/browser/render_widget_host_iterator.h" 35 #include "content/public/browser/render_widget_host_iterator.h"
36 #include "content/public/browser/render_widget_host_view.h" 36 #include "content/public/browser/render_widget_host_view.h"
37 #include "content/public/browser/user_metrics.h" 37 #include "content/public/browser/user_metrics.h"
38 #include "content/public/browser/web_ui_controller.h" 38 #include "content/public/browser/web_ui_controller.h"
39 #include "content/public/common/bindings_policy.h"
Charlie Reis 2014/10/21 19:10:41 Probably don't need this anymore.
Krzysztof Olczyk 2014/10/22 06:24:05 Done.
39 #include "content/public/common/content_switches.h" 40 #include "content/public/common/content_switches.h"
40 #include "content/public/common/referrer.h" 41 #include "content/public/common/referrer.h"
41 #include "content/public/common/url_constants.h" 42 #include "content/public/common/url_constants.h"
42 43
43 namespace content { 44 namespace content {
44 45
45 // static 46 // static
46 bool RenderFrameHostManager::ClearRFHsPendingShutdown(FrameTreeNode* node) { 47 bool RenderFrameHostManager::ClearRFHsPendingShutdown(FrameTreeNode* node) {
47 node->render_manager()->pending_delete_hosts_.clear(); 48 node->render_manager()->pending_delete_hosts_.clear();
48 return true; 49 return true;
(...skipping 634 matching lines...) Expand 10 before | Expand all | Expand 10 after
683 BrowserContext* browser_context = 684 BrowserContext* browser_context =
684 delegate_->GetControllerForRenderManager().GetBrowserContext(); 685 delegate_->GetControllerForRenderManager().GetBrowserContext();
685 686
686 // Don't force a new BrowsingInstance for debug URLs that are handled in the 687 // Don't force a new BrowsingInstance for debug URLs that are handled in the
687 // renderer process, like javascript: or chrome://crash. 688 // renderer process, like javascript: or chrome://crash.
688 if (IsRendererDebugURL(new_effective_url)) 689 if (IsRendererDebugURL(new_effective_url))
689 return false; 690 return false;
690 691
691 // For security, we should transition between processes when one is a Web UI 692 // For security, we should transition between processes when one is a Web UI
692 // page and one isn't. 693 // page and one isn't.
693 if (WebUIControllerFactoryRegistry::GetInstance()->UseWebUIForURL( 694 if (ChildProcessSecurityPolicyImpl::GetInstance()->HasWebUIBindings(
695 render_frame_host_->GetProcess()->GetID()) ||
696 WebUIControllerFactoryRegistry::GetInstance()->UseWebUIForURL(
694 browser_context, current_effective_url)) { 697 browser_context, current_effective_url)) {
695 // If so, force a swap if destination is not an acceptable URL for Web UI. 698 // If so, force a swap if destination is not an acceptable URL for Web UI.
696 // Here, data URLs are never allowed. 699 // Here, data URLs are never allowed.
697 if (!WebUIControllerFactoryRegistry::GetInstance()->IsURLAcceptableForWebUI( 700 if (!WebUIControllerFactoryRegistry::GetInstance()->IsURLAcceptableForWebUI(
698 browser_context, new_effective_url)) { 701 browser_context, new_effective_url)) {
699 return true; 702 return true;
700 } 703 }
701 } else { 704 } else {
702 // Force a swap if it's a Web UI URL. 705 // Force a swap if it's a Web UI URL.
703 if (WebUIControllerFactoryRegistry::GetInstance()->UseWebUIForURL( 706 if (WebUIControllerFactoryRegistry::GetInstance()->UseWebUIForURL(
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
740 SiteInstance* RenderFrameHostManager::GetSiteInstanceForNavigation( 743 SiteInstance* RenderFrameHostManager::GetSiteInstanceForNavigation(
741 const GURL& dest_url, 744 const GURL& dest_url,
742 SiteInstance* dest_instance, 745 SiteInstance* dest_instance,
743 ui::PageTransition dest_transition, 746 ui::PageTransition dest_transition,
744 bool dest_is_restore, 747 bool dest_is_restore,
745 bool dest_is_view_source_mode) { 748 bool dest_is_view_source_mode) {
746 SiteInstance* current_instance = render_frame_host_->GetSiteInstance(); 749 SiteInstance* current_instance = render_frame_host_->GetSiteInstance();
747 SiteInstance* new_instance = current_instance; 750 SiteInstance* new_instance = current_instance;
748 751
749 // We do not currently swap processes for navigations in webview tag guests. 752 // We do not currently swap processes for navigations in webview tag guests.
750 bool is_guest_scheme = current_instance->GetSiteURL().SchemeIs(kGuestScheme); 753 if (current_instance->GetSiteURL().SchemeIs(kGuestScheme))
754 return current_instance;
751 755
752 // Determine if we need a new BrowsingInstance for this entry. If true, this 756 // 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 757 // 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. 758 // 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 759 // This is used for cases that require a process swap even in the
756 // process-per-tab model, such as WebUI pages. 760 // process-per-tab model, such as WebUI pages.
757 // TODO(clamy): Remove the dependency on the current entry. 761 // TODO(clamy): Remove the dependency on the current entry.
758 const NavigationEntry* current_entry = 762 const NavigationEntry* current_entry =
759 delegate_->GetLastCommittedNavigationEntryForRenderManager(); 763 delegate_->GetLastCommittedNavigationEntryForRenderManager();
760 BrowserContext* browser_context = 764 BrowserContext* browser_context =
761 delegate_->GetControllerForRenderManager().GetBrowserContext(); 765 delegate_->GetControllerForRenderManager().GetBrowserContext();
762 const GURL& current_effective_url = current_entry ? 766 const GURL& current_effective_url = current_entry ?
763 SiteInstanceImpl::GetEffectiveURL(browser_context, 767 SiteInstanceImpl::GetEffectiveURL(browser_context,
764 current_entry->GetURL()) : 768 current_entry->GetURL()) :
765 render_frame_host_->GetSiteInstance()->GetSiteURL(); 769 render_frame_host_->GetSiteInstance()->GetSiteURL();
766 bool current_is_view_source_mode = current_entry ? 770 bool current_is_view_source_mode = current_entry ?
767 current_entry->IsViewSourceMode() : dest_is_view_source_mode; 771 current_entry->IsViewSourceMode() : dest_is_view_source_mode;
768 bool force_swap = !is_guest_scheme && 772 bool force_swap = ShouldSwapBrowsingInstancesForNavigation(
769 ShouldSwapBrowsingInstancesForNavigation( 773 current_effective_url,
770 current_effective_url, 774 current_is_view_source_mode,
771 current_is_view_source_mode, 775 dest_instance,
772 dest_instance, 776 SiteInstanceImpl::GetEffectiveURL(browser_context, dest_url),
773 SiteInstanceImpl::GetEffectiveURL(browser_context, dest_url), 777 dest_is_view_source_mode);
774 dest_is_view_source_mode); 778 if (ShouldTransitionCrossSite() || force_swap) {
775 if (!is_guest_scheme && (ShouldTransitionCrossSite() || force_swap)) {
776 new_instance = GetSiteInstanceForURL( 779 new_instance = GetSiteInstanceForURL(
777 dest_url, 780 dest_url,
778 dest_instance, 781 dest_instance,
779 dest_transition, 782 dest_transition,
780 dest_is_restore, 783 dest_is_restore,
781 dest_is_view_source_mode, 784 dest_is_view_source_mode,
782 current_instance, 785 current_instance,
783 force_swap); 786 force_swap);
784 } 787 }
785 788
(...skipping 808 matching lines...) Expand 10 before | Expand all | Expand 10 after
1594 void RenderFrameHostManager::DeleteRenderFrameProxyHost( 1597 void RenderFrameHostManager::DeleteRenderFrameProxyHost(
1595 SiteInstance* instance) { 1598 SiteInstance* instance) {
1596 RenderFrameProxyHostMap::iterator iter = proxy_hosts_.find(instance->GetId()); 1599 RenderFrameProxyHostMap::iterator iter = proxy_hosts_.find(instance->GetId());
1597 if (iter != proxy_hosts_.end()) { 1600 if (iter != proxy_hosts_.end()) {
1598 delete iter->second; 1601 delete iter->second;
1599 proxy_hosts_.erase(iter); 1602 proxy_hosts_.erase(iter);
1600 } 1603 }
1601 } 1604 }
1602 1605
1603 } // namespace content 1606 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698