Commit ebecf17e authored by Timothy Loh's avatar Timothy Loh Committed by Commit Bot

Don't surface download service API background downloads in extensions API

This CL prevents downloads by the internal download service from being
shown in the extensions API. The motivation comes from running the
Plugin VM installer while using ChromeVox -- the download progress is
reported to the user with a guid as a name, which is a bit confusing
and clashes with updates from the installer's progress bar.

In general, it seems like these internal downloads shouldn't be exposed
to the extensions API. chrome://download-internals uses a different API
to access this data so it will continue to display this data.

Bug: 1021414
Change-Id: Idabbd4548a672fe9b773289a7809c32013dda56c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2143186Reviewed-by: default avatarDavid Trainor <dtrainor@chromium.org>
Commit-Queue: Timothy Loh <timloh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#759960}
parent 4c2d2c7d
......@@ -443,8 +443,10 @@ void InitSortTypeMap(SortTypeMap* sorter_types_ptr) {
*sorter_types_ptr = SortTypeMap(std::move(v));
}
bool IsNotTemporaryDownloadFilter(const DownloadItem& download_item) {
return !download_item.IsTemporary();
bool ShouldExport(const DownloadItem& download_item) {
return !download_item.IsTemporary() &&
download_item.GetDownloadSource() !=
download::DownloadSource::INTERNAL_API;
}
// Set |manager| to the on-record DownloadManager, and |incognito_manager| to
......@@ -617,7 +619,7 @@ void RunDownloadQuery(
if (incognito_manager)
incognito_manager->GetAllDownloads(&all_items);
}
query_out.AddFilter(base::Bind(&IsNotTemporaryDownloadFilter));
query_out.AddFilter(base::Bind(&ShouldExport));
query_out.Search(all_items.begin(), all_items.end(), results);
}
......@@ -1863,7 +1865,7 @@ void ExtensionDownloadsEventRouter::OnListenerRemoved(
void ExtensionDownloadsEventRouter::OnDownloadCreated(
DownloadManager* manager, DownloadItem* download_item) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
if (download_item->IsTemporary())
if (!ShouldExport(*download_item))
return;
EventRouter* router = EventRouter::Get(profile_);
......@@ -1901,7 +1903,7 @@ void ExtensionDownloadsEventRouter::OnDownloadUpdated(
EventRouter* router = EventRouter::Get(profile_);
ExtensionDownloadsEventRouterData* data =
ExtensionDownloadsEventRouterData::Get(download_item);
if (download_item->IsTemporary() ||
if (!ShouldExport(*download_item) ||
!router->HasEventListener(downloads::OnChanged::kEventName)) {
return;
}
......@@ -1986,7 +1988,7 @@ void ExtensionDownloadsEventRouter::OnDownloadUpdated(
void ExtensionDownloadsEventRouter::OnDownloadRemoved(
DownloadManager* manager, DownloadItem* download_item) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
if (download_item->IsTemporary())
if (!ShouldExport(*download_item))
return;
DispatchEvent(
events::DOWNLOADS_ON_ERASED, downloads::OnErased::kEventName, true,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment