1 // Copyright (c) 2012 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. 4 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_USER_FLOW_H_ 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_USER_FLOW_H_ 7 8 #include "base/compiler_specific.h" 9 #include "chrome/browser/chromeos/login/login_status_consumer.h" 10 #include "chrome/browser/chromeos/login/user.h" 11 #include "chrome/browser/profiles/profile.h" 12 13 namespace chromeos { 14 15 class LoginDisplayHost; 16 // Defines possible variants of user flow upon logging in. 17 // See UserManager::SetUserFlow for usage contract. 18 class UserFlow { 19 public: 20 UserFlow(); 21 virtual ~UserFlow() = 0; 22 virtual bool ShouldShowSettings() = 0; 23 virtual bool ShouldLaunchBrowser() = 0; 24 virtual bool ShouldSkipPostLoginScreens() = 0; 25 virtual bool HandleLoginFailure(const LoginFailure& failure) = 0; 26 virtual bool HandlePasswordChangeDetected() = 0; 27 virtual void HandleOAuthTokenStatusChange(User::OAuthTokenStatus status) = 0; 28 virtual void LaunchExtraSteps(Profile* profile) = 0; 29 set_host(LoginDisplayHost * host)30 void set_host(LoginDisplayHost* host) { 31 host_ = host; 32 } 33 host()34 LoginDisplayHost* host() { 35 return host_; 36 } 37 38 private: 39 LoginDisplayHost* host_; 40 }; 41 42 // UserFlow implementation for regular login flow. 43 class DefaultUserFlow : public UserFlow { 44 public: 45 virtual ~DefaultUserFlow(); 46 47 virtual bool ShouldShowSettings() OVERRIDE; 48 virtual bool ShouldLaunchBrowser() OVERRIDE; 49 virtual bool ShouldSkipPostLoginScreens() OVERRIDE; 50 virtual bool HandleLoginFailure(const LoginFailure& failure) OVERRIDE; 51 virtual bool HandlePasswordChangeDetected() OVERRIDE; 52 virtual void HandleOAuthTokenStatusChange(User::OAuthTokenStatus status) 53 OVERRIDE; 54 virtual void LaunchExtraSteps(Profile* profile) OVERRIDE; 55 }; 56 57 // UserFlow stub for non-regular flows. 58 class ExtendedUserFlow : public UserFlow { 59 public: 60 explicit ExtendedUserFlow(const std::string& user_id); 61 virtual ~ExtendedUserFlow(); 62 63 virtual bool ShouldShowSettings() OVERRIDE; 64 65 protected: 66 // Subclasses can call this method to unregister flow in the next event. 67 virtual void UnregisterFlowSoon(); user_id()68 std::string user_id() { 69 return user_id_; 70 }; 71 72 private: 73 std::string user_id_; 74 }; 75 76 } // namespace chromeos 77 78 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USER_FLOW_H_ 79