Index: chrome/browser/download/download_extension_api.cc |
diff --git a/chrome/browser/download/download_extension_api.cc b/chrome/browser/download/download_extension_api.cc |
index b19c22c19b7bcf3c66c1b091a9f7e1de9c81d6bc..825a2f200487744fc6a122a42012da9678a17ded 100644 |
--- a/chrome/browser/download/download_extension_api.cc |
+++ b/chrome/browser/download/download_extension_api.cc |
@@ -37,9 +37,11 @@ |
#include "chrome/browser/renderer_host/chrome_render_message_filter.h" |
#include "chrome/browser/ui/browser_list.h" |
#include "chrome/browser/ui/webui/web_ui_util.h" |
+#include "chrome/common/chrome_notification_types.h" |
#include "content/public/browser/download_interrupt_reasons.h" |
#include "content/public/browser/download_item.h" |
#include "content/public/browser/download_save_info.h" |
+#include "content/public/browser/notification_service.h" |
#include "content/public/browser/render_process_host.h" |
#include "content/public/browser/render_view_host.h" |
#include "content/public/browser/resource_dispatcher_host.h" |
@@ -982,6 +984,8 @@ ExtensionDownloadsEventRouter::OnChangedStat::~OnChangedStat() { |
} |
void ExtensionDownloadsEventRouter::OnDownloadUpdated(DownloadItem* item) { |
+ if (!profile_) |
+ return; |
int download_id = item->GetId(); |
if (item->GetState() == DownloadItem::REMOVING) { |
// The REMOVING state indicates that this item is being erased. |
@@ -1106,10 +1110,13 @@ void ExtensionDownloadsEventRouter::ManagerGoingDown( |
DownloadManager* manager) { |
manager_->RemoveObserver(this); |
manager_ = NULL; |
+ profile_ = NULL; |
Randy Smith (Not in Mondays)
2012/06/18 18:42:58
So this means that you'll not handle the notificat
benjhayden
2012/06/19 15:01:59
When I made ChromeDownloadManagerDelegate own Exte
Randy Smith (Not in Mondays)
2012/06/19 19:23:23
Sure, that's a problem, but you've chosen one part
benjhayden
2012/06/21 17:50:48
An extension that wants to keep track of the state
|
} |
void ExtensionDownloadsEventRouter::DispatchEvent( |
const char* event_name, base::Value* arg) { |
+ if (!profile_) |
+ return; |
ListValue args; |
args.Append(arg); |
std::string json_args; |
@@ -1119,4 +1126,11 @@ void ExtensionDownloadsEventRouter::DispatchEvent( |
json_args, |
profile_, |
GURL()); |
+ DownloadsNotificationSource notification_source; |
+ notification_source.event_name = event_name; |
+ notification_source.profile = profile_; |
+ content::NotificationService::current()->Notify( |
+ chrome::NOTIFICATION_EXTENSION_DOWNLOADS_EVENT, |
+ content::Source<DownloadsNotificationSource>(¬ification_source), |
+ content::Details<std::string>(&json_args)); |
Randy Smith (Not in Mondays)
2012/06/18 18:42:58
This is two different mechanisms for notifying abo
benjhayden
2012/06/19 15:01:59
EDER is-a DM::O already. How would making it a DM:
Randy Smith (Not in Mondays)
2012/06/19 19:23:23
Sorry, this is my cluelessness; I didn't notice th
|
} |