| 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_SESSION_USER_SESSION_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_SESSION_USER_SESSION_MANAGER_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_SESSION_USER_SESSION_MANAGER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_SESSION_USER_SESSION_MANAGER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/memory/singleton.h" | 11 #include "base/memory/singleton.h" |
| 12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
| 13 #include "base/observer_list.h" | 13 #include "base/observer_list.h" |
| 14 #include "chrome/browser/chromeos/base/locale_util.h" | 14 #include "chrome/browser/chromeos/base/locale_util.h" |
| 15 #include "chrome/browser/chromeos/login/signin/oauth2_login_manager.h" | 15 #include "chrome/browser/chromeos/login/signin/oauth2_login_manager.h" |
| 16 #include "chrome/browser/chromeos/login/users/user_manager.h" |
| 16 #include "chromeos/dbus/session_manager_client.h" | 17 #include "chromeos/dbus/session_manager_client.h" |
| 18 #include "chromeos/ime/input_method_manager.h" |
| 17 #include "chromeos/login/auth/authenticator.h" | 19 #include "chromeos/login/auth/authenticator.h" |
| 18 #include "chromeos/login/auth/user_context.h" | 20 #include "chromeos/login/auth/user_context.h" |
| 19 #include "components/user_manager/user.h" | 21 #include "components/user_manager/user.h" |
| 20 #include "net/base/network_change_notifier.h" | 22 #include "net/base/network_change_notifier.h" |
| 21 | 23 |
| 22 class PrefRegistrySimple; | 24 class PrefRegistrySimple; |
| 23 class PrefService; | 25 class PrefService; |
| 24 class Profile; | 26 class Profile; |
| 25 | 27 |
| 28 namespace user_manager { |
| 29 |
| 30 class User; |
| 31 |
| 32 } // namespace user_manager |
| 33 |
| 26 namespace chromeos { | 34 namespace chromeos { |
| 27 | 35 |
| 28 class UserSessionManagerDelegate { | 36 class UserSessionManagerDelegate { |
| 29 public: | 37 public: |
| 30 // Called after profile is loaded and prepared for the session. | 38 // Called after profile is loaded and prepared for the session. |
| 31 virtual void OnProfilePrepared(Profile* profile) = 0; | 39 virtual void OnProfilePrepared(Profile* profile) = 0; |
| 32 | 40 |
| 33 #if defined(ENABLE_RLZ) | 41 #if defined(ENABLE_RLZ) |
| 34 // Called after post-profile RLZ initialization. | 42 // Called after post-profile RLZ initialization. |
| 35 virtual void OnRlzInitialized(); | 43 virtual void OnRlzInitialized(); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 51 // load and initialize Profile (including custom Profile preferences), | 59 // load and initialize Profile (including custom Profile preferences), |
| 52 // mark user as logged in and notify observers, | 60 // mark user as logged in and notify observers, |
| 53 // initialize OAuth2 authentication session, | 61 // initialize OAuth2 authentication session, |
| 54 // initialize and launch user session based on the user type. | 62 // initialize and launch user session based on the user type. |
| 55 // Also supports restoring active user sessions after browser crash: | 63 // Also supports restoring active user sessions after browser crash: |
| 56 // load profile, restore OAuth authentication session etc. | 64 // load profile, restore OAuth authentication session etc. |
| 57 class UserSessionManager | 65 class UserSessionManager |
| 58 : public OAuth2LoginManager::Observer, | 66 : public OAuth2LoginManager::Observer, |
| 59 public net::NetworkChangeNotifier::ConnectionTypeObserver, | 67 public net::NetworkChangeNotifier::ConnectionTypeObserver, |
| 60 public base::SupportsWeakPtr<UserSessionManager>, | 68 public base::SupportsWeakPtr<UserSessionManager>, |
| 61 public UserSessionManagerDelegate { | 69 public UserSessionManagerDelegate, |
| 70 public UserManager::UserSessionStateObserver { |
| 62 public: | 71 public: |
| 63 // Returns UserSessionManager instance. | 72 // Returns UserSessionManager instance. |
| 64 static UserSessionManager* GetInstance(); | 73 static UserSessionManager* GetInstance(); |
| 65 | 74 |
| 66 // Called when user is logged in to override base::DIR_HOME path. | 75 // Called when user is logged in to override base::DIR_HOME path. |
| 67 static void OverrideHomedir(); | 76 static void OverrideHomedir(); |
| 68 | 77 |
| 69 // Registers session related preferences. | 78 // Registers session related preferences. |
| 70 static void RegisterPrefs(PrefRegistrySimple* registry); | 79 static void RegisterPrefs(PrefRegistrySimple* registry); |
| 71 | 80 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 // TODO(nkostylev): Drop these methods once LoginUtilsImpl::AttemptRestart() | 114 // TODO(nkostylev): Drop these methods once LoginUtilsImpl::AttemptRestart() |
| 106 // is migrated. | 115 // is migrated. |
| 107 OAuth2LoginManager::SessionRestoreStrategy GetSigninSessionRestoreStrategy(); | 116 OAuth2LoginManager::SessionRestoreStrategy GetSigninSessionRestoreStrategy(); |
| 108 bool exit_after_session_restore() { return exit_after_session_restore_; } | 117 bool exit_after_session_restore() { return exit_after_session_restore_; } |
| 109 void set_exit_after_session_restore(bool value) { | 118 void set_exit_after_session_restore(bool value) { |
| 110 exit_after_session_restore_ = value; | 119 exit_after_session_restore_ = value; |
| 111 } | 120 } |
| 112 | 121 |
| 113 // Invoked when the user is logging in for the first time, or is logging in to | 122 // Invoked when the user is logging in for the first time, or is logging in to |
| 114 // an ephemeral session type, such as guest or a public session. | 123 // an ephemeral session type, such as guest or a public session. |
| 115 static void SetFirstLoginPrefs( | 124 void SetFirstLoginPrefs(Profile* profile, |
| 116 PrefService* prefs, | 125 const std::string& public_session_locale, |
| 117 const std::string& public_session_locale, | 126 const std::string& public_session_input_method); |
| 118 const std::string& public_session_input_method); | |
| 119 | 127 |
| 120 // Gets/sets Chrome OAuth client id and secret for kiosk app mode. The default | 128 // Gets/sets Chrome OAuth client id and secret for kiosk app mode. The default |
| 121 // values can be overridden with kiosk auth file. | 129 // values can be overridden with kiosk auth file. |
| 122 bool GetAppModeChromeClientOAuthInfo( | 130 bool GetAppModeChromeClientOAuthInfo( |
| 123 std::string* chrome_client_id, | 131 std::string* chrome_client_id, |
| 124 std::string* chrome_client_secret); | 132 std::string* chrome_client_secret); |
| 125 void SetAppModeChromeClientOAuthInfo( | 133 void SetAppModeChromeClientOAuthInfo( |
| 126 const std::string& chrome_client_id, | 134 const std::string& chrome_client_id, |
| 127 const std::string& chrome_client_secret); | 135 const std::string& chrome_client_secret); |
| 128 | 136 |
| 129 // Changes browser locale (selects best suitable locale from different | 137 // Changes browser locale (selects best suitable locale from different |
| 130 // user settings). Returns true if callback will be called. | 138 // user settings). Returns true if callback will be called. |
| 131 // Returns true if callback will be called. | 139 // Returns true if callback will be called. |
| 132 bool RespectLocalePreference( | 140 bool RespectLocalePreference( |
| 133 Profile* profile, | 141 Profile* profile, |
| 134 const user_manager::User* user, | 142 const user_manager::User* user, |
| 135 scoped_ptr<locale_util::SwitchLanguageCallback> callback) const; | 143 scoped_ptr<locale_util::SwitchLanguageCallback> callback) const; |
| 136 | 144 |
| 137 void AddSessionStateObserver(UserSessionStateObserver* observer); | 145 void AddSessionStateObserver(chromeos::UserSessionStateObserver* observer); |
| 138 void RemoveSessionStateObserver(UserSessionStateObserver* observer); | 146 void RemoveSessionStateObserver(chromeos::UserSessionStateObserver* observer); |
| 147 |
| 148 virtual void ActiveUserChanged( |
| 149 const user_manager::User* active_user) OVERRIDE; |
| 150 |
| 151 // Returns default IME state for user session. |
| 152 scoped_refptr<input_method::InputMethodManager::State> GetDefaultIMEState( |
| 153 Profile* profile); |
| 139 | 154 |
| 140 private: | 155 private: |
| 141 friend struct DefaultSingletonTraits<UserSessionManager>; | 156 friend struct DefaultSingletonTraits<UserSessionManager>; |
| 142 | 157 |
| 143 typedef std::set<std::string> SigninSessionRestoreStateSet; | 158 typedef std::set<std::string> SigninSessionRestoreStateSet; |
| 144 | 159 |
| 145 UserSessionManager(); | 160 UserSessionManager(); |
| 146 virtual ~UserSessionManager(); | 161 virtual ~UserSessionManager(); |
| 147 | 162 |
| 148 // OAuth2LoginManager::Observer overrides: | 163 // OAuth2LoginManager::Observer overrides: |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 // Active user session restoration related members. | 248 // Active user session restoration related members. |
| 234 | 249 |
| 235 // True is user sessions has been restored after crash. | 250 // True is user sessions has been restored after crash. |
| 236 // On a normal boot then login into user sessions this will be false. | 251 // On a normal boot then login into user sessions this will be false. |
| 237 bool user_sessions_restored_; | 252 bool user_sessions_restored_; |
| 238 | 253 |
| 239 // User sessions that have to be restored after browser crash. | 254 // User sessions that have to be restored after browser crash. |
| 240 // [user_id] > [user_id_hash] | 255 // [user_id] > [user_id_hash] |
| 241 SessionManagerClient::ActiveSessionsMap pending_user_sessions_; | 256 SessionManagerClient::ActiveSessionsMap pending_user_sessions_; |
| 242 | 257 |
| 243 ObserverList<UserSessionStateObserver> session_state_observer_list_; | 258 ObserverList<chromeos::UserSessionStateObserver> session_state_observer_list_; |
| 244 | 259 |
| 245 // OAuth2 session related members. | 260 // OAuth2 session related members. |
| 246 | 261 |
| 247 // True if we should restart chrome right after session restore. | 262 // True if we should restart chrome right after session restore. |
| 248 bool exit_after_session_restore_; | 263 bool exit_after_session_restore_; |
| 249 | 264 |
| 250 // Sesion restore strategy. | 265 // Sesion restore strategy. |
| 251 OAuth2LoginManager::SessionRestoreStrategy session_restore_strategy_; | 266 OAuth2LoginManager::SessionRestoreStrategy session_restore_strategy_; |
| 252 | 267 |
| 253 // OAuth2 refresh token for session restore. | 268 // OAuth2 refresh token for session restore. |
| 254 std::string oauth2_refresh_token_; | 269 std::string oauth2_refresh_token_; |
| 255 | 270 |
| 256 // Set of user_id for those users that we should restore authentication | 271 // Set of user_id for those users that we should restore authentication |
| 257 // session when notified about online state change. | 272 // session when notified about online state change. |
| 258 SigninSessionRestoreStateSet pending_signin_restore_sessions_; | 273 SigninSessionRestoreStateSet pending_signin_restore_sessions_; |
| 259 | 274 |
| 260 // Kiosk mode related members. | 275 // Kiosk mode related members. |
| 261 // Chrome oauth client id and secret - override values for kiosk mode. | 276 // Chrome oauth client id and secret - override values for kiosk mode. |
| 262 std::string chrome_client_id_; | 277 std::string chrome_client_id_; |
| 263 std::string chrome_client_secret_; | 278 std::string chrome_client_secret_; |
| 264 | 279 |
| 280 // Per-user-session Input Methods states. |
| 281 std::map<Profile*, scoped_refptr<input_method::InputMethodManager::State> > |
| 282 default_ime_states_; |
| 283 |
| 265 DISALLOW_COPY_AND_ASSIGN(UserSessionManager); | 284 DISALLOW_COPY_AND_ASSIGN(UserSessionManager); |
| 266 }; | 285 }; |
| 267 | 286 |
| 268 } // namespace chromeos | 287 } // namespace chromeos |
| 269 | 288 |
| 270 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_SESSION_USER_SESSION_MANAGER_H_ | 289 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_SESSION_USER_SESSION_MANAGER_H_ |
| OLD | NEW |