Commit 7c6293de authored by Timothy Loh's avatar Timothy Loh Committed by Commit Bot

Remove pinned Crostini apps on uninstall

This CL adds a LauncherCrostiniAppUpdater that ensures the Shelf knows
about app uninstallation so it can remove pinned Crostini apps.

TEST=Manually uninstalled an app and saw the pin disappear. Manually
uninstalled Crostini and saw pins disappear.

Bug: 839699
Change-Id: I81e6b60414ad8766ef159a9ea3969809beb5112c
Reviewed-on: https://chromium-review.googlesource.com/1046605Reviewed-by: default avatarStefan Kuhne <skuhne@chromium.org>
Commit-Queue: Timothy Loh <timloh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#558175}
parent 1fadef3c
......@@ -3686,6 +3686,8 @@ split_static_library("ui") {
"ash/launcher/internal_app_window_shelf_controller.h",
"ash/launcher/launcher_arc_app_updater.cc",
"ash/launcher/launcher_arc_app_updater.h",
"ash/launcher/launcher_crostini_app_updater.cc",
"ash/launcher/launcher_crostini_app_updater.h",
"views/arc_app_dialog_view.cc",
]
deps += [ "//mash/common" ]
......
......@@ -49,6 +49,7 @@
#include "chrome/browser/ui/ash/launcher/internal_app_window_shelf_controller.h"
#include "chrome/browser/ui/ash/launcher/launcher_arc_app_updater.h"
#include "chrome/browser/ui/ash/launcher/launcher_controller_helper.h"
#include "chrome/browser/ui/ash/launcher/launcher_crostini_app_updater.h"
#include "chrome/browser/ui/ash/launcher/launcher_extension_app_updater.h"
#include "chrome/browser/ui/ash/launcher/multi_profile_app_window_launcher_controller.h"
#include "chrome/browser/ui/ash/launcher/multi_profile_browser_status_monitor.h"
......@@ -1180,6 +1181,12 @@ void ChromeLauncherController::AttachProfile(Profile* profile_to_attach) {
app_updaters_.push_back(std::move(arc_app_updater));
}
if (IsCrostiniUIAllowedForProfile(profile())) {
std::unique_ptr<LauncherAppUpdater> crostini_app_updater(
new LauncherCrostiniAppUpdater(this, profile()));
app_updaters_.push_back(std::move(crostini_app_updater));
}
app_list::AppListSyncableService* app_service =
app_list::AppListSyncableServiceFactory::GetForProfile(profile());
if (app_service)
......
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/ui/ash/launcher/launcher_crostini_app_updater.h"
#include "chrome/browser/chromeos/crostini/crostini_registry_service_factory.h"
#include "chrome/browser/profiles/profile.h"
LauncherCrostiniAppUpdater::LauncherCrostiniAppUpdater(
Delegate* delegate,
content::BrowserContext* browser_context)
: LauncherAppUpdater(delegate, browser_context) {
crostini::CrostiniRegistryService* registry_service =
crostini::CrostiniRegistryServiceFactory::GetForProfile(
Profile::FromBrowserContext(browser_context));
registry_service->AddObserver(this);
}
LauncherCrostiniAppUpdater::~LauncherCrostiniAppUpdater() {
crostini::CrostiniRegistryService* registry_service =
crostini::CrostiniRegistryServiceFactory::GetForProfile(
Profile::FromBrowserContext(browser_context()));
registry_service->RemoveObserver(this);
}
void LauncherCrostiniAppUpdater::OnRegistryUpdated(
crostini::CrostiniRegistryService* registry_service,
const std::vector<std::string>& updated_apps,
const std::vector<std::string>& removed_apps,
const std::vector<std::string>& inserted_apps) {
for (const std::string& app_id : updated_apps)
delegate()->OnAppUpdated(browser_context(), app_id);
for (const std::string& app_id : removed_apps) {
delegate()->OnAppUninstalledPrepared(browser_context(), app_id);
delegate()->OnAppUninstalled(browser_context(), app_id);
}
for (const std::string& app_id : inserted_apps)
delegate()->OnAppInstalled(browser_context(), app_id);
}
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_UI_ASH_LAUNCHER_LAUNCHER_CROSTINI_APP_UPDATER_H_
#define CHROME_BROWSER_UI_ASH_LAUNCHER_LAUNCHER_CROSTINI_APP_UPDATER_H_
#include <string>
#include "base/macros.h"
#include "chrome/browser/chromeos/crostini/crostini_registry_service.h"
#include "chrome/browser/ui/ash/launcher/launcher_app_updater.h"
class LauncherCrostiniAppUpdater
: public LauncherAppUpdater,
public crostini::CrostiniRegistryService::Observer {
public:
LauncherCrostiniAppUpdater(Delegate* delegate,
content::BrowserContext* browser_context);
~LauncherCrostiniAppUpdater() override;
// crostini::CrostiniRegistryService::Observer:
void OnRegistryUpdated(
crostini::CrostiniRegistryService* registry_service,
const std::vector<std::string>& updated_apps,
const std::vector<std::string>& removed_apps,
const std::vector<std::string>& inserted_apps) override;
private:
DISALLOW_COPY_AND_ASSIGN(LauncherCrostiniAppUpdater);
};
#endif // CHROME_BROWSER_UI_ASH_LAUNCHER_LAUNCHER_CROSTINI_APP_UPDATER_H_
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