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

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: Call FlushAndSignBootAttributes() in SetOwner(). 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..35fe849003b89bbc82322100abb2637812c09f98
--- /dev/null
+++ b/chrome/browser/chromeos/policy/consumer_management_service.h
@@ -0,0 +1,89 @@
+// 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.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.
+#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 {
+
+// 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.
+// variable stored in local state to pass the enrollment status between all
+// 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 :).
+// 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.
+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.
+ public:
+ enum EnrollState {
bartfab (slow) 2014/08/04 18:44:52 Nit: s/Enroll/Enrollment/
davidyu 2014/08/05 07:26:58 Done.
+ 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.
+ ENROLL_ENROLLING, // Enrollment is in progress.
+ ENROLL_SUCCESS, // Success.
+ ENROLL_CANCELED, // Canceled by the user.
+ ENROLL_BOOT_LOCKBOX_FAILED, // Failed to write to the boot lockbox.
+ ENROLL_DM_SERVER_FAILED, // Failed to register the device.
+ };
+
+ // Registers prefs.
+ static void RegisterPrefs(PrefRegistrySimple* registry);
+
+ 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.
+
+ // Returns the enroll state.
+ 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
+
+ // Sets the enroll state.
+ 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.
+
+ // Returns the device owner stored in the boot lockbox via |callback|.
+ 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.
+
+ // Stores the device owner into the boot lockbox and signs it. |callback| is
+ // 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.
+ 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
+ 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.
+
+ private:
+ 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.
+
+ void OnGetBootAttributeDone(
+ const base::Callback<void(const std::string&)>& callback,
+ chromeos::DBusMethodCallStatus call_status,
+ 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
+ const cryptohome::BaseReply& reply);
+
+ void OnSetBootAttributeDone(const base::Callback<void(bool)>& callback,
+ chromeos::DBusMethodCallStatus call_status,
+ bool result,
bartfab (slow) 2014/08/04 18:44:53 Nit: How about s/result/success/?
davidyu 2014/08/05 07:26:59 Done.
+ const cryptohome::BaseReply& reply);
+
+ void OnFlushAndSignBootAttributesDone(
+ const base::Callback<void(bool)>& callback,
+ chromeos::DBusMethodCallStatus call_status,
+ bool result,
bartfab (slow) 2014/08/04 18:44:53 Nit: How about s/result/success/?
davidyu 2014/08/05 07:26:58 Done.
+ 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