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 COMPONENTS_PAIRING_HOST_PAIRING_CONTROLLER_H_ 6 #define COMPONENTS_PAIRING_HOST_PAIRING_CONTROLLER_H_ 7 8 #include <string> 9 10 #include "base/macros.h" 11 12 namespace pairing_chromeos { 13 14 class HostPairingController { 15 public: 16 enum Stage { 17 STAGE_NONE, 18 STAGE_INITIALIZATION_ERROR, 19 STAGE_WAITING_FOR_CONTROLLER, 20 STAGE_WAITING_FOR_CODE_CONFIRMATION, 21 STAGE_UPDATING, 22 STAGE_WAITING_FOR_CONTROLLER_AFTER_UPDATE, 23 STAGE_WAITING_FOR_CREDENTIALS, 24 STAGE_ENROLLING, 25 STAGE_ENROLLMENT_ERROR, 26 STAGE_PAIRING_DONE, 27 STAGE_FINISHED 28 }; 29 30 enum UpdateStatus { 31 UPDATE_STATUS_UNKNOWN, 32 UPDATE_STATUS_UPDATING, 33 UPDATE_STATUS_REBOOTING, 34 UPDATE_STATUS_UPDATED, 35 }; 36 37 class Observer { 38 public: 39 Observer(); 40 virtual ~Observer(); 41 42 // Called when pairing has moved on from one stage to another. 43 virtual void PairingStageChanged(Stage new_stage) = 0; 44 45 // Called when the controller has sent a configuration to apply. 46 virtual void ConfigureHost(bool accepted_eula, 47 const std::string& lang, 48 const std::string& timezone, 49 bool send_reports, 50 const std::string& keyboard_layout) = 0; 51 52 // Called when the controller has provided an |auth_token| for enrollment. 53 virtual void EnrollHost(const std::string& auth_token) = 0; 54 55 private: 56 DISALLOW_COPY_AND_ASSIGN(Observer); 57 }; 58 59 HostPairingController(); 60 virtual ~HostPairingController(); 61 62 // Returns current stage of pairing process. 63 virtual Stage GetCurrentStage() = 0; 64 65 // Starts pairing process. Can be called only on |STAGE_NONE| stage. 66 virtual void StartPairing() = 0; 67 68 // Returns device name. 69 virtual std::string GetDeviceName() = 0; 70 71 // Returns 6-digit confirmation code. Can be called only on 72 // |STAGE_WAITING_FOR_CODE_CONFIRMATION| stage. 73 virtual std::string GetConfirmationCode() = 0; 74 75 // Returns an enrollment domain name. Can be called on stage 76 // |STAGE_ENROLLMENT| and later. 77 virtual std::string GetEnrollmentDomain() = 0; 78 79 // Notify that the update status has changed. 80 // Can be called on stage |STAGE_UPDATING|. 81 virtual void OnUpdateStatusChanged(UpdateStatus update_status) = 0; 82 83 // Called when enrollment has completed. 84 virtual void SetEnrollmentComplete(bool success) = 0; 85 86 virtual void AddObserver(Observer* observer) = 0; 87 virtual void RemoveObserver(Observer* observer) = 0; 88 89 private: 90 DISALLOW_COPY_AND_ASSIGN(HostPairingController); 91 }; 92 93 } // namespace pairing_chromeos 94 95 #endif // COMPONENTS_PAIRING_HOST_PAIRING_CONTROLLER_H_ 96