blob: cef6dce83613e9a044162bc76a6c349979e6f525 (
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
// 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 CHROME_BROWSER_CHROMEOS_LOGIN_ENROLLMENT_AUTO_ENROLLMENT_CONTROLLER_H_
#define CHROME_BROWSER_CHROMEOS_LOGIN_ENROLLMENT_AUTO_ENROLLMENT_CONTROLLER_H_
#include <string>
#include <vector>
#include "base/callback_list.h"
#include "base/macros.h"
#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
#include "chrome/browser/chromeos/policy/auto_enrollment_client.h"
#include "chrome/browser/chromeos/settings/device_settings_service.h"
namespace policy {
class ServerBackedStateKeysBroker;
}
namespace chromeos {
// Drives the auto-enrollment check, running an AutoEnrollmentClient if
// appropriate to make a decision.
class AutoEnrollmentController {
public:
typedef base::CallbackList<void(policy::AutoEnrollmentState)>
ProgressCallbackList;
// Parameter values for the kEnterpriseEnableForcedReEnrollment flag.
static const char kForcedReEnrollmentAlways[];
static const char kForcedReEnrollmentLegacy[];
static const char kForcedReEnrollmentNever[];
static const char kForcedReEnrollmentOfficialBuild[];
// Auto-enrollment modes.
enum Mode {
// No automatic enrollment.
MODE_NONE,
// Legacy auto-enrollment.
MODE_LEGACY_AUTO_ENROLLMENT,
// Forced re-enrollment.
MODE_FORCED_RE_ENROLLMENT,
};
// Gets the auto-enrollment mode based on command-line flags and official
// build status.
static Mode GetMode();
AutoEnrollmentController();
~AutoEnrollmentController();
// Starts the auto-enrollment check.
void Start();
// Stops any pending auto-enrollment checking.
void Cancel();
// Retry checking.
void Retry();
// Registers a callback to invoke on state changes.
scoped_ptr<ProgressCallbackList::Subscription> RegisterProgressCallback(
const ProgressCallbackList::CallbackType& callback);
// Checks whether legacy auto-enrollment should be performed.
bool ShouldEnrollSilently();
policy::AutoEnrollmentState state() const { return state_; }
private:
// Callback for the ownership status check.
void OnOwnershipStatusCheckDone(
DeviceSettingsService::OwnershipStatus status);
// Starts the auto-enrollment client.
void StartClient(const std::vector<std::string>& state_keys, bool first_boot);
// Sets |state_| and notifies |progress_callbacks_|.
void UpdateState(policy::AutoEnrollmentState state);
policy::AutoEnrollmentState state_;
ProgressCallbackList progress_callbacks_;
scoped_ptr<policy::AutoEnrollmentClient> client_;
base::WeakPtrFactory<AutoEnrollmentController> client_start_weak_factory_;
DISALLOW_COPY_AND_ASSIGN(AutoEnrollmentController);
};
} // namespace chromeos
#endif // CHROME_BROWSER_CHROMEOS_LOGIN_ENROLLMENT_AUTO_ENROLLMENT_CONTROLLER_H_
|