summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/extensions')
-rw-r--r--chrome/browser/extensions/api/downloads/downloads_api.cc44
-rw-r--r--chrome/browser/extensions/api/downloads/downloads_api.h3
-rw-r--r--chrome/browser/extensions/webstore_installer.cc8
-rw-r--r--chrome/browser/extensions/webstore_installer.h2
4 files changed, 29 insertions, 28 deletions
diff --git a/chrome/browser/extensions/api/downloads/downloads_api.cc b/chrome/browser/extensions/api/downloads/downloads_api.cc
index bbfe75d..9ccd22c 100644
--- a/chrome/browser/extensions/api/downloads/downloads_api.cc
+++ b/chrome/browser/extensions/api/downloads/downloads_api.cc
@@ -139,7 +139,6 @@ const char* kStateStrings[] = {
kStateInProgress,
kStateComplete,
kStateInterrupted,
- NULL,
kStateInterrupted,
};
COMPILE_ASSERT(arraysize(kStateStrings) == DownloadItem::MAX_DOWNLOAD_STATE,
@@ -164,7 +163,6 @@ const char* StateString(DownloadItem::DownloadState state) {
DCHECK(state >= 0);
DCHECK(state < static_cast<DownloadItem::DownloadState>(
arraysize(kStateStrings)));
- DCHECK(state != DownloadItem::REMOVING);
return kStateStrings[state];
}
@@ -820,24 +818,31 @@ ExtensionDownloadsEventRouter::OnChangedStat::~OnChangedStat() {
UMA_HISTOGRAM_PERCENTAGE("Download.OnChanged", (fires * 100 / total));
}
-void ExtensionDownloadsEventRouter::OnDownloadUpdated(DownloadItem* item) {
+void ExtensionDownloadsEventRouter::OnDownloadDestroyed(DownloadItem* item) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
int download_id = item->GetId();
- if (item->GetState() == DownloadItem::REMOVING) {
- // The REMOVING state indicates that this item is being erased.
- // Let's unregister as an observer so that we don't see any more updates
- // from it, dispatch the onErased event, and remove its json and is
- // OnChangedStat from our maps.
- downloads_.erase(download_id);
- item->RemoveObserver(this);
- DispatchEvent(extensions::event_names::kOnDownloadErased,
- base::Value::CreateIntegerValue(download_id));
- delete item_jsons_[download_id];
- item_jsons_.erase(download_id);
- delete on_changed_stats_[download_id];
- on_changed_stats_.erase(download_id);
+ downloads_.erase(download_id);
+ item->RemoveObserver(this);
+ delete item_jsons_[download_id];
+ item_jsons_.erase(download_id);
+ delete on_changed_stats_[download_id];
+ on_changed_stats_.erase(download_id);
+}
+
+void ExtensionDownloadsEventRouter::OnDownloadRemoved(DownloadItem* item) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ if (!profile_)
return;
- }
+ int download_id = item->GetId();
+ DispatchEvent(extensions::event_names::kOnDownloadErased,
+ base::Value::CreateIntegerValue(download_id));
+}
+
+void ExtensionDownloadsEventRouter::OnDownloadUpdated(DownloadItem* item) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ if (!profile_)
+ return;
+ int download_id = item->GetId();
base::DictionaryValue* old_json = item_jsons_[download_id];
scoped_ptr<base::DictionaryValue> new_json(DownloadItemToJSON(item));
@@ -886,10 +891,6 @@ void ExtensionDownloadsEventRouter::OnDownloadUpdated(DownloadItem* item) {
item_jsons_[download_id]->Swap(new_json.get());
}
-void ExtensionDownloadsEventRouter::OnDownloadOpened(DownloadItem* item) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
-}
-
void ExtensionDownloadsEventRouter::OnDownloadCreated(
DownloadManager* manager, DownloadItem* download_item) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
@@ -913,6 +914,7 @@ void ExtensionDownloadsEventRouter::ManagerGoingDown(
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
manager_->RemoveObserver(this);
manager_ = NULL;
+ profile_ = NULL;
}
void ExtensionDownloadsEventRouter::DispatchEvent(
diff --git a/chrome/browser/extensions/api/downloads/downloads_api.h b/chrome/browser/extensions/api/downloads/downloads_api.h
index 9461dd4..178ff7a 100644
--- a/chrome/browser/extensions/api/downloads/downloads_api.h
+++ b/chrome/browser/extensions/api/downloads/downloads_api.h
@@ -226,7 +226,8 @@ class ExtensionDownloadsEventRouter : public content::DownloadManager::Observer,
// content::DownloadItem::Observer
virtual void OnDownloadUpdated(content::DownloadItem* download) OVERRIDE;
- virtual void OnDownloadOpened(content::DownloadItem* download) OVERRIDE;
+ virtual void OnDownloadRemoved(content::DownloadItem* download) OVERRIDE;
+ virtual void OnDownloadDestroyed(content::DownloadItem* download) OVERRIDE;
// Used for testing.
struct DownloadsNotificationSource {
diff --git a/chrome/browser/extensions/webstore_installer.cc b/chrome/browser/extensions/webstore_installer.cc
index 1dfb39f..13d9852 100644
--- a/chrome/browser/extensions/webstore_installer.cc
+++ b/chrome/browser/extensions/webstore_installer.cc
@@ -296,10 +296,6 @@ void WebstoreInstaller::OnDownloadUpdated(DownloadItem* download) {
case DownloadItem::INTERRUPTED:
ReportFailure(kDownloadInterruptedError);
break;
- case DownloadItem::REMOVING:
- download_item_->RemoveObserver(this);
- download_item_ = NULL;
- break;
case DownloadItem::COMPLETE:
// Wait for other notifications if the download is really an extension.
if (!download_crx_util::IsExtensionDownload(*download))
@@ -311,8 +307,10 @@ void WebstoreInstaller::OnDownloadUpdated(DownloadItem* download) {
}
}
-void WebstoreInstaller::OnDownloadOpened(DownloadItem* download) {
+void WebstoreInstaller::OnDownloadDestroyed(DownloadItem* download) {
CHECK_EQ(download_item_, download);
+ download_item_->RemoveObserver(this);
+ download_item_ = NULL;
}
void WebstoreInstaller::StartDownload(const FilePath& file) {
diff --git a/chrome/browser/extensions/webstore_installer.h b/chrome/browser/extensions/webstore_installer.h
index aaf95fb..8636c5b 100644
--- a/chrome/browser/extensions/webstore_installer.h
+++ b/chrome/browser/extensions/webstore_installer.h
@@ -137,7 +137,7 @@ class WebstoreInstaller :public content::NotificationObserver,
// DownloadItem::Observer implementation:
virtual void OnDownloadUpdated(content::DownloadItem* download) OVERRIDE;
- virtual void OnDownloadOpened(content::DownloadItem* download) OVERRIDE;
+ virtual void OnDownloadDestroyed(content::DownloadItem* download) OVERRIDE;
// Starts downloading the extension to |file_path|.
void StartDownload(const FilePath& file_path);