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

Side by Side Diff: chrome/browser/chromeos/app_mode/arc/arc_kiosk_app_service.cc

Issue 2809773004: Wait for compliance report to start ARC Kiosk app. (Closed)
Patch Set: small comment update Created 3 years, 8 months 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 unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/chromeos/arc/policy/arc_policy_bridge.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <chrome/browser/chromeos/app_mode/arc/arc_kiosk_app_service.h> 5 #include <chrome/browser/chromeos/app_mode/arc/arc_kiosk_app_service.h>
6 6
7 #include "base/time/time.h" 7 #include "base/time/time.h"
8 #include "chrome/browser/chromeos/app_mode/arc/arc_kiosk_app_service_factory.h" 8 #include "chrome/browser/chromeos/app_mode/arc/arc_kiosk_app_service_factory.h"
9 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/profiles/profile_manager.h" 10 #include "chrome/browser/profiles/profile_manager.h"
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 delegate_->OnAppWindowLaunched(); 134 delegate_->OnAppWindowLaunched();
135 } 135 }
136 136
137 ArcKioskAppService::ArcKioskAppService(Profile* profile) : profile_(profile) { 137 ArcKioskAppService::ArcKioskAppService(Profile* profile) : profile_(profile) {
138 ArcAppListPrefs::Get(profile_)->AddObserver(this); 138 ArcAppListPrefs::Get(profile_)->AddObserver(this);
139 app_manager_ = ArcKioskAppManager::Get(); 139 app_manager_ = ArcKioskAppManager::Get();
140 DCHECK(app_manager_); 140 DCHECK(app_manager_);
141 app_manager_->AddObserver(this); 141 app_manager_->AddObserver(this);
142 pref_change_registrar_.reset(new PrefChangeRegistrar()); 142 pref_change_registrar_.reset(new PrefChangeRegistrar());
143 pref_change_registrar_->Init(profile_->GetPrefs()); 143 pref_change_registrar_->Init(profile_->GetPrefs());
144 // Kiosk app can be started only when policy compliance is reported.
145 pref_change_registrar_->Add(
146 prefs::kArcPolicyComplianceReported,
147 base::Bind(&ArcKioskAppService::PreconditionsChanged,
148 base::Unretained(this)));
144 notification_blocker_.reset(new ArcKioskNotificationBlocker()); 149 notification_blocker_.reset(new ArcKioskNotificationBlocker());
145 PreconditionsChanged(); 150 PreconditionsChanged();
146 } 151 }
147 152
148 ArcKioskAppService::~ArcKioskAppService() { 153 ArcKioskAppService::~ArcKioskAppService() {
149 maintenance_timeout_timer_.Stop(); 154 maintenance_timeout_timer_.Stop();
150 } 155 }
151 156
152 void ArcKioskAppService::PreconditionsChanged() { 157 void ArcKioskAppService::PreconditionsChanged() {
153 VLOG(2) << "Preconditions for kiosk app changed"; 158 VLOG(2) << "Preconditions for kiosk app changed";
154 app_id_ = GetAppId(); 159 app_id_ = GetAppId();
155 if (app_id_.empty()) { 160 if (app_id_.empty()) {
156 VLOG(2) << "Kiosk app is not available"; 161 VLOG(2) << "Kiosk app is not available";
157 return; 162 return;
158 } 163 }
159 app_info_ = ArcAppListPrefs::Get(profile_)->GetApp(app_id_); 164 app_info_ = ArcAppListPrefs::Get(profile_)->GetApp(app_id_);
160 VLOG_IF(2, app_info_ && app_info_->ready) << "Kiosk app is ready"; 165 VLOG_IF(2, app_info_ && app_info_->ready) << "Kiosk app is ready";
161 VLOG(2) << "Maintenance session is " 166 VLOG(2) << "Maintenance session is "
162 << (maintenance_session_running_ ? "running" : "not running"); 167 << (maintenance_session_running_ ? "running" : "not running");
168 VLOG(2) << "Policy compliance is "
169 << (profile_->GetPrefs()->GetBoolean(
170 prefs::kArcPolicyComplianceReported)
171 ? "reported"
172 : "not yet reported");
163 VLOG(2) << "Kiosk app with id: " << app_id_ << " is " 173 VLOG(2) << "Kiosk app with id: " << app_id_ << " is "
164 << (app_launcher_ ? "already launched" : "not yet launched"); 174 << (app_launcher_ ? "already launched" : "not yet launched");
165 if (app_info_ && app_info_->ready && !maintenance_session_running_) { 175 if (app_info_ && app_info_->ready && !maintenance_session_running_ &&
176 profile_->GetPrefs()->GetBoolean(prefs::kArcPolicyComplianceReported)) {
166 if (!app_launcher_) { 177 if (!app_launcher_) {
167 VLOG(2) << "Starting kiosk app"; 178 VLOG(2) << "Starting kiosk app";
168 app_launcher_ = base::MakeUnique<ArcKioskAppLauncher>( 179 app_launcher_ = base::MakeUnique<ArcKioskAppLauncher>(
169 profile_, ArcAppListPrefs::Get(profile_), app_id_, this); 180 profile_, ArcAppListPrefs::Get(profile_), app_id_, this);
170 } 181 }
171 } else if (task_id_ != -1) { 182 } else if (task_id_ != -1) {
172 VLOG(2) << "Kiosk app should be closed"; 183 VLOG(2) << "Kiosk app should be closed";
173 arc::CloseTask(task_id_); 184 arc::CloseTask(task_id_);
174 } 185 }
175 } 186 }
176 187
177 std::string ArcKioskAppService::GetAppId() { 188 std::string ArcKioskAppService::GetAppId() {
178 AccountId account_id = multi_user_util::GetAccountIdFromProfile(profile_); 189 AccountId account_id = multi_user_util::GetAccountIdFromProfile(profile_);
179 const ArcKioskAppManager::ArcKioskApp* app = 190 const ArcKioskAppManager::ArcKioskApp* app =
180 app_manager_->GetAppByAccountId(account_id); 191 app_manager_->GetAppByAccountId(account_id);
181 if (!app) 192 if (!app)
182 return std::string(); 193 return std::string();
183 std::unordered_set<std::string> app_ids = 194 std::unordered_set<std::string> app_ids =
184 ArcAppListPrefs::Get(profile_)->GetAppsForPackage( 195 ArcAppListPrefs::Get(profile_)->GetAppsForPackage(
185 app->app_info().package_name()); 196 app->app_info().package_name());
186 if (app_ids.empty()) 197 if (app_ids.empty())
187 return std::string(); 198 return std::string();
188 // TODO(poromov@): Choose appropriate app id to launch. See 199 // TODO(poromov@): Choose appropriate app id to launch. See
189 // http://crbug.com/665904 200 // http://crbug.com/665904
190 return std::string(*app_ids.begin()); 201 return std::string(*app_ids.begin());
191 } 202 }
192 203
193 } // namespace chromeos 204 } // namespace chromeos
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/chromeos/arc/policy/arc_policy_bridge.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698