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

Unified 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: 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/policy/consumer_management_service.h
diff --git a/chrome/browser/chromeos/policy/consumer_management_service.h b/chrome/browser/chromeos/policy/consumer_management_service.h
new file mode 100644
index 0000000000000000000000000000000000000000..a00c38e3ef2c7ac96d92000971bb33661c1dbaad
--- /dev/null
+++ b/chrome/browser/chromeos/policy/consumer_management_service.h
@@ -0,0 +1,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_POLICY_CONSUMER_MANAGEMENT_SERVICE_H_
+#define CHROME_BROWSER_CHROMEOS_POLICY_CONSUMER_MANAGEMENT_SERVICE_H_
+
+#include <string>
+
+#include "base/callback_forward.h"
+#include "base/macros.h"
+#include "base/memory/weak_ptr.h"
+#include "chromeos/dbus/dbus_method_call_status.h"
+
+class PrefRegistrySimple;
+
+namespace chromeos {
+class CryptohomeClient;
+}
+
+namespace cryptohome {
+class BaseReply;
+}
+
+namespace policy {
+
+// The consumer management service handles the enrollment state, which is an
+// enum value stored in local state to pass the information across reboots
+// 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.
+// 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.
+class ConsumerManagementService {
+ public:
+ enum EnrollmentState {
+ ENROLLMENT_NONE = 0, // Not enrolled, or the enrollment is completed.
+ ENROLLMENT_ENROLLING, // Enrollment is in progress.
+ 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.
+ ENROLLMENT_CANCELED, // Canceled by the user.
+ ENROLLMENT_BOOT_LOCKBOX_FAILED, // Failed to write to the boot lockbox.
+ ENROLLMENT_DM_SERVER_FAILED, // Failed to register the device.
+
+ ENROLLMENT_LAST, // This should always be the last one.
+ };
+
+ // GetOwner() invokes this with an argument set to the owner user ID,
+ // or an empty string on failure.
+ typedef base::Callback<void(const std::string&)> GetOwnerCallback;
+
+ // SetOwner() invokes this with an argument indicating success or failure.
+ typedef base::Callback<void(bool)> SetOwnerCallback;
+
+ explicit ConsumerManagementService(chromeos::CryptohomeClient* client);
+
+ // Registers prefs.
+ static void RegisterPrefs(PrefRegistrySimple* registry);
+
+ // Returns the enrollment state.
+ EnrollmentState GetEnrollmentState() const;
+
+ // Sets the enrollment state.
+ void SetEnrollmentState(EnrollmentState state);
+
+ // Returns the device owner stored in the boot lockbox via |callback|.
+ void GetOwner(const GetOwnerCallback& callback);
+
+ // Stores the device owner user ID into the boot lockbox and signs it.
+ // |callback| is invoked with an agument indicating success or failure.
+ void SetOwner(const std::string& user_id, const SetOwnerCallback& callback);
+
+ private:
+ void OnGetBootAttributeDone(
+ const GetOwnerCallback& callback,
+ chromeos::DBusMethodCallStatus call_status,
+ bool dbus_success,
+ const cryptohome::BaseReply& reply);
+
+ void OnSetBootAttributeDone(const SetOwnerCallback& callback,
+ chromeos::DBusMethodCallStatus call_status,
+ bool dbus_success,
+ const cryptohome::BaseReply& reply);
+
+ void OnFlushAndSignBootAttributesDone(
+ const SetOwnerCallback& callback,
+ chromeos::DBusMethodCallStatus call_status,
+ bool dbus_success,
+ const cryptohome::BaseReply& reply);
+
+ chromeos::CryptohomeClient* client_;
+ base::WeakPtrFactory<ConsumerManagementService> weak_ptr_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(ConsumerManagementService);
+};
+
+} // namespace policy
+
+#endif // CHROME_BROWSER_CHROMEOS_POLICY_CONSUMER_MANAGEMENT_SERVICE_H_

Powered by Google App Engine
This is Rietveld 408576698