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

Unified Diff: chrome/browser/chromeos/policy/device_local_account.cc

Issue 24261010: Allow explicitly whitelisted apps/extensions in public sessions (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix handing of guest user ID. Created 7 years, 2 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 side-by-side diff with in-line comments
Download patch
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(

Powered by Google App Engine
This is Rietveld 408576698