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/tab_contents/render_view_host_manager.h" | 5 #include "content/browser/tab_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_view_host.h" | 12 #include "content/browser/renderer_host/render_view_host.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_widget_host_view.h" | 14 #include "content/browser/renderer_host/render_widget_host_view.h" |
15 #include "content/browser/site_instance_impl.h" | 15 #include "content/browser/site_instance_impl.h" |
16 #include "content/browser/tab_contents/navigation_controller_impl.h" | 16 #include "content/browser/tab_contents/navigation_controller_impl.h" |
17 #include "content/browser/tab_contents/navigation_entry_impl.h" | 17 #include "content/browser/tab_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/public/browser/content_browser_client.h" | 20 #include "content/public/browser/content_browser_client.h" |
21 #include "content/public/browser/notification_service.h" | 21 #include "content/public/browser/notification_service.h" |
22 #include "content/public/browser/notification_types.h" | 22 #include "content/public/browser/notification_types.h" |
23 #include "content/public/browser/render_view_host_delegate.h" | 23 #include "content/public/browser/render_view_host_delegate.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_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 using content::NavigationController; |
31 using content::NavigationEntry; | 31 using content::NavigationEntry; |
32 using content::NavigationEntryImpl; | 32 using content::NavigationEntryImpl; |
33 using content::SiteInstance; | 33 using content::SiteInstance; |
| 34 using content::WebUIControllerFactory; |
34 | 35 |
35 RenderViewHostManager::RenderViewHostManager( | 36 RenderViewHostManager::RenderViewHostManager( |
36 content::RenderViewHostDelegate* render_view_delegate, | 37 content::RenderViewHostDelegate* render_view_delegate, |
37 Delegate* delegate) | 38 Delegate* delegate) |
38 : delegate_(delegate), | 39 : delegate_(delegate), |
39 cross_navigation_pending_(false), | 40 cross_navigation_pending_(false), |
40 render_view_delegate_(render_view_delegate), | 41 render_view_delegate_(render_view_delegate), |
41 render_view_host_(NULL), | 42 render_view_host_(NULL), |
42 pending_render_view_host_(NULL), | 43 pending_render_view_host_(NULL), |
43 interstitial_page_(NULL) { | 44 interstitial_page_(NULL) { |
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
342 // Check for reasons to swap processes even if we are in a process model that | 343 // Check for reasons to swap processes even if we are in a process model that |
343 // doesn't usually swap (e.g., process-per-tab). | 344 // doesn't usually swap (e.g., process-per-tab). |
344 | 345 |
345 // For security, we should transition between processes when one is a Web UI | 346 // For security, we should transition between processes when one is a Web UI |
346 // page and one isn't. If there's no cur_entry, check the current RVH's | 347 // page and one isn't. If there's no cur_entry, check the current RVH's |
347 // site, which might already be committed to a Web UI URL (such as the NTP). | 348 // site, which might already be committed to a Web UI URL (such as the NTP). |
348 const GURL& current_url = (cur_entry) ? cur_entry->GetURL() : | 349 const GURL& current_url = (cur_entry) ? cur_entry->GetURL() : |
349 render_view_host_->site_instance()->GetSite(); | 350 render_view_host_->site_instance()->GetSite(); |
350 content::BrowserContext* browser_context = | 351 content::BrowserContext* browser_context = |
351 delegate_->GetControllerForRenderManager().GetBrowserContext(); | 352 delegate_->GetControllerForRenderManager().GetBrowserContext(); |
352 const content::WebUIFactory* web_ui_factory = | 353 const WebUIControllerFactory* web_ui_factory = |
353 content::GetContentClient()->browser()->GetWebUIFactory(); | 354 content::GetContentClient()->browser()->GetWebUIControllerFactory(); |
354 if (web_ui_factory->UseWebUIForURL(browser_context, current_url)) { | 355 if (web_ui_factory) { |
355 // Force swap if it's not an acceptable URL for Web UI. | 356 if (web_ui_factory->UseWebUIForURL(browser_context, current_url)) { |
356 if (!web_ui_factory->IsURLAcceptableForWebUI(browser_context, | 357 // Force swap if it's not an acceptable URL for Web UI. |
357 new_entry->GetURL())) | 358 if (!web_ui_factory->IsURLAcceptableForWebUI(browser_context, |
358 return true; | 359 new_entry->GetURL())) |
359 } else { | 360 return true; |
360 // Force swap if it's a Web UI URL. | 361 } else { |
361 if (web_ui_factory->UseWebUIForURL(browser_context, new_entry->GetURL())) | 362 // Force swap if it's a Web UI URL. |
362 return true; | 363 if (web_ui_factory->UseWebUIForURL(browser_context, new_entry->GetURL())) |
| 364 return true; |
| 365 } |
363 } | 366 } |
364 | 367 |
365 if (content::GetContentClient()->browser()->ShouldSwapProcessesForNavigation( | 368 if (content::GetContentClient()->browser()->ShouldSwapProcessesForNavigation( |
366 cur_entry ? cur_entry->GetURL() : GURL(), new_entry->GetURL())) { | 369 cur_entry ? cur_entry->GetURL() : GURL(), new_entry->GetURL())) { |
367 return true; | 370 return true; |
368 } | 371 } |
369 | 372 |
370 if (!cur_entry) | 373 if (!cur_entry) |
371 return false; | 374 return false; |
372 | 375 |
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
816 } | 819 } |
817 } | 820 } |
818 | 821 |
819 bool RenderViewHostManager::IsSwappedOut(RenderViewHost* rvh) { | 822 bool RenderViewHostManager::IsSwappedOut(RenderViewHost* rvh) { |
820 if (!rvh->site_instance()) | 823 if (!rvh->site_instance()) |
821 return false; | 824 return false; |
822 | 825 |
823 return swapped_out_hosts_.find(rvh->site_instance()->GetId()) != | 826 return swapped_out_hosts_.find(rvh->site_instance()->GetId()) != |
824 swapped_out_hosts_.end(); | 827 swapped_out_hosts_.end(); |
825 } | 828 } |
OLD | NEW |