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.
5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_MANAGED_MANAGED_USER_CREATION_CONTROLLER_H_
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_MANAGED_MANAGED_USER_CREATION_CONTROLLER_H_
10 #include "base/files/file_path.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "base/memory/weak_ptr.h"
13 #include "base/strings/string16.h"
14 #include "base/timer/timer.h"
15 #include "base/values.h"
16 #include "chrome/browser/chromeos/login/managed/managed_user_authenticator.h"
17 #include "chrome/browser/supervised_user/supervised_user_registration_utility.h"
23 // ManagedUserCreationController is used to locally managed user
25 class ManagedUserCreationController {
27 // This constant is used to indicate that user does not have one of default
28 // avatars: either he has no chromeos avatar at all, or has an external
29 // image as an avatar.
30 static const int kDummyAvatarIndex;
35 CRYPTOHOME_FAILED_MOUNT,
36 CRYPTOHOME_FAILED_TPM,
41 class StatusConsumer {
43 virtual ~StatusConsumer();
45 virtual void OnCreationError(ErrorCode code) = 0;
46 virtual void OnLongCreationWarning() = 0;
47 virtual void OnCreationTimeout() = 0;
48 virtual void OnCreationSuccess() = 0;
51 // All UI initialization is deferred till Init() call.
52 // |Consumer| is not owned by controller, and it is expected that it wouldn't
53 // be deleted before ManagedUserCreationController.
54 explicit ManagedUserCreationController(StatusConsumer* consumer);
55 virtual ~ManagedUserCreationController();
57 // Returns the current locally managed user controller if it has been created.
58 static ManagedUserCreationController* current_controller() {
59 return current_controller_;
62 // Set up controller for creating new supervised user with |display_name|,
63 // |password| and avatar indexed by |avatar_index|. StartCreation() have to
64 // be called to actually start creating user.
65 virtual void StartCreation(const base::string16& display_name,
66 const std::string& password,
67 int avatar_index) = 0;
69 // Configures and initiates importing existing supervised user to this device.
70 // Existing user is identified by |sync_id|, has |display_name|, |password|,
71 // |avatar_index|. The master key for cryptohome is a |master_key|.
72 virtual void StartImport(const base::string16& display_name,
73 const std::string& password,
75 const std::string& sync_id,
76 const std::string& master_key) = 0;
78 // Configures and initiates importing existing supervised user to this device.
79 // Existing user is identified by |sync_id|, has |display_name|,
80 // |avatar_index|. The master key for cryptohome is a |master_key|. The user
81 // has password specified in |password_data| and
82 // |encryption_key|/|signature_key| for cryptohome.
83 virtual void StartImport(const base::string16& display_name,
85 const std::string& sync_id,
86 const std::string& master_key,
87 const base::DictionaryValue* password_data,
88 const std::string& encryption_key,
89 const std::string& signature_key) = 0;
91 virtual void SetManagerProfile(Profile* manager_profile) = 0;
92 virtual Profile* GetManagerProfile() = 0;
93 virtual void CancelCreation() = 0;
94 virtual void FinishCreation() = 0;
95 virtual std::string GetManagedUserId() = 0;
98 // Pointer to the current instance of the controller to be used by
100 static ManagedUserCreationController* current_controller_;
102 StatusConsumer* consumer_;
105 DISALLOW_COPY_AND_ASSIGN(ManagedUserCreationController);
108 } // namespace chromeos
110 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_MANAGED_MANAGED_USER_CREATION_CONTROLLER_H_