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

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

Issue 8033001: Delegate decision what site instances can be rendered in what process to chrome (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: updates Created 9 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 | Annotate | Revision Log
« no previous file with comments | « content/browser/site_instance_unittest.cc ('k') | content/content_tests.gypi » ('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 "content/browser/content_browser_client.h" 9 #include "content/browser/content_browser_client.h"
10 #include "content/browser/renderer_host/render_view_host.h" 10 #include "content/browser/renderer_host/render_view_host.h"
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 // Check for reasons to swap processes even if we are in a process model that 341 // Check for reasons to swap processes even if we are in a process model that
342 // doesn't usually swap (e.g., process-per-tab). 342 // doesn't usually swap (e.g., process-per-tab).
343 343
344 // For security, we should transition between processes when one is a Web UI 344 // For security, we should transition between processes when one is a Web UI
345 // page and one isn't. If there's no cur_entry, check the current RVH's 345 // page and one isn't. If there's no cur_entry, check the current RVH's
346 // site, which might already be committed to a Web UI URL (such as the NTP). 346 // site, which might already be committed to a Web UI URL (such as the NTP).
347 const GURL& current_url = (cur_entry) ? cur_entry->url() : 347 const GURL& current_url = (cur_entry) ? cur_entry->url() :
348 render_view_host_->site_instance()->site(); 348 render_view_host_->site_instance()->site();
349 content::BrowserContext* browser_context = 349 content::BrowserContext* browser_context =
350 delegate_->GetControllerForRenderManager().browser_context(); 350 delegate_->GetControllerForRenderManager().browser_context();
351 content::ContentBrowserClient* browser =
352 content::GetContentClient()->browser();
351 const content::WebUIFactory* web_ui_factory = content::WebUIFactory::Get(); 353 const content::WebUIFactory* web_ui_factory = content::WebUIFactory::Get();
352 if (web_ui_factory->UseWebUIForURL(browser_context, current_url)) { 354 if (web_ui_factory->UseWebUIForURL(browser_context, current_url)) {
353 // Force swap if it's not an acceptable URL for Web UI. 355 // Force swap if it's not an acceptable URL for Web UI.
354 if (!web_ui_factory->IsURLAcceptableForWebUI(browser_context, 356 if (!web_ui_factory->IsURLAcceptableForWebUI(browser_context,
355 new_entry->url())) 357 new_entry->url()))
356 return true; 358 return true;
357 } else { 359 } else {
358 // Force swap if it's a Web UI URL. 360 // Force swap if it's a Web UI URL.
359 if (web_ui_factory->UseWebUIForURL(browser_context, new_entry->url())) 361 if (web_ui_factory->UseWebUIForURL(browser_context, new_entry->url()))
360 return true; 362 return true;
361 } 363 }
362 364
363 if (!cur_entry) { 365 if (!cur_entry) {
364 // Always choose a new process when navigating to extension URLs. The 366 // Always choose a new process when navigating to extension URLs. The
365 // process grouping logic will combine all of a given extension's pages 367 // process grouping logic will combine all of a given extension's pages
366 // into the same process. 368 // into the same process.
367 if (new_entry->url().SchemeIs(chrome::kExtensionScheme)) 369 if (browser->ShouldRunInPrivilegedProcess(new_entry->url()))
jam 2011/09/26 21:08:58 I think this concept of privilieged processes is s
368 return true; 370 return true;
369 371
370 return false; 372 return false;
371 } 373 }
372 374
373 // We can't switch a RenderView between view source and non-view source mode 375 // We can't switch a RenderView between view source and non-view source mode
374 // without screwing up the session history sometimes (when navigating between 376 // without screwing up the session history sometimes (when navigating between
375 // "view-source:http://foo.com/" and "http://foo.com/", WebKit doesn't treat 377 // "view-source:http://foo.com/" and "http://foo.com/", WebKit doesn't treat
376 // it as a new navigation). So require a view switch. 378 // it as a new navigation). So require a view switch.
377 if (cur_entry->IsViewSourceMode() != new_entry->IsViewSourceMode()) 379 if (cur_entry->IsViewSourceMode() != new_entry->IsViewSourceMode())
378 return true; 380 return true;
379 381
380 // Also, we must switch if one is an extension and the other is not the exact 382 // Also, we must switch if one is an extension and the other is not the exact
381 // same extension. 383 // same extension.
382 if (cur_entry->url().SchemeIs(chrome::kExtensionScheme) || 384 if (browser->ShouldRunInPrivilegedProcess(cur_entry->url()) ||
383 new_entry->url().SchemeIs(chrome::kExtensionScheme)) { 385 browser->ShouldRunInPrivilegedProcess(new_entry->url())) {
384 if (cur_entry->url().GetOrigin() != new_entry->url().GetOrigin()) 386 if (cur_entry->url().GetOrigin() != new_entry->url().GetOrigin())
385 return true; 387 return true;
386 } 388 }
387 389
388 return false; 390 return false;
389 } 391 }
390 392
391 SiteInstance* RenderViewHostManager::GetSiteInstanceForEntry( 393 SiteInstance* RenderViewHostManager::GetSiteInstanceForEntry(
392 const NavigationEntry& entry, 394 const NavigationEntry& entry,
393 SiteInstance* curr_instance) { 395 SiteInstance* curr_instance) {
(...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after
888 delegate_->NotifySwappedFromRenderManager(); 890 delegate_->NotifySwappedFromRenderManager();
889 } 891 }
890 892
891 bool RenderViewHostManager::IsSwappedOut(RenderViewHost* rvh) { 893 bool RenderViewHostManager::IsSwappedOut(RenderViewHost* rvh) {
892 if (!rvh->site_instance()) 894 if (!rvh->site_instance())
893 return false; 895 return false;
894 896
895 return swapped_out_hosts_.find(rvh->site_instance()->id()) != 897 return swapped_out_hosts_.find(rvh->site_instance()->id()) !=
896 swapped_out_hosts_.end(); 898 swapped_out_hosts_.end();
897 } 899 }
OLDNEW
« no previous file with comments | « content/browser/site_instance_unittest.cc ('k') | content/content_tests.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698