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

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

Issue 10546029: Revert 139933 - Clean up RenderViewHostManager swapping logic. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: 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 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 const Extension* extension = service->GetExtensionById(*iter, false); 254 const Extension* extension = service->GetExtensionById(*iter, false);
255 if (extension && 255 if (extension &&
256 extension->is_storage_isolated() && 256 extension->is_storage_isolated() &&
257 extension->url() == site_url) 257 extension->url() == site_url)
258 return true; 258 return true;
259 } 259 }
260 260
261 return false; 261 return false;
262 } 262 }
263 263
264 // If |url| has an extension or isolated app (not a hosted app) associated with
265 // it, return it. Otherwise return null.
266 const Extension* GetExtensionOrIsolatedApp(const GURL& url,
267 ExtensionService* service) {
268 const Extension* extension =
269 service->extensions()->GetExtensionOrAppByURL(ExtensionURLInfo(url));
270 // Ignore hosted apps that aren't isolated apps.
271 if (extension &&
272 extension->is_hosted_app() &&
273 !extension->is_storage_isolated())
274 extension = NULL;
275 return extension;
276 }
277
278
279 bool CertMatchesFilter(const net::X509Certificate& cert, 264 bool CertMatchesFilter(const net::X509Certificate& cert,
280 const base::DictionaryValue& filter) { 265 const base::DictionaryValue& filter) {
281 // TODO(markusheintz): This is the minimal required filter implementation. 266 // TODO(markusheintz): This is the minimal required filter implementation.
282 // Implement a better matcher. 267 // Implement a better matcher.
283 268
284 // An empty filter matches any client certificate since no requirements are 269 // An empty filter matches any client certificate since no requirements are
285 // specified at all. 270 // specified at all.
286 if (filter.empty()) 271 if (filter.empty())
287 return true; 272 return true;
288 273
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
639 site_instance->GetId()); 624 site_instance->GetId());
640 BrowserThread::PostTask( 625 BrowserThread::PostTask(
641 BrowserThread::IO, FROM_HERE, 626 BrowserThread::IO, FROM_HERE,
642 base::Bind(&ExtensionInfoMap::UnregisterExtensionProcess, 627 base::Bind(&ExtensionInfoMap::UnregisterExtensionProcess,
643 ExtensionSystem::Get(profile)->info_map(), 628 ExtensionSystem::Get(profile)->info_map(),
644 extension->id(), 629 extension->id(),
645 site_instance->GetProcess()->GetID(), 630 site_instance->GetProcess()->GetID(),
646 site_instance->GetId())); 631 site_instance->GetId()));
647 } 632 }
648 633
649 bool ChromeContentBrowserClient::ShouldSwapBrowsingInstanceForNavigation( 634 bool ChromeContentBrowserClient::ShouldSwapProcessesForNavigation(
650 content::BrowserContext* browser_context,
651 const GURL& current_url, 635 const GURL& current_url,
652 const GURL& new_url) { 636 const GURL& new_url) {
653 Profile* profile = Profile::FromBrowserContext(browser_context); 637 if (current_url.is_empty()) {
654 ExtensionService* service = profile->GetExtensionService(); 638 // Always choose a new process when navigating to extension URLs. The
655 if (!service) 639 // process grouping logic will combine all of a given extension's pages
640 // into the same process.
641 if (new_url.SchemeIs(chrome::kExtensionScheme))
642 return true;
643
656 return false; 644 return false;
645 }
657 646
658 // We must use a new BrowsingInstance (forcing a process swap and disabling 647 // Also, we must switch if one is an extension and the other is not the exact
659 // scripting by existing tabs) if one of the URLs is an extension and the 648 // same extension.
660 // other is not the exact same extension. 649 if (current_url.SchemeIs(chrome::kExtensionScheme) ||
661 // 650 new_url.SchemeIs(chrome::kExtensionScheme)) {
662 // We ignore hosted apps here so that other tabs in their BrowsingInstance can 651 if (current_url.GetOrigin() != new_url.GetOrigin())
663 // script them. Navigations to/from a hosted app will still trigger a 652 return true;
664 // SiteInstance swap in RenderViewHostManager. 653 }
665 // 654
666 // However, we do use a new BrowsingInstance for isolated apps, which should 655 return false;
667 // not be scriptable by other tabs.
668 const Extension* current_extension =
669 GetExtensionOrIsolatedApp(current_url, service);
670 const Extension* new_extension = GetExtensionOrIsolatedApp(new_url, service);
671 return current_extension != new_extension;
672 } 656 }
673 657
674 bool ChromeContentBrowserClient::ShouldSwapProcessesForRedirect( 658 bool ChromeContentBrowserClient::ShouldSwapProcessesForRedirect(
675 content::ResourceContext* resource_context, const GURL& current_url, 659 content::ResourceContext* resource_context, const GURL& current_url,
676 const GURL& new_url) { 660 const GURL& new_url) {
677 ProfileIOData* io_data = ProfileIOData::FromResourceContext(resource_context); 661 ProfileIOData* io_data = ProfileIOData::FromResourceContext(resource_context);
678 return extensions::CrossesExtensionProcessBoundary( 662 return extensions::CrossesExtensionProcessBoundary(
679 io_data->GetExtensionInfoMap()->extensions(), 663 io_data->GetExtensionInfoMap()->extensions(),
680 ExtensionURLInfo(current_url), ExtensionURLInfo(new_url), false); 664 ExtensionURLInfo(current_url), ExtensionURLInfo(new_url), false);
681 } 665 }
(...skipping 937 matching lines...) Expand 10 before | Expand all | Expand 10 after
1619 #if defined(USE_NSS) 1603 #if defined(USE_NSS)
1620 crypto::CryptoModuleBlockingPasswordDelegate* 1604 crypto::CryptoModuleBlockingPasswordDelegate*
1621 ChromeContentBrowserClient::GetCryptoPasswordDelegate( 1605 ChromeContentBrowserClient::GetCryptoPasswordDelegate(
1622 const GURL& url) { 1606 const GURL& url) {
1623 return browser::NewCryptoModuleBlockingDialogDelegate( 1607 return browser::NewCryptoModuleBlockingDialogDelegate(
1624 browser::kCryptoModulePasswordKeygen, url.host()); 1608 browser::kCryptoModulePasswordKeygen, url.host());
1625 } 1609 }
1626 #endif 1610 #endif
1627 1611
1628 } // namespace chrome 1612 } // 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