0

Remove ARC kiosk specific directories

This is the first step towards removing support for ARC Kiosk sessions,
since the last board that supported this is now EOL.

Bug: b/336756417
Change-Id: I3a2a8652124c31ffb64631251462756246aabf15
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5527061
Reviewed-by: Irina Fedorova <irfedorova@google.com>
Reviewed-by: Dominic Battre <battre@chromium.org>
Commit-Queue: Jeroen Dhollander <jeroendh@google.com>
Reviewed-by: Hidehiko Abe <hidehiko@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1301406}
This commit is contained in:
Jeroen Dhollander
2024-05-15 17:41:11 +00:00
committed by Chromium LUCI CQ
parent d5cbb84d27
commit 1c2be64c0e
39 changed files with 9 additions and 2172 deletions

@ -169,11 +169,6 @@
'filepath': 'chrome/browser/ash/arc/input_method_manager/'\
'|components/arc/ime/'
},
'arc_kiosk': {
'filepath': 'chrome/browser/ash/app_mode/arc/'\
'|components/arc/kiosk/'\
'|arc_kiosk'
},
'arc_mojom': {
'filepath': 'components/arc/mojom/',
},
@ -2518,7 +2513,6 @@
'arc_fileapi': ['alanding+watch@chromium.org',
'djacobo+watch@chromium.org'],
'arc_ime': ['yhanada+watch@chromium.org'],
'arc_kiosk': ['poromov+watch@chromium.org'],
'arc_mojom': ['hashimoto+watch@chromium.org'],
'arc_nearby_share': ['alanding+watch@chromium.org',
'jackshira+watch-nearby-arc@google.com',

@ -118,16 +118,6 @@ source_set("ash") {
"app_list/search/local_image_search/local_image_search_service_factory.h",
"app_mode/app_launch_utils.cc",
"app_mode/app_launch_utils.h",
"app_mode/arc/arc_kiosk_app_data.cc",
"app_mode/arc/arc_kiosk_app_data.h",
"app_mode/arc/arc_kiosk_app_launcher.cc",
"app_mode/arc/arc_kiosk_app_launcher.h",
"app_mode/arc/arc_kiosk_app_manager.cc",
"app_mode/arc/arc_kiosk_app_manager.h",
"app_mode/arc/arc_kiosk_app_service.cc",
"app_mode/arc/arc_kiosk_app_service.h",
"app_mode/arc/arc_kiosk_app_service_factory.cc",
"app_mode/arc/arc_kiosk_app_service_factory.h",
"app_mode/auto_sleep/device_weekly_scheduled_suspend_controller.cc",
"app_mode/auto_sleep/device_weekly_scheduled_suspend_controller.h",
"app_mode/auto_sleep/device_weekly_scheduled_suspend_policy_handler.cc",
@ -504,8 +494,6 @@ source_set("ash") {
"arc/keymint/arc_keymint_bridge.h",
"arc/keymint/cert_store_bridge_keymint.cc",
"arc/keymint/cert_store_bridge_keymint.h",
"arc/kiosk/arc_kiosk_bridge.cc",
"arc/kiosk/arc_kiosk_bridge.h",
"arc/memory_pressure/container_app_killer.cc",
"arc/memory_pressure/container_app_killer.h",
"arc/memory_pressure/container_oom_score_manager.cc",
@ -5397,7 +5385,6 @@ source_set("unit_tests") {
"app_list/test/fake_app_list_model_updater.cc",
"app_list/test/fake_app_list_model_updater.h",
"app_mode/app_launch_utils_unittest.cc",
"app_mode/arc/arc_kiosk_app_service_unittest.cc",
"app_mode/auto_sleep/device_weekly_scheduled_suspend_controller_unittest.cc",
"app_mode/auto_sleep/repeating_time_interval_task_executor_unittest.cc",
"app_mode/kiosk_app_launch_error_unittest.cc",
@ -5501,7 +5488,6 @@ source_set("unit_tests") {
"arc/instance_throttle/arc_provisioning_throttle_observer_unittest.cc",
"arc/instance_throttle/arc_switch_throttle_observer_unittest.cc",
"arc/intent_helper/arc_settings_service_unittest.cc",
"arc/kiosk/arc_kiosk_bridge_unittest.cc",
"arc/memory_pressure/container_app_killer_unittest.cc",
"arc/memory_pressure/container_oom_score_manager_unittest.cc",
"arc/nearby_share/arc_nearby_share_bridge_unittest.cc",

@ -1,32 +0,0 @@
include_rules = [
# ChromeOS should not depend on //chrome. See //docs/chromeos/code.md for
# details.
"-chrome",
# This directory is in //chrome, which violates the rule above. Allow this
# directory to #include its own files.
"+chrome/browser/ash/app_mode/arc",
# Existing dependencies within //chrome. There is an active effort to
# refactor //chrome/browser/ash to break these dependencies; see b/332804822.
# Whenever possible, avoid adding new //chrome dependencies to this list.
#
# Files residing in certain directories (e.g., //chrome/browser) are listed
# individually. Other dependencies within //chrome are listed on a per-
# directory basis. See //tools/chromeos/gen_deps.sh for details.
"+chrome/browser/ash/app_list/arc",
"+chrome/browser/ash/app_mode",
"+chrome/browser/ash/arc/kiosk",
"+chrome/browser/ash/arc/policy",
"+chrome/browser/ash/arc/session",
"+chrome/browser/ash/ownership",
"+chrome/browser/ash/policy/core",
"+chrome/browser/ash/settings",
"+chrome/browser/browser_process.h",
"+chrome/browser/lifetime",
"+chrome/browser/profiles",
"+chrome/browser/ui/ash/multi_user",
"+chrome/browser/ui/browser.h",
"+chrome/browser/ui/chromeos",
"+chrome/test/base",
]

@ -1 +0,0 @@
poromov@chromium.org

@ -1,90 +0,0 @@
// Copyright 2017 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/ash/app_mode/arc/arc_kiosk_app_data.h"
#include <optional>
#include <string>
#include "base/check.h"
#include "base/functional/bind.h"
#include "base/logging.h"
#include "chrome/browser/ash/app_mode/arc/arc_kiosk_app_manager.h"
#include "chrome/browser/ash/app_mode/kiosk_app_data_base.h"
#include "chrome/browser/browser_process.h"
#include "components/account_id/account_id.h"
#include "components/prefs/pref_service.h"
#include "components/prefs/scoped_user_pref_update.h"
#include "content/public/browser/browser_thread.h"
#include "ui/gfx/image/image_skia.h"
namespace ash {
ArcKioskAppData::ArcKioskAppData(const std::string& app_id,
const std::string& package_name,
const std::string& activity,
const std::string& intent,
const AccountId& account_id,
const std::string& name)
: KioskAppDataBase(ArcKioskAppManager::kArcKioskDictionaryName,
app_id,
account_id),
package_name_(package_name),
activity_(activity),
intent_(intent) {
DCHECK(!package_name_.empty());
DCHECK(activity.empty() || intent.empty());
name_ = name;
}
ArcKioskAppData::~ArcKioskAppData() = default;
bool ArcKioskAppData::operator==(const std::string& other_app_id) const {
return app_id() == other_app_id;
}
bool ArcKioskAppData::LoadFromCache() {
PrefService* local_state = g_browser_process->local_state();
const base::Value::Dict& dict = local_state->GetDict(dictionary_name());
if (!LoadFromDictionary(dict)) {
return false;
}
DecodeIcon(base::BindOnce(&ArcKioskAppData::OnIconLoadDone,
weak_ptr_factory_.GetWeakPtr()));
return true;
}
void ArcKioskAppData::SetCache(const std::string& name,
const gfx::ImageSkia& icon) {
DCHECK(!name.empty());
DCHECK(!icon.isNull());
name_ = name;
icon_ = icon;
base::FilePath cache_dir;
ArcKioskAppManager::Get()->GetKioskAppIconCacheDir(&cache_dir);
SaveIcon(*icon_.bitmap(), cache_dir);
PrefService* local_state = g_browser_process->local_state();
ScopedDictPrefUpdate dict_update(local_state, dictionary_name());
SaveToDictionary(dict_update);
}
void ArcKioskAppData::OnIconLoadDone(std::optional<gfx::ImageSkia> icon) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
kiosk_app_icon_loader_.reset();
if (!icon.has_value()) {
LOG(ERROR) << "Icon Load Failure";
return;
}
icon_ = icon.value();
}
} // namespace ash

@ -1,55 +0,0 @@
// Copyright 2017 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_ASH_APP_MODE_ARC_ARC_KIOSK_APP_DATA_H_
#define CHROME_BROWSER_ASH_APP_MODE_ARC_ARC_KIOSK_APP_DATA_H_
#include <string>
#include "chrome/browser/ash/app_mode/kiosk_app_data_base.h"
#include "components/account_id/account_id.h"
#include "ui/gfx/image/image_skia.h"
namespace ash {
// Fetches from Android side and caches ARC kiosk app data such as name and
// icon.
class ArcKioskAppData : public KioskAppDataBase {
public:
ArcKioskAppData(const std::string& app_id,
const std::string& package_name,
const std::string& activity,
const std::string& intent,
const AccountId& account_id,
const std::string& name);
ArcKioskAppData(const ArcKioskAppData&) = delete;
ArcKioskAppData& operator=(const ArcKioskAppData&) = delete;
~ArcKioskAppData() override;
const std::string& package_name() const { return package_name_; }
const std::string& activity() const { return activity_; }
const std::string& intent() const { return intent_; }
bool operator==(const std::string& other_app_id) const;
// Loads the locally cached data. Return false if there is none.
bool LoadFromCache();
// Sets the cached data.
void SetCache(const std::string& name, const gfx::ImageSkia& icon);
private:
void OnIconLoadDone(std::optional<gfx::ImageSkia> icon);
// Not cached, always provided in ctor.
const std::string package_name_;
const std::string activity_;
const std::string intent_;
base::WeakPtrFactory<ArcKioskAppData> weak_ptr_factory_{this};
};
} // namespace ash
#endif // CHROME_BROWSER_ASH_APP_MODE_ARC_ARC_KIOSK_APP_DATA_H_

@ -1,101 +0,0 @@
// Copyright 2016 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/ash/app_mode/arc/arc_kiosk_app_launcher.h"
#include <memory>
#include <string>
#include "ash/components/arc/arc_util.h"
#include "ash/components/arc/metrics/arc_metrics_constants.h"
#include "chrome/browser/ash/app_list/arc/arc_app_utils.h"
#include "chrome/browser/ui/chromeos/window_pin_util.h"
#include "components/exo/shell_surface_util.h"
#include "components/exo/wm_helper.h"
#include "ui/aura/env.h"
#include "ui/events/event_constants.h"
namespace ash {
ArcKioskAppLauncher::ArcKioskAppLauncher(content::BrowserContext* context,
ArcAppListPrefs* prefs,
const std::string& app_id,
Delegate* delegate)
: app_id_(app_id), prefs_(prefs), delegate_(delegate) {
prefs_->AddObserver(this);
exo::WMHelper::GetInstance()->AddExoWindowObserver(this);
// Launching the app by app id in landscape mode and in non-touch mode.
arc::LaunchApp(context, app_id_, ui::EF_NONE,
arc::UserInteractionType::NOT_USER_INITIATED);
}
ArcKioskAppLauncher::~ArcKioskAppLauncher() {
StopObserving();
}
void ArcKioskAppLauncher::OnTaskCreated(int32_t task_id,
const std::string& package_name,
const std::string& activity,
const std::string& intent,
int32_t session_id) {
std::unique_ptr<ArcAppListPrefs::AppInfo> app = prefs_->GetApp(app_id_);
if (!app || app->package_name != package_name || app->activity != activity) {
return;
}
task_id_ = task_id;
// The app window may have been created already.
for (aura::Window* window : windows_) {
if (CheckAndPinWindow(window)) {
break;
}
}
}
void ArcKioskAppLauncher::OnExoWindowCreated(aura::Window* window) {
window->AddObserver(this);
windows_.insert(window);
// The `window`s task ID might not be set yet. Record the window and
// OnTaskCreated will check if it's the window we're looking for.
if (task_id_ == -1) {
return;
}
CheckAndPinWindow(window);
}
void ArcKioskAppLauncher::OnWindowDestroying(aura::Window* window) {
window->RemoveObserver(this);
windows_.erase(window);
}
bool ArcKioskAppLauncher::CheckAndPinWindow(aura::Window* const window) {
DCHECK_GE(task_id_, 0);
if (arc::GetWindowTaskId(window) != task_id_) {
return false;
}
// Stop observing as target window is already found.
StopObserving();
PinWindow(window, /*trusted=*/true);
if (delegate_) {
delegate_->OnAppWindowLaunched();
}
return true;
}
void ArcKioskAppLauncher::StopObserving() {
if (exo::WMHelper::HasInstance()) {
// The `HasInstance` check is here, because of a crash where the `WMHelper`
// was already destroyed. We do not know how we would get into this
// position. See b/281992317 for reference.
exo::WMHelper::GetInstance()->RemoveExoWindowObserver(this);
}
for (aura::Window* window : windows_) {
window->RemoveObserver(this);
}
windows_.clear();
prefs_->RemoveObserver(this);
}
} // namespace ash

@ -1,71 +0,0 @@
// Copyright 2016 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_ASH_APP_MODE_ARC_ARC_KIOSK_APP_LAUNCHER_H_
#define CHROME_BROWSER_ASH_APP_MODE_ARC_ARC_KIOSK_APP_LAUNCHER_H_
#include "base/memory/raw_ptr.h"
#include "chrome/browser/ash/app_list/arc/arc_app_list_prefs.h"
#include "components/exo/wm_helper.h"
#include "ui/aura/env_observer.h"
#include "ui/aura/window.h"
#include "ui/aura/window_observer.h"
namespace ash {
// Starts Android app in kiosk mode.
// Keeps track of start progress and pins app window
// when it's finally opened.
class ArcKioskAppLauncher : public ArcAppListPrefs::Observer,
public exo::WMHelper::ExoWindowObserver,
public aura::WindowObserver {
public:
class Delegate {
public:
Delegate() = default;
Delegate(const Delegate&) = delete;
Delegate& operator=(const Delegate&) = delete;
virtual void OnAppWindowLaunched() = 0;
protected:
virtual ~Delegate() = default;
};
ArcKioskAppLauncher(content::BrowserContext* context,
ArcAppListPrefs* prefs,
const std::string& app_id,
Delegate* delegate);
ArcKioskAppLauncher(const ArcKioskAppLauncher&) = delete;
ArcKioskAppLauncher& operator=(const ArcKioskAppLauncher&) = delete;
~ArcKioskAppLauncher() override;
// ArcAppListPrefs::Observer overrides.
void OnTaskCreated(int32_t task_id,
const std::string& package_name,
const std::string& activity,
const std::string& intent,
int32_t session_id) override;
// exo::WMHelper::ExoWindowObserver
void OnExoWindowCreated(aura::Window* window) override;
// aura::WindowObserver overrides.
void OnWindowDestroying(aura::Window* window) override;
private:
// Check whether it's the app's window and pins it.
bool CheckAndPinWindow(aura::Window* const window);
void StopObserving();
const std::string app_id_;
const raw_ptr<ArcAppListPrefs> prefs_;
int task_id_ = -1;
std::set<raw_ptr<aura::Window, SetExperimental>> windows_;
// Not owning the delegate, delegate owns this class.
const raw_ptr<Delegate> delegate_;
};
} // namespace ash
#endif // CHROME_BROWSER_ASH_APP_MODE_ARC_ARC_KIOSK_APP_LAUNCHER_H_

@ -1,201 +0,0 @@
// Copyright 2016 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/ash/app_mode/arc/arc_kiosk_app_manager.h"
#include <algorithm>
#include <map>
#include <utility>
#include "ash/components/arc/arc_util.h"
#include "base/barrier_closure.h"
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/functional/callback_helpers.h"
#include "base/logging.h"
#include "base/values.h"
#include "chrome/browser/ash/app_list/arc/arc_app_list_prefs.h"
#include "chrome/browser/ash/app_mode/kiosk_cryptohome_remover.h"
#include "chrome/browser/ash/app_mode/pref_names.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/lifetime/application_lifetime.h"
#include "chromeos/ash/components/settings/cros_settings_names.h"
#include "components/prefs/pref_registry_simple.h"
#include "components/prefs/pref_service.h"
#include "components/prefs/scoped_user_pref_update.h"
#include "components/user_manager/user.h"
#include "components/user_manager/user_manager.h"
namespace ash {
namespace {
// This class is owned by `ChromeBrowserMainPartsAsh`.
static ArcKioskAppManager* g_arc_kiosk_app_manager = nullptr;
} // namespace
// static
const char ArcKioskAppManager::kArcKioskDictionaryName[] = "arc-kiosk";
// static
void ArcKioskAppManager::RegisterPrefs(PrefRegistrySimple* registry) {
registry->RegisterDictionaryPref(kArcKioskDictionaryName);
}
// static
ArcKioskAppManager* ArcKioskAppManager::Get() {
return g_arc_kiosk_app_manager;
}
ArcKioskAppManager::ArcKioskAppManager()
: auto_launch_account_id_(EmptyAccountId()) {
DCHECK(!g_arc_kiosk_app_manager); // Only one instance is allowed.
g_arc_kiosk_app_manager = this;
UpdateAppsFromPolicy();
}
ArcKioskAppManager::~ArcKioskAppManager() {
g_arc_kiosk_app_manager = nullptr;
}
const ArcKioskAppData* ArcKioskAppManager::GetAppByAccountId(
const AccountId& account_id) const {
for (auto& app : apps_) {
if (app->account_id() == account_id) {
return app.get();
}
}
return nullptr;
}
std::vector<ArcKioskAppManager::App> ArcKioskAppManager::GetApps() const {
std::vector<App> apps;
for (const auto& app : apps_) {
apps.emplace_back(*app);
}
return apps;
}
std::vector<const ArcKioskAppData*> ArcKioskAppManager::GetAppsForTesting()
const {
std::vector<const ArcKioskAppData*> apps;
for (const auto& app : apps_) {
apps.push_back(app.get());
}
return apps;
}
void ArcKioskAppManager::UpdateNameAndIcon(const AccountId& account_id,
const std::string& name,
const gfx::ImageSkia& icon) {
for (auto& app : apps_) {
if (app->account_id() == account_id) {
app->SetCache(name, icon);
return;
}
}
}
void ArcKioskAppManager::AddAutoLaunchAppForTest(
const std::string& app_id,
const policy::ArcKioskAppBasicInfo& app_info,
const AccountId& account_id) {
for (auto it = apps_.begin(); it != apps_.end(); ++it) {
if ((*it)->app_id() == app_id) {
apps_.erase(it);
break;
}
}
apps_.emplace_back(std::make_unique<ArcKioskAppData>(
app_id, app_info.package_name(), app_info.class_name(), app_info.action(),
account_id, app_info.display_name()));
auto_launch_account_id_ = account_id;
auto_launched_with_zero_delay_ = true;
NotifyKioskAppsChanged();
}
const AccountId& ArcKioskAppManager::GetAutoLaunchAccountId() const {
return auto_launch_account_id_;
}
void ArcKioskAppManager::UpdateAppsFromPolicy() {
// Do not populate ARC kiosk apps if ARC kiosk apps can't be run on the
// device.
// Apps won't be added to kiosk Apps menu and won't be auto-launched.
if (!arc::IsArcKioskAvailable()) {
VLOG(1) << "Device doesn't support ARC kiosk";
return;
}
// Store current apps. We will compare old and new apps to determine which
// apps are new, and which were deleted.
std::map<std::string, std::unique_ptr<ArcKioskAppData>> old_apps;
for (auto& app : apps_) {
old_apps[app->app_id()] = std::move(app);
}
apps_.clear();
auto_launch_account_id_.clear();
auto_launched_with_zero_delay_ = false;
std::string auto_login_account_id_from_settings;
CrosSettings::Get()->GetString(kAccountsPrefDeviceLocalAccountAutoLoginId,
&auto_login_account_id_from_settings);
// Re-populates `apps_` and reuses existing apps when possible.
const std::vector<policy::DeviceLocalAccount> device_local_accounts =
policy::GetDeviceLocalAccounts(CrosSettings::Get());
for (auto account : device_local_accounts) {
if (account.type != policy::DeviceLocalAccountType::kArcKioskApp) {
continue;
}
const AccountId account_id(AccountId::FromUserEmail(account.user_id));
if (account.account_id == auto_login_account_id_from_settings) {
auto_launch_account_id_ = account_id;
int auto_launch_delay = 0;
CrosSettings::Get()->GetInteger(
kAccountsPrefDeviceLocalAccountAutoLoginDelay, &auto_launch_delay);
auto_launched_with_zero_delay_ = auto_launch_delay == 0;
}
const policy::ArcKioskAppBasicInfo& app_info = account.arc_kiosk_app_info;
std::string app_id;
if (!app_info.class_name().empty()) {
app_id = ArcAppListPrefs::GetAppId(app_info.package_name(),
app_info.class_name());
} else {
app_id =
ArcAppListPrefs::GetAppId(app_info.package_name(), app_info.action());
}
auto old_it = old_apps.find(app_id);
if (old_it != old_apps.end()) {
apps_.push_back(std::move(old_it->second));
old_apps.erase(old_it);
} else {
// Use package name when display name is not specified.
std::string name = app_info.package_name();
if (!app_info.display_name().empty()) {
name = app_info.display_name();
}
apps_.push_back(std::make_unique<ArcKioskAppData>(
app_id, app_info.package_name(), app_info.class_name(),
app_info.action(), account_id, name));
apps_.back()->LoadFromCache();
}
KioskCryptohomeRemover::CancelDelayedCryptohomeRemoval(account_id);
}
std::vector<KioskAppDataBase*> old_apps_to_remove;
for (auto& entry : old_apps) {
old_apps_to_remove.emplace_back(entry.second.get());
}
ClearRemovedApps(old_apps_to_remove);
NotifyKioskAppsChanged();
}
} // namespace ash

@ -1,73 +0,0 @@
// Copyright 2016 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_ASH_APP_MODE_ARC_ARC_KIOSK_APP_MANAGER_H_
#define CHROME_BROWSER_ASH_APP_MODE_ARC_ARC_KIOSK_APP_MANAGER_H_
#include <memory>
#include <string>
#include <vector>
#include "chrome/browser/ash/app_mode/arc/arc_kiosk_app_data.h"
#include "chrome/browser/ash/app_mode/kiosk_app_manager_base.h"
#include "chrome/browser/ash/policy/core/device_local_account.h"
#include "chromeos/ash/components/settings/cros_settings.h"
#include "components/account_id/account_id.h"
class PrefRegistrySimple;
namespace ash {
// Keeps track of Android apps that are to be launched in kiosk mode.
// For removed apps deletes appropriate cryptohome. The information about
// kiosk apps are received from CrosSettings. For each app, the system
// creates a user in whose context the app then runs.
class ArcKioskAppManager : public KioskAppManagerBase {
public:
static const char kArcKioskDictionaryName[];
static ArcKioskAppManager* Get();
ArcKioskAppManager();
ArcKioskAppManager(const ArcKioskAppManager&) = delete;
ArcKioskAppManager& operator=(const ArcKioskAppManager&) = delete;
~ArcKioskAppManager() override;
// Registers kiosk app entries in local state.
static void RegisterPrefs(PrefRegistrySimple* registry);
// Returns app that should be started for given account id.
const ArcKioskAppData* GetAppByAccountId(const AccountId& account_id) const;
// KioskAppManagerBase:
std::vector<App> GetApps() const override;
void UpdateNameAndIcon(const AccountId& account_id,
const std::string& name,
const gfx::ImageSkia& icon);
// Adds an app with the given meta data directly, skips meta data fetching
// and sets the app as the auto launched one. Only for test.
void AddAutoLaunchAppForTest(const std::string& app_id,
const policy::ArcKioskAppBasicInfo& app_info,
const AccountId& account_id);
// If the app was auto launched, returns auto launched account id, otherwise
// returns empty account id.
const AccountId& GetAutoLaunchAccountId() const;
// Returns the list of all apps in their internal representation.
std::vector<const ArcKioskAppData*> GetAppsForTesting() const;
private:
// KioskAppmanagerBase:
// Updates `apps_` based on CrosSettings.
void UpdateAppsFromPolicy() override;
std::vector<std::unique_ptr<ArcKioskAppData>> apps_;
AccountId auto_launch_account_id_;
};
} // namespace ash
#endif // CHROME_BROWSER_ASH_APP_MODE_ARC_ARC_KIOSK_APP_MANAGER_H_

@ -1,260 +0,0 @@
// Copyright 2016 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <memory>
#include <string>
#include <utility>
#include <vector>
#include "ash/components/arc/test/arc_util_test_support.h"
#include "base/command_line.h"
#include "base/memory/raw_ptr.h"
#include "base/test/repeating_test_future.h"
#include "base/values.h"
#include "chrome/browser/ash/app_mode/arc/arc_kiosk_app_manager.h"
#include "chrome/browser/ash/app_mode/kiosk_app_manager_observer.h"
#include "chrome/browser/ash/ownership/fake_owner_settings_service.h"
#include "chrome/browser/ash/policy/core/device_local_account.h"
#include "chrome/browser/ash/settings/scoped_cros_settings_test_helper.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chromeos/ash/components/settings/cros_settings_names.h"
#include "content/public/test/browser_test.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/gfx/image/image_skia_rep_default.h"
namespace ash {
namespace {
// The purpose of this waiter - wait for being notified some amount of times.
class NotificationWaiter : public KioskAppManagerObserver {
public:
// In constructor we provide instance of ArcKioskAppManager and subscribe for
// notifications from it, and minimum amount of times we expect to get the
// notification.
explicit NotificationWaiter(ArcKioskAppManager* manager) : manager_(manager) {
manager_->AddObserver(this);
}
NotificationWaiter(const NotificationWaiter&) = delete;
NotificationWaiter& operator=(const NotificationWaiter&) = delete;
~NotificationWaiter() override { manager_->RemoveObserver(this); }
void Wait(int times) {
for (int count = 0; count < times; count++) {
EXPECT_TRUE(notifications_received_.Take());
}
}
private:
// KioskAppManagerObserver:
void OnKioskAppsSettingsChanged() override {
notifications_received_.AddValue(true);
}
base::test::RepeatingTestFuture<bool> notifications_received_;
raw_ptr<ArcKioskAppManager> manager_;
};
std::string GenerateAccountId(std::string package_name) {
return package_name + "@ark-kiosk-app";
}
} // namespace
class ArcKioskAppManagerTest : public InProcessBrowserTest {
public:
ArcKioskAppManagerTest() : settings_helper_(false) {}
ArcKioskAppManagerTest(const ArcKioskAppManagerTest&) = delete;
ArcKioskAppManagerTest& operator=(const ArcKioskAppManagerTest&) = delete;
~ArcKioskAppManagerTest() override = default;
void SetUpCommandLine(base::CommandLine* command_line) override {
arc::SetArcAvailableCommandLineForTesting(command_line);
}
void SetUpOnMainThread() override {
settings_helper_.ReplaceDeviceSettingsProviderWithStub();
owner_settings_service_ =
settings_helper_.CreateOwnerSettingsService(browser()->profile());
}
void TearDownOnMainThread() override {
owner_settings_service_.reset();
settings_helper_.RestoreRealDeviceSettingsProvider();
}
void SetApps(const std::vector<policy::ArcKioskAppBasicInfo>& apps,
const std::string& auto_login_account) {
base::Value::List device_local_accounts;
for (const policy::ArcKioskAppBasicInfo& app : apps) {
device_local_accounts.Append(
base::Value::Dict()
.Set(kAccountsPrefDeviceLocalAccountsKeyId,
GenerateAccountId(app.package_name()))
.Set(kAccountsPrefDeviceLocalAccountsKeyType,
policy::DeviceLocalAccount::TYPE_ARC_KIOSK_APP)
.Set(kAccountsPrefDeviceLocalAccountsKeyEphemeralMode,
static_cast<int>(
policy::DeviceLocalAccount::EphemeralMode::kUnset))
.Set(kAccountsPrefDeviceLocalAccountsKeyArcKioskPackage,
app.package_name())
.Set(kAccountsPrefDeviceLocalAccountsKeyArcKioskClass,
app.class_name())
.Set(kAccountsPrefDeviceLocalAccountsKeyArcKioskAction,
app.action())
.Set(kAccountsPrefDeviceLocalAccountsKeyArcKioskDisplayName,
app.display_name()));
}
owner_settings_service_->Set(kAccountsPrefDeviceLocalAccounts,
base::Value(std::move(device_local_accounts)));
if (!auto_login_account.empty()) {
owner_settings_service_->SetString(
kAccountsPrefDeviceLocalAccountAutoLoginId, auto_login_account);
}
}
void CleanApps() {
base::Value device_local_accounts(base::Value::Type::LIST);
owner_settings_service_->Set(kAccountsPrefDeviceLocalAccounts,
device_local_accounts);
}
ArcKioskAppManager* manager() const { return ArcKioskAppManager::Get(); }
protected:
ScopedCrosSettingsTestHelper settings_helper_;
std::unique_ptr<FakeOwnerSettingsService> owner_settings_service_;
};
IN_PROC_BROWSER_TEST_F(ArcKioskAppManagerTest, Basic) {
policy::ArcKioskAppBasicInfo app1("com.package.name1", "", "", "");
policy::ArcKioskAppBasicInfo app2("com.package.name2", "", "",
"display name");
std::vector<policy::ArcKioskAppBasicInfo> init_apps{app1, app2};
// Set initial list of apps.
{
// Observer must be notified once: app list was updated.
NotificationWaiter waiter(manager());
SetApps(init_apps, std::string());
waiter.Wait(1);
std::vector<const ArcKioskAppData*> apps = manager()->GetAppsForTesting();
ASSERT_EQ(2u, apps.size());
ASSERT_EQ(app1.package_name(), apps[0]->package_name());
ASSERT_EQ(app2.package_name(), apps[1]->package_name());
ASSERT_EQ(app1.package_name(), apps[0]->name());
ASSERT_EQ(app2.display_name(), apps[1]->name());
EXPECT_FALSE(manager()->GetAutoLaunchAccountId().is_valid());
EXPECT_FALSE(manager()->current_app_was_auto_launched_with_zero_delay());
CleanApps();
}
// Set auto-launch app.
{
// Observer must be notified twice: for policy list update and for
// auto-launch app update.
NotificationWaiter waiter(manager());
SetApps(init_apps, GenerateAccountId(app2.package_name()));
waiter.Wait(2);
EXPECT_TRUE(manager()->GetAutoLaunchAccountId().is_valid());
std::vector<const ArcKioskAppData*> apps = manager()->GetAppsForTesting();
ASSERT_EQ(2u, apps.size());
ASSERT_EQ(app1.package_name(), apps[0]->package_name());
ASSERT_EQ(app2.package_name(), apps[1]->package_name());
ASSERT_EQ(app1.package_name(), apps[0]->name());
ASSERT_EQ(app2.display_name(), apps[1]->name());
EXPECT_TRUE(manager()->GetAutoLaunchAccountId().is_valid());
ASSERT_EQ(apps[1]->account_id(), manager()->GetAutoLaunchAccountId());
EXPECT_TRUE(manager()->current_app_was_auto_launched_with_zero_delay());
}
// Create a new list of apps, where there is no app2 (is auto launch now),
// and present a new app.
policy::ArcKioskAppBasicInfo app3("com.package.name3", "", "", "");
std::vector<policy::ArcKioskAppBasicInfo> new_apps{app1, app3};
{
// Observer must be notified once: app list was updated.
NotificationWaiter waiter(manager());
SetApps(new_apps, std::string());
waiter.Wait(1);
std::vector<const ArcKioskAppData*> apps = manager()->GetAppsForTesting();
ASSERT_EQ(2u, apps.size());
ASSERT_EQ(app1.package_name(), apps[0]->package_name());
ASSERT_EQ(app3.package_name(), apps[1]->package_name());
ASSERT_EQ(app1.package_name(), apps[0]->name());
ASSERT_EQ(app3.package_name(), apps[1]->name());
// Auto launch app must be reset.
EXPECT_FALSE(manager()->GetAutoLaunchAccountId().is_valid());
EXPECT_FALSE(manager()->current_app_was_auto_launched_with_zero_delay());
}
// Clean the apps.
{
// Observer must be notified once: app list was updated.
NotificationWaiter waiter(manager());
CleanApps();
waiter.Wait(1);
ASSERT_EQ(0u, manager()->GetAppsForTesting().size());
EXPECT_FALSE(manager()->GetAutoLaunchAccountId().is_valid());
}
}
IN_PROC_BROWSER_TEST_F(ArcKioskAppManagerTest, GetAppByAccountId) {
const std::string package_name = "com.package.name";
// Initialize Arc Kiosk apps.
const policy::ArcKioskAppBasicInfo app1(package_name, "", "", "");
const std::vector<policy::ArcKioskAppBasicInfo> init_apps{app1};
SetApps(init_apps, std::string());
// Verify the app data searched by account id.
std::vector<const ArcKioskAppData*> apps = manager()->GetAppsForTesting();
ASSERT_EQ(1u, apps.size());
const ArcKioskAppData* app = apps[0];
const ArcKioskAppData* app_by_account_id =
manager()->GetAppByAccountId(app->account_id());
ASSERT_TRUE(app_by_account_id);
ASSERT_EQ(app_by_account_id, app);
ASSERT_EQ(app_by_account_id->package_name(), package_name);
// Verify the null value if the given account id is invalid.
const AccountId invalid_account_id;
const ArcKioskAppData* app_by_invalid_account_id =
manager()->GetAppByAccountId(invalid_account_id);
ASSERT_FALSE(app_by_invalid_account_id);
}
IN_PROC_BROWSER_TEST_F(ArcKioskAppManagerTest, UpdateNameAndIcon) {
const std::string package_name = "com.package.old";
const std::string new_name = "new_name";
const gfx::ImageSkiaRep new_image(gfx::Size(100, 100), 0.0f);
const gfx::ImageSkia new_icon(new_image);
// Initialize Arc Kiosk apps.
const policy::ArcKioskAppBasicInfo app1(package_name, "", "", "");
std::vector<policy::ArcKioskAppBasicInfo> init_apps{app1};
SetApps(init_apps, std::string());
// Verify the initialized app data.
std::vector<const ArcKioskAppData*> apps = manager()->GetAppsForTesting();
ASSERT_EQ(1u, apps.size());
const ArcKioskAppData* app = apps[0];
ASSERT_EQ(app->name(), package_name);
ASSERT_TRUE(app->icon().isNull());
// Update the name and icon of the app, then verify them.
manager()->UpdateNameAndIcon(app->account_id(), new_name, new_icon);
ASSERT_EQ(app->name(), new_name);
ASSERT_FALSE(app->icon().isNull());
ASSERT_TRUE(app->icon().BackedBySameObjectAs(new_icon));
}
} // namespace ash

@ -1,283 +0,0 @@
// Copyright 2016 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/ash/app_mode/arc/arc_kiosk_app_service.h"
#include <memory>
#include "ash/public/cpp/app_list/app_list_config.h"
#include "base/functional/bind.h"
#include "base/time/time.h"
#include "chrome/browser/ash/app_list/arc/arc_app_utils.h"
#include "chrome/browser/ash/app_mode/arc/arc_kiosk_app_manager.h"
#include "chrome/browser/ash/app_mode/arc/arc_kiosk_app_service_factory.h"
#include "chrome/browser/ash/arc/session/arc_session_manager.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/ash/multi_user/multi_user_util.h"
#include "ui/base/resource/resource_scale_factor.h"
#include "ui/display/display.h"
#include "ui/display/screen.h"
namespace ash {
namespace {
constexpr int kNonComplianceReasonAppNotInstalled = 5;
} // namespace
// Timeout maintenance session after 30 minutes.
constexpr base::TimeDelta kArcKioskMaintenanceSessionTimeout =
base::Minutes(30);
// static
ArcKioskAppService* ArcKioskAppService::Create(Profile* profile) {
return new ArcKioskAppService(profile);
}
// static
ArcKioskAppService* ArcKioskAppService::Get(content::BrowserContext* context) {
return ArcKioskAppServiceFactory::GetForBrowserContext(context);
}
void ArcKioskAppService::SetNetworkDelegate(NetworkDelegate* network_delegate) {
delegate_ = network_delegate;
}
void ArcKioskAppService::AddObserver(KioskAppLauncher::Observer* observer) {
observers_.AddObserver(observer);
}
void ArcKioskAppService::RemoveObserver(KioskAppLauncher::Observer* observer) {
observers_.RemoveObserver(observer);
}
void ArcKioskAppService::Shutdown() {
ArcAppListPrefs::Get(profile_)->RemoveObserver(this);
// It can be null unittests.
if (arc::ArcSessionManager::Get()) {
arc::ArcSessionManager::Get()->RemoveObserver(this);
}
app_manager_->RemoveObserver(this);
arc::ArcPolicyBridge::GetForBrowserContext(profile_)->RemoveObserver(this);
}
void ArcKioskAppService::OnAppRegistered(
const std::string& app_id,
const ArcAppListPrefs::AppInfo& app_info) {
if (!app_id_.empty() && app_id != app_id_) {
return;
}
PreconditionsChanged();
}
void ArcKioskAppService::OnAppStatesChanged(
const std::string& app_id,
const ArcAppListPrefs::AppInfo& app_info) {
if (!app_id_.empty() && app_id != app_id_) {
return;
}
PreconditionsChanged();
}
void ArcKioskAppService::OnPackageListInitialRefreshed() {
// The app could already be registered.
PreconditionsChanged();
}
void ArcKioskAppService::OnKioskAppsSettingsChanged() {
PreconditionsChanged();
}
void ArcKioskAppService::OnTaskCreated(int32_t task_id,
const std::string& package_name,
const std::string& activity,
const std::string& intent,
int32_t session_id) {
// Store task id of the app to stop it later when needed.
if (app_info_ && package_name == app_info_->package_name &&
activity == app_info_->activity) {
task_id_ = task_id;
observers_.NotifyAppLaunched();
}
}
void ArcKioskAppService::OnTaskDestroyed(int32_t task_id) {
if (task_id == task_id_) {
ResetAppLauncher();
// Trying to restart app if it was somehow closed or crashed
// as kiosk app should always be running during the session.
PreconditionsChanged();
}
}
void ArcKioskAppService::OnMaintenanceSessionCreated() {
maintenance_session_running_ = true;
PreconditionsChanged();
// Safe to bind `this` as timer is auto-cancelled on destruction.
maintenance_timeout_timer_.Start(
FROM_HERE, kArcKioskMaintenanceSessionTimeout,
base::BindOnce(&ArcKioskAppService::OnMaintenanceSessionFinished,
base::Unretained(this)));
}
void ArcKioskAppService::OnMaintenanceSessionFinished() {
if (!maintenance_timeout_timer_.IsRunning()) {
VLOG(1) << "Maintenance session timeout";
}
maintenance_timeout_timer_.Stop();
maintenance_session_running_ = false;
PreconditionsChanged();
}
void ArcKioskAppService::OnAppWindowLaunched() {
observers_.NotifyAppWindowCreated();
}
void ArcKioskAppService::OnIconUpdated(ArcAppIcon* icon) {
DCHECK_EQ(icon, app_icon_.get());
if (icon->image_skia().isNull()) {
app_icon_.release();
return;
}
AccountId account_id = multi_user_util::GetAccountIdFromProfile(profile_);
app_manager_->UpdateNameAndIcon(account_id, app_info_->name,
app_icon_->image_skia());
observers_.NotifyAppDataUpdated();
}
void ArcKioskAppService::OnArcSessionRestarting() {
// Reset state as the app is for sure not running.
VLOG(2) << "Clearing ARC Kiosk state on restart";
ResetAppLauncher();
}
void ArcKioskAppService::OnArcSessionStopped(arc::ArcStopReason reason) {
// Reset state as the app is for sure not running.
VLOG(2) << "Clearing ARC Kiosk state on stop";
ResetAppLauncher();
}
void ArcKioskAppService::OnComplianceReportReceived(
const base::Value* compliance_report) {
VLOG(2) << "Compliance report received";
compliance_report_received_ = true;
pending_policy_app_installs_.clear();
const base::Value::List* const details =
compliance_report->GetDict().FindList("nonComplianceDetails");
if (!details) {
PreconditionsChanged();
return;
}
for (const auto& detail : *details) {
const base::Value::Dict& detail_dict = detail.GetDict();
std::optional<int> reason = detail_dict.FindInt("nonComplianceReason");
if (!reason || *reason != kNonComplianceReasonAppNotInstalled) {
continue;
}
const std::string* const app_name = detail_dict.FindString("packageName");
if (!app_name || app_name->empty()) {
continue;
}
pending_policy_app_installs_.insert(*app_name);
}
PreconditionsChanged();
}
ArcKioskAppService::ArcKioskAppService(Profile* profile) : profile_(profile) {
ArcAppListPrefs::Get(profile_)->AddObserver(this);
arc::ArcSessionManager::Get()->AddObserver(this);
app_manager_ = ArcKioskAppManager::Get();
DCHECK(app_manager_);
app_manager_->AddObserver(this);
arc::ArcPolicyBridge::GetForBrowserContext(profile_)->AddObserver(this);
PreconditionsChanged();
}
ArcKioskAppService::~ArcKioskAppService() {
maintenance_timeout_timer_.Stop();
}
void ArcKioskAppService::RequestNameAndIconUpdate() {
// Request only once when app_icon_ is not initialized.
if (!app_info_ || !app_info_->ready || app_icon_) {
return;
}
app_icon_ = std::make_unique<ArcAppIcon>(
profile_, app_id_,
SharedAppListConfig::instance().default_grid_icon_dimension(), this);
app_icon_->image_skia().GetRepresentation(ui::GetSupportedResourceScaleFactor(
display::Screen::GetScreen()->GetPrimaryDisplay().device_scale_factor()));
// Apply default image now and in case icon is updated then OnIconUpdated()
// will be called additionally.
OnIconUpdated(app_icon_.get());
}
void ArcKioskAppService::PreconditionsChanged() {
VLOG(2) << "Preconditions for kiosk app changed";
app_id_ = GetAppId();
if (app_id_.empty()) {
VLOG(2) << "Kiosk app is not available";
return;
}
app_info_ = ArcAppListPrefs::Get(profile_)->GetApp(app_id_);
VLOG_IF(2, app_info_ && app_info_->ready) << "Kiosk app is ready";
VLOG(2) << "Maintenance session is "
<< (maintenance_session_running_ ? "running" : "not running");
VLOG(2) << "Policy compliance is "
<< (compliance_report_received_ ? "reported" : "not yet reported");
VLOG(2) << "Kiosk app with id: " << app_id_ << " is "
<< (app_launcher_ ? "already launched" : "not yet launched");
VLOG(2) << "Kiosk app is policy "
<< (pending_policy_app_installs_.count(app_info_->package_name)
? "non-compliant"
: "compliant");
RequestNameAndIconUpdate();
if (app_info_ && app_info_->ready && !maintenance_session_running_ &&
compliance_report_received_ &&
pending_policy_app_installs_.count(app_info_->package_name) == 0) {
if (!app_launcher_) {
VLOG(2) << "Starting kiosk app";
app_launcher_ = std::make_unique<ArcKioskAppLauncher>(
profile_, ArcAppListPrefs::Get(profile_), app_id_, this);
observers_.NotifyAppPrepared();
}
} else if (task_id_ != -1) {
VLOG(2) << "Kiosk app should be closed";
arc::CloseTask(task_id_);
}
}
std::string ArcKioskAppService::GetAppId() {
AccountId account_id = multi_user_util::GetAccountIdFromProfile(profile_);
const ArcKioskAppData* app = app_manager_->GetAppByAccountId(account_id);
if (!app) {
return std::string();
}
std::unordered_set<std::string> app_ids =
ArcAppListPrefs::Get(profile_)->GetAppsForPackage(app->package_name());
if (app_ids.empty()) {
return std::string();
}
// If `activity` and `intent` are not specified, return any app from the
// package.
if (app->activity().empty() && app->intent().empty()) {
return *app_ids.begin();
}
// Check that the app is registered for given package.
return app_ids.count(app->app_id()) ? app->app_id() : std::string();
}
void ArcKioskAppService::ResetAppLauncher() {
app_launcher_.reset();
task_id_ = -1;
}
// ArcKioskAppService manages his own state by itself.
void ArcKioskAppService::Initialize() {}
void ArcKioskAppService::ContinueWithNetworkReady() {}
void ArcKioskAppService::LaunchApp() {}
} // namespace ash

@ -1,137 +0,0 @@
// Copyright 2016 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_ASH_APP_MODE_ARC_ARC_KIOSK_APP_SERVICE_H_
#define CHROME_BROWSER_ASH_APP_MODE_ARC_ARC_KIOSK_APP_SERVICE_H_
#include "base/containers/flat_set.h"
#include "base/memory/raw_ptr.h"
#include "base/timer/timer.h"
#include "chrome/browser/ash/app_list/arc/arc_app_icon.h"
#include "chrome/browser/ash/app_list/arc/arc_app_list_prefs.h"
#include "chrome/browser/ash/app_mode/arc/arc_kiosk_app_launcher.h"
#include "chrome/browser/ash/app_mode/kiosk_app_launcher.h"
#include "chrome/browser/ash/app_mode/kiosk_app_manager_observer.h"
#include "chrome/browser/ash/arc/kiosk/arc_kiosk_bridge.h"
#include "chrome/browser/ash/arc/policy/arc_policy_bridge.h"
#include "chrome/browser/ash/arc/session/arc_session_manager_observer.h"
#include "components/keyed_service/core/keyed_service.h"
class Profile;
namespace content {
class BrowserContext;
} // namespace content
namespace ash {
class ArcKioskAppManager;
// Keeps track of ARC session state and auto-launches kiosk app when it's ready.
// App is started when the following conditions are satisfied:
// 1. App id is registered in ArcAppListPrefs and set to "ready" state.
// 2. Got empty policy compliance report from Android
// 3. App is not yet started
// Also, the app is stopped when one of above conditions changes.
class ArcKioskAppService : public KeyedService,
public ArcAppListPrefs::Observer,
public KioskAppManagerObserver,
public arc::ArcKioskBridge::Delegate,
public ArcKioskAppLauncher::Delegate,
public ArcAppIcon::Observer,
public arc::ArcSessionManagerObserver,
public arc::ArcPolicyBridge::Observer,
public KioskAppLauncher {
public:
static ArcKioskAppService* Create(Profile* profile);
static ArcKioskAppService* Get(content::BrowserContext* context);
ArcKioskAppService(const ArcKioskAppService&) = delete;
ArcKioskAppService& operator=(const ArcKioskAppService&) = delete;
void SetNetworkDelegate(NetworkDelegate* network_delegate);
// KeyedService overrides
void Shutdown() override;
// ArcAppListPrefs::Observer overrides
void OnAppRegistered(const std::string& app_id,
const ArcAppListPrefs::AppInfo& app_info) override;
void OnAppStatesChanged(const std::string& app_id,
const ArcAppListPrefs::AppInfo& app_info) override;
void OnTaskCreated(int32_t task_id,
const std::string& package_name,
const std::string& activity,
const std::string& intent,
int32_t session_id) override;
void OnTaskDestroyed(int32_t task_id) override;
void OnPackageListInitialRefreshed() override;
// KioskAppManagerObserver overrides
void OnKioskAppsSettingsChanged() override;
// ArcKioskBridge::Delegate overrides
void OnMaintenanceSessionCreated() override;
void OnMaintenanceSessionFinished() override;
// ArcKioskAppLauncher::Delegate overrides
void OnAppWindowLaunched() override;
// ArcAppIcon::Observer overrides
void OnIconUpdated(ArcAppIcon* icon) override;
// ArcSessionManagerObserver overrides
void OnArcSessionRestarting() override;
void OnArcSessionStopped(arc::ArcStopReason reason) override;
// ArcPolicyBridge::Observer overrides
void OnComplianceReportReceived(
const base::Value* compliance_report) override;
// `KioskAppLauncher`:
void AddObserver(KioskAppLauncher::Observer* observer) override;
void RemoveObserver(KioskAppLauncher::Observer* observer) override;
void Initialize() override;
void ContinueWithNetworkReady() override;
void LaunchApp() override;
ArcKioskAppLauncher* GetLauncherForTesting() { return app_launcher_.get(); }
private:
explicit ArcKioskAppService(Profile* profile);
~ArcKioskAppService() override;
std::string GetAppId();
// Called when app should be started or stopped.
void PreconditionsChanged();
// Updates local cache with proper name and icon.
void RequestNameAndIconUpdate();
// Triggered when app is closed to reset launcher.
void ResetAppLauncher();
const raw_ptr<Profile> profile_;
bool maintenance_session_running_ = false;
base::OneShotTimer maintenance_timeout_timer_;
raw_ptr<ArcKioskAppManager> app_manager_;
std::string app_id_;
std::unique_ptr<ArcAppListPrefs::AppInfo> app_info_;
std::unique_ptr<ArcAppIcon> app_icon_;
int32_t task_id_ = -1;
KioskAppLauncher::ObserverList observers_;
// This contains the list of apps that must be installed for the device to be
// policy-compliant according to the policy report. Even if an app has already
// finished installing, it could still remain in this list for some time.
// ArcKioskAppService may only start apps which are not in this list anymore,
// because it's only assured that kiosk policies have been applied (e.g.
// permission policies) when the app is not in this list anymore.
base::flat_set<std::string> pending_policy_app_installs_;
bool compliance_report_received_ = false;
// Keeps track whether the app is already launched
std::unique_ptr<ArcKioskAppLauncher> app_launcher_;
};
} // namespace ash
#endif // CHROME_BROWSER_ASH_APP_MODE_ARC_ARC_KIOSK_APP_SERVICE_H_

@ -1,48 +0,0 @@
// Copyright 2016 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/ash/app_mode/arc/arc_kiosk_app_service_factory.h"
#include "chrome/browser/ash/app_list/arc/arc_app_list_prefs_factory.h"
#include "chrome/browser/ash/app_mode/arc/arc_kiosk_app_service.h"
#include "chrome/browser/profiles/profile.h"
namespace ash {
// static
ArcKioskAppService* ArcKioskAppServiceFactory::GetForBrowserContext(
content::BrowserContext* context) {
return static_cast<ArcKioskAppService*>(
GetInstance()->GetServiceForBrowserContext(context, /*create=*/true));
}
// static
ArcKioskAppServiceFactory* ArcKioskAppServiceFactory::GetInstance() {
static base::NoDestructor<ArcKioskAppServiceFactory> instance;
return instance.get();
}
ArcKioskAppServiceFactory::ArcKioskAppServiceFactory()
: ProfileKeyedServiceFactory(
"ArcKioskAppService",
ProfileSelections::Builder()
.WithRegular(ProfileSelection::kOriginalOnly)
// TODO(crbug.com/40257657): Check if this service is needed in
// Guest mode.
.WithGuest(ProfileSelection::kOriginalOnly)
.Build()) {
DependsOn(ArcAppListPrefsFactory::GetInstance());
}
ArcKioskAppServiceFactory::~ArcKioskAppServiceFactory() = default;
KeyedService* ArcKioskAppServiceFactory::BuildServiceInstanceFor(
content::BrowserContext* context) const {
Profile* profile = static_cast<Profile*>(context);
DCHECK(profile);
return ArcKioskAppService::Create(profile);
}
} // namespace ash

@ -1,42 +0,0 @@
// Copyright 2016 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_ASH_APP_MODE_ARC_ARC_KIOSK_APP_SERVICE_FACTORY_H_
#define CHROME_BROWSER_ASH_APP_MODE_ARC_ARC_KIOSK_APP_SERVICE_FACTORY_H_
#include "base/no_destructor.h"
#include "chrome/browser/profiles/profile_keyed_service_factory.h"
namespace ash {
class ArcKioskAppService;
// Singleton that owns all ArcKioskAppServices and associates them with
// Profiles. Listens for the Profile's destruction notification and cleans up
// the associated ArcKioskAppService.
class ArcKioskAppServiceFactory : public ProfileKeyedServiceFactory {
public:
static ArcKioskAppService* GetForBrowserContext(
content::BrowserContext* context);
static ArcKioskAppServiceFactory* GetInstance();
ArcKioskAppServiceFactory(const ArcKioskAppServiceFactory&) = delete;
ArcKioskAppServiceFactory& operator=(const ArcKioskAppServiceFactory&) =
delete;
private:
friend base::NoDestructor<ArcKioskAppServiceFactory>;
ArcKioskAppServiceFactory();
~ArcKioskAppServiceFactory() override;
// BrowserContextKeyedServiceFactory overrides.
KeyedService* BuildServiceInstanceFor(
content::BrowserContext* context) const override;
};
} // namespace ash
#endif // CHROME_BROWSER_ASH_APP_MODE_ARC_ARC_KIOSK_APP_SERVICE_FACTORY_H_

@ -1,260 +0,0 @@
// Copyright 2020 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/ash/app_mode/arc/arc_kiosk_app_service.h"
#include "ash/components/arc/session/arc_service_manager.h"
#include "ash/components/arc/session/arc_stop_reason.h"
#include "ash/components/arc/test/fake_app_instance.h"
#include "ash/components/arc/test/fake_arc_session.h"
#include "ash/test/ash_test_helper.h"
#include "ash/test/test_window_builder.h"
#include "base/memory/raw_ptr.h"
#include "base/strings/strcat.h"
#include "base/test/task_environment.h"
#include "base/test/test_future.h"
#include "chrome/browser/ash/app_list/arc/arc_app_test.h"
#include "chrome/browser/ash/app_mode/arc/arc_kiosk_app_manager.h"
#include "chrome/browser/ash/arc/policy/arc_policy_bridge.h"
#include "chrome/browser/ash/ownership/fake_owner_settings_service.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/test/base/chrome_render_view_host_test_harness.h"
#include "chrome/test/base/scoped_testing_local_state.h"
#include "chrome/test/base/testing_browser_process.h"
#include "chrome/test/base/testing_profile.h"
#include "components/exo/shell_surface_util.h"
#include "components/exo/wm_helper.h"
#include "services/data_decoder/public/cpp/test_support/in_process_data_decoder.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace ash {
using base::test::TestFuture;
namespace {
const char kAppPackageName[] = "com.app";
const char kAppClassName[] = "Main";
const char kAppEmail[] = "email@app.com";
const char kAppName[] = "Name";
const char kAppWindowAppId[] = "org.chromium.arc.0";
} // namespace
class FakeController : public KioskAppLauncher::NetworkDelegate,
public KioskAppLauncher::Observer {
public:
explicit FakeController(ArcKioskAppService* service) : service_(service) {
service_->SetNetworkDelegate(this);
service_->AddObserver(this);
}
~FakeController() override {
service_->SetNetworkDelegate(nullptr);
service_->RemoveObserver(this);
}
// KioskAppLauncher::Delegate:
bool IsNetworkReady() const override { return true; }
void OnAppWindowCreated(const std::optional<std::string>& app_name) override {
window_created_signal_.SetValue();
}
void OnAppPrepared() override { app_prepared_signal_.SetValue(); }
void WaitUntilWindowCreated() {
EXPECT_TRUE(window_created_signal_.Wait());
window_created_signal_.Clear();
}
void WaitForAppToBePrepared() {
EXPECT_TRUE(app_prepared_signal_.Wait());
app_prepared_signal_.Clear();
}
void InitializeNetwork() override {}
private:
TestFuture<void> window_created_signal_;
TestFuture<void> app_prepared_signal_;
raw_ptr<ArcKioskAppService> service_;
};
class ArcKioskAppServiceTest : public testing::Test {
public:
ArcKioskAppServiceTest()
: testing_local_state_(TestingBrowserProcess::GetGlobal()) {}
void SetUp() override {
ash_test_helper_.SetUp();
wm_helper_ = std::make_unique<exo::WMHelper>();
profile_ = std::make_unique<TestingProfile>();
profile_->set_profile_name(kAppEmail);
arc_app_test_.set_persist_service_manager(true);
arc_app_test_.SetUp(profile_.get());
app_info_ = arc::mojom::AppInfo::New(kAppName, kAppPackageName,
kAppClassName, /*sticky=*/true);
arc_policy_bridge_ =
arc::ArcPolicyBridge::GetForBrowserContextForTesting(profile_.get());
app_manager_ = std::make_unique<ArcKioskAppManager>();
// Initialize ArcKioskAppService to listen to ArcKioskAppManager updates.
ArcKioskAppService::Get(profile());
app_manager_->AddAutoLaunchAppForTest(
ArcAppListPrefs::GetAppId(kAppPackageName, kAppClassName),
policy::ArcKioskAppBasicInfo(kAppPackageName, kAppClassName,
std::string(), kAppName),
AccountId::FromUserEmail(kAppEmail));
}
void TearDown() override {
arc_app_test_.TearDown();
ash_test_helper_.TearDown();
profile_.reset();
}
TestingProfile* profile() { return profile_.get(); }
ArcKioskAppService* service() { return ArcKioskAppService::Get(profile()); }
arc::mojom::ArcPackageInfoPtr package() {
auto package = arc::mojom::ArcPackageInfo::New();
package->package_name = kAppPackageName;
package->package_version = 1;
package->last_backup_android_id = 1;
package->last_backup_time = 1;
package->sync = false;
return package;
}
void SendComplianceReport() {
arc_policy_bridge_->ReportCompliance(
"{}", base::BindOnce([](const std::string&) {}));
}
void ExpectAppLaunch(FakeController& controller) {
// Wait before app is launched.
controller.WaitForAppToBePrepared();
launch_requests_++;
EXPECT_EQ(launch_requests_, app_instance()->launch_requests().size());
EXPECT_TRUE(
app_instance()->launch_requests().back()->IsForApp(*app_info()));
app_instance()->SendTaskCreated(0, *app_info(), std::string());
}
arc::mojom::AppInfoPtr& app_info() { return app_info_; }
ArcAppTest& arc_app_test() { return arc_app_test_; }
arc::FakeAppInstance* app_instance() { return arc_app_test_.app_instance(); }
void NotifyWindowCreated(aura::Window* window) {
wm_helper_->NotifyExoWindowCreated(window);
}
private:
// Number of times app tried to be launched.
size_t launch_requests_ = 0;
AshTestHelper ash_test_helper_;
content::BrowserTaskEnvironment task_environment;
ArcAppTest arc_app_test_;
ScopedTestingLocalState testing_local_state_;
data_decoder::test::InProcessDataDecoder in_process_data_decoder_;
arc::mojom::AppInfoPtr app_info_;
std::unique_ptr<TestingProfile> profile_;
std::unique_ptr<ArcKioskAppManager> app_manager_;
std::unique_ptr<exo::WMHelper> wm_helper_;
raw_ptr<arc::ArcPolicyBridge, DanglingUntriaged> arc_policy_bridge_;
};
TEST_F(ArcKioskAppServiceTest, LaunchConditions) {
FakeController controller(service());
// Load default apps from arc app test.
app_instance()->SendRefreshPackageList({});
// App gets installed.
arc_app_test().AddPackage(package()->Clone());
// Make app suspended.
std::vector<arc::mojom::AppInfoPtr> apps;
apps.emplace_back(app_info()->Clone())->suspended = true;
app_instance()->SendPackageAppListRefreshed(kAppPackageName, apps);
// Send a report which indicates that there were no installation issues.
SendComplianceReport();
// App should not be launched since it is suspended.
EXPECT_EQ(nullptr, service()->GetLauncherForTesting());
apps.clear();
apps.emplace_back(app_info()->Clone());
app_instance()->SendRefreshAppList(apps);
// App is installed, compliance report received, app should be launched.
ExpectAppLaunch(controller);
// If ARC process stops due to crash or shutdown, app should be terminated.
service()->OnArcSessionStopped(arc::ArcStopReason::CRASH);
EXPECT_EQ(nullptr, service()->GetLauncherForTesting());
// Send a notification which will remind ArcKioskAppService that it should
// launch the app again.
SendComplianceReport();
ExpectAppLaunch(controller);
// If ARC process stops due to crash or shutdown, app should be terminated.
service()->OnArcSessionRestarting();
EXPECT_EQ(nullptr, service()->GetLauncherForTesting());
// Send a notification which will remind ArcKioskAppService that it should
// launch the app again.
SendComplianceReport();
ExpectAppLaunch(controller);
// Start maintenance session.
service()->OnMaintenanceSessionCreated();
app_instance()->SendTaskDestroyed(0);
EXPECT_EQ(nullptr, service()->GetLauncherForTesting());
// The app should be restarted after maintenance is finished.
service()->OnMaintenanceSessionFinished();
ExpectAppLaunch(controller);
}
TEST_F(ArcKioskAppServiceTest, AppLaunches) {
FakeController controller(service());
// App gets installed.
arc_app_test().AddPackage(package()->Clone());
// Make app launchable.
std::vector<arc::mojom::AppInfoPtr> apps;
apps.emplace_back(app_info()->Clone());
app_instance()->SendPackageAppListRefreshed(kAppPackageName, apps);
SendComplianceReport();
ExpectAppLaunch(controller);
// Create window of other app which should not be handled.
auto other_window = std::make_unique<aura::Window>(nullptr);
other_window->Init(ui::LAYER_SOLID_COLOR);
other_window.reset();
TestWindowBuilder window_builder;
std::unique_ptr<aura::Window> app_window = window_builder.Build();
exo::SetShellApplicationId(app_window.get(), kAppWindowAppId);
NotifyWindowCreated(app_window.get());
controller.WaitUntilWindowCreated();
}
} // namespace ash

@ -23,8 +23,6 @@
#include "base/notreached.h"
#include "base/ranges/algorithm.h"
#include "base/task/sequenced_task_runner.h"
#include "chrome/browser/ash/app_mode/arc/arc_kiosk_app_data.h"
#include "chrome/browser/ash/app_mode/arc/arc_kiosk_app_manager.h"
#include "chrome/browser/ash/app_mode/kiosk_app.h"
#include "chrome/browser/ash/app_mode/kiosk_app_launch_error.h"
#include "chrome/browser/ash/app_mode/kiosk_app_manager_base.h"
@ -69,16 +67,6 @@ std::optional<KioskApp> ChromeAppById(const KioskChromeAppManager& manager,
manager_app.name, manager_app.icon);
}
std::optional<KioskApp> ArcAppById(const ArcKioskAppManager& manager,
const AccountId& account_id) {
const ArcKioskAppData* data = manager.GetAppByAccountId(account_id);
if (!data) {
return std::nullopt;
}
return KioskApp(KioskAppId::ForArcApp(account_id), data->name(),
data->icon());
}
} // namespace
KioskControllerImpl::KioskControllerImpl(
@ -100,10 +88,6 @@ std::vector<KioskApp> KioskControllerImpl::GetApps() const {
KioskAppId::ForChromeApp(chrome_app.app_id, chrome_app.account_id),
chrome_app.name, chrome_app.icon);
}
for (const KioskAppManagerBase::App& arc_app : arc_app_manager_.GetApps()) {
apps.emplace_back(KioskAppId::ForArcApp(arc_app.account_id), arc_app.name,
arc_app.icon);
}
return apps;
}
@ -115,7 +99,7 @@ std::optional<KioskApp> KioskControllerImpl::GetAppById(
case KioskAppType::kChromeApp:
return ChromeAppById(chrome_app_manager_, app_id.app_id.value());
case KioskAppType::kArcApp:
return ArcAppById(arc_app_manager_, app_id.account_id);
NOTREACHED_NORETURN();
}
}
@ -127,10 +111,6 @@ std::optional<KioskApp> KioskControllerImpl::GetAutoLaunchApp() const {
std::string chrome_app_id = chrome_app_manager_.GetAutoLaunchApp();
CHECK(!chrome_app_id.empty());
return ChromeAppById(chrome_app_manager_, chrome_app_id);
} else if (const auto& arc_account_id =
arc_app_manager_.GetAutoLaunchAccountId();
arc_account_id.is_valid()) {
return ArcAppById(arc_app_manager_, arc_account_id);
}
return std::nullopt;
}
@ -141,8 +121,6 @@ void KioskControllerImpl::InitializeKioskSystemSession(
const std::optional<std::string>& app_name) {
CHECK(!system_session_.has_value())
<< "KioskSystemSession is already initialized";
CHECK_NE(kiosk_app_id.type, KioskAppType::kArcApp)
<< "KioskSystemSession should not be created in ARC Kiosk";
system_session_.emplace(profile, kiosk_app_id, app_name);
@ -228,7 +206,7 @@ void KioskControllerImpl::OnUserLoggedIn(const user_manager::User& user) {
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
command_line->AppendSwitch(::switches::kForceAppMode);
// This happens in Web and Arc kiosks.
// This happens in Web kiosks.
if (!kiosk_app_id.empty()) {
command_line->AppendSwitchASCII(::switches::kAppId, kiosk_app_id);
}

@ -13,7 +13,6 @@
#include "ash/public/cpp/login_accelerators.h"
#include "base/memory/weak_ptr.h"
#include "base/scoped_observation.h"
#include "chrome/browser/ash/app_mode/arc/arc_kiosk_app_manager.h"
#include "chrome/browser/ash/app_mode/kiosk_app.h"
#include "chrome/browser/ash/app_mode/kiosk_app_launch_error.h"
#include "chrome/browser/ash/app_mode/kiosk_app_types.h"
@ -72,7 +71,6 @@ class KioskControllerImpl : public KioskController,
WebKioskAppManager web_app_manager_;
KioskChromeAppManager chrome_app_manager_;
ArcKioskAppManager arc_app_manager_;
// Created once the Kiosk session launch starts. Only not null during the
// kiosk launch.

@ -1,18 +0,0 @@
include_rules = [
# ChromeOS should not depend on //chrome. See //docs/chromeos/code.md for
# details.
"-chrome",
# This directory is in //chrome, which violates the rule above. Allow this
# directory to #include its own files.
"+chrome/browser/ash/arc/kiosk",
# Existing dependencies within //chrome. There is an active effort to
# refactor //chrome/browser/ash to break these dependencies; see b/332804822.
# Whenever possible, avoid adding new //chrome dependencies to this list.
#
# Files residing in certain directories (e.g., //chrome/browser) are listed
# individually. Other dependencies within //chrome are listed on a per-
# directory basis. See //tools/chromeos/gen_deps.sh for details.
"+chrome/browser/ash/app_mode/arc",
]

@ -1,103 +0,0 @@
// Copyright 2016 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/ash/arc/kiosk/arc_kiosk_bridge.h"
#include <utility>
#include "ash/components/arc/arc_browser_context_keyed_service_factory_base.h"
#include "ash/components/arc/session/arc_bridge_service.h"
#include "base/memory/ptr_util.h"
#include "base/memory/singleton.h"
#include "chrome/browser/ash/app_mode/arc/arc_kiosk_app_service.h"
#include "chrome/browser/ash/app_mode/arc/arc_kiosk_app_service_factory.h"
#include "components/user_manager/user_manager.h"
namespace arc {
namespace {
// Singleton factory for ArcKioskBridge.
class ArcKioskBridgeFactory
: public internal::ArcBrowserContextKeyedServiceFactoryBase<
ArcKioskBridge,
ArcKioskBridgeFactory> {
public:
// Factory name used by ArcBrowserContextKeyedServiceFactoryBase.
static constexpr const char* kName = "ArcKioskBridgeFactory";
static ArcKioskBridgeFactory* GetInstance() {
return base::Singleton<ArcKioskBridgeFactory>::get();
}
private:
friend base::DefaultSingletonTraits<ArcKioskBridgeFactory>;
ArcKioskBridgeFactory() {
DependsOn(ash::ArcKioskAppServiceFactory::GetInstance());
}
~ArcKioskBridgeFactory() override = default;
// BrowserContextKeyedServiceFactory override:
KeyedService* BuildServiceInstanceFor(
content::BrowserContext* context) const override {
// Kiosk apps should be run only for kiosk sessions.
if (!user_manager::UserManager::Get()->IsLoggedInAsArcKioskApp())
return nullptr;
return ArcBrowserContextKeyedServiceFactoryBase::BuildServiceInstanceFor(
context);
}
};
} // namespace
// static
ArcKioskBridge* ArcKioskBridge::GetForBrowserContext(
content::BrowserContext* context) {
return ArcKioskBridgeFactory::GetForBrowserContext(context);
}
// static
std::unique_ptr<ArcKioskBridge> ArcKioskBridge::CreateForTesting(
ArcBridgeService* arc_bridge_service,
Delegate* delegate) {
// std::make_unique() cannot be used because the ctor is private.
return base::WrapUnique(new ArcKioskBridge(arc_bridge_service, delegate));
}
ArcKioskBridge::ArcKioskBridge(content::BrowserContext* context,
ArcBridgeService* bridge_service)
: ArcKioskBridge(bridge_service, ash::ArcKioskAppService::Get(context)) {}
ArcKioskBridge::ArcKioskBridge(ArcBridgeService* bridge_service,
Delegate* delegate)
: arc_bridge_service_(bridge_service), delegate_(delegate) {
DCHECK(delegate_);
arc_bridge_service_->kiosk()->SetHost(this);
}
ArcKioskBridge::~ArcKioskBridge() {
arc_bridge_service_->kiosk()->SetHost(nullptr);
}
void ArcKioskBridge::OnMaintenanceSessionCreated(int32_t session_id) {
session_id_ = session_id;
delegate_->OnMaintenanceSessionCreated();
// TODO(poromov@) Show appropriate splash screen.
}
void ArcKioskBridge::OnMaintenanceSessionFinished(int32_t session_id,
bool success) {
// Filter only callbacks for the started kiosk session.
if (session_id != session_id_)
return;
session_id_ = -1;
delegate_->OnMaintenanceSessionFinished();
}
// static
void ArcKioskBridge::EnsureFactoryBuilt() {
ArcKioskBridgeFactory::GetInstance();
}
} // namespace arc

@ -1,72 +0,0 @@
// Copyright 2016 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_ASH_ARC_KIOSK_ARC_KIOSK_BRIDGE_H_
#define CHROME_BROWSER_ASH_ARC_KIOSK_ARC_KIOSK_BRIDGE_H_
#include <memory>
#include "ash/components/arc/mojom/kiosk.mojom.h"
#include "base/memory/raw_ptr.h"
#include "components/keyed_service/core/keyed_service.h"
namespace content {
class BrowserContext;
} // namespace content
namespace arc {
class ArcBridgeService;
// TODO(hidehiko): Consider to migrate this class into ArcKioskAppService.
class ArcKioskBridge : public KeyedService,
public mojom::KioskHost {
public:
// Received IPCs are passed to this delegate.
class Delegate {
public:
virtual ~Delegate() = default;
virtual void OnMaintenanceSessionCreated() = 0;
virtual void OnMaintenanceSessionFinished() = 0;
};
// Returns singleton instance for the given BrowserContext,
// or nullptr if the browser |context| is not allowed to use ARC.
static ArcKioskBridge* GetForBrowserContext(content::BrowserContext* context);
// Returns a created instance for testing.
static std::unique_ptr<ArcKioskBridge> CreateForTesting(
ArcBridgeService* bridge_service,
Delegate* delegate);
ArcKioskBridge(content::BrowserContext* context,
ArcBridgeService* bridge_service);
ArcKioskBridge(const ArcKioskBridge&) = delete;
ArcKioskBridge& operator=(const ArcKioskBridge&) = delete;
~ArcKioskBridge() override;
// mojom::KioskHost overrides.
void OnMaintenanceSessionCreated(int32_t session_id) override;
void OnMaintenanceSessionFinished(int32_t session_id, bool success) override;
static void EnsureFactoryBuilt();
private:
// |delegate| should be alive while the ArcKioskBridge instance is alive.
ArcKioskBridge(ArcBridgeService* bridge_service, Delegate* delegate);
const raw_ptr<ArcBridgeService>
arc_bridge_service_; // Owned by ArcServiceManager.
const raw_ptr<Delegate> delegate_;
// Tracks current maintenance session id.
int32_t session_id_ = -1;
};
} // namespace arc
#endif // CHROME_BROWSER_ASH_ARC_KIOSK_ARC_KIOSK_BRIDGE_H_

@ -1,58 +0,0 @@
// Copyright 2017 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/ash/arc/kiosk/arc_kiosk_bridge.h"
#include <memory>
#include "ash/components/arc/session/arc_bridge_service.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace {
class MockArcKioskBridgeDelegate : public arc::ArcKioskBridge::Delegate {
public:
MockArcKioskBridgeDelegate() = default;
MOCK_METHOD0(OnMaintenanceSessionCreated, void());
MOCK_METHOD0(OnMaintenanceSessionFinished, void());
};
} // namespace
namespace arc {
class ArcKioskBridgeTest : public testing::Test {
public:
ArcKioskBridgeTest()
: bridge_service_(std::make_unique<ArcBridgeService>()),
delegate_(std::make_unique<MockArcKioskBridgeDelegate>()),
kiosk_bridge_(ArcKioskBridge::CreateForTesting(bridge_service_.get(),
delegate_.get())) {}
ArcKioskBridgeTest(const ArcKioskBridgeTest&) = delete;
ArcKioskBridgeTest& operator=(const ArcKioskBridgeTest&) = delete;
protected:
std::unique_ptr<ArcBridgeService> bridge_service_;
std::unique_ptr<MockArcKioskBridgeDelegate> delegate_;
std::unique_ptr<ArcKioskBridge> kiosk_bridge_;
};
TEST_F(ArcKioskBridgeTest, MaintenanceSessionFinished) {
EXPECT_CALL(*delegate_, OnMaintenanceSessionCreated()).Times(1);
kiosk_bridge_->OnMaintenanceSessionCreated(1);
EXPECT_CALL(*delegate_, OnMaintenanceSessionFinished()).Times(1);
kiosk_bridge_->OnMaintenanceSessionFinished(1, true);
}
TEST_F(ArcKioskBridgeTest, MaintenanceSessionNotFinished) {
EXPECT_CALL(*delegate_, OnMaintenanceSessionCreated()).Times(1);
kiosk_bridge_->OnMaintenanceSessionCreated(1);
EXPECT_CALL(*delegate_, OnMaintenanceSessionFinished()).Times(0);
kiosk_bridge_->OnMaintenanceSessionFinished(2, true);
}
} // namespace arc

@ -74,7 +74,6 @@
#include "chrome/browser/ash/arc/intent_helper/chrome_arc_intent_helper_delegate.h"
#include "chrome/browser/ash/arc/keymaster/arc_keymaster_bridge.h"
#include "chrome/browser/ash/arc/keymint/arc_keymint_bridge.h"
#include "chrome/browser/ash/arc/kiosk/arc_kiosk_bridge.h"
#include "chrome/browser/ash/arc/metrics/arc_metrics_service_proxy.h"
#include "chrome/browser/ash/arc/nearby_share/arc_nearby_share_bridge.h"
#include "chrome/browser/ash/arc/net/browser_url_opener_impl.h"
@ -283,7 +282,6 @@ void ArcServiceLauncher::OnPrimaryUserProfilePrepared(Profile* profile) {
} else {
ArcKeymasterBridge::GetForBrowserContext(profile);
}
ArcKioskBridge::GetForBrowserContext(profile);
ArcMediaSessionBridge::GetForBrowserContext(profile);
{
auto* metrics_service = ArcMetricsService::GetForBrowserContext(profile);
@ -472,7 +470,6 @@ void ArcServiceLauncher::EnsureFactoriesBuilt() {
} else {
ArcKeymasterBridge::EnsureFactoryBuilt();
}
ArcKioskBridge::EnsureFactoryBuilt();
ArcMediaSessionBridge::EnsureFactoryBuilt();
ArcMemoryBridge::EnsureFactoryBuilt();
ArcMemoryPressureBridge::EnsureFactoryBuilt();

@ -17,7 +17,6 @@
#include "chrome/browser/ash/app_list/app_sync_ui_state_factory.h"
#include "chrome/browser/ash/app_list/arc/arc_vpn_provider_manager_factory.h"
#include "chrome/browser/ash/app_list/search/local_image_search/local_image_search_service_factory.h"
#include "chrome/browser/ash/app_mode/arc/arc_kiosk_app_service_factory.h"
#include "chrome/browser/ash/app_mode/kiosk_app_update_service.h"
#include "chrome/browser/ash/app_restore/app_restore_arc_task_handler_factory.h"
#include "chrome/browser/ash/app_restore/full_restore_service_factory.h"
@ -150,7 +149,6 @@ void EnsureBrowserContextKeyedServiceFactoriesBuilt() {
apps::ArcAppsFactory::GetInstance();
AppSyncUIStateFactory::GetInstance();
arc::ArcServiceLauncher::EnsureFactoriesBuilt();
ArcKioskAppServiceFactory::GetInstance();
AuthErrorObserverFactory::GetInstance();
ax::AccessibilityServiceRouterFactory::EnsureFactoryBuilt();
BirchKeyedServiceFactory::GetInstance();

@ -35,7 +35,6 @@
#include "base/task/sequenced_task_runner.h"
#include "base/time/time.h"
#include "chrome/browser/ash/app_mode/app_launch_utils.h"
#include "chrome/browser/ash/app_mode/arc/arc_kiosk_app_service.h"
#include "chrome/browser/ash/app_mode/kiosk_app.h"
#include "chrome/browser/ash/app_mode/kiosk_app_launch_error.h"
#include "chrome/browser/ash/app_mode/kiosk_app_launcher.h"
@ -128,39 +127,6 @@ void RecordKioskLaunchDuration(KioskAppType type, base::TimeDelta duration) {
break;
}
}
// This is a not-owning wrapper around ArcKioskAppService which allows to be
// plugged into a unique_ptr safely.
// TODO(apotapchuk): Remove this when ARC kiosk is fully deprecated.
class ArcKioskAppServiceWrapper : public KioskAppLauncher {
public:
ArcKioskAppServiceWrapper(ArcKioskAppService* service,
KioskAppLauncher::NetworkDelegate* delegate)
: service_(service) {
service_->SetNetworkDelegate(delegate);
}
~ArcKioskAppServiceWrapper() override {
service_->SetNetworkDelegate(nullptr);
}
// `KioskAppLauncher`:
void AddObserver(KioskAppLauncher::Observer* observer) override {
service_->AddObserver(observer);
}
void RemoveObserver(KioskAppLauncher::Observer* observer) override {
service_->RemoveObserver(observer);
}
void Initialize() override { service_->Initialize(); }
void ContinueWithNetworkReady() override {
service_->ContinueWithNetworkReady();
}
void LaunchApp() override { service_->LaunchApp(); }
private:
// `service_` is externally owned and it's the caller's responsibility to
// ensure that it outlives this wrapper.
const raw_ptr<ArcKioskAppService> service_;
};
std::unique_ptr<KioskAppLauncher> BuildKioskAppLauncher(
Profile* profile,
@ -168,10 +134,7 @@ std::unique_ptr<KioskAppLauncher> BuildKioskAppLauncher(
KioskAppLauncher::NetworkDelegate* network_delegate) {
switch (kiosk_app_id.type) {
case KioskAppType::kArcApp:
// ArcKioskAppService lifetime is bound to the profile, therefore
// wrap it into a separate object.
return std::make_unique<ArcKioskAppServiceWrapper>(
ArcKioskAppService::Get(profile), network_delegate);
NOTREACHED_NORETURN();
case KioskAppType::kChromeApp:
return std::make_unique<StartupAppLauncher>(
profile, kiosk_app_id.app_id.value(), /*should_skip_install=*/false,

@ -22,7 +22,6 @@
#include "base/test/scoped_command_line.h"
#include "base/test/task_environment.h"
#include "base/test/test_future.h"
#include "chrome/browser/ash/app_mode/arc/arc_kiosk_app_manager.h"
#include "chrome/browser/ash/app_mode/fake_kiosk_app_launcher.h"
#include "chrome/browser/ash/app_mode/kiosk_app_launch_error.h"
#include "chrome/browser/ash/app_mode/kiosk_app_launcher.h"

@ -7,7 +7,6 @@
#include "base/memory/ptr_util.h"
#include "base/values.h"
#include "chrome/browser/ash/app_mode/arc/arc_kiosk_app_manager.h"
#include "chrome/browser/ash/login/existing_user_controller.h"
#include "chrome/browser/ash/login/ui/mock_login_display_host.h"
#include "chrome/browser/ash/login/users/fake_chrome_user_manager.h"
@ -51,7 +50,6 @@ class ExistingUserControllerAutoLoginTest : public ::testing::Test {
}
void SetUp() override {
arc_kiosk_app_manager_ = std::make_unique<ArcKioskAppManager>();
existing_user_controller_ = std::make_unique<ExistingUserController>();
mock_login_display_host_ = std::make_unique<MockLoginDisplayHost>();
@ -144,7 +142,6 @@ class ExistingUserControllerAutoLoginTest : public ::testing::Test {
ScopedCrosSettingsTestHelper settings_helper_;
user_manager::TypedScopedUserManager<ash::FakeChromeUserManager>
fake_user_manager_;
std::unique_ptr<ArcKioskAppManager> arc_kiosk_app_manager_;
session_manager::SessionManager session_manager_;

@ -11,8 +11,6 @@
#include "ash/public/cpp/login_screen.h"
#include "base/check.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/ash/app_mode/arc/arc_kiosk_app_data.h"
#include "chrome/browser/ash/app_mode/arc/arc_kiosk_app_manager.h"
#include "chrome/browser/ash/app_mode/kiosk_app_launch_error.h"
#include "chrome/browser/ash/app_mode/kiosk_app_manager_observer.h"
#include "chrome/browser/ash/app_mode/kiosk_app_types.h"
@ -78,7 +76,6 @@ std::vector<KioskAppMenuEntry> BuildKioskAppMenuEntries() {
KioskAppMenuController::KioskAppMenuController() {
kiosk_observations_.AddObservation(KioskChromeAppManager::Get());
kiosk_observations_.AddObservation(ArcKioskAppManager::Get());
kiosk_observations_.AddObservation(WebKioskAppManager::Get());
}

@ -10,7 +10,6 @@
#include "base/functional/bind.h"
#include "base/notreached.h"
#include "base/time/time.h"
#include "chrome/browser/ash/app_mode/arc/arc_kiosk_app_manager.h"
#include "chrome/browser/ash/app_mode/kiosk_chrome_app_manager.h"
#include "chrome/browser/ash/app_mode/web_app/web_kiosk_app_manager.h"
#include "chrome/browser/ash/policy/remote_commands/crd/crd_logging.h"
@ -37,9 +36,6 @@ const ash::KioskAppManagerBase* GetKioskAppManager(
if (user_manager.IsLoggedInAsKioskApp()) {
return ash::KioskChromeAppManager::Get();
}
if (user_manager.IsLoggedInAsArcKioskApp()) {
return ash::ArcKioskAppManager::Get();
}
if (user_manager.IsLoggedInAsWebKioskApp()) {
return ash::WebKioskAppManager::Get();
}

@ -14,7 +14,6 @@
#include "base/test/test_future.h"
#include "base/test/values_test_util.h"
#include "base/values.h"
#include "chrome/browser/ash/app_mode/arc/arc_kiosk_app_manager.h"
#include "chrome/browser/ash/app_mode/kiosk_chrome_app_manager.h"
#include "chrome/browser/ash/app_mode/web_app/web_kiosk_app_manager.h"
#include "chrome/browser/ash/policy/remote_commands/crd/crd_remote_command_utils.h"
@ -109,7 +108,6 @@ class DeviceCommandFetchCrdAvailabilityInfoJobTest
ASSERT_TRUE(profile_manager_.SetUp());
user_activity_detector_ = ui::UserActivityDetector::Get();
arc_kiosk_app_manager_ = std::make_unique<ash::ArcKioskAppManager>();
web_kiosk_app_manager_ = std::make_unique<ash::WebKioskAppManager>();
kiosk_chrome_app_manager_ = std::make_unique<ash::KioskChromeAppManager>();
}
@ -117,7 +115,6 @@ class DeviceCommandFetchCrdAvailabilityInfoJobTest
void TearDown() override {
kiosk_chrome_app_manager_.reset();
web_kiosk_app_manager_.reset();
arc_kiosk_app_manager_.reset();
DeviceSettingsTestBase::TearDown();
}
@ -175,7 +172,6 @@ class DeviceCommandFetchCrdAvailabilityInfoJobTest
}
private:
std::unique_ptr<ash::ArcKioskAppManager> arc_kiosk_app_manager_;
std::unique_ptr<ash::WebKioskAppManager> web_kiosk_app_manager_;
std::unique_ptr<ash::KioskChromeAppManager> kiosk_chrome_app_manager_;
@ -272,11 +268,9 @@ TEST_P(DeviceCommandFetchCrdAvailabilityInfoJobTestParameterizedOverSessionType,
UserSessionType expected = [&]() {
switch (session_type) {
case TestSessionType::kManuallyLaunchedArcKioskSession:
case TestSessionType::kManuallyLaunchedWebKioskSession:
case TestSessionType::kManuallyLaunchedKioskSession:
return UserSessionType::MANUALLY_LAUNCHED_KIOSK_SESSION;
case TestSessionType::kAutoLaunchedArcKioskSession:
case TestSessionType::kAutoLaunchedWebKioskSession:
case TestSessionType::kAutoLaunchedKioskSession:
return UserSessionType::AUTO_LAUNCHED_KIOSK_SESSION;
@ -314,10 +308,8 @@ TEST_P(DeviceCommandFetchCrdAvailabilityInfoJobTestParameterizedOverSessionType,
case TestSessionType::kNoSession:
return ToList({CrdSessionType::REMOTE_ACCESS_SESSION});
case TestSessionType::kManuallyLaunchedArcKioskSession:
case TestSessionType::kManuallyLaunchedWebKioskSession:
case TestSessionType::kManuallyLaunchedKioskSession:
case TestSessionType::kAutoLaunchedArcKioskSession:
case TestSessionType::kAutoLaunchedWebKioskSession:
case TestSessionType::kAutoLaunchedKioskSession:
case TestSessionType::kManagedGuestSession:
@ -377,10 +369,8 @@ TEST_P(DeviceCommandFetchCrdAvailabilityInfoJobTestParameterizedOverSessionType,
return CrdSessionAvailability::
UNAVAILABLE_UNSUPPORTED_USER_SESSION_TYPE;
case TestSessionType::kManuallyLaunchedArcKioskSession:
case TestSessionType::kManuallyLaunchedWebKioskSession:
case TestSessionType::kManuallyLaunchedKioskSession:
case TestSessionType::kAutoLaunchedArcKioskSession:
case TestSessionType::kAutoLaunchedWebKioskSession:
case TestSessionType::kAutoLaunchedKioskSession:
case TestSessionType::kManagedGuestSession:
@ -411,10 +401,8 @@ TEST_P(DeviceCommandFetchCrdAvailabilityInfoJobTestParameterizedOverSessionType,
case TestSessionType::kGuestSession:
case TestSessionType::kUnaffiliatedUserSession:
case TestSessionType::kManuallyLaunchedArcKioskSession:
case TestSessionType::kManuallyLaunchedWebKioskSession:
case TestSessionType::kManuallyLaunchedKioskSession:
case TestSessionType::kAutoLaunchedArcKioskSession:
case TestSessionType::kAutoLaunchedWebKioskSession:
case TestSessionType::kAutoLaunchedKioskSession:
case TestSessionType::kManagedGuestSession:
@ -431,10 +419,8 @@ TEST_P(DeviceCommandFetchCrdAvailabilityInfoJobTestParameterizedOverSessionType,
INSTANTIATE_TEST_SUITE_P(
All,
DeviceCommandFetchCrdAvailabilityInfoJobTestParameterizedOverSessionType,
::testing::Values(TestSessionType::kManuallyLaunchedArcKioskSession,
TestSessionType::kManuallyLaunchedWebKioskSession,
::testing::Values(TestSessionType::kManuallyLaunchedWebKioskSession,
TestSessionType::kManuallyLaunchedKioskSession,
TestSessionType::kAutoLaunchedArcKioskSession,
TestSessionType::kAutoLaunchedWebKioskSession,
TestSessionType::kAutoLaunchedKioskSession,
TestSessionType::kManagedGuestSession,

@ -17,7 +17,6 @@
#include "base/test/test_future.h"
#include "base/test/values_test_util.h"
#include "base/time/time.h"
#include "chrome/browser/ash/app_mode/arc/arc_kiosk_app_manager.h"
#include "chrome/browser/ash/app_mode/kiosk_chrome_app_manager.h"
#include "chrome/browser/ash/app_mode/web_app/web_kiosk_app_manager.h"
#include "chrome/browser/ash/policy/remote_commands/crd/crd_remote_command_utils.h"
@ -70,11 +69,9 @@ constexpr char kHistogramDurationTemplate[] =
// Created for session type logged to UMA.
const char* SessionTypeToUmaString(TestSessionType session_type) {
switch (session_type) {
case TestSessionType::kManuallyLaunchedArcKioskSession:
case TestSessionType::kManuallyLaunchedWebKioskSession:
case TestSessionType::kManuallyLaunchedKioskSession:
return "ManuallyLaunchedKioskSession";
case TestSessionType::kAutoLaunchedArcKioskSession:
case TestSessionType::kAutoLaunchedWebKioskSession:
case TestSessionType::kAutoLaunchedKioskSession:
return "AutoLaunchedKioskSession";
@ -132,10 +129,8 @@ test::NetworkBuilder CreateNetwork(NetworkType type = NetworkType::kWiFi) {
// Returns true if the given session type supports a 'remote support' session.
bool SupportsRemoteSupport(TestSessionType user_session_type) {
switch (user_session_type) {
case TestSessionType::kManuallyLaunchedArcKioskSession:
case TestSessionType::kManuallyLaunchedWebKioskSession:
case TestSessionType::kManuallyLaunchedKioskSession:
case TestSessionType::kAutoLaunchedArcKioskSession:
case TestSessionType::kAutoLaunchedWebKioskSession:
case TestSessionType::kAutoLaunchedKioskSession:
case TestSessionType::kManagedGuestSession:
@ -155,10 +150,8 @@ bool SupportsRemoteAccess(TestSessionType user_session_type) {
case TestSessionType::kNoSession:
return true;
case TestSessionType::kManuallyLaunchedArcKioskSession:
case TestSessionType::kManuallyLaunchedWebKioskSession:
case TestSessionType::kManuallyLaunchedKioskSession:
case TestSessionType::kAutoLaunchedArcKioskSession:
case TestSessionType::kAutoLaunchedWebKioskSession:
case TestSessionType::kAutoLaunchedKioskSession:
case TestSessionType::kManagedGuestSession:
@ -172,10 +165,8 @@ bool SupportsRemoteAccess(TestSessionType user_session_type) {
// Returns true if the given session type is a kiosk session.
bool IsKioskSession(TestSessionType user_session_type) {
switch (user_session_type) {
case TestSessionType::kManuallyLaunchedArcKioskSession:
case TestSessionType::kManuallyLaunchedWebKioskSession:
case TestSessionType::kManuallyLaunchedKioskSession:
case TestSessionType::kAutoLaunchedArcKioskSession:
case TestSessionType::kAutoLaunchedWebKioskSession:
case TestSessionType::kAutoLaunchedKioskSession:
return true;
@ -221,7 +212,6 @@ class DeviceCommandStartCrdSessionJobTest : public ash::DeviceSettingsTestBase {
ASSERT_TRUE(profile_manager_.SetUp());
user_activity_detector_ = ui::UserActivityDetector::Get();
arc_kiosk_app_manager_ = std::make_unique<ash::ArcKioskAppManager>();
web_kiosk_app_manager_ = std::make_unique<ash::WebKioskAppManager>();
kiosk_chrome_app_manager_ = std::make_unique<ash::KioskChromeAppManager>();
}
@ -229,7 +219,6 @@ class DeviceCommandStartCrdSessionJobTest : public ash::DeviceSettingsTestBase {
void TearDown() override {
kiosk_chrome_app_manager_.reset();
web_kiosk_app_manager_.reset();
arc_kiosk_app_manager_.reset();
profile_ = nullptr;
@ -331,7 +320,6 @@ class DeviceCommandStartCrdSessionJobTest : public ash::DeviceSettingsTestBase {
ash::FakeChromeUserManager& user_manager() { return *user_manager_; }
private:
std::unique_ptr<ash::ArcKioskAppManager> arc_kiosk_app_manager_;
std::unique_ptr<ash::WebKioskAppManager> web_kiosk_app_manager_;
std::unique_ptr<ash::KioskChromeAppManager> kiosk_chrome_app_manager_;
@ -409,10 +397,8 @@ TEST_P(DeviceCommandStartCrdSessionJobTestParameterized,
bool is_supported = [&]() {
switch (user_session_type) {
case TestSessionType::kManuallyLaunchedArcKioskSession:
case TestSessionType::kManuallyLaunchedWebKioskSession:
case TestSessionType::kManuallyLaunchedKioskSession:
case TestSessionType::kAutoLaunchedArcKioskSession:
case TestSessionType::kAutoLaunchedWebKioskSession:
case TestSessionType::kAutoLaunchedKioskSession:
case TestSessionType::kManagedGuestSession:
@ -591,10 +577,8 @@ TEST_P(DeviceCommandStartCrdSessionJobTestParameterized,
bool terminate_upon_input = [&]() {
switch (user_session_type) {
case TestSessionType::kManuallyLaunchedArcKioskSession:
case TestSessionType::kManuallyLaunchedWebKioskSession:
case TestSessionType::kManuallyLaunchedKioskSession:
case TestSessionType::kAutoLaunchedArcKioskSession:
case TestSessionType::kAutoLaunchedWebKioskSession:
case TestSessionType::kAutoLaunchedKioskSession:
return true;
@ -656,10 +640,8 @@ TEST_P(DeviceCommandStartCrdSessionJobTestParameterized,
bool show_confirmation_dialog = [&]() {
switch (user_session_type) {
case TestSessionType::kManuallyLaunchedArcKioskSession:
case TestSessionType::kManuallyLaunchedWebKioskSession:
case TestSessionType::kManuallyLaunchedKioskSession:
case TestSessionType::kAutoLaunchedArcKioskSession:
case TestSessionType::kAutoLaunchedWebKioskSession:
case TestSessionType::kAutoLaunchedKioskSession:
return false;
@ -953,10 +935,8 @@ TEST_P(DeviceCommandStartCrdSessionJobRemoteAccessTestParameterized,
case TestSessionType::kNoSession:
return true;
case TestSessionType::kManuallyLaunchedArcKioskSession:
case TestSessionType::kManuallyLaunchedWebKioskSession:
case TestSessionType::kManuallyLaunchedKioskSession:
case TestSessionType::kAutoLaunchedArcKioskSession:
case TestSessionType::kAutoLaunchedWebKioskSession:
case TestSessionType::kAutoLaunchedKioskSession:
case TestSessionType::kManagedGuestSession:
@ -1294,10 +1274,8 @@ TEST_P(DeviceCommandStartCrdSessionJobRemoteAccessTestParameterized,
INSTANTIATE_TEST_SUITE_P(
All,
DeviceCommandStartCrdSessionJobTestParameterized,
::testing::Values(TestSessionType::kManuallyLaunchedArcKioskSession,
TestSessionType::kManuallyLaunchedWebKioskSession,
::testing::Values(TestSessionType::kManuallyLaunchedWebKioskSession,
TestSessionType::kManuallyLaunchedKioskSession,
TestSessionType::kAutoLaunchedArcKioskSession,
TestSessionType::kAutoLaunchedWebKioskSession,
TestSessionType::kAutoLaunchedKioskSession,
TestSessionType::kManagedGuestSession,
@ -1309,10 +1287,8 @@ INSTANTIATE_TEST_SUITE_P(
INSTANTIATE_TEST_SUITE_P(
All,
DeviceCommandStartCrdSessionJobRemoteAccessTestParameterized,
::testing::Values(TestSessionType::kManuallyLaunchedArcKioskSession,
TestSessionType::kManuallyLaunchedWebKioskSession,
::testing::Values(TestSessionType::kManuallyLaunchedWebKioskSession,
TestSessionType::kManuallyLaunchedKioskSession,
TestSessionType::kAutoLaunchedArcKioskSession,
TestSessionType::kAutoLaunchedWebKioskSession,
TestSessionType::kAutoLaunchedKioskSession,
TestSessionType::kManagedGuestSession,

@ -21,7 +21,6 @@
#include "base/threading/thread_restrictions.h"
#include "base/time/time.h"
#include "base/values.h"
#include "chrome/browser/ash/app_mode/arc/arc_kiosk_app_manager.h"
#include "chrome/browser/ash/app_mode/kiosk_chrome_app_manager.h"
#include "chrome/browser/ash/app_mode/web_app/web_kiosk_app_manager.h"
#include "chrome/browser/ash/policy/remote_commands/device_command_fetch_support_packet_job_test_util.h"
@ -99,7 +98,6 @@ class DeviceCommandFetchSupportPacketTest : public ash::DeviceSettingsTestBase {
ash::system::StatisticsProvider::SetTestProvider(&statistics_provider_);
cros_settings_helper_.ReplaceDeviceSettingsProviderWithStub();
arc_kiosk_app_manager_ = std::make_unique<ash::ArcKioskAppManager>();
web_kiosk_app_manager_ = std::make_unique<ash::WebKioskAppManager>();
kiosk_chrome_app_manager_ = std::make_unique<ash::KioskChromeAppManager>();
@ -117,7 +115,6 @@ class DeviceCommandFetchSupportPacketTest : public ash::DeviceSettingsTestBase {
kiosk_chrome_app_manager_.reset();
web_kiosk_app_manager_.reset();
arc_kiosk_app_manager_.reset();
ash::DebugDaemonClient::Shutdown();
DeviceSettingsTestBase::TearDown();
@ -146,7 +143,6 @@ class DeviceCommandFetchSupportPacketTest : public ash::DeviceSettingsTestBase {
protected:
// App manager instances for testing kiosk sessions.
std::unique_ptr<ash::ArcKioskAppManager> arc_kiosk_app_manager_;
std::unique_ptr<ash::WebKioskAppManager> web_kiosk_app_manager_;
std::unique_ptr<ash::KioskChromeAppManager> kiosk_chrome_app_manager_;
@ -344,14 +340,10 @@ INSTANTIATE_TEST_SUITE_P(
All,
DeviceCommandFetchSupportPacketTestParameterized,
::testing::Values(
test::SessionInfo{TestSessionType::kManuallyLaunchedArcKioskSession,
/*pii_allowed=*/true},
test::SessionInfo{TestSessionType::kManuallyLaunchedWebKioskSession,
/*pii_allowed=*/true},
test::SessionInfo{TestSessionType::kManuallyLaunchedKioskSession,
/*pii_allowed=*/true},
test::SessionInfo{TestSessionType::kAutoLaunchedArcKioskSession,
/*pii_allowed=*/true},
test::SessionInfo{TestSessionType::kAutoLaunchedWebKioskSession,
/*pii_allowed=*/true},
test::SessionInfo{TestSessionType::kAutoLaunchedKioskSession,

@ -5,7 +5,6 @@
#include "chrome/browser/ash/policy/remote_commands/user_session_type_test_util.h"
#include "base/check_deref.h"
#include "base/notreached.h"
#include "chrome/browser/ash/app_mode/arc/arc_kiosk_app_manager.h"
#include "chrome/browser/ash/app_mode/kiosk_chrome_app_manager.h"
#include "chrome/browser/ash/app_mode/web_app/web_kiosk_app_manager.h"
#include "chrome/browser/ash/login/users/fake_chrome_user_manager.h"
@ -27,10 +26,6 @@ const user_manager::User* CreateUserOfType(
AccountId account_id(AccountId::FromUserEmail(kTestAccountEmail));
switch (session_type) {
case TestSessionType::kManuallyLaunchedArcKioskSession:
CHECK_DEREF(ash::ArcKioskAppManager::Get())
.set_current_app_was_auto_launched_with_zero_delay_for_testing(false);
return user_manager.AddArcKioskAppUser(account_id);
case TestSessionType::kManuallyLaunchedWebKioskSession:
CHECK_DEREF(ash::WebKioskAppManager::Get())
.set_current_app_was_auto_launched_with_zero_delay_for_testing(false);
@ -39,10 +34,6 @@ const user_manager::User* CreateUserOfType(
CHECK_DEREF(ash::KioskChromeAppManager::Get())
.set_current_app_was_auto_launched_with_zero_delay_for_testing(false);
return user_manager.AddKioskAppUser(account_id);
case TestSessionType::kAutoLaunchedArcKioskSession:
CHECK_DEREF(ash::ArcKioskAppManager::Get())
.set_current_app_was_auto_launched_with_zero_delay_for_testing(true);
return user_manager.AddArcKioskAppUser(account_id);
case TestSessionType::kAutoLaunchedWebKioskSession:
CHECK_DEREF(ash::WebKioskAppManager::Get())
.set_current_app_was_auto_launched_with_zero_delay_for_testing(true);
@ -77,10 +68,8 @@ const char* SessionTypeToString(TestSessionType session_type) {
return #type
switch (session_type) {
CASE(kManuallyLaunchedArcKioskSession);
CASE(kManuallyLaunchedWebKioskSession);
CASE(kManuallyLaunchedKioskSession);
CASE(kAutoLaunchedArcKioskSession);
CASE(kAutoLaunchedWebKioskSession);
CASE(kAutoLaunchedKioskSession);
CASE(kManagedGuestSession);

@ -17,10 +17,8 @@ namespace policy::test {
// manually and auto launched kiosk sessions.
enum class TestSessionType {
// Kiosk sessions
kManuallyLaunchedArcKioskSession,
kManuallyLaunchedWebKioskSession,
kManuallyLaunchedKioskSession,
kAutoLaunchedArcKioskSession,
kAutoLaunchedWebKioskSession,
kAutoLaunchedKioskSession,

@ -45,7 +45,6 @@
#include "base/task/thread_pool.h"
#include "base/values.h"
#include "base/version.h"
#include "chrome/browser/ash/app_mode/arc/arc_kiosk_app_manager.h"
#include "chrome/browser/ash/app_mode/kiosk_chrome_app_manager.h"
#include "chrome/browser/ash/crosapi/browser_util.h"
#include "chrome/browser/ash/crostini/crostini_pref_names.h"

@ -43,7 +43,6 @@
#include "chrome/browser/apps/app_service/app_service_proxy_factory.h"
#include "chrome/browser/apps/app_service/app_service_test.h"
#include "chrome/browser/apps/app_service/publisher_host.h"
#include "chrome/browser/ash/app_mode/arc/arc_kiosk_app_manager.h"
#include "chrome/browser/ash/app_mode/kiosk_app_data.h"
#include "chrome/browser/ash/app_mode/kiosk_chrome_app_manager.h"
#include "chrome/browser/ash/app_mode/kiosk_cryptohome_remover.h"
@ -285,10 +284,8 @@ constexpr uint8_t kFakeUsbInterfaceNumber1 = 1;
constexpr base::TimeDelta kHour = base::Hours(1);
const char kKioskAccountId[] = "kiosk_user@localhost";
const char kArcKioskAccountId[] = "arc_kiosk_user@localhost";
const char kWebKioskAccountId[] = "web_kiosk_user@localhost";
const char kKioskAppId[] = "kiosk_app_id";
const char kArcKioskPackageName[] = "com.test.kioskapp";
const char kWebKioskAppUrl[] = "http://example.com";
const char kExternalMountPoint[] = "/a/b/c";
const char kPublicAccountId[] = "public_user@localhost";
@ -840,14 +837,6 @@ class DeviceStatusCollectorTest : public testing::Test {
kKioskAccountId,
kKioskAppId,
std::string() /* kiosk_app_update_url */),
fake_arc_kiosk_app_basic_info_(kArcKioskPackageName,
std::string() /* class_name */,
std::string() /* action */,
std::string() /* display_name */),
fake_arc_kiosk_device_local_account_(
DeviceLocalAccount::EphemeralMode::kUnset,
fake_arc_kiosk_app_basic_info_,
kArcKioskAccountId),
fake_web_kiosk_app_basic_info_(kWebKioskAppUrl,
std::string() /* title */,
std::string() /* icon_url */),
@ -1148,25 +1137,6 @@ class DeviceStatusCollectorTest : public testing::Test {
kiosk_chrome_app_manager_->GetAutoLaunchAppRequiredPlatformVersion());
}
void MockAutoLaunchArcKioskApp(
const DeviceLocalAccount& auto_launch_app_account) {
arc_kiosk_app_manager_ = std::make_unique<ash::ArcKioskAppManager>();
arc_kiosk_app_manager_->AddAutoLaunchAppForTest(
auto_launch_app_account.arc_kiosk_app_info.package_name(),
auto_launch_app_account.arc_kiosk_app_info,
AccountId::FromUserEmail(auto_launch_app_account.user_id));
std::vector<DeviceLocalAccount> accounts;
accounts.push_back(auto_launch_app_account);
SetDeviceLocalAccounts(&owner_settings_service_, accounts);
owner_settings_service_.SetString(
ash::kAccountsPrefDeviceLocalAccountAutoLoginId,
auto_launch_app_account.account_id);
base::RunLoop().RunUntilIdle();
}
void MockAutoLaunchWebKioskApp(
const DeviceLocalAccount& auto_launch_app_account) {
web_kiosk_app_manager_ = std::make_unique<ash::WebKioskAppManager>();
@ -1207,8 +1177,6 @@ class DeviceStatusCollectorTest : public testing::Test {
scoped_testing_cros_settings_.device_settings(), nullptr};
// Only set after MockRunningKioskApp was called.
std::unique_ptr<TestingProfile> testing_profile_;
// Only set after MockAutoLaunchArcKioskApp was called.
std::unique_ptr<ash::ArcKioskAppManager> arc_kiosk_app_manager_;
// Only set after MockAutoLaunchWebKioskApp was called.
std::unique_ptr<ash::WebKioskAppManager> web_kiosk_app_manager_;
// Only set after MockAutoLaunchKioskAppWithRequiredPlatformVersion was
@ -1223,8 +1191,6 @@ class DeviceStatusCollectorTest : public testing::Test {
std::unique_ptr<ManagedSessionService> managed_session_service_;
std::unique_ptr<TestingDeviceStatusCollector> status_collector_;
const DeviceLocalAccount fake_kiosk_device_local_account_;
const ArcKioskAppBasicInfo fake_arc_kiosk_app_basic_info_;
const DeviceLocalAccount fake_arc_kiosk_device_local_account_;
const WebKioskAppBasicInfo fake_web_kiosk_app_basic_info_;
const DeviceLocalAccount fake_web_kiosk_device_local_account_;
base::ScopedPathOverride user_data_dir_override_;
@ -1332,24 +1298,6 @@ TEST_F(DeviceStatusCollectorTest, MixedStatesForKiosk) {
GetActiveMilliseconds(device_status_));
}
// For Arc kiosks report total uptime instead of only active periods.
TEST_F(DeviceStatusCollectorTest, MixedStatesForArcKiosk) {
DisableDefaultSettings();
ui::IdleState test_states[] = {
ui::IDLE_STATE_ACTIVE, ui::IDLE_STATE_IDLE, ui::IDLE_STATE_ACTIVE,
ui::IDLE_STATE_ACTIVE, ui::IDLE_STATE_IDLE,
};
ash::LoginState::Get()->SetLoggedInState(
ash::LoginState::LOGGED_IN_ACTIVE, ash::LoginState::LOGGED_IN_USER_KIOSK);
scoped_testing_cros_settings_.device_settings()->SetBoolean(
ash::kReportDeviceActivityTimes, true);
status_collector_->Simulate(test_states,
sizeof(test_states) / sizeof(ui::IdleState));
GetStatus();
EXPECT_EQ(5 * ActivePeriodMilliseconds(),
GetActiveMilliseconds(device_status_));
}
TEST_F(DeviceStatusCollectorTest, StateKeptInPref) {
DisableDefaultSettings();
ui::IdleState test_states[] = {ui::IDLE_STATE_ACTIVE, ui::IDLE_STATE_IDLE,
@ -2621,29 +2569,6 @@ TEST_F(DeviceStatusCollectorTest, ReportKioskSessionStatus) {
EXPECT_FALSE(session_status_.has_user_dm_token());
}
TEST_F(DeviceStatusCollectorTest, ReportArcKioskSessionStatus) {
scoped_testing_cros_settings_.device_settings()->SetBoolean(
ash::kReportDeviceSessionStatus, true);
status_collector_->set_kiosk_account(std::make_unique<DeviceLocalAccount>(
fake_arc_kiosk_device_local_account_));
// Set up a device-local account for single-app ARC kiosk mode.
MockRunningKioskApp(fake_arc_kiosk_device_local_account_,
DeviceLocalAccount::TYPE_ARC_KIOSK_APP);
GetStatus();
EXPECT_TRUE(got_session_status_);
ASSERT_EQ(1, session_status_.installed_apps_size());
EXPECT_EQ(kArcKioskAccountId, session_status_.device_local_account_id());
const em::AppStatus app = session_status_.installed_apps(0);
EXPECT_EQ(kArcKioskPackageName, app.app_id());
EXPECT_TRUE(app.extension_version().empty());
EXPECT_FALSE(app.has_status());
EXPECT_FALSE(app.has_error());
// Expect no User DM Token for kiosk sessions.
EXPECT_FALSE(session_status_.has_user_dm_token());
}
TEST_F(DeviceStatusCollectorTest, ReportWebKioskSessionStatus) {
scoped_testing_cros_settings_.device_settings()->SetBoolean(
ash::kReportDeviceSessionStatus, true);
@ -2929,27 +2854,6 @@ TEST_F(DeviceStatusCollectorTest, ReportRunningKioskApp) {
EXPECT_FALSE(app.has_error());
}
TEST_F(DeviceStatusCollectorTest, ReportRunningArcKioskApp) {
DisableDefaultSettings();
scoped_testing_cros_settings_.device_settings()->SetBoolean(
ash::kReportRunningKioskApp, true);
MockAutoLaunchArcKioskApp(fake_arc_kiosk_device_local_account_);
MockRunningKioskApp(fake_arc_kiosk_device_local_account_,
DeviceLocalAccount::TYPE_ARC_KIOSK_APP);
status_collector_->set_kiosk_account(std::make_unique<DeviceLocalAccount>(
fake_arc_kiosk_device_local_account_));
GetStatus();
ASSERT_TRUE(device_status_.has_running_kiosk_app());
const em::AppStatus app = device_status_.running_kiosk_app();
EXPECT_EQ(kArcKioskPackageName, app.app_id());
EXPECT_TRUE(app.extension_version().empty());
EXPECT_TRUE(app.required_platform_version().empty());
EXPECT_FALSE(app.has_status());
EXPECT_FALSE(app.has_error());
}
TEST_F(DeviceStatusCollectorTest, ReportRunningWebKioskApp) {
DisableDefaultSettings();
scoped_testing_cros_settings_.device_settings()->SetBoolean(

@ -7,7 +7,6 @@
#include <string_view>
#include "base/time/time.h"
#include "chrome/browser/ash/app_mode/arc/arc_kiosk_app_manager.h"
#include "chrome/browser/ash/app_mode/kiosk_chrome_app_manager.h"
#include "chrome/browser/ash/app_mode/web_app/web_kiosk_app_manager.h"
#include "chrome/browser/ash/policy/core/device_local_account.h"
@ -126,16 +125,12 @@ StatusCollector::GetAutoLaunchedKioskSessionInfo() {
ash::KioskChromeAppManager::Get()->GetApp(account->kiosk_app_id,
&current_app) &&
current_app.was_auto_launched_with_zero_delay;
bool arc_app_auto_launched_with_zero_delay =
ash::ArcKioskAppManager::Get()
->current_app_was_auto_launched_with_zero_delay();
bool web_app_auto_launched_with_zero_delay =
ash::WebKioskAppManager::Get()
->current_app_was_auto_launched_with_zero_delay();
return regular_app_auto_launched_with_zero_delay ||
arc_app_auto_launched_with_zero_delay ||
web_app_auto_launched_with_zero_delay
? std::move(account)
: nullptr;

@ -345,7 +345,6 @@
#include "chrome/browser/ash/account_manager/account_manager_edu_coexistence_controller.h"
#include "chrome/browser/ash/app_list/app_list_syncable_service.h"
#include "chrome/browser/ash/app_list/arc/arc_app_list_prefs.h"
#include "chrome/browser/ash/app_mode/arc/arc_kiosk_app_manager.h"
#include "chrome/browser/ash/app_mode/kiosk_chrome_app_manager.h"
#include "chrome/browser/ash/app_mode/kiosk_cryptohome_remover.h"
#include "chrome/browser/ash/app_mode/kiosk_system_session.h"
@ -1060,6 +1059,7 @@ constexpr char kGlanceablesEnabled[] = "ash.glanceables_enabled";
// Deprecated 05/2024.
// A preference to keep track of the device registered time.
constexpr char kDeviceRegisteredTime[] = "DeviceRegisteredTime";
constexpr char kArcKioskDictionaryName[] = "arc-kiosk";
#endif // BUILDFLAG(IS_CHROMEOS_ASH)
#if !BUILDFLAG(IS_ANDROID)
@ -1209,6 +1209,7 @@ void RegisterLocalStatePrefsForMigration(PrefRegistrySimple* registry) {
// Deprecated 05/2024.
registry->RegisterTimePref(kDeviceRegisteredTime, base::Time());
registry->RegisterDictionaryPref(kArcKioskDictionaryName);
#endif // BUILDFLAG(IS_CHROMEOS_ASH)
// Deprecated 04/2024.
@ -1705,7 +1706,6 @@ void RegisterLocalState(PrefRegistrySimple* registry) {
#if BUILDFLAG(IS_CHROMEOS_ASH)
arc::prefs::RegisterLocalStatePrefs(registry);
ChromeOSMetricsProvider::RegisterPrefs(registry);
ash::ArcKioskAppManager::RegisterPrefs(registry);
ash::AudioDevicesPrefHandlerImpl::RegisterPrefs(registry);
ash::carrier_lock::CarrierLockManager::RegisterLocalPrefs(registry);
ash::cert_provisioning::RegisterLocalStatePrefs(registry);
@ -2468,6 +2468,7 @@ void MigrateObsoleteLocalStatePrefs(PrefService* local_state) {
// Added 05/2024.
local_state->ClearPref(kDeviceRegisteredTime);
local_state->ClearPref(kArcKioskDictionaryName);
#endif // BUILDFLAG(IS_CHROMEOS_ASH)
// Added 04/2024 .

@ -4495,7 +4495,6 @@ if (!is_android) {
"../browser/ash/app_list/search/test/search_results_changed_waiter.h",
"../browser/ash/app_list/search/test/test_continue_files_search_provider.cc",
"../browser/ash/app_list/search/test/test_continue_files_search_provider.h",
"../browser/ash/app_mode/arc/arc_kiosk_app_manager_browsertest.cc",
"../browser/ash/app_mode/auto_sleep/device_weekly_scheduled_suspend_controller_browsertest.cc",
"../browser/ash/app_mode/kiosk_app_update_service_browsertest.cc",
"../browser/ash/app_mode/kiosk_chrome_app_manager_browsertest.cc",