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 3 // found in the LICENSE file. 4 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_SUPERVISED_SUPERVISED_USER_LOGIN_FLOW_H_ 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_SUPERVISED_SUPERVISED_USER_LOGIN_FLOW_H_ 7 8 #include "base/basictypes.h" 9 #include "base/compiler_specific.h" 10 #include "base/memory/weak_ptr.h" 11 #include "base/strings/string16.h" 12 #include "chrome/browser/chromeos/login/user_flow.h" 13 #include "chromeos/login/auth/extended_authenticator.h" 14 #include "chromeos/login/auth/user_context.h" 15 16 namespace chromeos { 17 18 // UserFlow implementation for signing in supervised user. 19 class SupervisedUserLoginFlow 20 : public ExtendedUserFlow, 21 public ExtendedAuthenticator::NewAuthStatusConsumer { 22 public: 23 explicit SupervisedUserLoginFlow(const std::string& user_id); 24 virtual ~SupervisedUserLoginFlow(); 25 26 // ExtendedUserFlow overrides. 27 virtual bool CanLockScreen() OVERRIDE; 28 virtual bool ShouldLaunchBrowser() OVERRIDE; 29 virtual bool ShouldSkipPostLoginScreens() OVERRIDE; 30 virtual bool SupportsEarlyRestartToApplyFlags() OVERRIDE; 31 virtual bool HandleLoginFailure(const AuthFailure& failure) OVERRIDE; 32 virtual void HandleLoginSuccess(const UserContext& context) OVERRIDE; 33 virtual bool HandlePasswordChangeDetected() OVERRIDE; 34 virtual void HandleOAuthTokenStatusChange( 35 user_manager::User::OAuthTokenStatus status) OVERRIDE; 36 virtual void LaunchExtraSteps(Profile* profile) OVERRIDE; 37 38 // ExtendedAuthenticator::NewAuthStatusConsumer overrides. 39 virtual void OnAuthenticationFailure(ExtendedAuthenticator::AuthState state) 40 OVERRIDE; 41 42 private: 43 void Launch(); 44 void Finish(); 45 46 void OnSyncSetupDataLoaded(const std::string& token); 47 void ConfigureSync(const std::string& token); 48 void OnPasswordChangeDataLoaded(const base::DictionaryValue* password_data); 49 void OnPasswordChangeDataLoadFailed(); 50 void OnNewKeyAdded(scoped_ptr<base::DictionaryValue> password_data); 51 void OnOldKeyRemoved(); 52 void OnPasswordUpdated(scoped_ptr<base::DictionaryValue> password_data); 53 54 scoped_refptr<ExtendedAuthenticator> authenticator_; 55 56 bool data_loaded_; 57 UserContext context_; 58 Profile* profile_; 59 base::WeakPtrFactory<SupervisedUserLoginFlow> weak_factory_; 60 61 DISALLOW_COPY_AND_ASSIGN(SupervisedUserLoginFlow); 62 }; 63 64 } // namespace chromeos 65 66 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_SUPERVISED_SUPERVISED_USER_LOGIN_FLOW_H_ 67