Commit 7dbb56c0 authored by Tim Zheng's avatar Tim Zheng Committed by Commit Bot

Hard code some Crostini app wmclass to name map.

Unfortunately some Linux apps don't abide to the desktop specification.
This change add some hard coded mapping so that those apps can be
identified.

BUG=chromium:854911
TEST=Manually tested on a eve device.

Change-Id: Id53c889d46337766b77802682d964d5e2bda85dd
Reviewed-on: https://chromium-review.googlesource.com/1141055
Commit-Queue: Tim Zheng <timzheng@chromium.org>
Reviewed-by: default avatarNicholas Verne <nverne@chromium.org>
Cr-Commit-Position: refs/heads/master@{#576143}
parent 36fa5b4c
...@@ -4,6 +4,9 @@ ...@@ -4,6 +4,9 @@
#include "chrome/browser/chromeos/crostini/crostini_registry_service.h" #include "chrome/browser/chromeos/crostini/crostini_registry_service.h"
#include <map>
#include <string>
#include "ash/public/cpp/app_list/app_list_config.h" #include "ash/public/cpp/app_list/app_list_config.h"
#include "base/metrics/histogram_macros.h" #include "base/metrics/histogram_macros.h"
#include "base/strings/string_number_conversions.h" #include "base/strings/string_number_conversions.h"
...@@ -53,6 +56,15 @@ constexpr char kAppLastLaunchTimeKey[] = "last_launch_time"; ...@@ -53,6 +56,15 @@ constexpr char kAppLastLaunchTimeKey[] = "last_launch_time";
constexpr char kCrostiniAppsInstalledHistogram[] = constexpr char kCrostiniAppsInstalledHistogram[] =
"Crostini.AppsInstalledAtLogin"; "Crostini.AppsInstalledAtLogin";
// A hard-coded mapping from WMClass to app names.
// This is used to deal with the Linux apps that don't specify the correct
// WMClass in their desktop files so that their aura windows can be identified
// with their respective app IDs.
const std::map<std::string, std::string> wmclass_to_name = {
{"Octave-gui", "GNU Octave"},
{"MuseScore2", "MuseScore 2"},
{"XnViewMP", "XnView Multi Platform"}};
std::string GenerateAppId(const std::string& desktop_file_id, std::string GenerateAppId(const std::string& desktop_file_id,
const std::string& vm_name, const std::string& vm_name,
const std::string& container_name) { const std::string& container_name) {
...@@ -391,6 +403,13 @@ std::string CrostiniRegistryService::GetCrostiniShelfAppId( ...@@ -391,6 +403,13 @@ std::string CrostiniRegistryService::GetCrostiniShelfAppId(
true /* need_display */) == FindAppIdResult::UniqueMatch) true /* need_display */) == FindAppIdResult::UniqueMatch)
return app_id; return app_id;
auto it = wmclass_to_name.find(key.as_string());
if (it != wmclass_to_name.end() &&
FindAppId(apps, kAppNameKey, it->second, &app_id,
false /* require_startup_notification */,
true /* need_display */) == FindAppIdResult::UniqueMatch)
return app_id;
return kCrostiniAppIdPrefix + *window_app_id; return kCrostiniAppIdPrefix + *window_app_id;
} }
......
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