| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_FAKE_USER_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_FAKE_USER_MANAGER_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_FAKE_USER_MANAGER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_FAKE_USER_MANAGER_H_ |
| 7 | 7 |
| 8 #include <map> |
| 8 #include <string> | 9 #include <string> |
| 9 | 10 |
| 10 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 11 #include "chrome/browser/chromeos/login/user.h" | 12 #include "chrome/browser/chromeos/login/user.h" |
| 12 #include "chrome/browser/chromeos/login/user_flow.h" | 13 #include "chrome/browser/chromeos/login/user_flow.h" |
| 13 #include "chrome/browser/chromeos/login/user_image.h" | 14 #include "chrome/browser/chromeos/login/user_image.h" |
| 14 #include "chrome/browser/chromeos/login/user_manager.h" | 15 #include "chrome/browser/chromeos/login/user_manager.h" |
| 15 | 16 |
| 16 namespace chromeos { | 17 namespace chromeos { |
| 17 | 18 |
| 18 class FakeSupervisedUserManager; | 19 class FakeSupervisedUserManager; |
| 19 | 20 |
| 20 // Fake user manager with a barebones implementation. Users can be added | 21 // Fake user manager with a barebones implementation. Users can be added |
| 21 // and set as logged in, and those users can be returned. | 22 // and set as logged in, and those users can be returned. |
| 22 class FakeUserManager : public UserManager { | 23 class FakeUserManager : public UserManager { |
| 23 public: | 24 public: |
| 24 FakeUserManager(); | 25 FakeUserManager(); |
| 25 virtual ~FakeUserManager(); | 26 virtual ~FakeUserManager(); |
| 26 | 27 |
| 27 // Create and add a new user. | 28 // Create and add a new user. |
| 28 void AddUser(const std::string& email); | 29 const User* AddUser(const std::string& email); |
| 29 | 30 |
| 30 // Create and add a kiosk app user. | 31 // Create and add a kiosk app user. |
| 31 void AddKioskAppUser(const std::string& kiosk_app_username); | 32 void AddKioskAppUser(const std::string& kiosk_app_username); |
| 32 | 33 |
| 33 // Calculates the user name hash and calls UserLoggedIn to login a user. | 34 // Calculates the user name hash and calls UserLoggedIn to login a user. |
| 34 void LoginUser(const std::string& email); | 35 void LoginUser(const std::string& email); |
| 35 | 36 |
| 37 // Associates |profile| with |user|, for GetProfileByUser(). |
| 38 void SetProfileForUser(const User* user, Profile* profile); |
| 39 |
| 36 // UserManager overrides. | 40 // UserManager overrides. |
| 37 virtual const UserList& GetUsers() const OVERRIDE; | 41 virtual const UserList& GetUsers() const OVERRIDE; |
| 38 virtual UserList GetUsersAdmittedForMultiProfile() const OVERRIDE; | 42 virtual UserList GetUsersAdmittedForMultiProfile() const OVERRIDE; |
| 39 virtual const UserList& GetLoggedInUsers() const OVERRIDE; | 43 virtual const UserList& GetLoggedInUsers() const OVERRIDE; |
| 40 | 44 |
| 41 // Set the user as logged in. | 45 // Set the user as logged in. |
| 42 virtual void UserLoggedIn(const std::string& email, | 46 virtual void UserLoggedIn(const std::string& email, |
| 43 const std::string& username_hash, | 47 const std::string& username_hash, |
| 44 bool browser_restart) OVERRIDE; | 48 bool browser_restart) OVERRIDE; |
| 45 | 49 |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 | 133 |
| 130 private: | 134 private: |
| 131 // We use this internal function for const-correctness. | 135 // We use this internal function for const-correctness. |
| 132 User* GetActiveUserInternal() const; | 136 User* GetActiveUserInternal() const; |
| 133 | 137 |
| 134 scoped_ptr<FakeSupervisedUserManager> supervised_user_manager_; | 138 scoped_ptr<FakeSupervisedUserManager> supervised_user_manager_; |
| 135 UserList user_list_; | 139 UserList user_list_; |
| 136 UserList logged_in_users_; | 140 UserList logged_in_users_; |
| 137 std::string owner_email_; | 141 std::string owner_email_; |
| 138 User* primary_user_; | 142 User* primary_user_; |
| 143 std::map<const User*, Profile*> user_to_profile_; |
| 139 | 144 |
| 140 // If set this is the active user. If empty, the first created user is the | 145 // If set this is the active user. If empty, the first created user is the |
| 141 // active user. | 146 // active user. |
| 142 std::string active_user_id_; | 147 std::string active_user_id_; |
| 143 | 148 |
| 144 DISALLOW_COPY_AND_ASSIGN(FakeUserManager); | 149 DISALLOW_COPY_AND_ASSIGN(FakeUserManager); |
| 145 }; | 150 }; |
| 146 | 151 |
| 147 } // namespace chromeos | 152 } // namespace chromeos |
| 148 | 153 |
| 149 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_FAKE_USER_MANAGER_H_ | 154 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_FAKE_USER_MANAGER_H_ |
| OLD | NEW |