Don't preload rarely seen large images
[chromium-blink-merge.git] / components / user_manager / fake_user_manager.h
blobc71df24e80d7f8dad99553027cae51b1d762cf05
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.
5 #ifndef COMPONENTS_USER_MANAGER_FAKE_USER_MANAGER_H_
6 #define COMPONENTS_USER_MANAGER_FAKE_USER_MANAGER_H_
8 #include <map>
9 #include <string>
11 #include "base/memory/scoped_ptr.h"
12 #include "components/user_manager/user.h"
13 #include "components/user_manager/user_manager_base.h"
15 namespace user_manager {
17 // Fake user manager with a barebones implementation. Users can be added
18 // and set as logged in, and those users can be returned.
19 class USER_MANAGER_EXPORT FakeUserManager : public UserManagerBase {
20 public:
21 FakeUserManager();
22 ~FakeUserManager() override;
24 // Create and add a new user.
25 virtual const user_manager::User* AddUser(const std::string& email);
27 // Calculates the user name hash and calls UserLoggedIn to login a user.
28 void LoginUser(const std::string& email);
30 // UserManager overrides.
31 const user_manager::UserList& GetUsers() const override;
32 user_manager::UserList GetUsersAllowedForMultiProfile() const override;
33 const user_manager::UserList& GetLoggedInUsers() const override;
35 // Set the user as logged in.
36 void UserLoggedIn(const std::string& email,
37 const std::string& username_hash,
38 bool browser_restart) override;
40 const user_manager::User* GetActiveUser() const override;
41 user_manager::User* GetActiveUser() override;
42 void SwitchActiveUser(const std::string& email) override;
43 void SaveUserDisplayName(const std::string& username,
44 const base::string16& display_name) override;
46 // Not implemented.
47 void UpdateUserAccountData(const std::string& user_id,
48 const UserAccountData& account_data) override {}
49 void Shutdown() override {}
50 const user_manager::UserList& GetLRULoggedInUsers() const override;
51 user_manager::UserList GetUnlockUsers() const override;
52 const std::string& GetOwnerEmail() const override;
53 void SessionStarted() override {}
54 void RemoveUser(const std::string& email,
55 user_manager::RemoveUserDelegate* delegate) override {}
56 void RemoveUserFromList(const std::string& email) override;
57 bool IsKnownUser(const std::string& email) const override;
58 const user_manager::User* FindUser(const std::string& email) const override;
59 user_manager::User* FindUserAndModify(const std::string& email) override;
60 const user_manager::User* GetLoggedInUser() const override;
61 user_manager::User* GetLoggedInUser() override;
62 const user_manager::User* GetPrimaryUser() const override;
63 void SaveUserOAuthStatus(
64 const std::string& username,
65 user_manager::User::OAuthTokenStatus oauth_token_status) override {}
66 void SaveForceOnlineSignin(const std::string& user_id,
67 bool force_online_signin) override {}
68 base::string16 GetUserDisplayName(const std::string& username) const override;
69 void SaveUserDisplayEmail(const std::string& username,
70 const std::string& display_email) override {}
71 std::string GetUserDisplayEmail(const std::string& username) const override;
72 bool IsCurrentUserOwner() const override;
73 bool IsCurrentUserNew() const override;
74 bool IsCurrentUserNonCryptohomeDataEphemeral() const override;
75 bool CanCurrentUserLock() const override;
76 bool IsUserLoggedIn() const override;
77 bool IsLoggedInAsUserWithGaiaAccount() const override;
78 bool IsLoggedInAsPublicAccount() const override;
79 bool IsLoggedInAsGuest() const override;
80 bool IsLoggedInAsSupervisedUser() const override;
81 bool IsLoggedInAsKioskApp() const override;
82 bool IsLoggedInAsStub() const override;
83 bool IsSessionStarted() const override;
84 bool IsUserNonCryptohomeDataEphemeral(
85 const std::string& email) const override;
86 void AddObserver(Observer* obs) override {}
87 void RemoveObserver(Observer* obs) override {}
88 void AddSessionStateObserver(UserSessionStateObserver* obs) override {}
89 void RemoveSessionStateObserver(UserSessionStateObserver* obs) override {}
90 void NotifyLocalStateChanged() override {}
91 bool AreSupervisedUsersAllowed() const override;
93 // UserManagerBase overrides:
94 bool AreEphemeralUsersEnabled() const override;
95 const std::string& GetApplicationLocale() const override;
96 PrefService* GetLocalState() const override;
97 void HandleUserOAuthTokenStatusChange(
98 const std::string& user_id,
99 user_manager::User::OAuthTokenStatus status) const override {}
100 bool IsEnterpriseManaged() const override;
101 void LoadPublicAccounts(std::set<std::string>* public_sessions_set) override {
103 void PerformPreUserListLoadingActions() override {}
104 void PerformPostUserListLoadingActions() override {}
105 void PerformPostUserLoggedInActions(bool browser_restart) override {}
106 bool IsDemoApp(const std::string& user_id) const override;
107 bool IsKioskApp(const std::string& user_id) const override;
108 bool IsPublicAccountMarkedForRemoval(
109 const std::string& user_id) const override;
110 void DemoAccountLoggedIn() override {}
111 void KioskAppLoggedIn(const std::string& app_id) override {}
112 void PublicAccountUserLoggedIn(user_manager::User* user) override {}
113 void SupervisedUserLoggedIn(const std::string& user_id) override {}
115 protected:
116 user_manager::User* primary_user_;
118 // If set this is the active user. If empty, the first created user is the
119 // active user.
120 std::string active_user_id_;
122 private:
123 // We use this internal function for const-correctness.
124 user_manager::User* GetActiveUserInternal() const;
126 // stub, always empty string.
127 std::string owner_email_;
129 DISALLOW_COPY_AND_ASSIGN(FakeUserManager);
132 } // namespace user_manager
134 #endif // COMPONENTS_USER_MANAGER_FAKE_USER_MANAGER_H_