Commit 481c00e3 authored by Danan S's avatar Danan S Committed by Commit Bot

Fix null profile crash in Gellerization flow

The crash is fixed by null checking the profile, and made further
robust by removing the call to the crashing code and instead
using the AppService's own API for checking whether an app is
a system app, AKA "sticky".

Bug: 1026859
Change-Id: I7da239c74aa18e3bed157a7e0ce3c91cdb1e13bd
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2216601Reviewed-by: default avatarSteven Bennetts <stevenjb@chromium.org>
Auto-Submit: Dan S <danan@chromium.org>
Commit-Queue: Dan S <danan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#772320}
parent 607d25f3
...@@ -55,10 +55,16 @@ void AddSupervisionHandler::RequestClose(RequestCloseCallback callback) { ...@@ -55,10 +55,16 @@ void AddSupervisionHandler::RequestClose(RequestCloseCallback callback) {
void AddSupervisionHandler::GetInstalledArcApps( void AddSupervisionHandler::GetInstalledArcApps(
GetInstalledArcAppsCallback callback) { GetInstalledArcAppsCallback callback) {
Profile* profile = Profile::FromWebUI(web_ui_); Profile* profile = Profile::FromWebUI(web_ui_);
if (!profile) {
DLOG(WARNING) << "Profile not found in WebUI";
std::move(callback).Run({});
return;
}
apps::AppServiceProxy* proxy = apps::AppServiceProxy* proxy =
apps::AppServiceProxyFactory::GetForProfile(profile); apps::AppServiceProxyFactory::GetForProfile(profile);
if (arc::ArcSessionManager::Get() == nullptr) { if (!arc::ArcSessionManager::Get()) {
DLOG(WARNING) << "No ArcSessionManager available"; DLOG(WARNING) << "No ArcSessionManager available";
std::move(callback).Run({}); std::move(callback).Run({});
return; return;
...@@ -71,15 +77,9 @@ void AddSupervisionHandler::GetInstalledArcApps( ...@@ -71,15 +77,9 @@ void AddSupervisionHandler::GetInstalledArcApps(
} }
std::vector<std::string> installed_arc_apps; std::vector<std::string> installed_arc_apps;
proxy->AppRegistryCache().ForEachApp( proxy->AppRegistryCache().ForEachApp(
[&installed_arc_apps, profile](const apps::AppUpdate& update) { [&installed_arc_apps, profile](const apps::AppUpdate& update) {
// We don't include "sticky" ARC apps because they are system-required if (ShouldIncludeAppUpdate(update)) {
// apps that should not be offered for uninstallation. TODO(danan):
// check for stickyness via the App Service instead when that is
// available. (https://crbug.com/948408).
if (ShouldIncludeAppUpdate(update) &&
!arc::IsArcAppSticky(update.AppId(), profile)) {
std::string package_name = std::string package_name =
arc::AppIdToArcPackageName(update.AppId(), profile); arc::AppIdToArcPackageName(update.AppId(), profile);
if (!package_name.empty()) if (!package_name.empty())
......
...@@ -13,10 +13,8 @@ ...@@ -13,10 +13,8 @@
#include "components/services/app_service/public/mojom/types.mojom.h" #include "components/services/app_service/public/mojom/types.mojom.h"
bool ShouldIncludeAppUpdate(const apps::AppUpdate& app_update) { bool ShouldIncludeAppUpdate(const apps::AppUpdate& app_update) {
// TODO(danan): update this to only return sticky = true arc apps when that return app_update.AppType() == apps::mojom::AppType::kArc &&
// attribute is available via the App Service (https://crbug.com/948408). app_update.InstallSource() != apps::mojom::InstallSource::kSystem;
return app_update.AppType() == apps::mojom::AppType::kArc;
} }
void LogOutHelper() { void LogOutHelper() {
......
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