Index: chrome/browser/extensions/extension_webnavigation_api.cc |
diff --git a/chrome/browser/extensions/extension_webnavigation_api.cc b/chrome/browser/extensions/extension_webnavigation_api.cc |
index 1736110a38e89df94646960413d950c6c0b12a88..3733ac9cdcb6871935020f853ef02961ff7c9999 100644 |
--- a/chrome/browser/extensions/extension_webnavigation_api.cc |
+++ b/chrome/browser/extensions/extension_webnavigation_api.cc |
@@ -344,6 +344,9 @@ void ExtensionWebNavigationEventRouter::Init() { |
registrar_.Add(this, |
content::NOTIFICATION_TAB_ADDED, |
NotificationService::AllSources()); |
+ registrar_.Add(this, |
+ content::NOTIFICATION_TAB_CONTENTS_DESTROYED, |
+ NotificationService::AllSources()); |
} |
} |
@@ -360,6 +363,10 @@ void ExtensionWebNavigationEventRouter::Observe( |
TabAdded(Details<TabContents>(details).ptr()); |
break; |
+ case content::NOTIFICATION_TAB_CONTENTS_DESTROYED: |
+ TabDestroyed(Source<TabContents>(source).ptr()); |
+ break; |
+ |
default: |
NOTREACHED(); |
} |
@@ -419,6 +426,17 @@ void ExtensionWebNavigationEventRouter::TabAdded(TabContents* tab_contents) { |
pending_tab_contents_.erase(iter); |
} |
+void ExtensionWebNavigationEventRouter::TabDestroyed( |
+ TabContents* tab_contents) { |
+ pending_tab_contents_.erase(tab_contents); |
+ for (std::map<TabContents*, PendingTabContents>::iterator i = |
+ pending_tab_contents_.begin(); i != pending_tab_contents_.end(); ) { |
+ if (i->second.source_tab_contents == tab_contents) |
+ pending_tab_contents_.erase(i++); |
+ else |
+ ++i; |
+ } |
+} |
// ExtensionWebNavigationTabObserver ------------------------------------------ |