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

Unified Diff: chrome/browser/chromeos/settings/device_settings_service.h

Issue 2486813002: Add DeviceADPolicyManager to provide AD policy. (Closed)
Patch Set: Address Bernhard's comments Created 4 years, 1 month 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/settings/device_settings_service.h
diff --git a/chrome/browser/chromeos/settings/device_settings_service.h b/chrome/browser/chromeos/settings/device_settings_service.h
index fd4fe91fc813584d2f9565867a4b4a3fbdda68f5..c1c7ae0587b577806651ec081d5bca4e5ce21197 100644
--- a/chrome/browser/chromeos/settings/device_settings_service.h
+++ b/chrome/browser/chromeos/settings/device_settings_service.h
@@ -19,6 +19,7 @@
#include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h"
#include "chromeos/dbus/session_manager_client.h"
#include "components/ownership/owner_settings_service.h"
+#include "components/policy/core/common/cloud/cloud_policy_constants.h"
#include "components/policy/core/common/cloud/cloud_policy_validator.h"
#include "components/policy/proto/device_management_backend.pb.h"
#include "crypto/scoped_nss_types.h"
@@ -36,7 +37,7 @@ namespace chromeos {
class SessionManagerOperation;
-// Deals with the low-level interface to Chromium OS device settings. Device
+// Deals with the low-level interface to Chrome OS device settings. Device
// settings are stored in a protobuf that's protected by a cryptographic
// signature generated by a key in the device owner's possession. Key and
// settings are brokered by the session_manager daemon.
@@ -50,11 +51,13 @@ class SessionManagerOperation;
// events so interested parties can reload state as appropriate.
class DeviceSettingsService : public SessionManagerClient::Observer {
public:
- // Indicates ownership status of the device.
+ // Indicates ownership status of the device (listed in upgrade order).
enum OwnershipStatus {
- // Listed in upgrade order.
OWNERSHIP_UNKNOWN = 0,
+ // Not yet owned.
OWNERSHIP_NONE,
+ // Either consumer ownership, cloud management or Active Directory
+ // management.
OWNERSHIP_TAKEN
};
@@ -77,10 +80,13 @@ class DeviceSettingsService : public SessionManagerClient::Observer {
public:
virtual ~Observer();
- // Indicates device ownership status changes.
+ // Indicates device ownership status changes. This is triggered upon every
+ // browser start since the transition from uninitialized (OWNERSHIP_UNKNOWN)
+ // to initialized (either of OWNERSHIP_{NONE,TAKEN}) also counts as an
+ // ownership change.
virtual void OwnershipStatusChanged();
- // Gets call after updates to the device settings.
+ // Gets called after updates to the device settings.
virtual void DeviceSettingsUpdated();
virtual void OnDeviceSettingsServiceShutdown();
@@ -97,7 +103,7 @@ class DeviceSettingsService : public SessionManagerClient::Observer {
DeviceSettingsService();
~DeviceSettingsService() override;
- // To be called on startup once threads are initialized and DBus is ready.
+ // To be called on startup once threads are initialized and D-Bus is ready.
void SetSessionManager(SessionManagerClient* session_manager_client,
scoped_refptr<ownership::OwnerKeyUtil> owner_key_util);
@@ -105,6 +111,10 @@ class DeviceSettingsService : public SessionManagerClient::Observer {
// and stops any pending operations.
void UnsetSessionManager();
+ // Must only be used with a |device_mode| that has been read and verified by
+ // the InstallAttributes class.
+ void SetDeviceMode(policy::DeviceMode device_mode);
+
const enterprise_management::PolicyData* policy_data() {
return policy_data_.get();
}
@@ -120,9 +130,7 @@ class DeviceSettingsService : public SessionManagerClient::Observer {
scoped_refptr<ownership::PublicKey> GetPublicKey();
// Returns the status generated by the last operation.
- Status status() {
- return store_status_;
- }
+ Status status() { return store_status_; }
// Triggers an attempt to pull the public half of the owner key from disk and
// load the device settings.
@@ -182,11 +190,11 @@ class DeviceSettingsService : public SessionManagerClient::Observer {
void Enqueue(const linked_ptr<SessionManagerOperation>& operation);
// Enqueues a load operation.
- void EnqueueLoad(bool force_key_load);
+ void EnqueueLoad(bool request_key_load);
// Makes sure there's a reload operation so changes to the settings (and key,
- // in case force_key_load is set) are getting picked up.
- void EnsureReload(bool force_key_load);
+ // in case |request_key_load| is set) are getting picked up.
+ void EnsureReload(bool request_key_load);
// Runs the next pending operation.
void StartNextOperation();
@@ -200,21 +208,35 @@ class DeviceSettingsService : public SessionManagerClient::Observer {
// Updates status and invokes the callback immediately.
void HandleError(Status status, const base::Closure& callback);
- SessionManagerClient* session_manager_client_;
+ // Run OwnershipStatusChanged() for observers and push
+ // NOTIFICATION_OWNERSHIP_STATUS_CHANGED to NotificationService.
+ void NotifyOwnershipStatusChanged() const;
+
+ // Run DeviceSettingsUpdated() for observers.
+ void NotifyDeviceSettingsUpdated() const;
+
+ // Processes pending callbacks from GetOwnershipStatusAsync().
+ void RunPendingOwnershipStatusCallbacks();
+
+ SessionManagerClient* session_manager_client_ = nullptr;
scoped_refptr<ownership::OwnerKeyUtil> owner_key_util_;
- Status store_status_;
+ Status store_status_ = STORE_SUCCESS;
std::vector<OwnershipStatusCallback> pending_ownership_status_callbacks_;
std::string username_;
scoped_refptr<ownership::PublicKey> public_key_;
base::WeakPtr<ownership::OwnerSettingsService> owner_settings_service_;
+ // Ownership status before the current session manager operation.
+ OwnershipStatus previous_ownership_status_ = OWNERSHIP_UNKNOWN;
std::unique_ptr<enterprise_management::PolicyData> policy_data_;
std::unique_ptr<enterprise_management::ChromeDeviceSettingsProto>
device_settings_;
+ policy::DeviceMode device_mode_ = policy::DEVICE_MODE_PENDING;
+
// The queue of pending operations. The first operation on the queue is
// currently active; it gets removed and destroyed once it completes.
std::deque<linked_ptr<SessionManagerOperation>> pending_operations_;

Powered by Google App Engine
This is Rietveld 408576698