Commit 582e1eba authored by Reka Norman's avatar Reka Norman Committed by Commit Bot

[App Management] Load icons from chrome://app-icon.

This CL changes the app management page to load its app icons from
chrome://app-icon instead of chrome://extension-icon. It also fixes
a bug which prevents the default icon from loading in some cases where
the icon can't be found.

The chrome://app-icon url currently doesn't work for some Chrome
system apps (e.g. Web Store, Audio Player), so this will require
further investigation.

Bug: 906508
Change-Id: Ib350bf2490193fd17c807d2677f05355eefeb6bf
Reviewed-on: https://chromium-review.googlesource.com/c/1428620
Commit-Queue: Reka Norman <rekanorman@google.com>
Reviewed-by: default avatarEric Willigers <ericwilligers@chromium.org>
Reviewed-by: default avatarNigel Tao <nigeltao@chromium.org>
Reviewed-by: default avatarcalamity <calamity@chromium.org>
Cr-Commit-Position: refs/heads/master@{#626907}
parent 2ebf5f84
......@@ -41,6 +41,11 @@ std::vector<uint8_t> ReadFileAsCompressedData(const base::FilePath path) {
return std::vector<uint8_t>(data.begin(), data.end());
}
std::vector<uint8_t> CompressedDataFromResource(
const extensions::ExtensionResource resource) {
return ReadFileAsCompressedData(resource.GetFilePath());
}
// Runs |callback| passing an IconValuePtr with a compressed image: a
// std::vector<uint8_t>.
void RunCallbackWithCompressedData(
......@@ -188,8 +193,7 @@ void LoadIconFromExtension(apps::mojom::IconCompression icon_compression,
// decoding from and re-encoding to PNG before and after the filter.
base::PostTaskWithTraitsAndReplyWithResult(
FROM_HERE, {base::MayBlock(), base::TaskPriority::USER_VISIBLE},
base::BindOnce(&ReadFileAsCompressedData,
ext_resource.GetFilePath()),
base::BindOnce(&CompressedDataFromResource, ext_resource),
base::BindOnce(&RunCallbackWithCompressedData,
std::move(callback)));
return;
......
......@@ -36,7 +36,7 @@ void LoadDefaultImage(const content::URLDataSource::GotDataCallback& callback) {
void RunCallback(const content::URLDataSource::GotDataCallback& callback,
apps::mojom::IconValuePtr iv) {
if (!iv->compressed.has_value()) {
if (!iv->compressed.has_value() || iv->compressed.value().empty()) {
LoadDefaultImage(callback);
return;
}
......
......@@ -53,7 +53,7 @@ cr.define('app_management.util', function() {
* @return {string}
*/
function getAppIcon(app) {
return `chrome://extension-icon/${app.id}/128/1`;
return `chrome://app-icon/${app.id}/128`;
}
/**
......
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