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

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

Issue 10690048: Clean up RenderViewHostManager swapping logic. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix merge conflict Created 8 years, 1 month 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 324 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 const Extension* extension = service->GetExtensionById(*iter, false); 335 const Extension* extension = service->GetExtensionById(*iter, false);
336 if (extension && extension->is_storage_isolated()) 336 if (extension && extension->is_storage_isolated())
337 return PRIV_ISOLATED; 337 return PRIV_ISOLATED;
338 if (extension && extension->is_hosted_app()) 338 if (extension && extension->is_hosted_app())
339 return PRIV_HOSTED; 339 return PRIV_HOSTED;
340 } 340 }
341 341
342 return PRIV_EXTENSION; 342 return PRIV_EXTENSION;
343 } 343 }
344 344
345 // If |url| has an extension or isolated app (not a hosted app) associated with
346 // it, return it. Otherwise return null.
347 const Extension* GetExtensionOrIsolatedApp(const GURL& url,
348 ExtensionService* service) {
349 const Extension* extension =
350 service->extensions()->GetExtensionOrAppByURL(ExtensionURLInfo(url));
351 // Ignore hosted apps that aren't isolated apps.
352 if (extension &&
353 extension->is_hosted_app() &&
354 !extension->is_storage_isolated())
355 extension = NULL;
356 return extension;
357 }
358
345 bool CertMatchesFilter(const net::X509Certificate& cert, 359 bool CertMatchesFilter(const net::X509Certificate& cert,
346 const base::DictionaryValue& filter) { 360 const base::DictionaryValue& filter) {
347 // TODO(markusheintz): This is the minimal required filter implementation. 361 // TODO(markusheintz): This is the minimal required filter implementation.
348 // Implement a better matcher. 362 // Implement a better matcher.
349 363
350 // An empty filter matches any client certificate since no requirements are 364 // An empty filter matches any client certificate since no requirements are
351 // specified at all. 365 // specified at all.
352 if (filter.empty()) 366 if (filter.empty())
353 return true; 367 return true;
354 368
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after
817 site_instance->GetId()); 831 site_instance->GetId());
818 BrowserThread::PostTask( 832 BrowserThread::PostTask(
819 BrowserThread::IO, FROM_HERE, 833 BrowserThread::IO, FROM_HERE,
820 base::Bind(&ExtensionInfoMap::UnregisterExtensionProcess, 834 base::Bind(&ExtensionInfoMap::UnregisterExtensionProcess,
821 extensions::ExtensionSystem::Get(profile)->info_map(), 835 extensions::ExtensionSystem::Get(profile)->info_map(),
822 extension->id(), 836 extension->id(),
823 site_instance->GetProcess()->GetID(), 837 site_instance->GetProcess()->GetID(),
824 site_instance->GetId())); 838 site_instance->GetId()));
825 } 839 }
826 840
827 bool ChromeContentBrowserClient::ShouldSwapProcessesForNavigation( 841 bool ChromeContentBrowserClient::ShouldSwapBrowsingInstanceForNavigation(
842 content::BrowserContext* browser_context,
828 const GURL& current_url, 843 const GURL& current_url,
829 const GURL& new_url) { 844 const GURL& new_url) {
830 if (current_url.is_empty()) { 845 Profile* profile = Profile::FromBrowserContext(browser_context);
831 // Always choose a new process when navigating to extension URLs. The 846 ExtensionService* service = profile->GetExtensionService();
832 // process grouping logic will combine all of a given extension's pages 847 if (!service)
833 // into the same process. 848 return false;
834 if (new_url.SchemeIs(extensions::kExtensionScheme))
835 return true;
836 849
837 return false; 850 // We must use a new BrowsingInstance (forcing a process swap and disabling
838 } 851 // scripting by existing tabs) if one of the URLs is an extension and the
839 852 // other is not the exact same extension.
840 // Also, we must switch if one is an extension and the other is not the exact 853 //
841 // same extension. 854 // We ignore hosted apps here so that other tabs in their BrowsingInstance can
842 if (current_url.SchemeIs(extensions::kExtensionScheme) || 855 // script them. Navigations to/from a hosted app will still trigger a
843 new_url.SchemeIs(extensions::kExtensionScheme)) { 856 // SiteInstance swap in RenderViewHostManager.
844 if (current_url.GetOrigin() != new_url.GetOrigin()) 857 //
845 return true; 858 // However, we do use a new BrowsingInstance for isolated apps, which should
846 } 859 // not be scriptable by other tabs.
847 860 const Extension* current_extension =
848 return false; 861 GetExtensionOrIsolatedApp(current_url, service);
862 const Extension* new_extension = GetExtensionOrIsolatedApp(new_url, service);
863 return current_extension != new_extension;
849 } 864 }
850 865
851 bool ChromeContentBrowserClient::ShouldSwapProcessesForRedirect( 866 bool ChromeContentBrowserClient::ShouldSwapProcessesForRedirect(
852 content::ResourceContext* resource_context, const GURL& current_url, 867 content::ResourceContext* resource_context, const GURL& current_url,
853 const GURL& new_url) { 868 const GURL& new_url) {
854 ProfileIOData* io_data = ProfileIOData::FromResourceContext(resource_context); 869 ProfileIOData* io_data = ProfileIOData::FromResourceContext(resource_context);
855 return extensions::CrossesExtensionProcessBoundary( 870 return extensions::CrossesExtensionProcessBoundary(
856 io_data->GetExtensionInfoMap()->extensions(), 871 io_data->GetExtensionInfoMap()->extensions(),
857 ExtensionURLInfo(current_url), ExtensionURLInfo(new_url), false); 872 ExtensionURLInfo(current_url), ExtensionURLInfo(new_url), false);
858 } 873 }
(...skipping 1054 matching lines...) Expand 10 before | Expand all | Expand 10 after
1913 io_thread_application_locale_ = locale; 1928 io_thread_application_locale_ = locale;
1914 } 1929 }
1915 1930
1916 void ChromeContentBrowserClient::SetApplicationLocaleOnIOThread( 1931 void ChromeContentBrowserClient::SetApplicationLocaleOnIOThread(
1917 const std::string& locale) { 1932 const std::string& locale) {
1918 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 1933 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
1919 io_thread_application_locale_ = locale; 1934 io_thread_application_locale_ = locale;
1920 } 1935 }
1921 1936
1922 } // namespace chrome 1937 } // namespace chrome
OLDNEW
« no previous file with comments | « chrome/browser/chrome_content_browser_client.h ('k') | chrome/browser/extensions/api/management/management_api_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698