Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5360)

Unified Diff: chrome/browser/chromeos/app_mode/arc/arc_kiosk_app_service.cc

Issue 2524673003: arc: Stop/start ARC++ kiosk app when maintenance session started/finished. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/app_mode/arc/arc_kiosk_app_service.cc
diff --git a/chrome/browser/chromeos/app_mode/arc/arc_kiosk_app_service.cc b/chrome/browser/chromeos/app_mode/arc/arc_kiosk_app_service.cc
index 3e54f436ce08f75489b8ed750b4eb85ced66871b..c98036fd6fe916b0500cef23cfaf80c6ad6aecb3 100644
--- a/chrome/browser/chromeos/app_mode/arc/arc_kiosk_app_service.cc
+++ b/chrome/browser/chromeos/app_mode/arc/arc_kiosk_app_service.cc
@@ -15,9 +15,8 @@
namespace chromeos {
// static
-ArcKioskAppService* ArcKioskAppService::Create(Profile* profile,
- ArcAppListPrefs* prefs) {
- return new ArcKioskAppService(profile, prefs);
+ArcKioskAppService* ArcKioskAppService::Create(Profile* profile) {
+ return new ArcKioskAppService(profile);
}
// static
@@ -25,6 +24,11 @@ ArcKioskAppService* ArcKioskAppService::Get(content::BrowserContext* context) {
return ArcKioskAppServiceFactory::GetForBrowserContext(context);
}
+void ArcKioskAppService::Shutdown() {
+ ArcAppListPrefs::Get(profile_)->RemoveObserver(this);
+ app_manager_->RemoveObserver(this);
+}
+
void ArcKioskAppService::OnAppRegistered(
const std::string& app_id,
const ArcAppListPrefs::AppInfo& app_info) {
@@ -62,14 +66,21 @@ void ArcKioskAppService::OnTaskDestroyed(int32_t task_id) {
}
}
-ArcKioskAppService::ArcKioskAppService(Profile* profile, ArcAppListPrefs* prefs)
- : profile_(profile), prefs_(prefs) {
- if (prefs_)
- prefs_->AddObserver(this);
+void ArcKioskAppService::OnMaintenanceSessionCreated() {
+ maintenance_session_running_ = true;
+ PreconditionsChanged();
+}
+
+void ArcKioskAppService::OnMaintenanceSessionFinished() {
+ maintenance_session_running_ = false;
+ PreconditionsChanged();
+}
+
+ArcKioskAppService::ArcKioskAppService(Profile* profile) : profile_(profile) {
+ ArcAppListPrefs::Get(profile_)->AddObserver(this);
app_manager_ = ArcKioskAppManager::Get();
- if (app_manager_) {
- app_manager_->AddObserver(this);
- }
+ DCHECK(app_manager_);
+ app_manager_->AddObserver(this);
pref_change_registrar_.reset(new PrefChangeRegistrar());
pref_change_registrar_->Init(profile_->GetPrefs());
// Try to start/stop kiosk app on policy compliance state change.
@@ -80,22 +91,19 @@ ArcKioskAppService::ArcKioskAppService(Profile* profile, ArcAppListPrefs* prefs)
PreconditionsChanged();
}
-ArcKioskAppService::~ArcKioskAppService() {
- if (prefs_)
- prefs_->RemoveObserver(this);
- if (app_manager_)
- app_manager_->RemoveObserver(this);
-}
+ArcKioskAppService::~ArcKioskAppService() = default;
void ArcKioskAppService::PreconditionsChanged() {
app_id_ = GetAppId();
if (app_id_.empty())
return;
- app_info_ = prefs_->GetApp(app_id_);
+ app_info_ = ArcAppListPrefs::Get(profile_)->GetApp(app_id_);
if (app_info_ && app_info_->ready &&
- profile_->GetPrefs()->GetBoolean(prefs::kArcPolicyCompliant)) {
+ profile_->GetPrefs()->GetBoolean(prefs::kArcPolicyCompliant) &&
+ !maintenance_session_running_) {
if (!app_launcher_)
- app_launcher_.reset(new ArcKioskAppLauncher(profile_, prefs_, app_id_));
+ app_launcher_.reset(new ArcKioskAppLauncher(
+ profile_, ArcAppListPrefs::Get(profile_), app_id_));
} else if (task_id_ != -1) {
arc::CloseTask(task_id_);
}
@@ -108,7 +116,8 @@ std::string ArcKioskAppService::GetAppId() {
if (!app)
return std::string();
std::unordered_set<std::string> app_ids =
- prefs_->GetAppsForPackage(app->app_info().package_name());
+ ArcAppListPrefs::Get(profile_)->GetAppsForPackage(
+ app->app_info().package_name());
if (app_ids.empty())
return std::string();
// TODO(poromov@): Choose appropriate app id to launch. See

Powered by Google App Engine
This is Rietveld 408576698