Commit 5477350e authored by Eugene But's avatar Eugene But Committed by Commit Bot

Add more values to DownloadMimeTypeResult UMA enum.

.exe and .apk could be dangerous downloads and it would be useful to
know if Chrome should use Safe Browsing for blacklisting these
downloads.

.zip is probably the most common downloaded format, so logging it can
make "other" bucket smaller.

Bug: None
Cq-Include-Trybots: luci.chromium.try:ios-simulator-cronet;luci.chromium.try:ios-simulator-full-configs
Change-Id: Icbd76954c57756169ef942cfddfce29d8a34861c
Reviewed-on: https://chromium-review.googlesource.com/1227132
Commit-Queue: Eugene But <eugenebut@chromium.org>
Reviewed-by: default avatarMark Pearson <mpearson@chromium.org>
Reviewed-by: default avatarSylvain Defresne <sdefresne@chromium.org>
Cr-Commit-Position: refs/heads/master@{#592086}
parent c49c9875
...@@ -28,7 +28,13 @@ enum class DownloadMimeTypeResult { ...@@ -28,7 +28,13 @@ enum class DownloadMimeTypeResult {
PkPass = 1, PkPass = 1,
// application/x-apple-aspen-config MIME type. // application/x-apple-aspen-config MIME type.
iOSMobileConfig = 2, iOSMobileConfig = 2,
kMaxValue = iOSMobileConfig, // application/zip MIME type.
ZipArchive = 3,
// application/x-msdownload MIME type (.exe file).
MicrosoftApplication = 4,
// application/vnd.android.package-archive MIME type (.apk file).
AndroidPackageArchive = 5,
kMaxValue = AndroidPackageArchive,
}; };
// Keyed Service which acts as web::DownloadController delegate and routes // Keyed Service which acts as web::DownloadController delegate and routes
......
...@@ -21,9 +21,18 @@ DownloadMimeTypeResult GetUmaResult(const std::string& mime_type) { ...@@ -21,9 +21,18 @@ DownloadMimeTypeResult GetUmaResult(const std::string& mime_type) {
if (mime_type == kPkPassMimeType) if (mime_type == kPkPassMimeType)
return DownloadMimeTypeResult::PkPass; return DownloadMimeTypeResult::PkPass;
if (mime_type == "application/zip")
return DownloadMimeTypeResult::ZipArchive;
if (mime_type == "application/x-apple-aspen-config") if (mime_type == "application/x-apple-aspen-config")
return DownloadMimeTypeResult::iOSMobileConfig; return DownloadMimeTypeResult::iOSMobileConfig;
if (mime_type == "application/x-msdownload")
return DownloadMimeTypeResult::MicrosoftApplication;
if (mime_type == "application/vnd.android.package-archive")
return DownloadMimeTypeResult::AndroidPackageArchive;
return DownloadMimeTypeResult::Other; return DownloadMimeTypeResult::Other;
} }
} // namespace } // namespace
......
...@@ -157,3 +157,59 @@ TEST_F(BrowserDownloadServiceTest, iOSMobileConfigMimeType) { ...@@ -157,3 +157,59 @@ TEST_F(BrowserDownloadServiceTest, iOSMobileConfigMimeType) {
DownloadMimeTypeResult::iOSMobileConfig), DownloadMimeTypeResult::iOSMobileConfig),
1); 1);
} }
// Tests that BrowserDownloadService uses DownloadManagerTabHelper for Zip Mime
// Type.
TEST_F(BrowserDownloadServiceTest, ZipArchiveMimeType) {
ASSERT_TRUE(download_controller()->GetDelegate());
auto task =
std::make_unique<web::FakeDownloadTask>(GURL(kUrl), "application/zip");
web::DownloadTask* task_ptr = task.get();
download_controller()->GetDelegate()->OnDownloadCreated(
download_controller(), &web_state_, std::move(task));
ASSERT_TRUE(pass_kit_tab_helper()->tasks().empty());
ASSERT_EQ(1U, download_manager_tab_helper()->tasks().size());
EXPECT_EQ(task_ptr, download_manager_tab_helper()->tasks()[0].get());
histogram_tester_.ExpectUniqueSample("Download.IOSDownloadMimeType",
static_cast<base::HistogramBase::Sample>(
DownloadMimeTypeResult::ZipArchive),
1);
}
// Tests that BrowserDownloadService uses DownloadManagerTabHelper for .exe Mime
// Type.
TEST_F(BrowserDownloadServiceTest, ExeMimeType) {
ASSERT_TRUE(download_controller()->GetDelegate());
auto task = std::make_unique<web::FakeDownloadTask>(
GURL(kUrl), "application/x-msdownload");
web::DownloadTask* task_ptr = task.get();
download_controller()->GetDelegate()->OnDownloadCreated(
download_controller(), &web_state_, std::move(task));
ASSERT_TRUE(pass_kit_tab_helper()->tasks().empty());
ASSERT_EQ(1U, download_manager_tab_helper()->tasks().size());
EXPECT_EQ(task_ptr, download_manager_tab_helper()->tasks()[0].get());
histogram_tester_.ExpectUniqueSample(
"Download.IOSDownloadMimeType",
static_cast<base::HistogramBase::Sample>(
DownloadMimeTypeResult::MicrosoftApplication),
1);
}
// Tests that BrowserDownloadService uses DownloadManagerTabHelper for .apk Mime
// Type.
TEST_F(BrowserDownloadServiceTest, ApkMimeType) {
ASSERT_TRUE(download_controller()->GetDelegate());
auto task = std::make_unique<web::FakeDownloadTask>(
GURL(kUrl), "application/vnd.android.package-archive");
web::DownloadTask* task_ptr = task.get();
download_controller()->GetDelegate()->OnDownloadCreated(
download_controller(), &web_state_, std::move(task));
ASSERT_TRUE(pass_kit_tab_helper()->tasks().empty());
ASSERT_EQ(1U, download_manager_tab_helper()->tasks().size());
EXPECT_EQ(task_ptr, download_manager_tab_helper()->tasks()[0].get());
histogram_tester_.ExpectUniqueSample(
"Download.IOSDownloadMimeType",
static_cast<base::HistogramBase::Sample>(
DownloadMimeTypeResult::AndroidPackageArchive),
1);
}
...@@ -11997,6 +11997,13 @@ Called by update_net_error_codes.py.--> ...@@ -11997,6 +11997,13 @@ Called by update_net_error_codes.py.-->
<int value="2" label="iOS mobile config"> <int value="2" label="iOS mobile config">
application/x-apple-aspen-config MIME type. application/x-apple-aspen-config MIME type.
</int> </int>
<int value="3" label="Zip Archive">application/zip MIME type.</int>
<int value="4" label="Microsoft Application (.exe file)">
application/x-msdownload MIME type.
</int>
<int value="5" label="Android Package Archive (.apk file)">
application/vnd.android.package-archive MIME type.
</int>
</enum> </enum>
<enum name="DownloadNotificationForegroundLifecycle"> <enum name="DownloadNotificationForegroundLifecycle">
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