1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173
|
// 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_BROWSER_POLICY_CONNECTOR_CHROMEOS_H_
#define CHROME_BROWSER_CHROMEOS_POLICY_BROWSER_POLICY_CONNECTOR_CHROMEOS_H_
#include <string>
#include "base/basictypes.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
#include "chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos.h"
#include "chrome/browser/policy/chrome_browser_policy_connector.h"
#include "components/policy/core/common/cloud/cloud_policy_constants.h"
class PrefRegistrySimple;
class PrefService;
namespace net {
class URLRequestContextGetter;
}
namespace policy {
class ConsumerManagementService;
class DeviceCloudPolicyInitializer;
class DeviceCloudPolicyInvalidator;
class DeviceLocalAccountPolicyService;
class DeviceManagementService;
struct EnrollmentConfig;
class EnterpriseInstallAttributes;
class NetworkConfigurationUpdater;
class ProxyPolicyProvider;
class ServerBackedStateKeysBroker;
// Extends ChromeBrowserPolicyConnector with the setup specific to ChromeOS.
class BrowserPolicyConnectorChromeOS
: public ChromeBrowserPolicyConnector,
public DeviceCloudPolicyManagerChromeOS::Observer {
public:
BrowserPolicyConnectorChromeOS();
virtual ~BrowserPolicyConnectorChromeOS();
virtual void Init(
PrefService* local_state,
scoped_refptr<net::URLRequestContextGetter> request_context) override;
// Shutdown() is called from BrowserProcessImpl::StartTearDown() but |this|
// observes some objects that get destroyed earlier. PreShutdown() is called
// from ChromeBrowserMainPartsChromeos::PostMainMessageLoopRun(), allowing the
// connection to these dependencies to be severed earlier.
void PreShutdown();
virtual void Shutdown() override;
// Returns true if this device is managed by an enterprise (as opposed to
// a local owner).
bool IsEnterpriseManaged();
// Returns the enterprise domain if device is managed.
std::string GetEnterpriseDomain();
// Returns the device mode. For ChromeOS this function will return the mode
// stored in the lockbox, or DEVICE_MODE_CONSUMER if the lockbox has been
// locked empty, or DEVICE_MODE_UNKNOWN if the device has not been owned yet.
// For other OSes the function will always return DEVICE_MODE_CONSUMER.
DeviceMode GetDeviceMode();
// Get the enrollment configuration for the device as decided by various
// factors. See DeviceCloudPolicyInitializer::GetPrescribedEnrollmentConfig()
// for details.
EnrollmentConfig GetPrescribedEnrollmentConfig() const;
// Works out the user affiliation by checking the given |user_name| against
// the installation attributes.
UserAffiliation GetUserAffiliation(const std::string& user_name);
DeviceCloudPolicyManagerChromeOS* GetDeviceCloudPolicyManager() {
return device_cloud_policy_manager_;
}
DeviceCloudPolicyInitializer* GetDeviceCloudPolicyInitializer() {
return device_cloud_policy_initializer_.get();
}
DeviceLocalAccountPolicyService* GetDeviceLocalAccountPolicyService() {
return device_local_account_policy_service_.get();
}
EnterpriseInstallAttributes* GetInstallAttributes() {
return install_attributes_.get();
}
ServerBackedStateKeysBroker* GetStateKeysBroker() {
return state_keys_broker_.get();
}
// The browser-global PolicyService is created before Profiles are ready, to
// provide managed values for the local state PrefService. It includes a
// policy provider that forwards policies from a delegate policy provider.
// This call can be used to set the user policy provider as that delegate
// once the Profile is ready, so that user policies can also affect local
// state preferences.
// Only one user policy provider can be set as a delegate at a time, and any
// previously set delegate is removed. Passing NULL removes the current
// delegate, if there is one.
void SetUserPolicyDelegate(ConfigurationPolicyProvider* user_policy_provider);
ConsumerManagementService* GetConsumerManagementService() const {
return consumer_management_service_.get();
}
DeviceManagementService* GetDeviceManagementServiceForConsumer() const {
return consumer_device_management_service_.get();
}
// Sets the consumer management service for testing.
void SetConsumerManagementServiceForTesting(
scoped_ptr<ConsumerManagementService> service);
// Sets the device cloud policy initializer for testing.
void SetDeviceCloudPolicyInitializerForTesting(
scoped_ptr<DeviceCloudPolicyInitializer> initializer);
// Sets the install attributes for testing. Must be called before the browser
// is created. RemoveInstallAttributesForTesting must be called after the test
// to free the attributes.
static void SetInstallAttributesForTesting(
EnterpriseInstallAttributes* attributes);
static void RemoveInstallAttributesForTesting();
// Registers device refresh rate pref.
static void RegisterPrefs(PrefRegistrySimple* registry);
// DeviceCloudPolicyManagerChromeOS::Observer:
void OnDeviceCloudPolicyManagerConnected() override;
private:
// Set the timezone as soon as the policies are available.
void SetTimezoneIfPolicyAvailable();
// Components of the device cloud policy implementation.
scoped_ptr<ServerBackedStateKeysBroker> state_keys_broker_;
scoped_ptr<EnterpriseInstallAttributes> install_attributes_;
scoped_ptr<ConsumerManagementService> consumer_management_service_;
DeviceCloudPolicyManagerChromeOS* device_cloud_policy_manager_;
scoped_ptr<DeviceManagementService> consumer_device_management_service_;
scoped_ptr<DeviceCloudPolicyInitializer> device_cloud_policy_initializer_;
scoped_ptr<DeviceLocalAccountPolicyService>
device_local_account_policy_service_;
scoped_ptr<DeviceCloudPolicyInvalidator> device_cloud_policy_invalidator_;
// This policy provider is used on Chrome OS to feed user policy into the
// global PolicyService instance. This works by installing the cloud policy
// provider of the primary profile as the delegate of the ProxyPolicyProvider,
// after login.
// The provider is owned by the base class; this field is just a typed weak
// pointer to get to the ProxyPolicyProvider at SetUserPolicyDelegate().
ProxyPolicyProvider* global_user_cloud_policy_provider_;
scoped_ptr<NetworkConfigurationUpdater> network_configuration_updater_;
base::WeakPtrFactory<BrowserPolicyConnectorChromeOS> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(BrowserPolicyConnectorChromeOS);
};
} // namespace policy
#endif // CHROME_BROWSER_CHROMEOS_POLICY_BROWSER_POLICY_CONNECTOR_CHROMEOS_H_
|