summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--apps/app_window_contents.cc2
-rw-r--r--chrome/browser/extensions/extension_process_manager.cc37
-rw-r--r--chrome/browser/extensions/extension_process_manager.h4
-rw-r--r--chrome/browser/extensions/extension_service.h2
4 files changed, 37 insertions, 8 deletions
diff --git a/apps/app_window_contents.cc b/apps/app_window_contents.cc
index d163c2c..7b88e67 100644
--- a/apps/app_window_contents.cc
+++ b/apps/app_window_contents.cc
@@ -96,7 +96,7 @@ void AppWindowContents::NativeWindowChanged(
content::RenderViewHost* rvh = web_contents_->GetRenderViewHost();
rvh->Send(new ExtensionMsg_MessageInvoke(rvh->GetRoutingID(),
- host_->extension()->id(),
+ host_->extension_id(),
"app.window",
"updateAppWindowProperties",
args,
diff --git a/chrome/browser/extensions/extension_process_manager.cc b/chrome/browser/extensions/extension_process_manager.cc
index 1f8c9fb..1de7f35 100644
--- a/chrome/browser/extensions/extension_process_manager.cc
+++ b/chrome/browser/extensions/extension_process_manager.cc
@@ -66,6 +66,14 @@ std::string GetExtensionID(RenderViewHost* render_view_host) {
return render_view_host->GetSiteInstance()->GetSiteURL().host();
}
+void OnRenderViewHostUnregistered(Profile* profile,
+ RenderViewHost* render_view_host) {
+ content::NotificationService::current()->Notify(
+ chrome::NOTIFICATION_EXTENSION_VIEW_UNREGISTERED,
+ content::Source<Profile>(profile),
+ content::Details<RenderViewHost>(render_view_host));
+}
+
// Incognito profiles use this process manager. It is mostly a shim that decides
// whether to fall back on the original profile's ExtensionProcessManager based
// on whether a given extension uses "split" or "spanning" incognito behavior.
@@ -360,11 +368,7 @@ void ExtensionProcessManager::UnregisterRenderViewHost(
if (view == all_extension_views_.end())
return;
- content::NotificationService::current()->Notify(
- chrome::NOTIFICATION_EXTENSION_VIEW_UNREGISTERED,
- content::Source<Profile>(GetProfile()),
- content::Details<RenderViewHost>(render_view_host));
-
+ OnRenderViewHostUnregistered(GetProfile(), render_view_host);
extensions::ViewType view_type = view->second;
all_extension_views_.erase(view);
@@ -607,7 +611,7 @@ void ExtensionProcessManager::Observe(
break;
}
}
- background_page_data_.erase(extension->id());
+ UnregisterExtension(extension->id());
break;
}
@@ -773,6 +777,27 @@ void ExtensionProcessManager::CloseBackgroundHosts() {
}
}
+void ExtensionProcessManager::UnregisterExtension(
+ const std::string& extension_id) {
+ // The lazy_keepalive_count may be greater than zero at this point because
+ // RenderViewHosts are still alive. During extension reloading, they will
+ // decrement the lazy_keepalive_count to negative for the new extension
+ // instance when they are destroyed. Since we are erasing the background page
+ // data for the unloaded extension, unregister the RenderViewHosts too.
+ Profile* profile = GetProfile();
+ for (ExtensionRenderViews::iterator it = all_extension_views_.begin();
+ it != all_extension_views_.end(); ) {
+ if (GetExtensionID(it->first) == extension_id) {
+ OnRenderViewHostUnregistered(profile, it->first);
+ all_extension_views_.erase(it++);
+ } else {
+ ++it;
+ }
+ }
+
+ background_page_data_.erase(extension_id);
+}
+
void ExtensionProcessManager::ClearBackgroundPageData(
const std::string& extension_id) {
background_page_data_.erase(extension_id);
diff --git a/chrome/browser/extensions/extension_process_manager.h b/chrome/browser/extensions/extension_process_manager.h
index b234b3c..64d4d26 100644
--- a/chrome/browser/extensions/extension_process_manager.h
+++ b/chrome/browser/extensions/extension_process_manager.h
@@ -199,6 +199,10 @@ class ExtensionProcessManager : public content::NotificationObserver {
// extension. Does nothing if this is not an extension renderer.
void RegisterRenderViewHost(content::RenderViewHost* render_view_host);
+ // Unregister RenderViewHosts and clear background page data for an extension
+ // which has been unloaded.
+ void UnregisterExtension(const std::string& extension_id);
+
// Clears background page data for this extension.
void ClearBackgroundPageData(const std::string& extension_id);
diff --git a/chrome/browser/extensions/extension_service.h b/chrome/browser/extensions/extension_service.h
index 055663e..0db83a2 100644
--- a/chrome/browser/extensions/extension_service.h
+++ b/chrome/browser/extensions/extension_service.h
@@ -224,7 +224,7 @@ class ExtensionService
// Getter and setter for the flag that specifies whether the extension is
// being reloaded.
- bool IsBeingReloaded(const std::string& extension_name) const;
+ bool IsBeingReloaded(const std::string& extension_id) const;
void SetBeingReloaded(const std::string& extension_id, bool value);
// Getter and setter for the flag that specifies if the extension has used