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

Unified Diff: chrome/renderer/extensions/chrome_v8_context_set.cc

Issue 11882035: Stop sending events and messages to content script contexts after their (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/renderer/extensions/chrome_v8_context_set.h ('k') | chrome/renderer/extensions/dispatcher.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/renderer/extensions/chrome_v8_context_set.cc
diff --git a/chrome/renderer/extensions/chrome_v8_context_set.cc b/chrome/renderer/extensions/chrome_v8_context_set.cc
index 4d8a222f6834fb8f839decc5167667c605bd70ed..3ec45261ce9c8642b46f0fa157c7eeabdc60026b 100644
--- a/chrome/renderer/extensions/chrome_v8_context_set.cc
+++ b/chrome/renderer/extensions/chrome_v8_context_set.cc
@@ -80,8 +80,7 @@ void ChromeV8ContextSet::Remove(ChromeV8Context* context) {
}
}
-ChromeV8ContextSet::ContextSet ChromeV8ContextSet::GetAll()
- const {
+ChromeV8ContextSet::ContextSet ChromeV8ContextSet::GetAll() const {
return contexts_;
}
@@ -151,4 +150,19 @@ void ChromeV8ContextSet::DispatchChromeHiddenMethod(
}
}
+void ChromeV8ContextSet::OnExtensionUnloaded(const std::string& extension_id) {
+ ContextSet contexts = GetAll();
+
+ // Clean up contexts belonging to the unloaded extension. This is done so
+ // that content scripts (which remain injected into the page) don't continue
+ // receiving events and sending messages.
+ for (ContextSet::iterator it = contexts.begin(); it != contexts.end();
+ ++it) {
+ if ((*it)->extension() && (*it)->extension()->id() == extension_id) {
+ (*it)->DispatchOnUnloadEvent();
+ Remove(*it);
+ }
+ }
+}
+
} // namespace extensions
« no previous file with comments | « chrome/renderer/extensions/chrome_v8_context_set.h ('k') | chrome/renderer/extensions/dispatcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698