1 // Copyright (c) 2012 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.
5 #ifndef CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_CLOUD_POLICY_MANAGER_CHROMEOS_H_
6 #define CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_CLOUD_POLICY_MANAGER_CHROMEOS_H_
11 #include "base/basictypes.h"
12 #include "base/compiler_specific.h"
13 #include "base/memory/ref_counted.h"
14 #include "base/memory/scoped_ptr.h"
15 #include "chrome/browser/chromeos/policy/server_backed_state_keys_broker.h"
16 #include "components/policy/core/common/cloud/cloud_policy_client.h"
17 #include "components/policy/core/common/cloud/cloud_policy_manager.h"
20 class SequencedTaskRunner;
24 namespace attestation {
25 class AttestationPolicyObserver;
29 class PrefRegistrySimple;
34 class DeviceCloudPolicyStoreChromeOS;
36 // CloudPolicyManager specialization for device policy on Chrome OS.
37 class DeviceCloudPolicyManagerChromeOS : public CloudPolicyManager {
39 // |task_runner| is the runner for policy refresh tasks.
40 DeviceCloudPolicyManagerChromeOS(
41 scoped_ptr<DeviceCloudPolicyStoreChromeOS> store,
42 const scoped_refptr<base::SequencedTaskRunner>& task_runner,
43 ServerBackedStateKeysBroker* state_keys_broker);
44 virtual ~DeviceCloudPolicyManagerChromeOS();
46 // Initializes state keys and requisition information.
47 void Initialize(PrefService* local_state);
49 // TODO(davidyu): Move these two functions to a more appropriate place. See
50 // http://crbug.com/383695.
51 // Gets/Sets the device requisition.
52 std::string GetDeviceRequisition() const;
53 void SetDeviceRequisition(const std::string& requisition);
54 bool IsRemoraRequisition() const;
55 bool IsSharkRequisition() const;
57 // CloudPolicyManager:
58 virtual void Shutdown() OVERRIDE;
60 // Pref registration helper.
61 static void RegisterPrefs(PrefRegistrySimple* registry);
63 // Returns the device serial number, or an empty string if not available.
64 static std::string GetMachineID();
66 // Returns the machine model, or an empty string if not available.
67 static std::string GetMachineModel();
69 // Returns the robot 'email address' associated with the device robot
70 // account (sometimes called a service account) associated with this device
71 // during enterprise enrollment.
72 std::string GetRobotAccountId();
74 // Starts the connection via |client_to_connect|.
75 void StartConnection(scoped_ptr<CloudPolicyClient> client_to_connect,
76 scoped_ptr<CloudPolicyClient::StatusProvider>
77 device_status_provider);
79 DeviceCloudPolicyStoreChromeOS* device_store() {
80 return device_store_.get();
84 // Saves the state keys received from |session_manager_client_|.
85 void OnStateKeysUpdated();
87 // Initializes requisition settings at OOBE with values from VPD.
88 void InitializeRequisition();
90 // Points to the same object as the base CloudPolicyManager::store(), but with
91 // actual device policy specific type.
92 scoped_ptr<DeviceCloudPolicyStoreChromeOS> device_store_;
93 ServerBackedStateKeysBroker* state_keys_broker_;
95 ServerBackedStateKeysBroker::Subscription state_keys_update_subscription_;
97 // PrefService instance to read the policy refresh rate from.
98 PrefService* local_state_;
100 scoped_ptr<chromeos::attestation::AttestationPolicyObserver>
101 attestation_policy_observer_;
103 // TODO(davidyu): Currently we need to keep this object alive while
104 // CloudPolicyClient is in use. We should have CPC take over the
105 // ownership of this object instead. See http://crbug.com/383696.
106 scoped_ptr<CloudPolicyClient::StatusProvider> device_status_provider_;
108 DISALLOW_COPY_AND_ASSIGN(DeviceCloudPolicyManagerChromeOS);
111 } // namespace policy
113 #endif // CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_CLOUD_POLICY_MANAGER_CHROMEOS_H_