OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/kiosk_app_manager.h" | 5 #include "chrome/browser/chromeos/app_mode/kiosk_app_manager.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 it->kiosk_app_id == app_id) { | 262 it->kiosk_app_id == app_id) { |
263 device_local_accounts.erase(it); | 263 device_local_accounts.erase(it); |
264 break; | 264 break; |
265 } | 265 } |
266 } | 266 } |
267 | 267 |
268 policy::SetDeviceLocalAccounts(CrosSettings::Get(), device_local_accounts); | 268 policy::SetDeviceLocalAccounts(CrosSettings::Get(), device_local_accounts); |
269 } | 269 } |
270 | 270 |
271 void KioskAppManager::GetApps(Apps* apps) const { | 271 void KioskAppManager::GetApps(Apps* apps) const { |
| 272 apps->clear(); |
272 apps->reserve(apps_.size()); | 273 apps->reserve(apps_.size()); |
273 for (size_t i = 0; i < apps_.size(); ++i) | 274 for (size_t i = 0; i < apps_.size(); ++i) |
274 apps->push_back(App(*apps_[i])); | 275 apps->push_back(App(*apps_[i])); |
275 } | 276 } |
276 | 277 |
277 bool KioskAppManager::GetApp(const std::string& app_id, App* app) const { | 278 bool KioskAppManager::GetApp(const std::string& app_id, App* app) const { |
278 const KioskAppData* data = GetAppData(app_id); | 279 const KioskAppData* data = GetAppData(app_id); |
279 if (!data) | 280 if (!data) |
280 return false; | 281 return false; |
281 | 282 |
(...skipping 13 matching lines...) Expand all Loading... |
295 bool KioskAppManager::GetDisableBailoutShortcut() const { | 296 bool KioskAppManager::GetDisableBailoutShortcut() const { |
296 bool enable; | 297 bool enable; |
297 if (CrosSettings::Get()->GetBoolean( | 298 if (CrosSettings::Get()->GetBoolean( |
298 kAccountsPrefDeviceLocalAccountAutoLoginBailoutEnabled, &enable)) { | 299 kAccountsPrefDeviceLocalAccountAutoLoginBailoutEnabled, &enable)) { |
299 return !enable; | 300 return !enable; |
300 } | 301 } |
301 | 302 |
302 return false; | 303 return false; |
303 } | 304 } |
304 | 305 |
| 306 void KioskAppManager::ClearAppData(const std::string& app_id) { |
| 307 KioskAppData* app_data = GetAppDataMutable(app_id); |
| 308 if (!app_data) |
| 309 return; |
| 310 |
| 311 app_data->ClearCache(); |
| 312 } |
| 313 |
| 314 void KioskAppManager::UpdateAppDataFromProfile( |
| 315 const std::string& app_id, |
| 316 Profile* profile, |
| 317 const extensions::Extension* app) { |
| 318 KioskAppData* app_data = GetAppDataMutable(app_id); |
| 319 if (!app_data) |
| 320 return; |
| 321 |
| 322 app_data->LoadFromInstalledApp(profile, app); |
| 323 } |
| 324 |
305 void KioskAppManager::AddObserver(KioskAppManagerObserver* observer) { | 325 void KioskAppManager::AddObserver(KioskAppManagerObserver* observer) { |
306 observers_.AddObserver(observer); | 326 observers_.AddObserver(observer); |
307 } | 327 } |
308 | 328 |
309 void KioskAppManager::RemoveObserver(KioskAppManagerObserver* observer) { | 329 void KioskAppManager::RemoveObserver(KioskAppManagerObserver* observer) { |
310 observers_.RemoveObserver(observer); | 330 observers_.RemoveObserver(observer); |
311 } | 331 } |
312 | 332 |
313 KioskAppManager::KioskAppManager() : ownership_established_(false) { | 333 KioskAppManager::KioskAppManager() : ownership_established_(false) { |
314 UpdateAppData(); | 334 UpdateAppData(); |
(...skipping 19 matching lines...) Expand all Loading... |
334 const std::string& app_id) const { | 354 const std::string& app_id) const { |
335 for (size_t i = 0; i < apps_.size(); ++i) { | 355 for (size_t i = 0; i < apps_.size(); ++i) { |
336 const KioskAppData* data = apps_[i]; | 356 const KioskAppData* data = apps_[i]; |
337 if (data->app_id() == app_id) | 357 if (data->app_id() == app_id) |
338 return data; | 358 return data; |
339 } | 359 } |
340 | 360 |
341 return NULL; | 361 return NULL; |
342 } | 362 } |
343 | 363 |
| 364 KioskAppData* KioskAppManager::GetAppDataMutable(const std::string& app_id) { |
| 365 return const_cast<KioskAppData*>(GetAppData(app_id)); |
| 366 } |
| 367 |
344 void KioskAppManager::UpdateAppData() { | 368 void KioskAppManager::UpdateAppData() { |
345 // Gets app id to data mapping for existing apps. | 369 // Gets app id to data mapping for existing apps. |
346 std::map<std::string, KioskAppData*> old_apps; | 370 std::map<std::string, KioskAppData*> old_apps; |
347 for (size_t i = 0; i < apps_.size(); ++i) | 371 for (size_t i = 0; i < apps_.size(); ++i) |
348 old_apps[apps_[i]->app_id()] = apps_[i]; | 372 old_apps[apps_[i]->app_id()] = apps_[i]; |
349 apps_.weak_clear(); // |old_apps| takes ownership | 373 apps_.weak_clear(); // |old_apps| takes ownership |
350 | 374 |
351 auto_launch_app_id_.clear(); | 375 auto_launch_app_id_.clear(); |
352 std::string auto_login_account_id; | 376 std::string auto_login_account_id; |
353 CrosSettings::Get()->GetString(kAccountsPrefDeviceLocalAccountAutoLoginId, | 377 CrosSettings::Get()->GetString(kAccountsPrefDeviceLocalAccountAutoLoginId, |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
426 | 450 |
427 void KioskAppManager::SetAutoLoginState(AutoLoginState state) { | 451 void KioskAppManager::SetAutoLoginState(AutoLoginState state) { |
428 PrefService* prefs = g_browser_process->local_state(); | 452 PrefService* prefs = g_browser_process->local_state(); |
429 DictionaryPrefUpdate dict_update(prefs, | 453 DictionaryPrefUpdate dict_update(prefs, |
430 KioskAppManager::kKioskDictionaryName); | 454 KioskAppManager::kKioskDictionaryName); |
431 dict_update->SetInteger(kKeyAutoLoginState, state); | 455 dict_update->SetInteger(kKeyAutoLoginState, state); |
432 prefs->CommitPendingWrite(); | 456 prefs->CommitPendingWrite(); |
433 } | 457 } |
434 | 458 |
435 } // namespace chromeos | 459 } // namespace chromeos |
OLD | NEW |