Roll src/third_party/WebKit e2f1087:c936ac9 (svn 200537:200538)
[chromium-blink-merge.git] / components / pairing / host_pairing_controller.h
blobb360d071fea3fef03e0b7ae4b48979ab3d4ba5e8
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 COMPONENTS_PAIRING_HOST_PAIRING_CONTROLLER_H_
6 #define COMPONENTS_PAIRING_HOST_PAIRING_CONTROLLER_H_
8 #include <string>
10 #include "base/macros.h"
12 namespace pairing_chromeos {
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_WAITING_FOR_CONTROLLER_AFTER_UPDATE,
22 STAGE_WAITING_FOR_CREDENTIALS,
23 STAGE_ENROLLING,
24 STAGE_ENROLLMENT_ERROR,
25 STAGE_ENROLLMENT_SUCCESS,
26 STAGE_FINISHED
29 enum UpdateStatus {
30 UPDATE_STATUS_UNKNOWN,
31 UPDATE_STATUS_UPDATING,
32 UPDATE_STATUS_REBOOTING,
33 UPDATE_STATUS_UPDATED,
36 enum EnrollmentStatus {
37 ENROLLMENT_STATUS_UNKNOWN,
38 ENROLLMENT_STATUS_ENROLLING,
39 ENROLLMENT_STATUS_FAILURE,
40 ENROLLMENT_STATUS_SUCCESS,
43 class Observer {
44 public:
45 Observer();
46 virtual ~Observer();
48 // Called when pairing has moved on from one stage to another.
49 virtual void PairingStageChanged(Stage new_stage) = 0;
51 // Called when the controller has sent a configuration to apply.
52 virtual void ConfigureHostRequested(bool accepted_eula,
53 const std::string& lang,
54 const std::string& timezone,
55 bool send_reports,
56 const std::string& keyboard_layout) {}
58 // Called when the controller has sent a network to add.
59 virtual void AddNetworkRequested(const std::string& onc_spec) {}
61 // Called when the controller has provided an |auth_token| for enrollment.
62 virtual void EnrollHostRequested(const std::string& auth_token) {}
64 private:
65 DISALLOW_COPY_AND_ASSIGN(Observer);
68 HostPairingController();
69 virtual ~HostPairingController();
71 // Returns current stage of pairing process.
72 virtual Stage GetCurrentStage() = 0;
74 // Starts pairing process. Can be called only on |STAGE_NONE| stage.
75 virtual void StartPairing() = 0;
77 // Returns device name.
78 virtual std::string GetDeviceName() = 0;
80 // Returns 6-digit confirmation code. Can be called only on
81 // |STAGE_WAITING_FOR_CODE_CONFIRMATION| stage.
82 virtual std::string GetConfirmationCode() = 0;
84 // Returns an enrollment domain name. Can be called on stage
85 // |STAGE_ENROLLMENT| and later.
86 virtual std::string GetEnrollmentDomain() = 0;
88 // Notify that the update status has changed.
89 virtual void OnUpdateStatusChanged(UpdateStatus update_status) = 0;
91 // Notify that enrollment status has changed.
92 // Can be called on stage |STAGE_WAITING_FOR_CREDENTIALS|.
93 virtual void OnEnrollmentStatusChanged(
94 EnrollmentStatus enrollment_status) = 0;
96 // Set the permanent id assigned during enrollment.
97 virtual void SetPermanentId(const std::string& permanent_id) = 0;
99 virtual void AddObserver(Observer* observer) = 0;
100 virtual void RemoveObserver(Observer* observer) = 0;
102 private:
103 DISALLOW_COPY_AND_ASSIGN(HostPairingController);
106 } // namespace pairing_chromeos
108 #endif // COMPONENTS_PAIRING_HOST_PAIRING_CONTROLLER_H_