Commit fb8fbb18 authored by nancy's avatar nancy Committed by Commit Bot

Load the default icon when Crostini app_id is invalid.

Crostini could generate a shelf id with the prefix 'crostini:', and use
this shelf id as the app_id, which couldn't match to an app in
AppService. Therefore AppService loads an empty icon. This CL checks
the prefix, and if it is a Crostini app, sets the resource_id as the
invalid resourceId, so that AppService can load the default penguin
icon as the expectation.

BUG=1006121

Change-Id: I08e4a21e4cf7119170e5c2eeb6d410020559af7a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1820923Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Reviewed-by: default avatarNic Hollingum <hollingum@google.com>
Commit-Queue: Nancy Wang <nancylingwang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#699619}
parent bb77f7a3
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include "chrome/browser/apps/app_service/app_service_proxy.h" #include "chrome/browser/apps/app_service/app_service_proxy.h"
#include "chrome/browser/apps/app_service/app_service_proxy_factory.h" #include "chrome/browser/apps/app_service/app_service_proxy_factory.h"
#include "chrome/browser/chromeos/crostini/crostini_registry_service.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/services/app_service/public/cpp/app_registry_cache.h" #include "chrome/services/app_service/public/cpp/app_registry_cache.h"
#include "chrome/services/app_service/public/cpp/app_update.h" #include "chrome/services/app_service/public/cpp/app_update.h"
...@@ -84,6 +85,21 @@ void AppServiceAppIconLoader::CallLoadIcon(const std::string& app_id, ...@@ -84,6 +85,21 @@ void AppServiceAppIconLoader::CallLoadIcon(const std::string& app_id,
return; return;
} }
// When Crostini generates shelf id as the app_id, which couldn't match to an
// app, the default penguin icon should be loaded.
if (base::StartsWith(app_id, crostini::kCrostiniAppIdPrefix,
base::CompareCase::SENSITIVE)) {
apps::mojom::IconKeyPtr icon_key = apps::mojom::IconKey::New();
icon_key->resource_id = apps::mojom::IconKey::kInvalidResourceId;
proxy->LoadIconFromIconKey(
apps::mojom::AppType::kCrostini, app_id, std::move(icon_key),
apps::mojom::IconCompression::kUncompressed, icon_size_in_dip(),
allow_placeholder_icon,
base::BindOnce(&AppServiceAppIconLoader::OnLoadIcon,
weak_ptr_factory_.GetWeakPtr(), app_id));
return;
}
apps::mojom::AppType app_type = proxy->AppRegistryCache().GetAppType(app_id); apps::mojom::AppType app_type = proxy->AppRegistryCache().GetAppType(app_id);
if (app_type == apps::mojom::AppType::kUnknown) { if (app_type == apps::mojom::AppType::kUnknown) {
return; return;
......
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