OLD | NEW |
---|---|
(Empty) | |
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 CHROME_BROWSER_CHROMEOS_POLICY_CONSUMER_MANAGEMENT_SERVICE_H_ | |
6 #define CHROME_BROWSER_CHROMEOS_POLICY_CONSUMER_MANAGEMENT_SERVICE_H_ | |
7 | |
8 #include <string> | |
9 | |
10 #include "base/callback_forward.h" | |
11 #include "base/macros.h" | |
12 #include "base/memory/weak_ptr.h" | |
13 #include "chromeos/dbus/dbus_method_call_status.h" | |
14 | |
15 class PrefRegistrySimple; | |
16 | |
17 namespace chromeos { | |
18 class CryptohomeClient; | |
19 } | |
20 | |
21 namespace cryptohome { | |
22 class BaseReply; | |
23 } | |
24 | |
25 namespace policy { | |
26 | |
27 // The consumer management service handles the enrollment state, which is an | |
28 // enum value stored in local state to pass the information across reboots | |
29 // between compoments, including settings page, sign-in screen, and user | |
bartfab (slow)
2014/08/05 18:07:13
Nit: s/between/and between/
davidyu
2014/08/06 03:04:32
Done.
| |
30 // notification. It also handles the owner user ID stored in boot lockbox. | |
bartfab (slow)
2014/08/05 18:07:13
Nit: s/boot/the boot/
davidyu
2014/08/06 03:04:31
Done.
| |
31 class ConsumerManagementService { | |
32 public: | |
33 enum EnrollmentState { | |
34 ENROLLMENT_NONE = 0, // Not enrolled, or the enrollment is completed. | |
35 ENROLLMENT_ENROLLING, // Enrollment is in progress. | |
36 ENROLLMENT_SUCCESS, // Success. | |
bartfab (slow)
2014/08/05 18:07:13
How does "Success" differ from "enrollment is comp
davidyu
2014/08/06 03:04:31
Update the comment.
| |
37 ENROLLMENT_CANCELED, // Canceled by the user. | |
38 ENROLLMENT_BOOT_LOCKBOX_FAILED, // Failed to write to the boot lockbox. | |
39 ENROLLMENT_DM_SERVER_FAILED, // Failed to register the device. | |
40 | |
41 ENROLLMENT_LAST, // This should always be the last one. | |
42 }; | |
43 | |
44 // GetOwner() invokes this with an argument set to the owner user ID, | |
45 // or an empty string on failure. | |
46 typedef base::Callback<void(const std::string&)> GetOwnerCallback; | |
47 | |
48 // SetOwner() invokes this with an argument indicating success or failure. | |
49 typedef base::Callback<void(bool)> SetOwnerCallback; | |
50 | |
51 explicit ConsumerManagementService(chromeos::CryptohomeClient* client); | |
52 | |
53 // Registers prefs. | |
54 static void RegisterPrefs(PrefRegistrySimple* registry); | |
55 | |
56 // Returns the enrollment state. | |
57 EnrollmentState GetEnrollmentState() const; | |
58 | |
59 // Sets the enrollment state. | |
60 void SetEnrollmentState(EnrollmentState state); | |
61 | |
62 // Returns the device owner stored in the boot lockbox via |callback|. | |
63 void GetOwner(const GetOwnerCallback& callback); | |
64 | |
65 // Stores the device owner user ID into the boot lockbox and signs it. | |
66 // |callback| is invoked with an agument indicating success or failure. | |
67 void SetOwner(const std::string& user_id, const SetOwnerCallback& callback); | |
68 | |
69 private: | |
70 void OnGetBootAttributeDone( | |
71 const GetOwnerCallback& callback, | |
72 chromeos::DBusMethodCallStatus call_status, | |
73 bool dbus_success, | |
74 const cryptohome::BaseReply& reply); | |
75 | |
76 void OnSetBootAttributeDone(const SetOwnerCallback& callback, | |
77 chromeos::DBusMethodCallStatus call_status, | |
78 bool dbus_success, | |
79 const cryptohome::BaseReply& reply); | |
80 | |
81 void OnFlushAndSignBootAttributesDone( | |
82 const SetOwnerCallback& callback, | |
83 chromeos::DBusMethodCallStatus call_status, | |
84 bool dbus_success, | |
85 const cryptohome::BaseReply& reply); | |
86 | |
87 chromeos::CryptohomeClient* client_; | |
88 base::WeakPtrFactory<ConsumerManagementService> weak_ptr_factory_; | |
89 | |
90 DISALLOW_COPY_AND_ASSIGN(ConsumerManagementService); | |
91 }; | |
92 | |
93 } // namespace policy | |
94 | |
95 #endif // CHROME_BROWSER_CHROMEOS_POLICY_CONSUMER_MANAGEMENT_SERVICE_H_ | |
OLD | NEW |