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

Unified Diff: chrome/browser/chromeos/ownership/owner_settings_service_chromeos.h

Issue 654263003: Implemented OwnerSettingsService::Set() method. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixes. Created 6 years, 2 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/ownership/owner_settings_service_chromeos.h
diff --git a/chrome/browser/chromeos/ownership/owner_settings_service_chromeos.h b/chrome/browser/chromeos/ownership/owner_settings_service_chromeos.h
index 8f47b4d968582b8e0ed8a6a907ea2cc25d325ddf..4b03af9ecaf7a811e57ea9bdc769adbbb73510ee 100644
--- a/chrome/browser/chromeos/ownership/owner_settings_service_chromeos.h
+++ b/chrome/browser/chromeos/ownership/owner_settings_service_chromeos.h
@@ -5,12 +5,12 @@
#ifndef CHROME_BROWSER_CHROMEOS_OWNERSHIP_OWNER_SETTINGS_SERVICE_CHROMEOS_H_
#define CHROME_BROWSER_CHROMEOS_OWNERSHIP_OWNER_SETTINGS_SERVICE_CHROMEOS_H_
-#include <deque>
+#include <string>
#include <vector>
#include "base/callback_forward.h"
-#include "base/compiler_specific.h"
#include "base/macros.h"
+#include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h"
#include "chrome/browser/chromeos/settings/device_settings_service.h"
#include "chromeos/dbus/session_manager_client.h"
#include "components/keyed_service/core/keyed_service.h"
@@ -27,8 +27,6 @@ class OwnerKeyUtil;
namespace chromeos {
-class SessionManagerOperation;
-
// The class is a profile-keyed service which holds public/private
// keypair corresponds to a profile. The keypair is reloaded automatically when
// profile is created and TPM token is ready. Note that the private part of a
@@ -38,16 +36,17 @@ class SessionManagerOperation;
// (crbug.com/230018).
class OwnerSettingsServiceChromeOS : public ownership::OwnerSettingsService,
public content::NotificationObserver,
- public SessionManagerClient::Observer {
+ public SessionManagerClient::Observer,
+ public DeviceSettingsService::Observer {
public:
virtual ~OwnerSettingsServiceChromeOS();
void OnTPMTokenReady(bool tpm_token_enabled);
// ownership::OwnerSettingsService implementation:
- virtual void SignAndStorePolicyAsync(
- scoped_ptr<enterprise_management::PolicyData> policy,
- const base::Closure& callback) override;
+ virtual bool HandlesSetting(const std::string& setting) override;
+ virtual bool Set(const std::string& setting,
+ const base::Value& value) override;
// NotificationObserver implementation:
virtual void Observe(int type,
@@ -57,6 +56,10 @@ class OwnerSettingsServiceChromeOS : public ownership::OwnerSettingsService,
// SessionManagerClient::Observer:
virtual void OwnerKeySet(bool success) override;
+ // DeviceSettingsService::Observer:
+ virtual void OwnershipStatusChanged() override;
+ virtual void DeviceSettingsUpdated() override;
+
// Checks if the user is the device owner, without the user profile having to
// been initialized. Should be used only if login state is in safe mode.
static void IsOwnerForSafeModeAsync(
@@ -64,13 +67,26 @@ class OwnerSettingsServiceChromeOS : public ownership::OwnerSettingsService,
const scoped_refptr<ownership::OwnerKeyUtil>& owner_key_util,
const IsOwnerCallback& callback);
- static void SetDeviceSettingsServiceForTesting(
- DeviceSettingsService* device_settings_service);
+ // Assembles PolicyData based on |settings|, |policy_data| and
+ // |user_id|.
+ static scoped_ptr<enterprise_management::PolicyData> AssemblePolicy(
+ const std::string& user_id,
+ const enterprise_management::PolicyData* policy_data,
+ const enterprise_management::ChromeDeviceSettingsProto* settings);
+
+ // Updates device |settings|.
+ static void UpdateDeviceSettings(
+ const std::string& path,
+ const base::Value& value,
+ enterprise_management::ChromeDeviceSettingsProto& settings);
+
+ bool has_pending_changes() const { return has_pending_changes_; }
private:
friend class OwnerSettingsServiceChromeOSFactory;
OwnerSettingsServiceChromeOS(
+ DeviceSettingsService* device_settings_service,
Profile* profile,
const scoped_refptr<ownership::OwnerKeyUtil>& owner_key_util);
@@ -85,13 +101,26 @@ class OwnerSettingsServiceChromeOS : public ownership::OwnerSettingsService,
// Possibly notifies DeviceSettingsService that owner's keypair is loaded.
virtual void OnPostKeypairLoadedActions() override;
- // Performs next operation in the queue.
- void StartNextOperation();
+ // Tries to sign store current device settings if there're pending
+ // changes in device settings and no active previous call to
+ // DeviceSettingsService::Store().
+ void StoreDeviceSettings();
+
+ // Called when current device settings are successfully signed.
+ // Sends signed settings for storage.
+ void OnPolicyAssembledAndSigned(
+ scoped_ptr<enterprise_management::PolicyFetchResponse> policy_response);
- // Called when sign-and-store operation completes it's work.
- void HandleCompletedOperation(const base::Closure& callback,
- SessionManagerOperation* operation,
- DeviceSettingsService::Status status);
+ // Called by DeviceSettingsService when modified and signed device
+ // settings are stored. Notifies observers and tries to store device
+ // settings again.
+ void OnSignedPolicyStored(bool success);
+
+ // Fetches device settings from DeviceSettingsService and merges
+ // them with local device settings.
+ bool UpdateFromService();
+
+ DeviceSettingsService* device_settings_service_;
// Profile this service instance belongs to.
Profile* profile_;
@@ -105,14 +134,22 @@ class OwnerSettingsServiceChromeOS : public ownership::OwnerSettingsService,
// Whether TPM token still needs to be initialized.
bool waiting_for_tpm_token_;
- // The queue of pending sign-and-store operations. The first operation on the
- // queue is currently active; it gets removed and destroyed once it completes.
- std::deque<SessionManagerOperation*> pending_operations_;
+ // The device settings. This may be different from the actual
+ // current device settings (which can be obtained from
+ // DeviceSettingsService) in case the device does not have an owner
+ // yet or there are pending changes that have not yet been written
+ // to session_manager.
+ enterprise_management::ChromeDeviceSettingsProto device_settings_;
+
+ // True if some settings were changed but not stored.
+ bool has_pending_changes_;
content::NotificationRegistrar registrar_;
base::WeakPtrFactory<OwnerSettingsServiceChromeOS> weak_factory_;
+ base::WeakPtrFactory<OwnerSettingsServiceChromeOS> store_settings_factory_;
+
DISALLOW_COPY_AND_ASSIGN(OwnerSettingsServiceChromeOS);
};

Powered by Google App Engine
This is Rietveld 408576698