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

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: Wait for compliance report to start ARC Kiosk app. 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
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 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 app_icon_->image_skia()); 148 app_icon_->image_skia());
149 } 149 }
150 150
151 ArcKioskAppService::ArcKioskAppService(Profile* profile) : profile_(profile) { 151 ArcKioskAppService::ArcKioskAppService(Profile* profile) : profile_(profile) {
152 ArcAppListPrefs::Get(profile_)->AddObserver(this); 152 ArcAppListPrefs::Get(profile_)->AddObserver(this);
153 app_manager_ = ArcKioskAppManager::Get(); 153 app_manager_ = ArcKioskAppManager::Get();
154 DCHECK(app_manager_); 154 DCHECK(app_manager_);
155 app_manager_->AddObserver(this); 155 app_manager_->AddObserver(this);
156 pref_change_registrar_.reset(new PrefChangeRegistrar()); 156 pref_change_registrar_.reset(new PrefChangeRegistrar());
157 pref_change_registrar_->Init(profile_->GetPrefs()); 157 pref_change_registrar_->Init(profile_->GetPrefs());
158 // Kiosk app can be started only when policy compliance is reported.
159 pref_change_registrar_->Add(
160 prefs::kArcPolicyComplianceReported,
161 base::Bind(&ArcKioskAppService::PreconditionsChanged,
162 base::Unretained(this)));
158 notification_blocker_.reset(new ArcKioskNotificationBlocker()); 163 notification_blocker_.reset(new ArcKioskNotificationBlocker());
159 PreconditionsChanged(); 164 PreconditionsChanged();
160 } 165 }
161 166
162 ArcKioskAppService::~ArcKioskAppService() { 167 ArcKioskAppService::~ArcKioskAppService() {
163 maintenance_timeout_timer_.Stop(); 168 maintenance_timeout_timer_.Stop();
164 } 169 }
165 170
166 void ArcKioskAppService::RequestNameAndIconUpdate() { 171 void ArcKioskAppService::RequestNameAndIconUpdate() {
167 // Request only once when app_icon_ is not initialized. 172 // Request only once when app_icon_ is not initialized.
(...skipping 10 matching lines...) Expand all
178 VLOG(2) << "Preconditions for kiosk app changed"; 183 VLOG(2) << "Preconditions for kiosk app changed";
179 app_id_ = GetAppId(); 184 app_id_ = GetAppId();
180 if (app_id_.empty()) { 185 if (app_id_.empty()) {
181 VLOG(2) << "Kiosk app is not available"; 186 VLOG(2) << "Kiosk app is not available";
182 return; 187 return;
183 } 188 }
184 app_info_ = ArcAppListPrefs::Get(profile_)->GetApp(app_id_); 189 app_info_ = ArcAppListPrefs::Get(profile_)->GetApp(app_id_);
185 VLOG_IF(2, app_info_ && app_info_->ready) << "Kiosk app is ready"; 190 VLOG_IF(2, app_info_ && app_info_->ready) << "Kiosk app is ready";
186 VLOG(2) << "Maintenance session is " 191 VLOG(2) << "Maintenance session is "
187 << (maintenance_session_running_ ? "running" : "not running"); 192 << (maintenance_session_running_ ? "running" : "not running");
193 VLOG(2) << "Policy compliance is "
194 << (profile_->GetPrefs()->GetBoolean(
195 prefs::kArcPolicyComplianceReported)
196 ? "reported"
197 : "not yet reported");
188 VLOG(2) << "Kiosk app with id: " << app_id_ << " is " 198 VLOG(2) << "Kiosk app with id: " << app_id_ << " is "
189 << (app_launcher_ ? "already launched" : "not yet launched"); 199 << (app_launcher_ ? "already launched" : "not yet launched");
190 if (app_info_ && app_info_->ready && !maintenance_session_running_) { 200 if (app_info_ && app_info_->ready && !maintenance_session_running_ &&
201 profile_->GetPrefs()->GetBoolean(prefs::kArcPolicyComplianceReported)) {
191 if (!app_launcher_) { 202 if (!app_launcher_) {
192 VLOG(2) << "Starting kiosk app"; 203 VLOG(2) << "Starting kiosk app";
193 app_launcher_ = base::MakeUnique<ArcKioskAppLauncher>( 204 app_launcher_ = base::MakeUnique<ArcKioskAppLauncher>(
194 profile_, ArcAppListPrefs::Get(profile_), app_id_, this); 205 profile_, ArcAppListPrefs::Get(profile_), app_id_, this);
195 } 206 }
196 } else if (task_id_ != -1) { 207 } else if (task_id_ != -1) {
197 VLOG(2) << "Kiosk app should be closed"; 208 VLOG(2) << "Kiosk app should be closed";
198 arc::CloseTask(task_id_); 209 arc::CloseTask(task_id_);
199 } 210 }
200 RequestNameAndIconUpdate(); 211 RequestNameAndIconUpdate();
201 } 212 }
202 213
203 std::string ArcKioskAppService::GetAppId() { 214 std::string ArcKioskAppService::GetAppId() {
204 AccountId account_id = multi_user_util::GetAccountIdFromProfile(profile_); 215 AccountId account_id = multi_user_util::GetAccountIdFromProfile(profile_);
205 const ArcKioskAppData* app = app_manager_->GetAppByAccountId(account_id); 216 const ArcKioskAppData* app = app_manager_->GetAppByAccountId(account_id);
206 if (!app) 217 if (!app)
207 return std::string(); 218 return std::string();
208 std::unordered_set<std::string> app_ids = 219 std::unordered_set<std::string> app_ids =
209 ArcAppListPrefs::Get(profile_)->GetAppsForPackage(app->app_id()); 220 ArcAppListPrefs::Get(profile_)->GetAppsForPackage(app->app_id());
210 if (app_ids.empty()) 221 if (app_ids.empty())
211 return std::string(); 222 return std::string();
212 // TODO(poromov@): Choose appropriate app id to launch. See 223 // TODO(poromov@): Choose appropriate app id to launch. See
213 // http://crbug.com/665904 224 // http://crbug.com/665904
214 return std::string(*app_ids.begin()); 225 return std::string(*app_ids.begin());
215 } 226 }
216 227
217 } // namespace chromeos 228 } // namespace chromeos
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/chromeos/arc/policy/arc_policy_bridge.h » ('j') | chrome/common/pref_names.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698