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.h" | |
bartfab (slow)
2014/08/04 18:44:52
Nit: #include "base/callback_forward.h" and move t
davidyu
2014/08/05 07:26:59
Done.
| |
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 // Consumer management service handles the enroll state, which is an integer | |
bartfab (slow)
2014/08/04 18:44:52
Nit 1: s/Consumer/The consumer/
Nit 2: s/enroll/en
davidyu
2014/08/05 07:26:59
Done.
| |
28 // variable stored in local state to pass the enrollment status between all | |
29 // involved compoments, including settings page, signin page, and user | |
bartfab (slow)
2014/08/04 18:44:52
Nit: What is the "signin page"?
davidyu
2014/08/05 07:26:58
sign-in screen?
bartfab (slow)
2014/08/05 18:07:13
Yes, that is the canonical term :).
| |
30 // notification. It also handles the owner email stored in boot lockbox. | |
bartfab (slow)
2014/08/04 18:44:53
Nit: s/email/e-mail/
davidyu
2014/08/05 07:26:59
Done.
| |
31 class ConsumerManagementService { | |
bartfab (slow)
2014/08/04 18:44:51
I am not sure this name is very well chosen. We ha
davidyu
2014/08/05 07:26:59
I'm planning to add other consumer management rela
bartfab (slow)
2014/08/05 18:07:13
Thanks for clarifying. The name makes sense then.
| |
32 public: | |
33 enum EnrollState { | |
bartfab (slow)
2014/08/04 18:44:52
Nit: s/Enroll/Enrollment/
davidyu
2014/08/05 07:26:58
Done.
| |
34 ENROLL_NONE = 0, // Nothing. All notifications have been sent. | |
bartfab (slow)
2014/08/04 18:44:53
Nit 1: Here and below: s/ENROLL/ENROLLMENT/
Nit 2:
davidyu
2014/08/05 07:26:59
Updated the comment.
| |
35 ENROLL_ENROLLING, // Enrollment is in progress. | |
36 ENROLL_SUCCESS, // Success. | |
37 ENROLL_CANCELED, // Canceled by the user. | |
38 ENROLL_BOOT_LOCKBOX_FAILED, // Failed to write to the boot lockbox. | |
39 ENROLL_DM_SERVER_FAILED, // Failed to register the device. | |
40 }; | |
41 | |
42 // Registers prefs. | |
43 static void RegisterPrefs(PrefRegistrySimple* registry); | |
44 | |
45 explicit ConsumerManagementService(chromeos::CryptohomeClient* client); | |
bartfab (slow)
2014/08/04 18:44:52
Nit: Make the constructor the first method.
davidyu
2014/08/05 07:26:58
Done.
| |
46 | |
47 // Returns the enroll state. | |
48 EnrollState GetEnrollState(); | |
bartfab (slow)
2014/08/04 18:44:52
Nit 1: s/Enroll/Enrollment/g
Nit 2: const.
davidyu
2014/08/05 07:26:58
Done.
Actually, GetOwner() should also be const a
bartfab (slow)
2014/08/05 18:07:13
Yeah, I would say we prefer non-const to mutable i
| |
49 | |
50 // Sets the enroll state. | |
51 void SetEnrollState(EnrollState state); | |
bartfab (slow)
2014/08/04 18:44:53
Nit: s/Enroll/Enrollment/g
davidyu
2014/08/05 07:26:59
Done.
| |
52 | |
53 // Returns the device owner stored in the boot lockbox via |callback|. | |
54 void GetOwner(const base::Callback<void(const std::string&)>& callback); | |
bartfab (slow)
2014/08/04 18:44:52
Nit: Add a typedef for this callback. Since you us
davidyu
2014/08/05 07:26:59
Done.
| |
55 | |
56 // Stores the device owner into the boot lockbox and signs it. |callback| is | |
57 // invoked with a status when done. | |
bartfab (slow)
2014/08/04 18:44:51
Nit: s/a status/an argzument indicating success or
davidyu
2014/08/05 07:26:59
Done.
| |
58 void SetOwner(const std::string& email, | |
bartfab (slow)
2014/08/04 18:44:51
+rogertawa@
All of Chrome OS needs to move from e
davidyu
2014/08/05 07:26:58
Changed the argument name to user_id. When we migr
bartfab (slow)
2014/08/05 18:07:13
Yes, it will be a long and difficult journey. What
davidyu
2014/08/06 03:04:31
BTW, we may still need to keep the owner email aro
| |
59 const base::Callback<void(bool)>& callback); | |
bartfab (slow)
2014/08/04 18:44:52
Nit: Add a typedef for this callback. Since you us
davidyu
2014/08/05 07:26:59
Done.
| |
60 | |
61 private: | |
62 static const char* kDeviceOwner; | |
bartfab (slow)
2014/08/04 18:44:51
Nit: Move this to an anonymous namespace in the im
davidyu
2014/08/05 07:26:59
Done.
| |
63 | |
64 void OnGetBootAttributeDone( | |
65 const base::Callback<void(const std::string&)>& callback, | |
66 chromeos::DBusMethodCallStatus call_status, | |
67 bool result, | |
bartfab (slow)
2014/08/04 18:44:52
Nit: How about s/result/success/?
davidyu
2014/08/05 07:26:58
Renamed to dbus_success, as it's just D-Bus callin
| |
68 const cryptohome::BaseReply& reply); | |
69 | |
70 void OnSetBootAttributeDone(const base::Callback<void(bool)>& callback, | |
71 chromeos::DBusMethodCallStatus call_status, | |
72 bool result, | |
bartfab (slow)
2014/08/04 18:44:53
Nit: How about s/result/success/?
davidyu
2014/08/05 07:26:59
Done.
| |
73 const cryptohome::BaseReply& reply); | |
74 | |
75 void OnFlushAndSignBootAttributesDone( | |
76 const base::Callback<void(bool)>& callback, | |
77 chromeos::DBusMethodCallStatus call_status, | |
78 bool result, | |
bartfab (slow)
2014/08/04 18:44:53
Nit: How about s/result/success/?
davidyu
2014/08/05 07:26:58
Done.
| |
79 const cryptohome::BaseReply& reply); | |
80 | |
81 chromeos::CryptohomeClient* client_; | |
82 base::WeakPtrFactory<ConsumerManagementService> weak_ptr_factory_; | |
83 | |
84 DISALLOW_COPY_AND_ASSIGN(ConsumerManagementService); | |
85 }; | |
86 | |
87 } // namespace policy | |
88 | |
89 #endif // CHROME_BROWSER_CHROMEOS_POLICY_CONSUMER_MANAGEMENT_SERVICE_H_ | |
OLD | NEW |