Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(383)

Side by Side Diff: chrome/browser/chromeos/policy/consumer_management_service.h

Issue 438493002: Added ConsumerManagementService class to handle enroll state and device owner info in boot lockbox. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@signin
Patch Set: Fixed the broken test. Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 // and between compoments, including settings page, sign-in screen, and user
30 // notification. It also handles the owner user ID stored in the boot lockbox.
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. The notification is not sent yet.
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 virtual ~ConsumerManagementService();
54
55 // Registers prefs.
56 static void RegisterPrefs(PrefRegistrySimple* registry);
57
58 // Returns the enrollment state.
59 EnrollmentState GetEnrollmentState() const;
60
61 // Sets the enrollment state.
62 void SetEnrollmentState(EnrollmentState state);
63
64 // Returns the device owner stored in the boot lockbox via |callback|.
65 void GetOwner(const GetOwnerCallback& callback);
66
67 // Stores the device owner user ID into the boot lockbox and signs it.
68 // |callback| is invoked with an agument indicating success or failure.
69 void SetOwner(const std::string& user_id, const SetOwnerCallback& callback);
70
71 private:
72 void OnGetBootAttributeDone(
73 const GetOwnerCallback& callback,
74 chromeos::DBusMethodCallStatus call_status,
75 bool dbus_success,
76 const cryptohome::BaseReply& reply);
77
78 void OnSetBootAttributeDone(const SetOwnerCallback& callback,
79 chromeos::DBusMethodCallStatus call_status,
80 bool dbus_success,
81 const cryptohome::BaseReply& reply);
82
83 void OnFlushAndSignBootAttributesDone(
84 const SetOwnerCallback& callback,
85 chromeos::DBusMethodCallStatus call_status,
86 bool dbus_success,
87 const cryptohome::BaseReply& reply);
88
89 chromeos::CryptohomeClient* client_;
90 base::WeakPtrFactory<ConsumerManagementService> weak_ptr_factory_;
91
92 DISALLOW_COPY_AND_ASSIGN(ConsumerManagementService);
93 };
94
95 } // namespace policy
96
97 #endif // CHROME_BROWSER_CHROMEOS_POLICY_CONSUMER_MANAGEMENT_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698