Chromium Code Reviews| Index: chrome/browser/chromeos/app_mode/kiosk_app_launcher.cc |
| diff --git a/chrome/browser/chromeos/app_mode/kiosk_app_launcher.cc b/chrome/browser/chromeos/app_mode/kiosk_app_launcher.cc |
| index f5a760a82d62f08af34b4039062e2f560c123ca6..00c279b594cadf8eef3492d0709a60042be5bf35 100644 |
| --- a/chrome/browser/chromeos/app_mode/kiosk_app_launcher.cc |
| +++ b/chrome/browser/chromeos/app_mode/kiosk_app_launcher.cc |
| @@ -4,6 +4,8 @@ |
| #include "chrome/browser/chromeos/app_mode/kiosk_app_launcher.h" |
| +#include <vector> |
| + |
| #include "base/chromeos/chromeos_version.h" |
| #include "base/logging.h" |
| #include "base/memory/weak_ptr.h" |
| @@ -12,6 +14,8 @@ |
| #include "chrome/browser/chromeos/login/login_display_host_impl.h" |
| #include "chrome/browser/chromeos/login/login_utils.h" |
| #include "chrome/browser/chromeos/login/user_manager.h" |
| +#include "chrome/browser/chromeos/policy/device_local_account.h" |
| +#include "chrome/browser/chromeos/settings/cros_settings.h" |
| #include "chrome/browser/chromeos/ui/app_launch_view.h" |
| #include "chrome/browser/lifetime/application_lifetime.h" |
| #include "chromeos/cryptohome/async_method_caller.h" |
| @@ -26,10 +30,6 @@ namespace chromeos { |
| namespace { |
| -std::string GetAppUserNameFromAppId(const std::string& app_id) { |
| - return app_id + "@" + UserManager::kKioskAppUserDomain; |
| -} |
| - |
| } // namespace |
| // static |
| @@ -114,8 +114,20 @@ class KioskAppLauncher::ProfileLoader : public LoginUtils::Delegate { |
| } |
| void Start() { |
| + const std::vector<policy::DeviceLocalAccount> device_local_accounts = |
|
Mattias Nissler (ping if slow)
2013/05/17 14:29:44
We might better go through KioskAppManager to find
xiyuan
2013/05/17 15:46:52
Let's add a new method to KioskAppManager and move
bartfab (slow)
2013/05/17 16:08:47
Done.
I reused the existing KioskAppManager::GetA
|
| + policy::GetDeviceLocalAccounts(CrosSettings::Get()); |
| + for (std::vector<policy::DeviceLocalAccount>::const_iterator |
| + it = device_local_accounts.begin(); |
| + it != device_local_accounts.end(); ++it) { |
| + if (it->type == policy::DeviceLocalAccount::TYPE_KIOSK_APP && |
| + it->kiosk_app_id == launcher_->app_id_) { |
| + user_id_ = it->user_id; |
| + break; |
| + } |
| + } |
| + |
| cryptohome::AsyncMethodCaller::GetInstance()->AsyncGetSanitizedUsername( |
| - GetAppUserNameFromAppId(launcher_->app_id_), |
| + user_id_, |
| base::Bind(&ProfileLoader::OnUsernameHashRetrieved, |
| base::Unretained(this))); |
| } |
| @@ -124,14 +136,14 @@ class KioskAppLauncher::ProfileLoader : public LoginUtils::Delegate { |
| void OnUsernameHashRetrieved(bool success, |
| const std::string& username_hash) { |
| if (!success) { |
| - LOG(ERROR) << "Unable to retrieve username hash for user '" << |
| - GetAppUserNameFromAppId(launcher_->app_id_) << "'"; |
| + LOG(ERROR) << "Unable to retrieve username hash for user '" << user_id_ |
| + << "'."; |
|
xiyuan
2013/05/17 15:46:52
nit: think "'" is more correct since we have an op
bartfab (slow)
2013/05/17 16:08:47
It is a single quote already - this is probably ha
|
| launcher_->ReportLaunchResult( |
| KioskAppLaunchError::UNABLE_TO_RETRIEVE_HASH); |
| return; |
| } |
| LoginUtils::Get()->PrepareProfile( |
| - UserContext(GetAppUserNameFromAppId(launcher_->app_id_), |
| + UserContext(user_id_, |
| std::string(), // password |
| std::string(), // auth_code |
| username_hash), |
| @@ -147,6 +159,8 @@ class KioskAppLauncher::ProfileLoader : public LoginUtils::Delegate { |
| } |
| KioskAppLauncher* launcher_; |
| + std::string user_id_; |
| + |
| DISALLOW_COPY_AND_ASSIGN(ProfileLoader); |
| }; |