Index: chrome/browser/chromeos/app_mode/arc/arc_kiosk_app_manager.cc |
diff --git a/chrome/browser/chromeos/app_mode/arc/arc_kiosk_app_manager.cc b/chrome/browser/chromeos/app_mode/arc/arc_kiosk_app_manager.cc |
index 6a4426ea7a5be3a2e8fee456f7be471bdda4f49e..6687d28f742a760c27a6597ebf6f8b1b301da10d 100644 |
--- a/chrome/browser/chromeos/app_mode/arc/arc_kiosk_app_manager.cc |
+++ b/chrome/browser/chromeos/app_mode/arc/arc_kiosk_app_manager.cc |
@@ -12,7 +12,6 @@ |
#include "base/bind_helpers.h" |
#include "base/callback.h" |
#include "base/logging.h" |
-#include "base/memory/ptr_util.h" |
#include "base/values.h" |
#include "chrome/browser/browser_process.h" |
#include "chrome/browser/lifetime/application_lifetime.h" |
@@ -97,11 +96,7 @@ |
} // namespace |
// static |
-const char ArcKioskAppManager::kArcKioskDictionaryName[] = "arc-kiosk"; |
- |
-// static |
void ArcKioskAppManager::RegisterPrefs(PrefRegistrySimple* registry) { |
- registry->RegisterDictionaryPref(kArcKioskDictionaryName); |
registry->RegisterListPref(kArcKioskUsersToRemove); |
} |
@@ -111,6 +106,22 @@ |
chromeos::DBusThreadManager::Get()->GetCryptohomeClient(); |
client->WaitForServiceToBeAvailable( |
base::Bind(&PerformDelayedCryptohomeRemovals)); |
+} |
+ |
+ArcKioskAppManager::ArcKioskApp::ArcKioskApp(const ArcKioskApp& other) = |
+ default; |
+ |
+ArcKioskAppManager::ArcKioskApp::ArcKioskApp( |
+ const policy::ArcKioskAppBasicInfo& app_info, |
+ const AccountId& account_id, |
+ const std::string& name) |
+ : app_info_(app_info), account_id_(account_id), name_(name) {} |
+ |
+ArcKioskAppManager::ArcKioskApp::~ArcKioskApp() = default; |
+ |
+bool ArcKioskAppManager::ArcKioskApp::operator==( |
+ const policy::ArcKioskAppBasicInfo& app_info) const { |
+ return this->app_info_ == app_info; |
} |
// static |
@@ -143,31 +154,12 @@ |
return auto_launch_account_id_; |
} |
-const ArcKioskAppData* ArcKioskAppManager::GetAppByAccountId( |
+const ArcKioskAppManager::ArcKioskApp* ArcKioskAppManager::GetAppByAccountId( |
const AccountId& account_id) { |
- for (auto& app : apps_) { |
- if (app->account_id() == account_id) |
- return app.get(); |
- } |
+ for (auto& app : GetAllApps()) |
+ if (app.account_id() == account_id) |
+ return &app; |
return nullptr; |
-} |
- |
-void ArcKioskAppManager::GetAllApps(Apps* apps) const { |
- apps->clear(); |
- apps->reserve(apps_.size()); |
- for (auto& app : apps_) |
- apps->push_back(app.get()); |
-} |
- |
-void ArcKioskAppManager::UpdateNameAndIcon(const std::string& app_id, |
- const std::string& name, |
- const gfx::ImageSkia& icon) { |
- for (auto& app : apps_) { |
- if (app->app_id() == app_id) { |
- app->SetCache(name, icon); |
- return; |
- } |
- } |
} |
void ArcKioskAppManager::AddObserver(ArcKioskAppManagerObserver* observer) { |
@@ -189,10 +181,8 @@ |
// 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(); |
+ ArcKioskApps old_apps(std::move(apps_)); |
+ |
auto_launch_account_id_.clear(); |
auto_launched_with_zero_delay_ = false; |
std::string auto_login_account_id_from_settings; |
@@ -216,19 +206,18 @@ |
auto_launched_with_zero_delay_ = auto_launch_delay == 0; |
} |
- // Apps are keyed by package name. http://crbug.com/665904 |
- auto old_it = old_apps.find(account.arc_kiosk_app_info.package_name()); |
+ auto old_it = |
+ std::find(old_apps.begin(), old_apps.end(), account.arc_kiosk_app_info); |
if (old_it != old_apps.end()) { |
- apps_.push_back(std::move(old_it->second)); |
+ apps_.push_back(std::move(*old_it)); |
old_apps.erase(old_it); |
} else { |
// Use package name when display name is not specified. |
std::string name = account.arc_kiosk_app_info.package_name(); |
if (!account.arc_kiosk_app_info.display_name().empty()) |
name = account.arc_kiosk_app_info.display_name(); |
- apps_.push_back(base::MakeUnique<ArcKioskAppData>( |
- account.arc_kiosk_app_info.package_name(), account_id, name)); |
- apps_.back()->LoadFromCache(); |
+ apps_.push_back( |
+ ArcKioskApp(account.arc_kiosk_app_info, account_id, name)); |
} |
CancelDelayedCryptohomeRemoval(cryptohome::Identification(account_id)); |
} |
@@ -241,7 +230,7 @@ |
} |
void ArcKioskAppManager::ClearRemovedApps( |
- const std::map<std::string, std::unique_ptr<ArcKioskAppData>>& old_apps) { |
+ const std::vector<ArcKioskApp>& old_apps) { |
// Check if currently active user must be deleted. |
bool active_user_to_be_deleted = false; |
const user_manager::User* active_user = |
@@ -249,7 +238,7 @@ |
if (active_user) { |
const AccountId active_account_id = active_user->GetAccountId(); |
for (const auto& it : old_apps) { |
- if (it.second->account_id() == active_account_id) { |
+ if (it.account_id() == active_account_id) { |
active_user_to_be_deleted = true; |
break; |
} |
@@ -258,8 +247,7 @@ |
// Remove cryptohome |
for (auto& entry : old_apps) { |
- entry.second->ClearCache(); |
- const cryptohome::Identification cryptohome_id(entry.second->account_id()); |
+ const cryptohome::Identification cryptohome_id(entry.account_id()); |
if (active_user_to_be_deleted) { |
// Schedule cryptohome removal after active user logout. |
ScheduleDelayedCryptohomeRemoval(cryptohome_id); |