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

Side by Side Diff: chrome/browser/chrome_content_browser_client.cc

Issue 9965091: Clean up RenderViewHostManager swapping logic. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix review comments. Created 8 years, 6 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
OLDNEW
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 "chrome/browser/chrome_content_browser_client.h" 5 #include "chrome/browser/chrome_content_browser_client.h"
6 6
7 #include <set> 7 #include <set>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 const Extension* extension = service->GetExtensionById(*iter, false); 260 const Extension* extension = service->GetExtensionById(*iter, false);
261 if (extension && 261 if (extension &&
262 extension->is_storage_isolated() && 262 extension->is_storage_isolated() &&
263 extension->url() == site_url) 263 extension->url() == site_url)
264 return true; 264 return true;
265 } 265 }
266 266
267 return false; 267 return false;
268 } 268 }
269 269
270 // If |url| has an extension or isolated app (not a hosted app) associated with
271 // it, return it. Otherwise return null.
272 const Extension* GetExtensionOrIsolatedApp(const GURL& url,
273 ExtensionService* service) {
274 const Extension* extension =
275 service->extensions()->GetExtensionOrAppByURL(ExtensionURLInfo(url));
276 // Ignore hosted apps that aren't isolated apps.
277 if (extension &&
278 extension->is_hosted_app() &&
279 !extension->is_storage_isolated())
280 extension = NULL;
281 return extension;
282 }
283
284
270 bool CertMatchesFilter(const net::X509Certificate& cert, 285 bool CertMatchesFilter(const net::X509Certificate& cert,
271 const base::DictionaryValue& filter) { 286 const base::DictionaryValue& filter) {
272 // TODO(markusheintz): This is the minimal required filter implementation. 287 // TODO(markusheintz): This is the minimal required filter implementation.
273 // Implement a better matcher. 288 // Implement a better matcher.
274 289
275 // An empty filter matches any client certificate since no requirements are 290 // An empty filter matches any client certificate since no requirements are
276 // specified at all. 291 // specified at all.
277 if (filter.empty()) 292 if (filter.empty())
278 return true; 293 return true;
279 294
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after
640 site_instance->GetId()); 655 site_instance->GetId());
641 BrowserThread::PostTask( 656 BrowserThread::PostTask(
642 BrowserThread::IO, FROM_HERE, 657 BrowserThread::IO, FROM_HERE,
643 base::Bind(&ExtensionInfoMap::UnregisterExtensionProcess, 658 base::Bind(&ExtensionInfoMap::UnregisterExtensionProcess,
644 ExtensionSystem::Get(profile)->info_map(), 659 ExtensionSystem::Get(profile)->info_map(),
645 extension->id(), 660 extension->id(),
646 site_instance->GetProcess()->GetID(), 661 site_instance->GetProcess()->GetID(),
647 site_instance->GetId())); 662 site_instance->GetId()));
648 } 663 }
649 664
650 bool ChromeContentBrowserClient::ShouldSwapProcessesForNavigation( 665 bool ChromeContentBrowserClient::ShouldSwapBrowsingInstanceForNavigation(
666 content::BrowserContext* browser_context,
651 const GURL& current_url, 667 const GURL& current_url,
652 const GURL& new_url) { 668 const GURL& new_url) {
653 if (current_url.is_empty()) { 669 Profile* profile = Profile::FromBrowserContext(browser_context);
654 // Always choose a new process when navigating to extension URLs. The 670 ExtensionService* service = profile->GetExtensionService();
655 // process grouping logic will combine all of a given extension's pages 671 if (!service)
656 // into the same process. 672 return false;
657 if (new_url.SchemeIs(chrome::kExtensionScheme))
658 return true;
659 673
660 return false; 674 // We must use a new BrowsingInstance (forcing a process swap and disabling
661 } 675 // scripting by existing tabs) if one of the URLs is an extension and the
662 676 // other is not the exact same extension.
663 // Also, we must switch if one is an extension and the other is not the exact 677 //
664 // same extension. 678 // We ignore hosted apps here so that other tabs in their BrowsingInstance can
665 if (current_url.SchemeIs(chrome::kExtensionScheme) || 679 // script them. Navigations to/from a hosted app will still trigger a
666 new_url.SchemeIs(chrome::kExtensionScheme)) { 680 // SiteInstance swap in RenderViewHostManager.
667 if (current_url.GetOrigin() != new_url.GetOrigin()) 681 //
668 return true; 682 // However, we do use a new BrowsingInstance for isolated apps, which should
669 } 683 // not be scriptable by other tabs.
670 684 const Extension* current_extension =
671 return false; 685 GetExtensionOrIsolatedApp(current_url, service);
686 const Extension* new_extension = GetExtensionOrIsolatedApp(new_url, service);
687 return current_extension != new_extension;
672 } 688 }
673 689
674 bool ChromeContentBrowserClient::ShouldSwapProcessesForRedirect( 690 bool ChromeContentBrowserClient::ShouldSwapProcessesForRedirect(
675 content::ResourceContext* resource_context, const GURL& current_url, 691 content::ResourceContext* resource_context, const GURL& current_url,
676 const GURL& new_url) { 692 const GURL& new_url) {
677 ProfileIOData* io_data = ProfileIOData::FromResourceContext(resource_context); 693 ProfileIOData* io_data = ProfileIOData::FromResourceContext(resource_context);
678 return extensions::CrossesExtensionProcessBoundary( 694 return extensions::CrossesExtensionProcessBoundary(
679 io_data->GetExtensionInfoMap()->extensions(), 695 io_data->GetExtensionInfoMap()->extensions(),
680 ExtensionURLInfo(current_url), ExtensionURLInfo(new_url), false); 696 ExtensionURLInfo(current_url), ExtensionURLInfo(new_url), false);
681 } 697 }
(...skipping 932 matching lines...) Expand 10 before | Expand all | Expand 10 after
1614 #if defined(USE_NSS) 1630 #if defined(USE_NSS)
1615 crypto::CryptoModuleBlockingPasswordDelegate* 1631 crypto::CryptoModuleBlockingPasswordDelegate*
1616 ChromeContentBrowserClient::GetCryptoPasswordDelegate( 1632 ChromeContentBrowserClient::GetCryptoPasswordDelegate(
1617 const GURL& url) { 1633 const GURL& url) {
1618 return browser::NewCryptoModuleBlockingDialogDelegate( 1634 return browser::NewCryptoModuleBlockingDialogDelegate(
1619 browser::kCryptoModulePasswordKeygen, url.host()); 1635 browser::kCryptoModulePasswordKeygen, url.host());
1620 } 1636 }
1621 #endif 1637 #endif
1622 1638
1623 } // namespace chrome 1639 } // namespace chrome
OLDNEW
« no previous file with comments | « chrome/browser/chrome_content_browser_client.h ('k') | content/browser/debugger/devtools_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698