ExtensionSyncService: listen for relevant changes instead of being explicitly called...
[chromium-blink-merge.git] / chrome / browser / chromeos / login / easy_unlock / bootstrap_user_flow.h
blob9b6926ba64dffa1ccab053ccca90020e0956e8d8
1 // Copyright 2015 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.
5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_EASY_UNLOCK_BOOTSTRAP_USER_FLOW_H_
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_EASY_UNLOCK_BOOTSTRAP_USER_FLOW_H_
8 #include "base/macros.h"
9 #include "base/memory/weak_ptr.h"
10 #include "chrome/browser/chromeos/login/user_flow.h"
11 #include "chromeos/login/auth/extended_authenticator.h"
12 #include "chromeos/login/auth/user_context.h"
14 class Profile;
16 namespace chromeos {
18 // BootstrapUserFlow executes post cryptohome mount bootstraping tasks:
19 // 1. Performs Easy unlock pairing with the user's phone;
20 // 2. Creates easy unlock cryptohome keys;
21 // 3. Drops temp random cryptohome key;
22 // After these tasks, it finishes and resumes user session.
23 class BootstrapUserFlow final
24 : public ExtendedUserFlow,
25 public ExtendedAuthenticator::NewAuthStatusConsumer {
26 public:
27 // Constructs a BootstrapUserFlow. |user_context| is the user this flow
28 // represents and contains the user id and key needed for cryptohome
29 // operations. |is_new_account| is a boolean flag of whether the user
30 // is being added to the device.
31 BootstrapUserFlow(const UserContext& user_context, bool is_new_account);
32 ~BootstrapUserFlow() override;
34 private:
35 void StartAutoPairing();
36 void SetAutoPairingResult(bool success, const std::string& error_message);
38 void OnKeysRefreshed(bool success);
39 void RemoveBootstrapRandomKey();
40 void OnBootstrapRandomKeyRemoved();
41 void Finish();
43 // chromeos::ExtendedUserFlow
44 bool CanLockScreen() override;
45 bool ShouldLaunchBrowser() override;
46 bool ShouldSkipPostLoginScreens() override;
47 bool HandleLoginFailure(const chromeos::AuthFailure& failure) override;
48 void HandleLoginSuccess(const chromeos::UserContext& context) override;
49 bool HandlePasswordChangeDetected() override;
50 void HandleOAuthTokenStatusChange(
51 user_manager::User::OAuthTokenStatus status) override;
52 void LaunchExtraSteps(Profile* user_profile) override;
53 bool SupportsEarlyRestartToApplyFlags() override;
55 // ExtendedAuthenticator::NewAuthStatusConsumer
56 void OnAuthenticationFailure(ExtendedAuthenticator::AuthState state) override;
58 UserContext user_context_;
59 const bool is_new_account_;
61 bool finished_;
62 Profile* user_profile_;
64 base::WeakPtrFactory<BootstrapUserFlow> weak_ptr_factory_;
66 DISALLOW_COPY_AND_ASSIGN(BootstrapUserFlow);
69 } // namespace chromeos
71 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_EASY_UNLOCK_BOOTSTRAP_USER_FLOW_H_