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

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

Issue 1723016: Force extensions to run in their shared processes, even with --process-per-tab. (Closed)
Patch Set: feedback Created 10 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
« no previous file with comments | « chrome/browser/browsing_instance.cc ('k') | no next file » | 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "chrome/browser/tab_contents/render_view_host_manager.h" 5 #include "chrome/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/dom_ui/dom_ui.h" 9 #include "chrome/browser/dom_ui/dom_ui.h"
10 #include "chrome/browser/dom_ui/dom_ui_factory.h" 10 #include "chrome/browser/dom_ui/dom_ui_factory.h"
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 281
282 bool RenderViewHostManager::ShouldTransitionCrossSite() { 282 bool RenderViewHostManager::ShouldTransitionCrossSite() {
283 // True if we are using process-per-site-instance (default) or 283 // True if we are using process-per-site-instance (default) or
284 // process-per-site (kProcessPerSite). 284 // process-per-site (kProcessPerSite).
285 return !CommandLine::ForCurrentProcess()->HasSwitch(switches::kProcessPerTab); 285 return !CommandLine::ForCurrentProcess()->HasSwitch(switches::kProcessPerTab);
286 } 286 }
287 287
288 bool RenderViewHostManager::ShouldSwapProcessesForNavigation( 288 bool RenderViewHostManager::ShouldSwapProcessesForNavigation(
289 const NavigationEntry* cur_entry, 289 const NavigationEntry* cur_entry,
290 const NavigationEntry* new_entry) const { 290 const NavigationEntry* new_entry) const {
291 if (!cur_entry || !new_entry) 291 DCHECK(new_entry);
292
293 if (!cur_entry) {
294 // Always choose a new process when navigating to extension URLs. The
295 // process grouping logic will combine all of a given extension's pages
296 // into the same process.
297 if (new_entry->url().SchemeIs(chrome::kExtensionScheme))
298 return true;
292 return false; 299 return false;
300 }
293 301
294 // We can't switch a RenderView between view source and non-view source mode 302 // We can't switch a RenderView between view source and non-view source mode
295 // without screwing up the session history sometimes (when navigating between 303 // without screwing up the session history sometimes (when navigating between
296 // "view-source:http://foo.com/" and "http://foo.com/", WebKit doesn't treat 304 // "view-source:http://foo.com/" and "http://foo.com/", WebKit doesn't treat
297 // it as a new navigation). So require a view switch. 305 // it as a new navigation). So require a view switch.
298 if (cur_entry->IsViewSourceMode() != new_entry->IsViewSourceMode()) 306 if (cur_entry->IsViewSourceMode() != new_entry->IsViewSourceMode())
299 return true; 307 return true;
300 308
301 // For security, we should transition between processes when one is a DOM UI 309 // For security, we should transition between processes when one is a DOM UI
302 // page and one isn't. 310 // page and one isn't.
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
562 pending_dom_ui_.reset(delegate_->CreateDOMUIForRenderManager(entry.url())); 570 pending_dom_ui_.reset(delegate_->CreateDOMUIForRenderManager(entry.url()));
563 571
564 // render_view_host_ will not be deleted before the end of this method, so we 572 // render_view_host_ will not be deleted before the end of this method, so we
565 // don't have to worry about this SiteInstance's ref count dropping to zero. 573 // don't have to worry about this SiteInstance's ref count dropping to zero.
566 SiteInstance* curr_instance = render_view_host_->site_instance(); 574 SiteInstance* curr_instance = render_view_host_->site_instance();
567 575
568 // Determine if we need a new SiteInstance for this entry. 576 // Determine if we need a new SiteInstance for this entry.
569 // Again, new_instance won't be deleted before the end of this method, so it 577 // Again, new_instance won't be deleted before the end of this method, so it
570 // is safe to use a normal pointer here. 578 // is safe to use a normal pointer here.
571 SiteInstance* new_instance = curr_instance; 579 SiteInstance* new_instance = curr_instance;
572 if (ShouldTransitionCrossSite()) 580 bool force_swap = ShouldSwapProcessesForNavigation(
581 delegate_->GetLastCommittedNavigationEntryForRenderManager(),
582 &entry);
583 if (ShouldTransitionCrossSite() || force_swap)
573 new_instance = GetSiteInstanceForEntry(entry, curr_instance); 584 new_instance = GetSiteInstanceForEntry(entry, curr_instance);
574 585
575 if (new_instance != curr_instance || 586 if (new_instance != curr_instance || force_swap) {
576 ShouldSwapProcessesForNavigation(
577 delegate_->GetLastCommittedNavigationEntryForRenderManager(),
578 &entry)) {
579 // New SiteInstance. 587 // New SiteInstance.
580 DCHECK(!cross_navigation_pending_); 588 DCHECK(!cross_navigation_pending_);
581 589
582 // Create a pending RVH and navigate it. 590 // Create a pending RVH and navigate it.
583 bool success = CreatePendingRenderView(entry, new_instance); 591 bool success = CreatePendingRenderView(entry, new_instance);
584 if (!success) 592 if (!success)
585 return NULL; 593 return NULL;
586 594
587 // Check if our current RVH is live before we set up a transition. 595 // Check if our current RVH is live before we set up a transition.
588 if (!render_view_host_->IsRenderViewLive()) { 596 if (!render_view_host_->IsRenderViewLive()) {
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
658 // deleted (not sure from where) but not NULLed. 666 // deleted (not sure from where) but not NULLed.
659 if (rvh == pending_render_view_host_) { 667 if (rvh == pending_render_view_host_) {
660 // If you hit this NOTREACHED, please report it in the following bug 668 // If you hit this NOTREACHED, please report it in the following bug
661 // http://crbug.com/23411 Make sure to include what you were doing when it 669 // http://crbug.com/23411 Make sure to include what you were doing when it
662 // happened (navigating to a new page, closing a tab...) and if you can 670 // happened (navigating to a new page, closing a tab...) and if you can
663 // reproduce. 671 // reproduce.
664 NOTREACHED(); 672 NOTREACHED();
665 pending_render_view_host_ = NULL; 673 pending_render_view_host_ = NULL;
666 } 674 }
667 } 675 }
OLDNEW
« no previous file with comments | « chrome/browser/browsing_instance.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698