| OLD | NEW |
| (Empty) |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 #include "chromeos/login/user_names.h" | |
| 5 | |
| 6 #include "base/macros.h" | |
| 7 #include "base/memory/singleton.h" | |
| 8 #include "components/signin/core/account_id/account_id.h" | |
| 9 #include "google_apis/gaia/gaia_auth_util.h" | |
| 10 | |
| 11 class AccountId; | |
| 12 | |
| 13 namespace { | |
| 14 | |
| 15 // Username for Demo session user. | |
| 16 constexpr const char kDemoUserName[] = "demouser@demo.app.local"; | |
| 17 | |
| 18 // Username for Signin account id. | |
| 19 constexpr const char kSignInUser[] = "sign-in-user-id"; | |
| 20 | |
| 21 // This is a singleton object that is used to store several | |
| 22 // global AccountIds for special accounts. | |
| 23 class FixedAccountManager { | |
| 24 public: | |
| 25 static FixedAccountManager* GetInstance() { | |
| 26 return base::Singleton<FixedAccountManager>::get(); | |
| 27 } | |
| 28 | |
| 29 const AccountId& stub_account_id() const { return stub_account_id_; } | |
| 30 const AccountId& signin_account_id() const { return signin_account_id_; } | |
| 31 const AccountId& guest_account_id() const { return guest_account_id_; } | |
| 32 const AccountId& demo_account_id() const { return demo_account_id_; } | |
| 33 | |
| 34 private: | |
| 35 friend struct base::DefaultSingletonTraits<FixedAccountManager>; | |
| 36 | |
| 37 FixedAccountManager(); | |
| 38 | |
| 39 const AccountId stub_account_id_; | |
| 40 const AccountId signin_account_id_; | |
| 41 const AccountId guest_account_id_; | |
| 42 const AccountId demo_account_id_; | |
| 43 | |
| 44 DISALLOW_COPY_AND_ASSIGN(FixedAccountManager); | |
| 45 }; | |
| 46 | |
| 47 FixedAccountManager::FixedAccountManager() | |
| 48 : stub_account_id_(AccountId::FromUserEmail(chromeos::login::kStubUser)), | |
| 49 signin_account_id_(AccountId::FromUserEmail(kSignInUser)), | |
| 50 guest_account_id_( | |
| 51 AccountId::FromUserEmail(chromeos::login::kGuestUserName)), | |
| 52 demo_account_id_(AccountId::FromUserEmail(kDemoUserName)) {} | |
| 53 | |
| 54 } // namespace | |
| 55 | |
| 56 namespace chromeos { | |
| 57 | |
| 58 namespace login { | |
| 59 | |
| 60 constexpr const char kStubUser[] = "stub-user@example.com"; | |
| 61 | |
| 62 // Should match cros constant in platform/libchromeos/chromeos/cryptohome.h | |
| 63 constexpr const char kGuestUserName[] = "$guest"; | |
| 64 | |
| 65 constexpr const char kSupervisedUserDomain[] = "locally-managed.localhost"; | |
| 66 | |
| 67 std::string CanonicalizeUserID(const std::string& user_id) { | |
| 68 if (user_id == chromeos::login::kGuestUserName) | |
| 69 return user_id; | |
| 70 return gaia::CanonicalizeEmail(user_id); | |
| 71 } | |
| 72 | |
| 73 const AccountId& StubAccountId() { | |
| 74 return FixedAccountManager::GetInstance()->stub_account_id(); | |
| 75 } | |
| 76 | |
| 77 const AccountId& SignInAccountId() { | |
| 78 return FixedAccountManager::GetInstance()->signin_account_id(); | |
| 79 } | |
| 80 | |
| 81 const AccountId& GuestAccountId() { | |
| 82 return FixedAccountManager::GetInstance()->guest_account_id(); | |
| 83 } | |
| 84 | |
| 85 const AccountId& DemoAccountId() { | |
| 86 return FixedAccountManager::GetInstance()->demo_account_id(); | |
| 87 } | |
| 88 | |
| 89 } // namespace login | |
| 90 | |
| 91 } // namespace chromeos | |
| OLD | NEW |