Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / chrome / browser / chromeos / login / users / fake_chrome_user_manager.h
blob238f21c973e27a064968089d517f96ad8b4ffd76
1 // Copyright 2015 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.
5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_USERS_FAKE_CHROME_USER_MANAGER_H_
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_USERS_FAKE_CHROME_USER_MANAGER_H_
8 #include <map>
9 #include <string>
11 #include "base/memory/scoped_ptr.h"
12 #include "chrome/browser/chromeos/login/user_flow.h"
13 #include "chrome/browser/chromeos/login/users/user_manager_interface.h"
14 #include "components/user_manager/fake_user_manager.h"
15 #include "components/user_manager/user.h"
16 #include "components/user_manager/user_image/user_image.h"
17 #include "components/user_manager/user_manager_base.h"
19 namespace chromeos {
21 class FakeSupervisedUserManager;
23 // Fake chrome user manager with a barebones implementation. Users can be added
24 // and set as logged in, and those users can be returned.
25 class FakeChromeUserManager : public user_manager::FakeUserManager,
26 public UserManagerInterface {
27 public:
28 FakeChromeUserManager();
29 ~FakeChromeUserManager() override;
31 // Create and add a kiosk app user.
32 void AddKioskAppUser(const std::string& kiosk_app_username);
34 // Create and add a public account user.
35 const user_manager::User* AddPublicAccountUser(const std::string& email);
37 // Calculates the user name hash and calls UserLoggedIn to login a user.
38 void LoginUser(const std::string& email);
40 // UserManager overrides.
41 user_manager::UserList GetUsersAllowedForMultiProfile() const override;
43 // user_manager::FakeUserManager override.
44 const user_manager::User* AddUser(const std::string& email) override;
46 // UserManagerInterface implementation.
47 BootstrapManager* GetBootstrapManager() override;
48 MultiProfileUserController* GetMultiProfileUserController() override;
49 UserImageManager* GetUserImageManager(const std::string& user_id) override;
50 SupervisedUserManager* GetSupervisedUserManager() override;
51 void SetUserFlow(const std::string& email, UserFlow* flow) override;
52 UserFlow* GetCurrentUserFlow() const override;
53 UserFlow* GetUserFlow(const std::string& email) const override;
54 void ResetUserFlow(const std::string& email) override;
55 user_manager::UserList GetUsersAllowedForSupervisedUsersCreation()
56 const override;
57 void SwitchActiveUser(const std::string& email) override;
58 const std::string& GetOwnerEmail() const override;
59 void SessionStarted() override;
60 void RemoveUser(const std::string& email,
61 user_manager::RemoveUserDelegate* delegate) override;
62 bool FindKnownUserPrefs(const user_manager::UserID& user_id,
63 const base::DictionaryValue** out_value) override;
64 void UpdateKnownUserPrefs(const user_manager::UserID& user_id,
65 const base::DictionaryValue& values,
66 bool clear) override;
68 void set_owner_email(const std::string& owner_email) {
69 owner_email_ = owner_email;
72 void set_bootstrap_manager(BootstrapManager* bootstrap_manager) {
73 bootstrap_manager_ = bootstrap_manager;
76 void set_multi_profile_user_controller(
77 MultiProfileUserController* controller) {
78 multi_profile_user_controller_ = controller;
81 private:
82 // Lazily creates default user flow.
83 UserFlow* GetDefaultUserFlow() const;
85 scoped_ptr<FakeSupervisedUserManager> supervised_user_manager_;
86 std::string owner_email_;
88 BootstrapManager* bootstrap_manager_;
89 MultiProfileUserController* multi_profile_user_controller_;
91 typedef std::map<std::string, UserFlow*> FlowMap;
93 // Lazy-initialized default flow.
94 mutable scoped_ptr<UserFlow> default_flow_;
96 // Specific flows by user e-mail.
97 // Keys should be canonicalized before access.
98 FlowMap specific_flows_;
100 DISALLOW_COPY_AND_ASSIGN(FakeChromeUserManager);
103 } // namespace chromeos
105 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USERS_FAKE_CHROME_USER_MANAGER_H_