blob: 48335cea658f9bf704083666ec8690cbaad3ec1a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef COMPONENTS_PAIRING_FAKE_HOST_PAIRING_CONTROLLER_H_
#define COMPONENTS_PAIRING_FAKE_HOST_PAIRING_CONTROLLER_H_
#include "base/macros.h"
#include "base/observer_list.h"
#include "base/time/time.h"
#include "components/pairing/host_pairing_controller.h"
namespace pairing_chromeos {
class FakeHostPairingController
: public HostPairingController,
public HostPairingController::Observer {
public:
typedef HostPairingController::Observer Observer;
// Config is a comma separated list of key-value pairs separated by colon.
// Supported options:
// * async_duration - integer. Default: 3000.
// * start_after_update - {0,1}. Default: 0.
// * fail_enrollment - {0,1}. Default: 0.
// * code - 6 digits or empty string. Default: empty string. If strings is
// empty, random code is generated.
// * device_name - string. Default: "Chromebox-01".
// * domain - string. Default: "example.com".
explicit FakeHostPairingController(const std::string& config);
virtual ~FakeHostPairingController();
// Applies given |config| to flow.
void ApplyConfig(const std::string& config);
private:
void ChangeStage(Stage new_stage);
void ChangeStageLater(Stage new_stage);
// HostPairingController:
virtual void AddObserver(Observer* observer) override;
virtual void RemoveObserver(Observer* observer) override;
virtual Stage GetCurrentStage() override;
virtual void StartPairing() override;
virtual std::string GetDeviceName() override;
virtual std::string GetConfirmationCode() override;
virtual std::string GetEnrollmentDomain() override;
virtual void OnUpdateStatusChanged(UpdateStatus update_status) override;
virtual void OnEnrollmentStatusChanged(
EnrollmentStatus enrollment_status) override;
// HostPairingController::Observer:
virtual void PairingStageChanged(Stage new_stage) override;
virtual void ConfigureHost(bool accepted_eula,
const std::string& lang,
const std::string& timezone,
bool send_reports,
const std::string& keyboard_layout) override;
virtual void EnrollHost(const std::string& auth_token) override;
ObserverList<Observer> observers_;
Stage current_stage_;
std::string device_name_;
std::string confirmation_code_;
base::TimeDelta async_duration_;
// If this flag is true error happens on |STAGE_ENROLLING| once.
bool enrollment_should_fail_;
// Controller starts its work like if update and reboot already happened.
bool start_after_update_;
std::string enrollment_domain_;
DISALLOW_COPY_AND_ASSIGN(FakeHostPairingController);
};
} // namespace pairing_chromeos
#endif // COMPONENTS_PAIRING_FAKE_HOST_PAIRING_CONTROLLER_H_
|