Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef COMPONENTS_POLICY_CORE_BROWSER_BROWSER_POLICY_CONNECTOR_H_ | 5 #ifndef COMPONENTS_POLICY_CORE_BROWSER_BROWSER_POLICY_CONNECTOR_H_ |
| 6 #define COMPONENTS_POLICY_CORE_BROWSER_BROWSER_POLICY_CONNECTOR_H_ | 6 #define COMPONENTS_POLICY_CORE_BROWSER_BROWSER_POLICY_CONNECTOR_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 29 class DeviceManagementService; | 29 class DeviceManagementService; |
| 30 class PolicyService; | 30 class PolicyService; |
| 31 class PolicyStatisticsCollector; | 31 class PolicyStatisticsCollector; |
| 32 | 32 |
| 33 // The BrowserPolicyConnector keeps the browser-global (non Profile-specific) | 33 // The BrowserPolicyConnector keeps the browser-global (non Profile-specific) |
| 34 // policy providers, and some shared components of the policy system. | 34 // policy providers, and some shared components of the policy system. |
| 35 // This is a basic implementation that gets extended by platform-specific | 35 // This is a basic implementation that gets extended by platform-specific |
| 36 // subclasses. | 36 // subclasses. |
| 37 class POLICY_EXPORT BrowserPolicyConnector { | 37 class POLICY_EXPORT BrowserPolicyConnector { |
| 38 public: | 38 public: |
| 39 enum ManagementMode { | |
| 40 ENTERPRISE_MANAGED = 0, | |
| 41 CONSUMER_MANAGED, | |
| 42 NUM_MANAGEMENT_MODES // This should always be the last line. | |
| 43 }; | |
| 44 | |
| 39 // Invoke Shutdown() before deleting, see below. | 45 // Invoke Shutdown() before deleting, see below. |
| 40 virtual ~BrowserPolicyConnector(); | 46 virtual ~BrowserPolicyConnector(); |
| 41 | 47 |
| 42 // Finalizes the initialization of the connector. This call can be skipped on | 48 // Finalizes the initialization of the connector. This call can be skipped on |
| 43 // tests that don't require the full policy system running. | 49 // tests that don't require the full policy system running. |
| 44 virtual void Init( | 50 virtual void Init( |
| 45 PrefService* local_state, | 51 PrefService* local_state, |
| 46 scoped_refptr<net::URLRequestContextGetter> request_context) = 0; | 52 scoped_refptr<net::URLRequestContextGetter> request_context) = 0; |
| 47 | 53 |
| 48 // Stops the policy providers and cleans up the connector before it can be | 54 // Stops the policy providers and cleans up the connector before it can be |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 68 | 74 |
| 69 // Returns the platform-specific policy provider, if there is one. | 75 // Returns the platform-specific policy provider, if there is one. |
| 70 ConfigurationPolicyProvider* GetPlatformProvider(); | 76 ConfigurationPolicyProvider* GetPlatformProvider(); |
| 71 | 77 |
| 72 // Schedules initialization of the cloud policy backend services, if the | 78 // Schedules initialization of the cloud policy backend services, if the |
| 73 // services are already constructed. | 79 // services are already constructed. |
| 74 void ScheduleServiceInitialization(int64 delay_milliseconds); | 80 void ScheduleServiceInitialization(int64 delay_milliseconds); |
| 75 | 81 |
| 76 const ConfigurationPolicyHandlerList* GetHandlerList() const; | 82 const ConfigurationPolicyHandlerList* GetHandlerList() const; |
| 77 | 83 |
| 84 // DEPRECATED: use GetDeviceManagementService() instead. | |
|
bartfab (slow)
2014/04/23 12:17:18
Nit: Add a TODO and a bug number to have all curre
davidyu
2014/04/23 12:56:58
Done.
| |
| 78 DeviceManagementService* device_management_service() { | 85 DeviceManagementService* device_management_service() { |
| 79 return device_management_service_.get(); | 86 return GetDeviceManagementService(ENTERPRISE_MANAGED); |
| 80 } | 87 } |
| 81 | 88 |
| 89 // Returns the device management service based on the management mode. | |
| 90 DeviceManagementService* GetDeviceManagementService( | |
| 91 ManagementMode management_mode); | |
| 92 | |
| 82 // Sets a |provider| that will be included in PolicyServices returned by | 93 // Sets a |provider| that will be included in PolicyServices returned by |
| 83 // GetPolicyService. This is a static method because local state is | 94 // GetPolicyService. This is a static method because local state is |
| 84 // created immediately after the connector, and tests don't have a chance to | 95 // created immediately after the connector, and tests don't have a chance to |
| 85 // inject the provider otherwise. |provider| must outlive the connector, and | 96 // inject the provider otherwise. |provider| must outlive the connector, and |
| 86 // its ownership is not taken though the connector will initialize and shut it | 97 // its ownership is not taken though the connector will initialize and shut it |
| 87 // down. | 98 // down. |
| 88 static void SetPolicyProviderForTesting( | 99 static void SetPolicyProviderForTesting( |
| 89 ConfigurationPolicyProvider* provider); | 100 ConfigurationPolicyProvider* provider); |
| 90 | 101 |
| 91 // Check whether a user is known to be non-enterprise. Domains such as | 102 // Check whether a user is known to be non-enterprise. Domains such as |
| 92 // gmail.com and googlemail.com are known to not be managed. Also returns | 103 // gmail.com and googlemail.com are known to not be managed. Also returns |
| 93 // false if the username is empty. | 104 // false if the username is empty. |
| 94 static bool IsNonEnterpriseUser(const std::string& username); | 105 static bool IsNonEnterpriseUser(const std::string& username); |
| 95 | 106 |
| 96 // Returns the URL for the device management service endpoint. | 107 // Returns the URL for the device management service endpoint. |
| 97 static std::string GetDeviceManagementUrl(); | 108 static std::string GetDeviceManagementUrl(ManagementMode management_mode); |
| 98 | 109 |
| 99 // Registers refresh rate prefs. | 110 // Registers refresh rate prefs. |
| 100 static void RegisterPrefs(PrefRegistrySimple* registry); | 111 static void RegisterPrefs(PrefRegistrySimple* registry); |
| 101 | 112 |
| 102 protected: | 113 protected: |
| 103 // Builds an uninitialized BrowserPolicyConnector. | 114 // Builds an uninitialized BrowserPolicyConnector. |
| 104 // Init() should be called to create and start the policy components. | 115 // Init() should be called to create and start the policy components. |
| 105 explicit BrowserPolicyConnector( | 116 explicit BrowserPolicyConnector( |
| 106 const HandlerListFactory& handler_list_factory); | 117 const HandlerListFactory& handler_list_factory); |
| 107 | 118 |
| 108 // Helper for the public Init() that must be called by subclasses. | 119 // Helper for the public Init() that must be called by subclasses. |
| 109 void Init(PrefService* local_state, | 120 void Init(PrefService* local_state, |
| 110 scoped_refptr<net::URLRequestContextGetter> request_context, | 121 scoped_refptr<net::URLRequestContextGetter> request_context, |
| 111 scoped_ptr<DeviceManagementService> device_management_service); | 122 ScopedVector<DeviceManagementService> device_management_services); |
| 112 | 123 |
| 113 // Adds |provider| to the list of |policy_providers_|. Providers should | 124 // Adds |provider| to the list of |policy_providers_|. Providers should |
| 114 // be added in decreasing order of priority. | 125 // be added in decreasing order of priority. |
| 115 void AddPolicyProvider(scoped_ptr<ConfigurationPolicyProvider> provider); | 126 void AddPolicyProvider(scoped_ptr<ConfigurationPolicyProvider> provider); |
| 116 | 127 |
| 117 // Same as AddPolicyProvider(), but |provider| becomes the platform provider | 128 // Same as AddPolicyProvider(), but |provider| becomes the platform provider |
| 118 // which can be retrieved by GetPlatformProvider(). This can be called at | 129 // which can be retrieved by GetPlatformProvider(). This can be called at |
| 119 // most once, and uses the same priority order as AddPolicyProvider(). | 130 // most once, and uses the same priority order as AddPolicyProvider(). |
| 120 void SetPlatformPolicyProvider( | 131 void SetPlatformPolicyProvider( |
| 121 scoped_ptr<ConfigurationPolicyProvider> provider); | 132 scoped_ptr<ConfigurationPolicyProvider> provider); |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 139 | 150 |
| 140 // The browser-global policy providers, in decreasing order of priority. | 151 // The browser-global policy providers, in decreasing order of priority. |
| 141 ScopedVector<ConfigurationPolicyProvider> policy_providers_; | 152 ScopedVector<ConfigurationPolicyProvider> policy_providers_; |
| 142 ConfigurationPolicyProvider* platform_policy_provider_; | 153 ConfigurationPolicyProvider* platform_policy_provider_; |
| 143 | 154 |
| 144 // Must be deleted before all the policy providers. | 155 // Must be deleted before all the policy providers. |
| 145 scoped_ptr<PolicyService> policy_service_; | 156 scoped_ptr<PolicyService> policy_service_; |
| 146 | 157 |
| 147 scoped_ptr<PolicyStatisticsCollector> policy_statistics_collector_; | 158 scoped_ptr<PolicyStatisticsCollector> policy_statistics_collector_; |
| 148 | 159 |
| 149 scoped_ptr<DeviceManagementService> device_management_service_; | 160 ScopedVector<DeviceManagementService> device_management_services_; |
| 150 | 161 |
| 151 DISALLOW_COPY_AND_ASSIGN(BrowserPolicyConnector); | 162 DISALLOW_COPY_AND_ASSIGN(BrowserPolicyConnector); |
| 152 }; | 163 }; |
| 153 | 164 |
| 154 } // namespace policy | 165 } // namespace policy |
| 155 | 166 |
| 156 #endif // COMPONENTS_POLICY_CORE_BROWSER_BROWSER_POLICY_CONNECTOR_H_ | 167 #endif // COMPONENTS_POLICY_CORE_BROWSER_BROWSER_POLICY_CONNECTOR_H_ |
| OLD | NEW |