Commit 172b81f4 authored by Joel Hockey's avatar Joel Hockey Committed by Commit Bot

Update VmType checks in crostini_apps and plugin_vm_apps

Convert should only be called with expected VmType.
Add DCHECKs, and remove unneeded conditional.

TBR=nancylingwang@chromium.org

Change-Id: I0b921d1b1db82c213eda1ad2cb8dcd5596156ae2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2426151
Commit-Queue: Joel Hockey <joelhockey@chromium.org>
Reviewed-by: default avatarJason Lin <lxj@google.com>
Auto-Submit: Joel Hockey <joelhockey@chromium.org>
Cr-Commit-Position: refs/heads/master@{#810127}
parent c2ca6d1c
......@@ -254,6 +254,10 @@ void CrostiniApps::OnCrostiniEnabledChanged() {
apps::mojom::AppPtr CrostiniApps::Convert(
const guest_os::GuestOsRegistryService::Registration& registration,
bool new_icon_key) {
DCHECK_EQ(
registration.VmType(),
guest_os::GuestOsRegistryService::VmType::ApplicationList_VmType_TERMINA);
apps::mojom::AppPtr app = PublisherBase::MakeApp(
apps::mojom::AppType::kCrostini, registration.app_id(),
apps::mojom::Readiness::kReady, registration.Name(),
......@@ -275,10 +279,7 @@ apps::mojom::AppPtr CrostiniApps::Convert(
app->install_time = registration.InstallTime();
auto show = apps::mojom::OptionalBool::kTrue;
// Only display for termina (not Plugin VM), if no_display not set.
if (registration.VmType() != guest_os::GuestOsRegistryService::VmType::
ApplicationList_VmType_TERMINA ||
registration.NoDisplay()) {
if (registration.NoDisplay()) {
show = apps::mojom::OptionalBool::kFalse;
}
auto show_in_search = show;
......
......@@ -315,6 +315,9 @@ void PluginVmApps::OnRegistryUpdated(
apps::mojom::AppPtr PluginVmApps::Convert(
const guest_os::GuestOsRegistryService::Registration& registration,
bool new_icon_key) {
DCHECK_EQ(registration.VmType(), guest_os::GuestOsRegistryService::VmType::
ApplicationList_VmType_PLUGIN_VM);
apps::mojom::AppPtr app = PublisherBase::MakeApp(
apps::mojom::AppType::kPluginVm, registration.app_id(),
apps::mojom::Readiness::kReady, registration.Name(),
......
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