diff --git a/toolkit/components/downloads/nsDownloadManager.cpp b/toolkit/components/downloads/nsDownloadManager.cpp index c985ab9387b1..46a55a83c3e7 100644 --- a/toolkit/components/downloads/nsDownloadManager.cpp +++ b/toolkit/components/downloads/nsDownloadManager.cpp @@ -2765,7 +2765,7 @@ nsDownload::SetState(DownloadState aState) file && NS_SUCCEEDED(file->GetPath(path))) { -#if defined(XP_WIN) || defined(MOZ_WIDGET_GTK) +#if defined(XP_WIN) || defined(MOZ_WIDGET_GTK) || defined(MOZ_WIDGET_ANDROID) // On Windows and Gtk, add the download to the system's "recent documents" // list, with a pref to disable. { @@ -2785,6 +2785,15 @@ nsDownload::SetState(DownloadState aState) gtk_recent_manager_add_item(manager, uri); g_free(uri); } +#elif defined(MOZ_WIDGET_ANDROID) + nsCOMPtr mimeInfo; + nsAutoCString contentType; + GetMIMEInfo(getter_AddRefs(mimeInfo)); + + if (mimeInfo) + mimeInfo->GetMIMEType(contentType); + + mozilla::widget::android::GeckoAppShell::ScanMedia(path, NS_ConvertUTF8toUTF16(contentType)); #endif } #ifdef MOZ_ENABLE_GIO @@ -2813,16 +2822,6 @@ nsDownload::SetState(DownloadState aState) ::CFNotificationCenterPostNotification(center, CFSTR("com.apple.DownloadFileFinished"), observedObject, nullptr, TRUE); ::CFRelease(observedObject); -#endif -#ifdef MOZ_WIDGET_ANDROID - nsCOMPtr mimeInfo; - nsAutoCString contentType; - GetMIMEInfo(getter_AddRefs(mimeInfo)); - - if (mimeInfo) - mimeInfo->GetMIMEType(contentType); - - mozilla::widget::android::GeckoAppShell::ScanMedia(path, NS_ConvertUTF8toUTF16(contentType)); #endif } diff --git a/toolkit/components/jsdownloads/src/DownloadPlatform.cpp b/toolkit/components/jsdownloads/src/DownloadPlatform.cpp index cc66fc452691..88c949636367 100644 --- a/toolkit/components/jsdownloads/src/DownloadPlatform.cpp +++ b/toolkit/components/jsdownloads/src/DownloadPlatform.cpp @@ -72,7 +72,7 @@ nsresult DownloadPlatform::DownloadDone(nsIURI* aSource, nsIFile* aTarget, #if defined(XP_WIN) || defined(XP_MACOSX) || defined(MOZ_WIDGET_ANDROID) || defined(MOZ_WIDGET_GTK) nsAutoString path; if (aTarget && NS_SUCCEEDED(aTarget->GetPath(path))) { -#if defined(XP_WIN) || defined(MOZ_WIDGET_GTK) +#if defined(XP_WIN) || defined(MOZ_WIDGET_GTK) || defined(MOZ_WIDGET_ANDROID) // On Windows and Gtk, add the download to the system's "recent documents" // list, with a pref to disable. { @@ -89,6 +89,8 @@ nsresult DownloadPlatform::DownloadDone(nsIURI* aSource, nsIFile* aTarget, gtk_recent_manager_add_item(manager, uri); g_free(uri); } +#elif MOZ_WIDGET_ANDROID + mozilla::widget::android::GeckoAppShell::ScanMedia(path, NS_ConvertUTF8toUTF16(aContentType)); #endif } #ifdef MOZ_ENABLE_GIO @@ -117,11 +119,6 @@ nsresult DownloadPlatform::DownloadDone(nsIURI* aSource, nsIFile* aTarget, ::CFNotificationCenterPostNotification(center, CFSTR("com.apple.DownloadFileFinished"), observedObject, nullptr, TRUE); ::CFRelease(observedObject); -#endif -#ifdef MOZ_WIDGET_ANDROID - if (!aContentType.IsEmpty()) { - mozilla::widget::android::GeckoAppShell::ScanMedia(path, NS_ConvertUTF8toUTF16(aContentType)); - } #endif }