summaryrefslogtreecommitdiffstats
path: root/chrome/browser/chromeos/login/supervised/supervised_user_login_flow.h
blob: 23c90a7d96182a9ce8f639ab3a8b5cbc900f95b2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROME_BROWSER_CHROMEOS_LOGIN_SUPERVISED_SUPERVISED_USER_LOGIN_FLOW_H_
#define CHROME_BROWSER_CHROMEOS_LOGIN_SUPERVISED_SUPERVISED_USER_LOGIN_FLOW_H_

#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "base/memory/weak_ptr.h"
#include "base/strings/string16.h"
#include "chrome/browser/chromeos/login/user_flow.h"
#include "chromeos/login/auth/extended_authenticator.h"
#include "chromeos/login/auth/user_context.h"

namespace chromeos {

// UserFlow implementation for signing in supervised user.
class SupervisedUserLoginFlow
    : public ExtendedUserFlow,
      public ExtendedAuthenticator::NewAuthStatusConsumer {
 public:
  explicit SupervisedUserLoginFlow(const std::string& user_id);
  virtual ~SupervisedUserLoginFlow();

  // ExtendedUserFlow overrides.
  virtual bool CanLockScreen() override;
  virtual bool ShouldLaunchBrowser() override;
  virtual bool ShouldSkipPostLoginScreens() override;
  virtual bool HandleLoginFailure(const AuthFailure& failure) override;
  virtual void HandleLoginSuccess(const UserContext& context) override;
  virtual bool HandlePasswordChangeDetected() override;
  virtual void HandleOAuthTokenStatusChange(
      user_manager::User::OAuthTokenStatus status) override;
  virtual void LaunchExtraSteps(Profile* profile) override;

  // ExtendedAuthenticator::NewAuthStatusConsumer overrides.
  virtual void OnAuthenticationFailure(ExtendedAuthenticator::AuthState state)
      override;

 private:
  void Launch();
  void Finish();

  void OnSyncSetupDataLoaded(const std::string& token);
  void ConfigureSync(const std::string& token);
  void OnPasswordChangeDataLoaded(const base::DictionaryValue* password_data);
  void OnPasswordChangeDataLoadFailed();
  void OnNewKeyAdded(scoped_ptr<base::DictionaryValue> password_data);
  void OnOldKeyRemoved();
  void OnPasswordUpdated(scoped_ptr<base::DictionaryValue> password_data);

  scoped_refptr<ExtendedAuthenticator> authenticator_;

  bool data_loaded_;
  UserContext context_;
  Profile* profile_;
  base::WeakPtrFactory<SupervisedUserLoginFlow> weak_factory_;

  DISALLOW_COPY_AND_ASSIGN(SupervisedUserLoginFlow);
};

}  // namespace chromeos

#endif  // CHROME_BROWSER_CHROMEOS_LOGIN_SUPERVISED_SUPERVISED_USER_LOGIN_FLOW_H_