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