diff --git a/chrome/browser/ash/file_manager/guest_os_file_tasks.cc b/chrome/browser/ash/file_manager/guest_os_file_tasks.cc index fefdca4ca19bf5..7db251a1204773 100644 --- a/chrome/browser/ash/file_manager/guest_os_file_tasks.cc +++ b/chrome/browser/ash/file_manager/guest_os_file_tasks.cc @@ -112,8 +112,8 @@ bool HasSupportedExtension(const std::set& supported_extensions, const auto& extension = entry.path.Extension(); if (extension.size() <= 1 || extension[0] != '.') return false; - // Strip the leading period. - return supported_extensions.find({extension.begin() + 1, extension.end()}) != + // Strip the leading period, convert to lower case for insensitive match. + return supported_extensions.find(base::ToLowerASCII(extension.substr(1))) != supported_extensions.end(); } diff --git a/chrome/browser/ash/file_manager/guest_os_file_tasks_unittest.cc b/chrome/browser/ash/file_manager/guest_os_file_tasks_unittest.cc index 3128d79f49b9c6..1ed49589229a41 100644 --- a/chrome/browser/ash/file_manager/guest_os_file_tasks_unittest.cc +++ b/chrome/browser/ash/file_manager/guest_os_file_tasks_unittest.cc @@ -175,6 +175,16 @@ TEST_F(GuestOsFileTasksTest, PluginVm_AppRegistered) { EXPECT_THAT(app_vm_types_, testing::ElementsAre(PLUGIN_VM)); } +TEST_F(GuestOsFileTasksTest, PluginVm_IgnoreCase) { + AddApp("app1", "name1", {}, {"Txt"}, PLUGIN_VM); + AddEntry("entry.txT", "test/mime1"); + FindGuestOsApps(&profile_, entries_, urls_, &app_ids_, &app_names_, + &app_vm_types_); + EXPECT_THAT(app_ids_, testing::ElementsAre("app1")); + EXPECT_THAT(app_names_, testing::ElementsAre("name1 (Windows)")); + EXPECT_THAT(app_vm_types_, testing::ElementsAre(PLUGIN_VM)); +} + TEST_F(GuestOsFileTasksTest, PluginVm_NotEnabled) { fake_plugin_vm_features_.set_enabled(false); AddApp("app1", "name1", {}, {"txt"}, PLUGIN_VM); diff --git a/chrome/browser/ash/guest_os/guest_os_registry_service.cc b/chrome/browser/ash/guest_os/guest_os_registry_service.cc index 562c8d03853c87..b6f9675cccc9c7 100644 --- a/chrome/browser/ash/guest_os/guest_os_registry_service.cc +++ b/chrome/browser/ash/guest_os/guest_os_registry_service.cc @@ -77,12 +77,14 @@ base::Value ProtoToDictionary(const App::LocaleString& locale_string) { return result; } -std::set ListToStringSet(const base::Value* list) { +std::set ListToStringSet(const base::Value* list, + bool to_lower_ascii = false) { std::set result; if (!list) return result; for (const base::Value& value : list->GetList()) - result.insert(value.GetString()); + result.insert(to_lower_ascii ? base::ToLowerASCII(value.GetString()) + : value.GetString()); return result; } @@ -407,15 +409,19 @@ std::string GuestOsRegistryService::Registration::ExecutableFileName() const { std::set GuestOsRegistryService::Registration::Extensions() const { if (pref_.is_none()) return {}; + // Convert to lowercase ASCII to allow case-insensitive match. return ListToStringSet(pref_.FindKeyOfType(guest_os::prefs::kAppExtensionsKey, - base::Value::Type::LIST)); + base::Value::Type::LIST), + /*to_lower_ascii=*/true); } std::set GuestOsRegistryService::Registration::MimeTypes() const { if (pref_.is_none()) return {}; + // TODO(crbug.com/1258348): It may make sense for mime types to ignore case. return ListToStringSet(pref_.FindKeyOfType(guest_os::prefs::kAppMimeTypesKey, - base::Value::Type::LIST)); + base::Value::Type::LIST), + /*to_lower_ascii=*/false); } std::set GuestOsRegistryService::Registration::Keywords() const {