user_flow.h revision 5f1c94371a64b3196d4be9466099bb892df9b88e
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/profiles/profile.h" 10#include "chromeos/login/auth/auth_status_consumer.h" 11#include "components/user_manager/user.h" 12 13namespace chromeos { 14 15class UserContext; 16 17class LoginDisplayHost; 18// Defines possible variants of user flow upon logging in. 19// See UserManager::SetUserFlow for usage contract. 20class UserFlow { 21 public: 22 UserFlow(); 23 virtual ~UserFlow() = 0; 24 // Indicates if screen locking should be enabled or disabled for a flow. 25 virtual bool CanLockScreen() = 0; 26 virtual bool ShouldShowSettings() = 0; 27 virtual bool ShouldLaunchBrowser() = 0; 28 virtual bool ShouldSkipPostLoginScreens() = 0; 29 virtual bool HandleLoginFailure(const AuthFailure& failure) = 0; 30 virtual void HandleLoginSuccess(const UserContext& context) = 0; 31 virtual bool HandlePasswordChangeDetected() = 0; 32 virtual void HandleOAuthTokenStatusChange( 33 user_manager::User::OAuthTokenStatus status) = 0; 34 virtual void LaunchExtraSteps(Profile* profile) = 0; 35 36 void set_host(LoginDisplayHost* host) { 37 host_ = host; 38 } 39 40 LoginDisplayHost* host() { 41 return host_; 42 } 43 44 private: 45 LoginDisplayHost* host_; 46}; 47 48// UserFlow implementation for regular login flow. 49class DefaultUserFlow : public UserFlow { 50 public: 51 virtual ~DefaultUserFlow(); 52 53 virtual bool CanLockScreen() OVERRIDE; 54 virtual bool ShouldShowSettings() OVERRIDE; 55 virtual bool ShouldLaunchBrowser() OVERRIDE; 56 virtual bool ShouldSkipPostLoginScreens() OVERRIDE; 57 virtual bool HandleLoginFailure(const AuthFailure& failure) OVERRIDE; 58 virtual void HandleLoginSuccess(const UserContext& context) OVERRIDE; 59 virtual bool HandlePasswordChangeDetected() OVERRIDE; 60 virtual void HandleOAuthTokenStatusChange( 61 user_manager::User::OAuthTokenStatus status) OVERRIDE; 62 virtual void LaunchExtraSteps(Profile* profile) OVERRIDE; 63}; 64 65// UserFlow stub for non-regular flows. 66class ExtendedUserFlow : public UserFlow { 67 public: 68 explicit ExtendedUserFlow(const std::string& user_id); 69 virtual ~ExtendedUserFlow(); 70 71 virtual bool ShouldShowSettings() OVERRIDE; 72 73 protected: 74 // Subclasses can call this method to unregister flow in the next event. 75 virtual void UnregisterFlowSoon(); 76 std::string user_id() { 77 return user_id_; 78 } 79 80 private: 81 std::string user_id_; 82}; 83 84} // namespace chromeos 85 86#endif // CHROME_BROWSER_CHROMEOS_LOGIN_USER_FLOW_H_ 87