Index: chrome/browser/chromeos/policy/device_local_account.cc |
diff --git a/chrome/browser/chromeos/policy/device_local_account.cc b/chrome/browser/chromeos/policy/device_local_account.cc |
index 2ad53ead08d131f0510cff9c9f137c649213851f..a614a9d8705fd11baf3de9b3105ffb07de8d44d0 100644 |
--- a/chrome/browser/chromeos/policy/device_local_account.cc |
+++ b/chrome/browser/chromeos/policy/device_local_account.cc |
@@ -6,11 +6,13 @@ |
#include <set> |
+#include "base/basictypes.h" |
#include "base/logging.h" |
#include "base/memory/scoped_ptr.h" |
#include "base/strings/string_number_conversions.h" |
#include "base/strings/string_util.h" |
#include "base/values.h" |
+#include "chrome/browser/chromeos/login/user_manager.h" |
#include "chrome/browser/chromeos/settings/cros_settings.h" |
#include "chrome/browser/chromeos/settings/cros_settings_names.h" |
#include "google_apis/gaia/gaia_auth_util.h" |
@@ -56,16 +58,35 @@ std::string GenerateDeviceLocalAccountUserId(const std::string& account_id, |
domain_prefix + kDeviceLocalAccountDomainSuffix); |
} |
-bool IsDeviceLocalAccountUser(const std::string& user_id) { |
- return EndsWith(gaia::ExtractDomainName(user_id), |
- kDeviceLocalAccountDomainSuffix, |
- true); |
-} |
+bool IsDeviceLocalAccountUser(const std::string& user_id, |
+ DeviceLocalAccount::Type* type) { |
+ // For historical reasons, the guest user ID does not contain an @ symbol and |
+ // therefore, cannot be parsed by gaia::ExtractDomainName(). |
+ if (user_id == chromeos::UserManager::kGuestUserName) |
+ return false; |
+ const std::string domain = gaia::ExtractDomainName(user_id); |
+ if (!EndsWith(domain, kDeviceLocalAccountDomainSuffix, true)) |
+ return false; |
+ |
+ const std::string domain_prefix = domain.substr( |
+ 0, domain.size() - arraysize(kDeviceLocalAccountDomainSuffix) + 1); |
+ |
+ if (domain_prefix == kPublicAccountDomainPrefix) { |
+ if (type) |
+ *type = DeviceLocalAccount::TYPE_PUBLIC_SESSION; |
+ return true; |
+ } |
+ if (domain_prefix == kKioskAppAccountDomainPrefix) { |
+ if (type) |
+ *type = DeviceLocalAccount::TYPE_KIOSK_APP; |
+ return true; |
+ } |
-bool IsKioskAppUser(const std::string& user_id) { |
- return gaia::ExtractDomainName(user_id) == |
- std::string(kKioskAppAccountDomainPrefix) + |
- kDeviceLocalAccountDomainSuffix; |
+ // |user_id| is a device-local account but its type is not recognized. |
+ NOTREACHED(); |
+ if (type) |
+ *type = DeviceLocalAccount::TYPE_COUNT; |
+ return true; |
} |
void SetDeviceLocalAccounts( |