summaryrefslogtreecommitdiffstats
path: root/content
diff options
context:
space:
mode:
authorcreis@chromium.org <creis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-25 03:47:11 +0000
committercreis@chromium.org <creis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-25 03:47:11 +0000
commitd292d8a82d12129d1e061f469b8edee035be8b97 (patch)
treeaa0e706189af2477088e0211e1d8c7dd3844750c /content
parent9dade396bc7bcd363ba481fb2c328c93f226858d (diff)
downloadchromium_src-d292d8a82d12129d1e061f469b8edee035be8b97.zip
chromium_src-d292d8a82d12129d1e061f469b8edee035be8b97.tar.gz
chromium_src-d292d8a82d12129d1e061f469b8edee035be8b97.tar.bz2
Swap processes on reload if a hosted app has been installed/uninstalled.
Also ensure the task manager only shows "App" if the process is an app process. BUG=80621 TEST=AppApiTest.ReloadIntoAppProcess TEST=TaskManagerBrowserTest.NoticeHostedAppTabs Review URL: http://codereview.chromium.org/7063015 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@86566 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
-rw-r--r--content/browser/site_instance.cc12
-rw-r--r--content/browser/site_instance.h5
-rw-r--r--content/browser/tab_contents/navigation_entry.h2
-rw-r--r--content/browser/tab_contents/render_view_host_manager.cc26
4 files changed, 36 insertions, 9 deletions
diff --git a/content/browser/site_instance.cc b/content/browser/site_instance.cc
index f96e3b2..610de02 100644
--- a/content/browser/site_instance.cc
+++ b/content/browser/site_instance.cc
@@ -116,6 +116,18 @@ SiteInstance* SiteInstance::GetRelatedSiteInstance(const GURL& url) {
return browsing_instance_->GetSiteInstanceForURL(url);
}
+bool SiteInstance::HasWrongProcessForURL(const GURL& url) const {
+ // Having no process isn't a problem, since we'll assign it correctly.
+ if (!HasProcess())
+ return false;
+
+ // If the effective URL is an extension (e.g., for hosted apps) but the
+ // process is not (or vice versa), make sure we notice and fix it.
+ GURL effective_url = GetEffectiveURL(browsing_instance_->profile(), url);
+ return effective_url.SchemeIs(chrome::kExtensionScheme) !=
+ process_->is_extension_process();
+}
+
/*static*/
SiteInstance* SiteInstance::CreateSiteInstance(Profile* profile) {
return new SiteInstance(new BrowsingInstance(profile));
diff --git a/content/browser/site_instance.h b/content/browser/site_instance.h
index 3b6346d..ebe1b3e 100644
--- a/content/browser/site_instance.h
+++ b/content/browser/site_instance.h
@@ -105,6 +105,11 @@ class SiteInstance : public base::RefCounted<SiteInstance>,
// Darin suggests.
SiteInstance* GetRelatedSiteInstance(const GURL& url);
+ // Returns whether this SiteInstance has a process that is the wrong type for
+ // the given URL. If so, the browser should force a process swap when
+ // navigating to the URL.
+ bool HasWrongProcessForURL(const GURL& url) const;
+
// Factory method to create a new SiteInstance. This will create a new
// new BrowsingInstance, so it should only be used when creating a new tab
// from scratch (or similar circumstances). Callers should ensure that
diff --git a/content/browser/tab_contents/navigation_entry.h b/content/browser/tab_contents/navigation_entry.h
index 671cc5b..4c118b3 100644
--- a/content/browser/tab_contents/navigation_entry.h
+++ b/content/browser/tab_contents/navigation_entry.h
@@ -206,7 +206,7 @@ class NavigationEntry {
//
// Note that the SiteInstance should usually not be changed after it is set,
// but this may happen if the NavigationEntry was cloned and needs to use a
- // different SiteInstance.
+ // different SiteInstance, or if a hosted app is installed or uninstalled.
void set_site_instance(SiteInstance* site_instance);
SiteInstance* site_instance() const {
return site_instance_;
diff --git a/content/browser/tab_contents/render_view_host_manager.cc b/content/browser/tab_contents/render_view_host_manager.cc
index accb225..d827a087 100644
--- a/content/browser/tab_contents/render_view_host_manager.cc
+++ b/content/browser/tab_contents/render_view_host_manager.cc
@@ -393,9 +393,19 @@ SiteInstance* RenderViewHostManager::GetSiteInstanceForEntry(
SiteInstance* curr_instance) {
// NOTE: This is only called when ShouldTransitionCrossSite is true.
- // If the entry has an instance already, we should use it.
- if (entry.site_instance())
- return entry.site_instance();
+ const GURL& dest_url = entry.url();
+ NavigationController& controller = delegate_->GetControllerForRenderManager();
+ Profile* profile = controller.profile();
+
+ // If the entry has an instance already we should use it, unless the URL
+ // is part of an app that has been installed or uninstalled since the last
+ // visit.
+ if (entry.site_instance()) {
+ if (entry.site_instance()->HasWrongProcessForURL(dest_url))
+ return curr_instance->GetRelatedSiteInstance(dest_url);
+ else
+ return entry.site_instance();
+ }
// (UGLY) HEURISTIC, process-per-site only:
//
@@ -411,10 +421,6 @@ SiteInstance* RenderViewHostManager::GetSiteInstanceForEntry(
entry.transition_type() == PageTransition::GENERATED)
return curr_instance;
- const GURL& dest_url = entry.url();
- NavigationController& controller = delegate_->GetControllerForRenderManager();
- Profile* profile = controller.profile();
-
// If we haven't used our SiteInstance (and thus RVH) yet, then we can use it
// for this entry. We won't commit the SiteInstance to this site until the
// navigation commits (in DidNavigate), unless the navigation entry was
@@ -480,7 +486,11 @@ SiteInstance* RenderViewHostManager::GetSiteInstanceForEntry(
const GURL& current_url = (curr_entry) ? curr_entry->url() :
curr_instance->site();
- if (SiteInstance::IsSameWebSite(profile, current_url, dest_url)) {
+ // Use the current SiteInstance for same site navigations, as long as the
+ // process type is correct. (The URL may have been installed as an app since
+ // the last time we visited it.)
+ if (SiteInstance::IsSameWebSite(profile, current_url, dest_url) &&
+ !curr_instance->HasWrongProcessForURL(dest_url)) {
return curr_instance;
} else if (ShouldSwapProcessesForNavigation(curr_entry, &entry)) {
// When we're swapping, we need to force the site instance AND browsing