Index: chrome/browser/ui/webui/inspect_ui.cc |
diff --git a/chrome/browser/ui/webui/inspect_ui.cc b/chrome/browser/ui/webui/inspect_ui.cc |
index 27d538325af0574a66bd53822f0d4c6b58493b57..a5a0194effaa718fadb03bbf3306c8fec74c74bf 100644 |
--- a/chrome/browser/ui/webui/inspect_ui.cc |
+++ b/chrome/browser/ui/webui/inspect_ui.cc |
@@ -397,8 +397,7 @@ InspectUI::InspectUI(content::WebUI* web_ui) |
} |
InspectUI::~InspectUI() { |
- observer_->InspectUIDestroyed(); |
- observer_ = NULL; |
+ StopListeningNotifications(); |
} |
void InspectUI::RefreshUI() { |
@@ -408,5 +407,19 @@ void InspectUI::RefreshUI() { |
void InspectUI::Observe(int type, |
const content::NotificationSource& source, |
const content::NotificationDetails& details) { |
+ if (source == content::Source<WebContents>(web_ui()->GetWebContents())) { |
+ if (type == content::NOTIFICATION_WEB_CONTENTS_DISCONNECTED) |
+ StopListeningNotifications(); |
+ return; |
+ } |
RefreshUI(); |
} |
+ |
+void InspectUI::StopListeningNotifications() |
+{ |
+ if (!observer_) |
+ return; |
+ observer_->InspectUIDestroyed(); |
+ observer_ = NULL; |
+ registrar_.RemoveAll(); |
+} |