| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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_USERS_CHROME_USER_MANAGER_IMPL_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_USERS_CHROME_USER_MANAGER_IMPL_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_USERS_CHROME_USER_MANAGER_IMPL_H_ | 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_USERS_CHROME_USER_MANAGER_IMPL_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
| 13 #include "base/containers/hash_tables.h" | 13 #include "base/containers/hash_tables.h" |
| 14 #include "base/memory/linked_ptr.h" | 14 #include "base/memory/linked_ptr.h" |
| 15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
| 16 #include "base/memory/weak_ptr.h" | 16 #include "base/memory/weak_ptr.h" |
| 17 #include "base/observer_list.h" | 17 #include "base/observer_list.h" |
| 18 #include "base/synchronization/lock.h" | 18 #include "base/synchronization/lock.h" |
| 19 #include "base/time/time.h" | 19 #include "base/time/time.h" |
| 20 #include "chrome/browser/chromeos/login/easy_unlock/bootstrap_manager.h" | 20 #include "chrome/browser/chromeos/login/easy_unlock/bootstrap_manager.h" |
| 21 #include "chrome/browser/chromeos/login/user_flow.h" | 21 #include "chrome/browser/chromeos/login/user_flow.h" |
| 22 #include "chrome/browser/chromeos/login/users/affiliation.h" | 22 #include "chrome/browser/chromeos/login/users/affiliation.h" |
| 23 #include "chrome/browser/chromeos/login/users/avatar/user_image_manager_impl.h" | 23 #include "chrome/browser/chromeos/login/users/avatar/user_image_manager_impl.h" |
| 24 #include "chrome/browser/chromeos/login/users/chrome_user_manager.h" | 24 #include "chrome/browser/chromeos/login/users/chrome_user_manager.h" |
| 25 #include "chrome/browser/chromeos/login/users/multi_profile_user_controller_dele
gate.h" | 25 #include "chrome/browser/chromeos/login/users/multi_profile_user_controller_dele
gate.h" |
| 26 #include "chrome/browser/chromeos/policy/cloud_external_data_policy_observer.h" | 26 #include "chrome/browser/chromeos/policy/cloud_external_data_policy_observer.h" |
| 27 #include "chrome/browser/chromeos/policy/device_local_account_policy_service.h" | 27 #include "chrome/browser/chromeos/policy/device_local_account_policy_service.h" |
| 28 #include "chrome/browser/chromeos/settings/cros_settings.h" | 28 #include "chrome/browser/chromeos/settings/cros_settings.h" |
| 29 #include "chrome/browser/chromeos/settings/device_settings_service.h" | 29 #include "chrome/browser/chromeos/settings/device_settings_service.h" |
| 30 #include "components/signin/core/account_id/account_id.h" | |
| 31 #include "components/user_manager/user.h" | 30 #include "components/user_manager/user.h" |
| 32 #include "content/public/browser/notification_observer.h" | 31 #include "content/public/browser/notification_observer.h" |
| 33 #include "content/public/browser/notification_registrar.h" | 32 #include "content/public/browser/notification_registrar.h" |
| 34 | 33 |
| 35 class PrefRegistrySimple; | 34 class PrefRegistrySimple; |
| 36 class PrefService; | 35 class PrefService; |
| 37 class ProfileSyncService; | 36 class ProfileSyncService; |
| 38 | 37 |
| 39 namespace policy { | 38 namespace policy { |
| 40 struct DeviceLocalAccount; | 39 struct DeviceLocalAccount; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 63 | 62 |
| 64 // Creates ChromeUserManagerImpl instance. | 63 // Creates ChromeUserManagerImpl instance. |
| 65 static scoped_ptr<ChromeUserManager> CreateChromeUserManager(); | 64 static scoped_ptr<ChromeUserManager> CreateChromeUserManager(); |
| 66 | 65 |
| 67 // Registers user manager preferences. | 66 // Registers user manager preferences. |
| 68 static void RegisterPrefs(PrefRegistrySimple* registry); | 67 static void RegisterPrefs(PrefRegistrySimple* registry); |
| 69 | 68 |
| 70 // UserManagerInterface implementation: | 69 // UserManagerInterface implementation: |
| 71 BootstrapManager* GetBootstrapManager() override; | 70 BootstrapManager* GetBootstrapManager() override; |
| 72 MultiProfileUserController* GetMultiProfileUserController() override; | 71 MultiProfileUserController* GetMultiProfileUserController() override; |
| 73 UserImageManager* GetUserImageManager(const AccountId& account_id) override; | 72 UserImageManager* GetUserImageManager(const std::string& user_id) override; |
| 74 SupervisedUserManager* GetSupervisedUserManager() override; | 73 SupervisedUserManager* GetSupervisedUserManager() override; |
| 75 UserFlow* GetCurrentUserFlow() const override; | 74 UserFlow* GetCurrentUserFlow() const override; |
| 76 UserFlow* GetUserFlow(const AccountId& account_id) const override; | 75 UserFlow* GetUserFlow(const std::string& user_id) const override; |
| 77 void SetUserFlow(const AccountId& account_id, UserFlow* flow) override; | 76 void SetUserFlow(const std::string& user_id, UserFlow* flow) override; |
| 78 void ResetUserFlow(const AccountId& account_id) override; | 77 void ResetUserFlow(const std::string& user_id) override; |
| 79 | 78 |
| 80 // UserManager implementation: | 79 // UserManager implementation: |
| 81 void Shutdown() override; | 80 void Shutdown() override; |
| 82 user_manager::UserList GetUsersAllowedForMultiProfile() const override; | 81 user_manager::UserList GetUsersAllowedForMultiProfile() const override; |
| 83 user_manager::UserList GetUsersAllowedForSupervisedUsersCreation() | 82 user_manager::UserList GetUsersAllowedForSupervisedUsersCreation() |
| 84 const override; | 83 const override; |
| 85 user_manager::UserList GetUnlockUsers() const override; | 84 user_manager::UserList GetUnlockUsers() const override; |
| 86 void SessionStarted() override; | 85 void SessionStarted() override; |
| 87 void SaveUserOAuthStatus( | 86 void SaveUserOAuthStatus( |
| 88 const AccountId& account_id, | 87 const std::string& user_id, |
| 89 user_manager::User::OAuthTokenStatus oauth_token_status) override; | 88 user_manager::User::OAuthTokenStatus oauth_token_status) override; |
| 90 void SaveUserDisplayName(const AccountId& account_id, | 89 void SaveUserDisplayName(const std::string& user_id, |
| 91 const base::string16& display_name) override; | 90 const base::string16& display_name) override; |
| 92 bool CanCurrentUserLock() const override; | 91 bool CanCurrentUserLock() const override; |
| 93 bool IsUserNonCryptohomeDataEphemeral( | 92 bool IsUserNonCryptohomeDataEphemeral( |
| 94 const AccountId& account_id) const override; | 93 const std::string& user_id) const override; |
| 95 bool AreSupervisedUsersAllowed() const override; | 94 bool AreSupervisedUsersAllowed() const override; |
| 96 | 95 |
| 97 // content::NotificationObserver implementation. | 96 // content::NotificationObserver implementation. |
| 98 void Observe(int type, | 97 void Observe(int type, |
| 99 const content::NotificationSource& source, | 98 const content::NotificationSource& source, |
| 100 const content::NotificationDetails& details) override; | 99 const content::NotificationDetails& details) override; |
| 101 | 100 |
| 102 // policy::CloudExternalDataPolicyObserver::Delegate: | 101 // policy::CloudExternalDataPolicyObserver::Delegate: |
| 103 void OnExternalDataSet(const std::string& policy, | 102 void OnExternalDataSet(const std::string& policy, |
| 104 const std::string& user_id) override; | 103 const std::string& user_id) override; |
| 105 void OnExternalDataCleared(const std::string& policy, | 104 void OnExternalDataCleared(const std::string& policy, |
| 106 const std::string& user_id) override; | 105 const std::string& user_id) override; |
| 107 void OnExternalDataFetched(const std::string& policy, | 106 void OnExternalDataFetched(const std::string& policy, |
| 108 const std::string& user_id, | 107 const std::string& user_id, |
| 109 scoped_ptr<std::string> data) override; | 108 scoped_ptr<std::string> data) override; |
| 110 | 109 |
| 111 // policy::DeviceLocalAccountPolicyService::Observer implementation. | 110 // policy::DeviceLocalAccountPolicyService::Observer implementation. |
| 112 void OnPolicyUpdated(const std::string& user_id) override; | 111 void OnPolicyUpdated(const std::string& user_id) override; |
| 113 void OnDeviceLocalAccountsChanged() override; | 112 void OnDeviceLocalAccountsChanged() override; |
| 114 | 113 |
| 115 void StopPolicyObserverForTesting(); | 114 void StopPolicyObserverForTesting(); |
| 116 | 115 |
| 117 // UserManagerBase implementation: | 116 // UserManagerBase implementation: |
| 118 bool AreEphemeralUsersEnabled() const override; | 117 bool AreEphemeralUsersEnabled() const override; |
| 119 void OnUserRemoved(const AccountId& account_id) override; | 118 void OnUserRemoved(const std::string& user_id) override; |
| 120 | 119 |
| 121 // ChromeUserManager implementation: | 120 // ChromeUserManager implementation: |
| 122 bool ShouldReportUser(const std::string& user_id) const override; | 121 bool ShouldReportUser(const std::string& user_id) const override; |
| 123 void SetUserAffiliation( | 122 void SetUserAffiliation( |
| 124 const std::string& user_email, | 123 const std::string& user_email, |
| 125 const AffiliationIDSet& user_affiliation_ids) override; | 124 const AffiliationIDSet& user_affiliation_ids) override; |
| 126 | 125 |
| 127 protected: | 126 protected: |
| 128 const std::string& GetApplicationLocale() const override; | 127 const std::string& GetApplicationLocale() const override; |
| 129 PrefService* GetLocalState() const override; | 128 PrefService* GetLocalState() const override; |
| 130 void HandleUserOAuthTokenStatusChange( | 129 void HandleUserOAuthTokenStatusChange( |
| 131 const AccountId& account_id, | 130 const std::string& user_id, |
| 132 user_manager::User::OAuthTokenStatus status) const override; | 131 user_manager::User::OAuthTokenStatus status) const override; |
| 133 bool IsEnterpriseManaged() const override; | 132 bool IsEnterpriseManaged() const override; |
| 134 void LoadPublicAccounts(std::set<AccountId>* users_set) override; | 133 void LoadPublicAccounts(std::set<std::string>* users_set) override; |
| 135 void NotifyOnLogin() override; | 134 void NotifyOnLogin() override; |
| 136 void NotifyUserAddedToSession(const user_manager::User* added_user, | 135 void NotifyUserAddedToSession(const user_manager::User* added_user, |
| 137 bool user_switch_pending) override; | 136 bool user_switch_pending) override; |
| 138 void PerformPreUserListLoadingActions() override; | 137 void PerformPreUserListLoadingActions() override; |
| 139 void PerformPostUserListLoadingActions() override; | 138 void PerformPostUserListLoadingActions() override; |
| 140 void PerformPostUserLoggedInActions(bool browser_restart) override; | 139 void PerformPostUserLoggedInActions(bool browser_restart) override; |
| 141 void RemoveNonCryptohomeData(const AccountId& account_id) override; | 140 void RemoveNonCryptohomeData(const std::string& user_id) override; |
| 142 void RemoveUserInternal(const AccountId& account_id, | 141 void RemoveUserInternal(const std::string& user_email, |
| 143 user_manager::RemoveUserDelegate* delegate) override; | 142 user_manager::RemoveUserDelegate* delegate) override; |
| 144 bool IsDemoApp(const AccountId& account_id) const override; | 143 bool IsDemoApp(const std::string& user_id) const override; |
| 145 bool IsKioskApp(const AccountId& account_id) const override; | 144 bool IsKioskApp(const std::string& user_id) const override; |
| 146 bool IsPublicAccountMarkedForRemoval( | 145 bool IsPublicAccountMarkedForRemoval( |
| 147 const AccountId& account_id) const override; | 146 const std::string& user_id) const override; |
| 148 void DemoAccountLoggedIn() override; | 147 void DemoAccountLoggedIn() override; |
| 149 void GuestUserLoggedIn() override; | 148 void GuestUserLoggedIn() override; |
| 150 void KioskAppLoggedIn(const AccountId& kiosk_app_account_id) override; | 149 void KioskAppLoggedIn(const std::string& app_id) override; |
| 151 void PublicAccountUserLoggedIn(user_manager::User* user) override; | 150 void PublicAccountUserLoggedIn(user_manager::User* user) override; |
| 152 void RegularUserLoggedIn(const AccountId& account_id) override; | 151 void RegularUserLoggedIn(const std::string& user_id) override; |
| 153 void RegularUserLoggedInAsEphemeral(const AccountId& account_id) override; | 152 void RegularUserLoggedInAsEphemeral(const std::string& user_id) override; |
| 154 void SupervisedUserLoggedIn(const AccountId& account_id) override; | 153 void SupervisedUserLoggedIn(const std::string& user_id) override; |
| 155 bool HasPendingBootstrap(const AccountId& account_id) const override; | 154 bool HasPendingBootstrap(const std::string& user_id) const override; |
| 156 | 155 |
| 157 private: | 156 private: |
| 158 friend class SupervisedUserManagerImpl; | 157 friend class SupervisedUserManagerImpl; |
| 159 friend class UserManagerTest; | 158 friend class UserManagerTest; |
| 160 friend class WallpaperManager; | 159 friend class WallpaperManager; |
| 161 friend class WallpaperManagerTest; | 160 friend class WallpaperManagerTest; |
| 162 | 161 |
| 163 using UserImageManagerMap = | 162 typedef base::hash_map<std::string, linked_ptr<UserImageManager> > |
| 164 base::hash_map<AccountId, linked_ptr<UserImageManager> >; | 163 UserImageManagerMap; |
| 165 | 164 |
| 166 ChromeUserManagerImpl(); | 165 ChromeUserManagerImpl(); |
| 167 | 166 |
| 168 // Retrieves trusted device policies and removes users from the persistent | 167 // Retrieves trusted device policies and removes users from the persistent |
| 169 // list if ephemeral users are enabled. Schedules a callback to itself if | 168 // list if ephemeral users are enabled. Schedules a callback to itself if |
| 170 // trusted device policies are not yet available. | 169 // trusted device policies are not yet available. |
| 171 void RetrieveTrustedDevicePolicies(); | 170 void RetrieveTrustedDevicePolicies(); |
| 172 | 171 |
| 173 // Updates current user ownership on UI thread. | 172 // Updates current user ownership on UI thread. |
| 174 void UpdateOwnership(); | 173 void UpdateOwnership(); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 | 230 |
| 232 // User avatar managers. | 231 // User avatar managers. |
| 233 UserImageManagerMap user_image_managers_; | 232 UserImageManagerMap user_image_managers_; |
| 234 | 233 |
| 235 // Supervised user manager. | 234 // Supervised user manager. |
| 236 scoped_ptr<SupervisedUserManagerImpl> supervised_user_manager_; | 235 scoped_ptr<SupervisedUserManagerImpl> supervised_user_manager_; |
| 237 | 236 |
| 238 // Session length limiter. | 237 // Session length limiter. |
| 239 scoped_ptr<SessionLengthLimiter> session_length_limiter_; | 238 scoped_ptr<SessionLengthLimiter> session_length_limiter_; |
| 240 | 239 |
| 241 using FlowMap = std::map<AccountId, UserFlow*>; | 240 typedef std::map<std::string, UserFlow*> FlowMap; |
| 242 | 241 |
| 243 // Lazy-initialized default flow. | 242 // Lazy-initialized default flow. |
| 244 mutable scoped_ptr<UserFlow> default_flow_; | 243 mutable scoped_ptr<UserFlow> default_flow_; |
| 245 | 244 |
| 246 // Specific flows by user e-mail. Keys should be canonicalized before | 245 // Specific flows by user e-mail. Keys should be canonicalized before |
| 247 // access. | 246 // access. |
| 248 FlowMap specific_flows_; | 247 FlowMap specific_flows_; |
| 249 | 248 |
| 250 scoped_ptr<CrosSettings::ObserverSubscription> local_accounts_subscription_; | 249 scoped_ptr<CrosSettings::ObserverSubscription> local_accounts_subscription_; |
| 251 | 250 |
| 252 scoped_ptr<MultiProfileUserController> multi_profile_user_controller_; | 251 scoped_ptr<MultiProfileUserController> multi_profile_user_controller_; |
| 253 | 252 |
| 254 // Observer for the policy that can be used to manage user images. | 253 // Observer for the policy that can be used to manage user images. |
| 255 scoped_ptr<policy::CloudExternalDataPolicyObserver> avatar_policy_observer_; | 254 scoped_ptr<policy::CloudExternalDataPolicyObserver> avatar_policy_observer_; |
| 256 | 255 |
| 257 // Observer for the policy that can be used to manage wallpapers. | 256 // Observer for the policy that can be used to manage wallpapers. |
| 258 scoped_ptr<policy::CloudExternalDataPolicyObserver> | 257 scoped_ptr<policy::CloudExternalDataPolicyObserver> |
| 259 wallpaper_policy_observer_; | 258 wallpaper_policy_observer_; |
| 260 | 259 |
| 261 scoped_ptr<BootstrapManager> bootstrap_manager_; | 260 scoped_ptr<BootstrapManager> bootstrap_manager_; |
| 262 | 261 |
| 263 base::WeakPtrFactory<ChromeUserManagerImpl> weak_factory_; | 262 base::WeakPtrFactory<ChromeUserManagerImpl> weak_factory_; |
| 264 | 263 |
| 265 DISALLOW_COPY_AND_ASSIGN(ChromeUserManagerImpl); | 264 DISALLOW_COPY_AND_ASSIGN(ChromeUserManagerImpl); |
| 266 }; | 265 }; |
| 267 | 266 |
| 268 } // namespace chromeos | 267 } // namespace chromeos |
| 269 | 268 |
| 270 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USERS_CHROME_USER_MANAGER_IMPL_H_ | 269 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USERS_CHROME_USER_MANAGER_IMPL_H_ |
| OLD | NEW |