| 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;
|
| }
|
|
|
| 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));
|
| }
|
|
|