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

Side by Side Diff: content/browser/tab_contents/render_view_host_manager.cc

Issue 6713082: Move WebUIFactory to chrome/browser. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: synced Created 9 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « content/browser/site_instance.cc ('k') | content/browser/tab_contents/tab_contents.h » ('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 (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/common/chrome_switches.h" 10 #include "chrome/common/chrome_switches.h"
11 #include "chrome/common/render_messages.h" 11 #include "chrome/common/render_messages.h"
12 #include "chrome/common/url_constants.h" 12 #include "chrome/common/url_constants.h"
13 #include "content/browser/content_browser_client.h" 13 #include "content/browser/content_browser_client.h"
14 #include "content/browser/renderer_host/render_view_host.h" 14 #include "content/browser/renderer_host/render_view_host.h"
15 #include "content/browser/renderer_host/render_view_host_delegate.h" 15 #include "content/browser/renderer_host/render_view_host_delegate.h"
16 #include "content/browser/renderer_host/render_view_host_factory.h" 16 #include "content/browser/renderer_host/render_view_host_factory.h"
17 #include "content/browser/renderer_host/render_widget_host_view.h" 17 #include "content/browser/renderer_host/render_widget_host_view.h"
18 #include "content/browser/site_instance.h" 18 #include "content/browser/site_instance.h"
19 #include "content/browser/tab_contents/navigation_controller.h" 19 #include "content/browser/tab_contents/navigation_controller.h"
20 #include "content/browser/tab_contents/navigation_entry.h" 20 #include "content/browser/tab_contents/navigation_entry.h"
21 #include "content/browser/tab_contents/tab_contents_view.h" 21 #include "content/browser/tab_contents/tab_contents_view.h"
22 #include "content/browser/webui/web_ui.h" 22 #include "content/browser/webui/web_ui.h"
23 #include "content/browser/webui/web_ui_factory.h" 23 #include "content/browser/webui/web_ui_factory.h"
24 #include "content/common/content_client.h"
24 #include "content/common/notification_service.h" 25 #include "content/common/notification_service.h"
25 #include "content/common/notification_type.h" 26 #include "content/common/notification_type.h"
26 #include "content/common/view_messages.h" 27 #include "content/common/view_messages.h"
27 28
28 namespace base { 29 namespace base {
29 class WaitableEvent; 30 class WaitableEvent;
30 } 31 }
31 32
32 RenderViewHostManager::RenderViewHostManager( 33 RenderViewHostManager::RenderViewHostManager(
33 RenderViewHostDelegate* render_view_delegate, 34 RenderViewHostDelegate* render_view_delegate,
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 295
295 // Check for reasons to swap processes even if we are in a process model that 296 // Check for reasons to swap processes even if we are in a process model that
296 // doesn't usually swap (e.g., process-per-tab). 297 // doesn't usually swap (e.g., process-per-tab).
297 298
298 // For security, we should transition between processes when one is a Web UI 299 // For security, we should transition between processes when one is a Web UI
299 // page and one isn't. If there's no cur_entry, check the current RVH's 300 // page and one isn't. If there's no cur_entry, check the current RVH's
300 // site, which might already be committed to a Web UI URL (such as the NTP). 301 // site, which might already be committed to a Web UI URL (such as the NTP).
301 const GURL& current_url = (cur_entry) ? cur_entry->url() : 302 const GURL& current_url = (cur_entry) ? cur_entry->url() :
302 render_view_host_->site_instance()->site(); 303 render_view_host_->site_instance()->site();
303 Profile* profile = delegate_->GetControllerForRenderManager().profile(); 304 Profile* profile = delegate_->GetControllerForRenderManager().profile();
304 if (WebUIFactory::UseWebUIForURL(profile, current_url)) { 305 const content::WebUIFactory* web_ui_factory = content::WebUIFactory::Get();
306 if (web_ui_factory->UseWebUIForURL(profile, current_url)) {
305 // Force swap if it's not an acceptable URL for Web UI. 307 // Force swap if it's not an acceptable URL for Web UI.
306 if (!WebUIFactory::IsURLAcceptableForWebUI(profile, new_entry->url())) 308 if (!web_ui_factory->IsURLAcceptableForWebUI(profile, new_entry->url()))
307 return true; 309 return true;
308 } else { 310 } else {
309 // Force swap if it's a Web UI URL. 311 // Force swap if it's a Web UI URL.
310 if (WebUIFactory::UseWebUIForURL(profile, new_entry->url())) 312 if (web_ui_factory->UseWebUIForURL(profile, new_entry->url()))
311 return true; 313 return true;
312 } 314 }
313 315
314 if (!cur_entry) { 316 if (!cur_entry) {
315 // Always choose a new process when navigating to extension URLs. The 317 // Always choose a new process when navigating to extension URLs. The
316 // process grouping logic will combine all of a given extension's pages 318 // process grouping logic will combine all of a given extension's pages
317 // into the same process. 319 // into the same process.
318 if (new_entry->url().SchemeIs(chrome::kExtensionScheme)) 320 if (new_entry->url().SchemeIs(chrome::kExtensionScheme))
319 return true; 321 return true;
320 322
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 // to compare against the current URL and not the SiteInstance's site. In 379 // to compare against the current URL and not the SiteInstance's site. In
378 // this case, there is no current URL, so comparing against the site is ok. 380 // this case, there is no current URL, so comparing against the site is ok.
379 // See additional comments below.) 381 // See additional comments below.)
380 if (curr_instance->HasRelatedSiteInstance(dest_url)) 382 if (curr_instance->HasRelatedSiteInstance(dest_url))
381 return curr_instance->GetRelatedSiteInstance(dest_url); 383 return curr_instance->GetRelatedSiteInstance(dest_url);
382 384
383 // For extensions and Web UI URLs (such as the new tab page), we do not 385 // For extensions and Web UI URLs (such as the new tab page), we do not
384 // want to use the curr_instance if it has no site, since it will have a 386 // want to use the curr_instance if it has no site, since it will have a
385 // RenderProcessHost of TYPE_NORMAL. Create a new SiteInstance for this 387 // RenderProcessHost of TYPE_NORMAL. Create a new SiteInstance for this
386 // URL instead (with the correct process type). 388 // URL instead (with the correct process type).
387 if (WebUIFactory::UseWebUIForURL(profile, dest_url)) 389 if (content::WebUIFactory::Get()->UseWebUIForURL(profile, dest_url)) {
388 return SiteInstance::CreateSiteInstanceForURL(profile, dest_url); 390 return SiteInstance::CreateSiteInstanceForURL(profile, dest_url);
391 }
389 392
390 // Normally the "site" on the SiteInstance is set lazily when the load 393 // Normally the "site" on the SiteInstance is set lazily when the load
391 // actually commits. This is to support better process sharing in case 394 // actually commits. This is to support better process sharing in case
392 // the site redirects to some other site: we want to use the destination 395 // the site redirects to some other site: we want to use the destination
393 // site in the site instance. 396 // site in the site instance.
394 // 397 //
395 // In the case of session restore, as it loads all the pages immediately 398 // In the case of session restore, as it loads all the pages immediately
396 // we need to set the site first, otherwise after a restore none of the 399 // we need to set the site first, otherwise after a restore none of the
397 // pages would share renderers in process-per-site. 400 // pages would share renderers in process-per-site.
398 if (entry.restore_type() != NavigationEntry::RESTORE_NONE) 401 if (entry.restore_type() != NavigationEntry::RESTORE_NONE)
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
719 Source<NavigationController>(&delegate_->GetControllerForRenderManager()), 722 Source<NavigationController>(&delegate_->GetControllerForRenderManager()),
720 Details<RenderViewHostSwitchedDetails>(&details)); 723 Details<RenderViewHostSwitchedDetails>(&details));
721 724
722 // This will cause the old RenderViewHost to delete itself. 725 // This will cause the old RenderViewHost to delete itself.
723 old_render_view_host->Shutdown(); 726 old_render_view_host->Shutdown();
724 727
725 // Let the task manager know that we've swapped RenderViewHosts, since it 728 // Let the task manager know that we've swapped RenderViewHosts, since it
726 // might need to update its process groupings. 729 // might need to update its process groupings.
727 delegate_->NotifySwappedFromRenderManager(); 730 delegate_->NotifySwappedFromRenderManager();
728 } 731 }
OLDNEW
« no previous file with comments | « content/browser/site_instance.cc ('k') | content/browser/tab_contents/tab_contents.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698