| OLD | NEW |
| (Empty) |
| 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_MANAGED_MANAGED_USER_CREATION_CONTROLLER_H
_ | |
| 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_MANAGED_MANAGED_USER_CREATION_CONTROLLER_H
_ | |
| 7 | |
| 8 #include <string> | |
| 9 | |
| 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" | |
| 18 | |
| 19 class Profile; | |
| 20 | |
| 21 namespace chromeos { | |
| 22 | |
| 23 // ManagedUserCreationController is used to locally managed user | |
| 24 // creation. | |
| 25 class ManagedUserCreationController { | |
| 26 public: | |
| 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; | |
| 31 | |
| 32 enum ErrorCode { | |
| 33 NO_ERROR, | |
| 34 CRYPTOHOME_NO_MOUNT, | |
| 35 CRYPTOHOME_FAILED_MOUNT, | |
| 36 CRYPTOHOME_FAILED_TPM, | |
| 37 CLOUD_SERVER_ERROR, | |
| 38 TOKEN_WRITE_FAILED, | |
| 39 }; | |
| 40 | |
| 41 class StatusConsumer { | |
| 42 public: | |
| 43 virtual ~StatusConsumer(); | |
| 44 | |
| 45 virtual void OnCreationError(ErrorCode code) = 0; | |
| 46 virtual void OnLongCreationWarning() = 0; | |
| 47 virtual void OnCreationTimeout() = 0; | |
| 48 virtual void OnCreationSuccess() = 0; | |
| 49 }; | |
| 50 | |
| 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(); | |
| 56 | |
| 57 // Returns the current locally managed user controller if it has been created. | |
| 58 static ManagedUserCreationController* current_controller() { | |
| 59 return current_controller_; | |
| 60 } | |
| 61 | |
| 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; | |
| 68 | |
| 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, | |
| 74 int avatar_index, | |
| 75 const std::string& sync_id, | |
| 76 const std::string& master_key) = 0; | |
| 77 | |
| 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, | |
| 84 int avatar_index, | |
| 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; | |
| 90 | |
| 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; | |
| 96 | |
| 97 protected: | |
| 98 // Pointer to the current instance of the controller to be used by | |
| 99 // automation tests. | |
| 100 static ManagedUserCreationController* current_controller_; | |
| 101 | |
| 102 StatusConsumer* consumer_; | |
| 103 | |
| 104 private: | |
| 105 DISALLOW_COPY_AND_ASSIGN(ManagedUserCreationController); | |
| 106 }; | |
| 107 | |
| 108 } // namespace chromeos | |
| 109 | |
| 110 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_MANAGED_MANAGED_USER_CREATION_CONTROLLE
R_H_ | |
| OLD | NEW |