Commit 3dd80924 authored by Lucas Tenório's avatar Lucas Tenório Committed by Commit Bot

Allow Kiosk Next Home to load chrome://app-icons.

With this change we will be able to show any app icons just by appending
their app id to chrome://app-icons. If we don't do this type of
whitelisting, the only other way we can pass the icons to the
Kiosk Next Home is to encode their images and pass them through mojo.

That other approach was implented here but it's much more cumbersome:
http://crrev/c/1539156.

Bug: 927809
Change-Id: Id1b63b3959d335dabcccd6d8a743e2e6e825ef01
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1534414Reviewed-by: default avatarMichael Giuffrida <michaelpg@chromium.org>
Commit-Queue: Lucas Tenório <ltenorio@chromium.org>
Cr-Commit-Position: refs/heads/master@{#644673}
parent d559e501
......@@ -4833,11 +4833,12 @@ void ChromeContentBrowserClient::
(extension->is_platform_app() &&
Manifest::IsComponentLocation(extension->location()))) {
// Extensions, legacy packaged apps, and component platform apps are allowed
// to use chrome://favicon/ and chrome://extension-icon/ URLs. Hosted apps
// are not allowed because they are served via web servers (and are
// generally never given access to Chrome APIs).
// to use chrome://favicon/, chrome://extension-icon/ and chrome://app-icon
// URLs. Hosted apps are not allowed because they are served via web servers
// (and are generally never given access to Chrome APIs).
allowed_webui_hosts.emplace_back(chrome::kChromeUIExtensionIconHost);
allowed_webui_hosts.emplace_back(chrome::kChromeUIFaviconHost);
allowed_webui_hosts.emplace_back(chrome::kChromeUIAppIconHost);
}
if (!allowed_webui_hosts.empty()) {
factories->emplace(
......
......@@ -14,6 +14,7 @@
#include "base/optional.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "chrome/browser/apps/app_service/app_icon_source.h"
#include "chrome/browser/apps/app_service/app_service_proxy.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h"
......@@ -23,6 +24,7 @@
#include "components/arc/arc_service_manager.h"
#include "components/arc/common/app.mojom.h"
#include "components/arc/session/arc_bridge_service.h"
#include "content/public/browser/url_data_source.h"
#include "ui/display/types/display_constants.h"
#include "ui/events/event_constants.h"
#include "url/gurl.h"
......@@ -36,6 +38,14 @@ AppControllerImpl::AppControllerImpl(Profile* profile)
url_prefix_(base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
chromeos::switches::kKioskNextHomeUrlPrefix)) {
app_service_proxy_->AppRegistryCache().AddObserver(this);
// Add the chrome://app-icon URL data source.
// TODO(ltenorio): Move this to a more suitable location when we change
// the Kiosk Next Home to WebUI.
if (profile) {
content::URLDataSource::Add(profile,
std::make_unique<apps::AppIconSource>(profile));
}
}
AppControllerImpl::~AppControllerImpl() {
......
......@@ -54,8 +54,9 @@ function buildApp(mojoApp) {
displayName: mojoApp.displayName,
packageName: mojoApp.androidPackageName,
readiness: getReadiness(mojoApp),
// TODO(ltenorio): Add the thumbnail when it's available from mojo.
thumbnailImage: '',
// We append the intended size of the icon in density-independent
// pixels, in this case 128x128 dips.
thumbnailImage: 'chrome://app-icon/' + mojoApp.appId + '/128',
};
}
......
......@@ -10,12 +10,13 @@
},
"permissions": [
"arcAppsPrivate",
"https://*.googleapis.com"
"https://*.googleapis.com",
"chrome://app-icon/"
],
"app": {
"background": {
"scripts": ["bg.js"]
},
"content_security_policy": "script-src 'self'; object-src 'self'; img-src 'self' data: https://lh3.googleusercontent.com"
"content_security_policy": "script-src 'self'; object-src 'self'; img-src 'self' data: https://lh3.googleusercontent.com chrome://app-icon"
}
}
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