Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / chrome / browser / chromeos / login / supervised / supervised_user_creation_controller.h
blob8c7dfb7c9ec777696aefd2685c4eb1ba06c69b82
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_SUPERVISED_SUPERVISED_USER_CREATION_CONTROLLER_H_
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_SUPERVISED_SUPERVISED_USER_CREATION_CONTROLLER_H_
8 #include <string>
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/values.h"
15 #include "chrome/browser/chromeos/login/supervised/supervised_user_authenticator.h"
16 #include "chrome/browser/supervised_user/legacy/supervised_user_registration_utility.h"
18 class Profile;
20 namespace chromeos {
22 class SupervisedUserCreationController {
23 public:
24 // This constant is used to indicate that user does not have one of default
25 // avatars: either he has no chromeos avatar at all, or has an external
26 // image as an avatar.
27 static const int kDummyAvatarIndex;
29 enum ErrorCode {
30 NO_ERROR,
31 CRYPTOHOME_NO_MOUNT,
32 CRYPTOHOME_FAILED_MOUNT,
33 CRYPTOHOME_FAILED_TPM,
34 CLOUD_SERVER_ERROR,
35 TOKEN_WRITE_FAILED,
38 class StatusConsumer {
39 public:
40 virtual ~StatusConsumer();
42 virtual void OnCreationError(ErrorCode code) = 0;
43 virtual void OnLongCreationWarning() = 0;
44 virtual void OnCreationTimeout() = 0;
45 virtual void OnCreationSuccess() = 0;
48 // All UI initialization is deferred till Init() call.
49 // |Consumer| is not owned by controller, and it is expected that it wouldn't
50 // be deleted before SupervisedUserCreationController.
51 explicit SupervisedUserCreationController(StatusConsumer* consumer);
52 virtual ~SupervisedUserCreationController();
54 // Returns the current supervised user controller if it has been created.
55 static SupervisedUserCreationController* current_controller() {
56 return current_controller_;
59 // Set up controller for creating new supervised user with |display_name|,
60 // |password| and avatar indexed by |avatar_index|. StartCreation() have to
61 // be called to actually start creating user.
62 virtual void StartCreation(const base::string16& display_name,
63 const std::string& password,
64 int avatar_index) = 0;
66 // Configures and initiates importing existing supervised user to this device.
67 // Existing user is identified by |sync_id|, has |display_name|, |password|,
68 // |avatar_index|. The master key for cryptohome is a |master_key|.
69 virtual void StartImport(const base::string16& display_name,
70 const std::string& password,
71 int avatar_index,
72 const std::string& sync_id,
73 const std::string& master_key) = 0;
75 // Configures and initiates importing existing supervised user to this device.
76 // Existing user is identified by |sync_id|, has |display_name|,
77 // |avatar_index|. The master key for cryptohome is a |master_key|. The user
78 // has password specified in |password_data| and
79 // |encryption_key|/|signature_key| for cryptohome.
80 virtual void StartImport(const base::string16& display_name,
81 int avatar_index,
82 const std::string& sync_id,
83 const std::string& master_key,
84 const base::DictionaryValue* password_data,
85 const std::string& encryption_key,
86 const std::string& signature_key) = 0;
88 virtual void SetManagerProfile(Profile* manager_profile) = 0;
89 virtual Profile* GetManagerProfile() = 0;
90 virtual void CancelCreation() = 0;
91 virtual void FinishCreation() = 0;
92 virtual std::string GetSupervisedUserId() = 0;
94 protected:
95 // Pointer to the current instance of the controller to be used by
96 // automation tests.
97 static SupervisedUserCreationController* current_controller_;
99 StatusConsumer* consumer_;
101 private:
102 DISALLOW_COPY_AND_ASSIGN(SupervisedUserCreationController);
105 } // namespace chromeos
107 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_SUPERVISED_SUPERVISED_USER_CREATION_CONTROLLER_H_