blob: 7d14b6e9c8a3ffb8566b9b501088e12a901ae79c [file] [log] [blame]
[email protected]03c32fe12014-06-24 17:34:541// 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
[email protected]7d54a192014-07-22 00:17:385#ifndef COMPONENTS_PAIRING_HOST_PAIRING_CONTROLLER_H_
6#define COMPONENTS_PAIRING_HOST_PAIRING_CONTROLLER_H_
[email protected]03c32fe12014-06-24 17:34:547
8#include <string>
9
10#include "base/macros.h"
[email protected]03c32fe12014-06-24 17:34:5411
[email protected]7d54a192014-07-22 00:17:3812namespace pairing_chromeos {
[email protected]03c32fe12014-06-24 17:34:5413
[email protected]7d54a192014-07-22 00:17:3814class HostPairingController {
[email protected]03c32fe12014-06-24 17:34:5415 public:
16 enum Stage {
17 STAGE_NONE,
18 STAGE_WAITING_FOR_CONTROLLER,
19 STAGE_WAITING_FOR_CODE_CONFIRMATION,
20 STAGE_UPDATING,
21 STAGE_WAITING_FOR_CONTROLLER_AFTER_UPDATE,
22 STAGE_WAITING_FOR_CREDENTIALS,
23 STAGE_ENROLLING,
24 STAGE_ENROLLMENT_ERROR,
25 STAGE_PAIRING_DONE,
26 STAGE_FINISHED
27 };
28
29 struct UpdateProgress {
30 // Number in [0, 1].
31 double progress;
32 };
33
34 class Observer {
35 public:
36 Observer();
37 virtual ~Observer();
38
39 // Called when pairing has moved on from one stage to another.
40 virtual void PairingStageChanged(Stage new_stage) = 0;
41
42 // Called periodically on |STAGE_UPDATING| stage. Current update progress
43 // is stored in |progress|.
44 virtual void UpdateAdvanced(const UpdateProgress& progress) = 0;
45
46 private:
47 DISALLOW_COPY_AND_ASSIGN(Observer);
48 };
49
50 HostPairingController();
51 virtual ~HostPairingController();
52
53 virtual void AddObserver(Observer* observer) = 0;
54 virtual void RemoveObserver(Observer* observer) = 0;
55
56 // Returns current stage of pairing process.
57 virtual Stage GetCurrentStage() = 0;
58
59 // Starts pairing process. Can be called only on |STAGE_NONE| stage.
60 virtual void StartPairing() = 0;
61
62 // Returns device name.
63 virtual std::string GetDeviceName() = 0;
64
65 // Returns 6-digit confirmation code. Can be called only on
66 // |STAGE_WAITING_FOR_CODE_CONFIRMATION| stage.
67 virtual std::string GetConfirmationCode() = 0;
68
[email protected]7730e382014-07-04 18:38:0569 // Returns an enrollment domain name. Can be called on stage
70 // |STAGE_ENROLLMENT| and later.
71 virtual std::string GetEnrollmentDomain() = 0;
72
[email protected]03c32fe12014-06-24 17:34:5473 private:
74 DISALLOW_COPY_AND_ASSIGN(HostPairingController);
75};
76
[email protected]7d54a192014-07-22 00:17:3877} // namespace pairing_chromeos
[email protected]03c32fe12014-06-24 17:34:5478
[email protected]7d54a192014-07-22 00:17:3879#endif // COMPONENTS_PAIRING_HOST_PAIRING_CONTROLLER_H_