OLD | NEW |
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" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "content/browser/child_process_security_policy_impl.h" | 12 #include "content/browser/child_process_security_policy_impl.h" |
13 #include "content/browser/devtools/render_view_devtools_agent_host.h" | 13 #include "content/browser/devtools/render_view_devtools_agent_host.h" |
14 #include "content/browser/frame_host/cross_process_frame_connector.h" | 14 #include "content/browser/frame_host/cross_process_frame_connector.h" |
| 15 #include "content/browser/frame_host/debug_urls.h" |
15 #include "content/browser/frame_host/interstitial_page_impl.h" | 16 #include "content/browser/frame_host/interstitial_page_impl.h" |
16 #include "content/browser/frame_host/navigation_controller_impl.h" | 17 #include "content/browser/frame_host/navigation_controller_impl.h" |
17 #include "content/browser/frame_host/navigation_entry_impl.h" | 18 #include "content/browser/frame_host/navigation_entry_impl.h" |
18 #include "content/browser/frame_host/render_frame_host_factory.h" | 19 #include "content/browser/frame_host/render_frame_host_factory.h" |
19 #include "content/browser/frame_host/render_frame_host_impl.h" | 20 #include "content/browser/frame_host/render_frame_host_impl.h" |
20 #include "content/browser/renderer_host/render_process_host_impl.h" | 21 #include "content/browser/renderer_host/render_process_host_impl.h" |
21 #include "content/browser/renderer_host/render_view_host_factory.h" | 22 #include "content/browser/renderer_host/render_view_host_factory.h" |
22 #include "content/browser/renderer_host/render_view_host_impl.h" | 23 #include "content/browser/renderer_host/render_view_host_impl.h" |
23 #include "content/browser/site_instance_impl.h" | 24 #include "content/browser/site_instance_impl.h" |
24 #include "content/browser/webui/web_ui_controller_factory_registry.h" | 25 #include "content/browser/webui/web_ui_controller_factory_registry.h" |
(...skipping 570 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
595 // be committed to a Web UI URL (such as the NTP). | 596 // be committed to a Web UI URL (such as the NTP). |
596 BrowserContext* browser_context = | 597 BrowserContext* browser_context = |
597 delegate_->GetControllerForRenderManager().GetBrowserContext(); | 598 delegate_->GetControllerForRenderManager().GetBrowserContext(); |
598 const GURL& current_url = (current_entry) ? | 599 const GURL& current_url = (current_entry) ? |
599 SiteInstanceImpl::GetEffectiveURL(browser_context, | 600 SiteInstanceImpl::GetEffectiveURL(browser_context, |
600 current_entry->GetURL()) : | 601 current_entry->GetURL()) : |
601 render_frame_host_->render_view_host()->GetSiteInstance()->GetSiteURL(); | 602 render_frame_host_->render_view_host()->GetSiteInstance()->GetSiteURL(); |
602 const GURL& new_url = SiteInstanceImpl::GetEffectiveURL(browser_context, | 603 const GURL& new_url = SiteInstanceImpl::GetEffectiveURL(browser_context, |
603 new_entry->GetURL()); | 604 new_entry->GetURL()); |
604 | 605 |
| 606 // Don't force a new BrowsingInstance for debug URLs that are handled in the |
| 607 // renderer process, like javascript: or chrome://crash. |
| 608 if (IsRendererDebugURL(new_url)) |
| 609 return false; |
| 610 |
605 // For security, we should transition between processes when one is a Web UI | 611 // For security, we should transition between processes when one is a Web UI |
606 // page and one isn't. | 612 // page and one isn't. |
607 if (WebUIControllerFactoryRegistry::GetInstance()->UseWebUIForURL( | 613 if (WebUIControllerFactoryRegistry::GetInstance()->UseWebUIForURL( |
608 browser_context, current_url)) { | 614 browser_context, current_url)) { |
609 // If so, force a swap if destination is not an acceptable URL for Web UI. | 615 // If so, force a swap if destination is not an acceptable URL for Web UI. |
610 // Here, data URLs are never allowed. | 616 // Here, data URLs are never allowed. |
611 if (!WebUIControllerFactoryRegistry::GetInstance()->IsURLAcceptableForWebUI( | 617 if (!WebUIControllerFactoryRegistry::GetInstance()->IsURLAcceptableForWebUI( |
612 browser_context, new_url)) { | 618 browser_context, new_url)) { |
613 return true; | 619 return true; |
614 } | 620 } |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
774 // the SiteInstance. This will be correct when we intercept links and | 780 // the SiteInstance. This will be correct when we intercept links and |
775 // script-based navigations, but for now, it could place some pages in a | 781 // script-based navigations, but for now, it could place some pages in a |
776 // new process unnecessarily. We should only hit this case if a page tries | 782 // new process unnecessarily. We should only hit this case if a page tries |
777 // to open a new tab to an interstitial-inducing URL, and then navigates | 783 // to open a new tab to an interstitial-inducing URL, and then navigates |
778 // the page to a different same-site URL. (This seems very unlikely in | 784 // the page to a different same-site URL. (This seems very unlikely in |
779 // practice.) | 785 // practice.) |
780 const GURL& current_url = (current_entry) ? current_entry->GetURL() : | 786 const GURL& current_url = (current_entry) ? current_entry->GetURL() : |
781 current_instance->GetSiteURL(); | 787 current_instance->GetSiteURL(); |
782 | 788 |
783 // View-source URLs must use a new SiteInstance and BrowsingInstance. | 789 // View-source URLs must use a new SiteInstance and BrowsingInstance. |
| 790 // We don't need a swap when going from view-source to a debug URL like |
| 791 // chrome://crash, however. |
784 // TODO(creis): Refactor this method so this duplicated code isn't needed. | 792 // TODO(creis): Refactor this method so this duplicated code isn't needed. |
785 // See http://crbug.com/123007. | 793 // See http://crbug.com/123007. |
786 if (current_entry && | 794 if (current_entry && |
787 current_entry->IsViewSourceMode() != entry.IsViewSourceMode()) { | 795 current_entry->IsViewSourceMode() != entry.IsViewSourceMode() && |
| 796 !IsRendererDebugURL(dest_url)) { |
788 return SiteInstance::CreateForURL(browser_context, dest_url); | 797 return SiteInstance::CreateForURL(browser_context, dest_url); |
789 } | 798 } |
790 | 799 |
791 // Use the current SiteInstance for same site navigations, as long as the | 800 // Use the current SiteInstance for same site navigations, as long as the |
792 // process type is correct. (The URL may have been installed as an app since | 801 // process type is correct. (The URL may have been installed as an app since |
793 // the last time we visited it.) | 802 // the last time we visited it.) |
794 if (SiteInstance::IsSameWebSite(browser_context, current_url, dest_url) && | 803 if (SiteInstance::IsSameWebSite(browser_context, current_url, dest_url) && |
795 !current_site_instance->HasWrongProcessForURL(dest_url)) { | 804 !current_site_instance->HasWrongProcessForURL(dest_url)) { |
796 return current_instance; | 805 return current_instance; |
797 } | 806 } |
(...skipping 582 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1380 SiteInstance* instance) const { | 1389 SiteInstance* instance) const { |
1381 RenderFrameHostMap::const_iterator iter = | 1390 RenderFrameHostMap::const_iterator iter = |
1382 swapped_out_hosts_.find(instance->GetId()); | 1391 swapped_out_hosts_.find(instance->GetId()); |
1383 if (iter != swapped_out_hosts_.end()) | 1392 if (iter != swapped_out_hosts_.end()) |
1384 return iter->second; | 1393 return iter->second; |
1385 | 1394 |
1386 return NULL; | 1395 return NULL; |
1387 } | 1396 } |
1388 | 1397 |
1389 } // namespace content | 1398 } // namespace content |
OLD | NEW |