Index: chrome/browser/download/download_request_limiter.cc |
diff --git a/chrome/browser/download/download_request_limiter.cc b/chrome/browser/download/download_request_limiter.cc |
index 829e3538e23a2cab77b3bc27ac2297f1f9fdf0a3..631d89d67acbff22f4114d7de3da831d574bf523 100644 |
--- a/chrome/browser/download/download_request_limiter.cc |
+++ b/chrome/browser/download/download_request_limiter.cc |
@@ -37,9 +37,12 @@ DownloadRequestLimiter::TabDownloadState::TabDownloadState( |
download_count_(0), |
infobar_(NULL) { |
content::Source<NavigationController> notification_source(controller); |
+ content::Source<content::WebContents> web_contents_source( |
+ controller->GetWebContents()); |
registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_PENDING, |
notification_source); |
- registrar_.Add(this, content::NOTIFICATION_TAB_CLOSED, notification_source); |
+ registrar_.Add(this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED, |
+ web_contents_source); |
NavigationEntry* active_entry = originating_controller ? |
originating_controller->GetActiveEntry() : controller->GetActiveEntry(); |
@@ -101,12 +104,22 @@ void DownloadRequestLimiter::TabDownloadState::Observe( |
int type, |
const content::NotificationSource& source, |
const content::NotificationDetails& details) { |
- if ((type != content::NOTIFICATION_NAV_ENTRY_PENDING && |
- type != content::NOTIFICATION_TAB_CLOSED) || |
+ if (type != content::NOTIFICATION_NAV_ENTRY_PENDING && |
+ type != content::NOTIFICATION_WEB_CONTENTS_DESTROYED) { |
+ NOTREACHED(); |
+ return; |
+ } |
+ if (type == content::NOTIFICATION_NAV_ENTRY_PENDING && |
content::Source<NavigationController>(source).ptr() != controller_) { |
NOTREACHED(); |
return; |
} |
+ if (type == content::NOTIFICATION_WEB_CONTENTS_DESTROYED && |
+ &content::Source<content::WebContents>(source).ptr()-> |
+ GetController() != controller_) { |
+ NOTREACHED(); |
+ return; |
+ } |
switch (type) { |
case content::NOTIFICATION_NAV_ENTRY_PENDING: { |
@@ -138,7 +151,7 @@ void DownloadRequestLimiter::TabDownloadState::Observe( |
break; |
} |
- case content::NOTIFICATION_TAB_CLOSED: |
+ case content::NOTIFICATION_WEB_CONTENTS_DESTROYED: |
// Tab closed, no need to handle closing the dialog as it's owned by the |
// TabContents, break so that we get deleted after switch. |
break; |