Commit 4cda792f authored by Shakti Sahu's avatar Shakti Sahu Committed by Commit Bot

Show .ogg files in audio section in download home

This CL adds special handling for .ogg files to be shown in the audio
section on download home.

Bug: 982090
Change-Id: I10c09f799ea196044f5dfcac31445d3076750dc6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1713870Reviewed-by: default avatarMin Qin <qinmin@chromium.org>
Reviewed-by: default avatarShakti Sahu <shaktisahu@chromium.org>
Commit-Queue: Shakti Sahu <shaktisahu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#680032}
parent ab2088c5
......@@ -109,6 +109,9 @@ public class DownloadFilter {
public static @Type int fromMimeType(String mimeType) {
if (TextUtils.isEmpty(mimeType)) return Type.OTHER;
Integer type = filterForSpecialMimeTypes(mimeType);
if (type != null) return type;
String[] pieces = mimeType.toLowerCase(Locale.getDefault()).split("/");
if (pieces.length != 2) return Type.OTHER;
......@@ -124,4 +127,9 @@ public class DownloadFilter {
return Type.OTHER;
}
}
private static Integer filterForSpecialMimeTypes(String mimeType) {
if (mimeType.equals("application/ogg")) return Type.AUDIO;
return null;
}
}
......@@ -41,8 +41,18 @@ const char kDownloadNamespacePrefix[] = "LEGACY_DOWNLOAD";
// The remaining time for a download item if it cannot be calculated.
constexpr int64_t kUnknownRemainingTime = -1;
base::Optional<OfflineItemFilter> FilterForSpecialMimeTypes(
const std::string& mime_type) {
if (base::EqualsCaseInsensitiveASCII(mime_type, "application/ogg"))
return OfflineItemFilter::FILTER_AUDIO;
return base::nullopt;
}
OfflineItemFilter MimeTypeToOfflineItemFilter(const std::string& mime_type) {
OfflineItemFilter filter = OfflineItemFilter::FILTER_OTHER;
auto filter = FilterForSpecialMimeTypes(mime_type);
if (filter.has_value())
return filter.value();
if (base::StartsWith(mime_type, "audio/", base::CompareCase::SENSITIVE)) {
filter = OfflineItemFilter::FILTER_AUDIO;
......@@ -59,7 +69,7 @@ OfflineItemFilter MimeTypeToOfflineItemFilter(const std::string& mime_type) {
filter = OfflineItemFilter::FILTER_OTHER;
}
return filter;
return filter.value();
}
bool IsInterruptedDownloadAutoResumable(download::DownloadItem* item) {
......
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