Commit e4e00438 authored by Ewann's avatar Ewann Committed by Commit Bot

Adds .reality files QuickLook support

Bug: 1051609
Change-Id: Ife252c5ccad7457bd5944ddff93178ab046049b1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2228158Reviewed-by: default avatarEugene But <eugenebut@chromium.org>
Commit-Queue: Ewann Pellé <ewannpv@chromium.org>
Cr-Commit-Position: refs/heads/master@{#775004}
parent 6cc67b23
......@@ -31,6 +31,7 @@
namespace {
char kUrl[] = "https://test.test/";
char kUsdzFileName[] = "important_file.usdz";
char kRealityFileName[] = "important_file.reality";
// Substitutes real TabHelper for testing.
template <class TabHelper>
......@@ -177,6 +178,23 @@ TEST_F(BrowserDownloadServiceTest, UsdzExtension) {
1);
}
// Tests that BrowserDownloadService uses ARQuickLookTabHelper for .REALITY
// extension.
TEST_F(BrowserDownloadServiceTest, RealityExtension) {
ASSERT_TRUE(download_controller()->GetDelegate());
auto task = std::make_unique<web::FakeDownloadTask>(GURL(kUrl), "other");
task->SetSuggestedFilename(base::UTF8ToUTF16(kRealityFileName));
web::DownloadTask* task_ptr = task.get();
download_controller()->GetDelegate()->OnDownloadCreated(
download_controller(), &web_state_, std::move(task));
ASSERT_EQ(1U, ar_quick_look_tab_helper()->tasks().size());
EXPECT_EQ(task_ptr, ar_quick_look_tab_helper()->tasks()[0].get());
ASSERT_TRUE(download_manager_tab_helper()->tasks().empty());
histogram_tester_.ExpectUniqueSample(
"Download.IOSDownloadMimeType",
static_cast<base::HistogramBase::Sample>(DownloadMimeTypeResult::Other),
1);
}
// Tests that BrowserDownloadService uses ARQuickLookTabHelper for USDZ Mime
// type.
TEST_F(BrowserDownloadServiceTest, UsdzMimeType) {
......
......@@ -11,11 +11,14 @@ char kUsdzFileExtension[] = ".usdz";
char kUsdzMimeType[] = "model/vnd.usdz+zip";
char kLegacyUsdzMimeType[] = "model/usd";
char kLegacyPixarUsdzMimeType[] = "model/vnd.pixar.usd";
char krealityFileExtension[] = ".reality";
bool IsUsdzFileFormat(const std::string& mime_type,
const base::string16& suggested_filename) {
base::FilePath suggested_path =
base::FilePath(base::UTF16ToUTF8(suggested_filename));
return mime_type == kUsdzMimeType || mime_type == kLegacyUsdzMimeType ||
mime_type == kLegacyPixarUsdzMimeType ||
base::FilePath(base::UTF16ToUTF8(suggested_filename))
.MatchesExtension(kUsdzFileExtension);
suggested_path.MatchesExtension(kUsdzFileExtension) ||
suggested_path.MatchesExtension(krealityFileExtension);
}
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