Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / components / pairing / host_pairing_controller.h
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_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
69   // Returns an enrollment domain name. Can be called on stage
70   // |STAGE_ENROLLMENT| and later.
71   virtual std::string GetEnrollmentDomain() = 0;
72
73  private:
74   DISALLOW_COPY_AND_ASSIGN(HostPairingController);
75 };
76
77 }  // namespace pairing_chromeos
78
79 #endif  // COMPONENTS_PAIRING_HOST_PAIRING_CONTROLLER_H_