OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 CHROME_BROWSER_POLICY_BROWSER_POLICY_CONNECTOR_H_ | 5 #ifndef CHROME_BROWSER_POLICY_BROWSER_POLICY_CONNECTOR_H_ |
6 #define CHROME_BROWSER_POLICY_BROWSER_POLICY_CONNECTOR_H_ | 6 #define CHROME_BROWSER_POLICY_BROWSER_POLICY_CONNECTOR_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 22 matching lines...) Expand all Loading... |
33 // TODO(gfeher,mnissler): Factor out device and user specific methods into their | 33 // TODO(gfeher,mnissler): Factor out device and user specific methods into their |
34 // respective classes. | 34 // respective classes. |
35 class BrowserPolicyConnector : public content::NotificationObserver { | 35 class BrowserPolicyConnector : public content::NotificationObserver { |
36 public: | 36 public: |
37 // Indicates the type of token passed to SetDeviceCredentials. | 37 // Indicates the type of token passed to SetDeviceCredentials. |
38 enum TokenType { | 38 enum TokenType { |
39 TOKEN_TYPE_GAIA, // A gaia service token. | 39 TOKEN_TYPE_GAIA, // A gaia service token. |
40 TOKEN_TYPE_OAUTH, // An OAuth v2 access token. | 40 TOKEN_TYPE_OAUTH, // An OAuth v2 access token. |
41 }; | 41 }; |
42 | 42 |
43 static BrowserPolicyConnector* Create(); | 43 // Builds an uninitialized BrowserPolicyConnector, suitable for testing. |
| 44 // Init() should be called to create and start the policy machinery. |
| 45 BrowserPolicyConnector(); |
44 virtual ~BrowserPolicyConnector(); | 46 virtual ~BrowserPolicyConnector(); |
45 | 47 |
| 48 // Creates the policy providers and finalizes the initialization of the |
| 49 // connector. This call can be skipped on tests that don't require the full |
| 50 // policy system running. |
| 51 void Init(); |
| 52 |
46 ConfigurationPolicyProvider* GetManagedPlatformProvider() const; | 53 ConfigurationPolicyProvider* GetManagedPlatformProvider() const; |
47 ConfigurationPolicyProvider* GetManagedCloudProvider() const; | 54 ConfigurationPolicyProvider* GetManagedCloudProvider() const; |
48 ConfigurationPolicyProvider* GetRecommendedPlatformProvider() const; | 55 ConfigurationPolicyProvider* GetRecommendedPlatformProvider() const; |
49 ConfigurationPolicyProvider* GetRecommendedCloudProvider() const; | 56 ConfigurationPolicyProvider* GetRecommendedCloudProvider() const; |
50 | 57 |
51 // Returns a weak pointer to the CloudPolicySubsystem corresponding to the | 58 // Returns a weak pointer to the CloudPolicySubsystem corresponding to the |
52 // device policy managed by this policy connector, or NULL if no such | 59 // device policy managed by this policy connector, or NULL if no such |
53 // subsystem exists (i.e. when running outside ChromeOS). | 60 // subsystem exists (i.e. when running outside ChromeOS). |
54 CloudPolicySubsystem* device_cloud_policy_subsystem() { | 61 CloudPolicySubsystem* device_cloud_policy_subsystem() { |
55 #if defined(OS_CHROMEOS) | 62 #if defined(OS_CHROMEOS) |
(...skipping 23 matching lines...) Expand all Loading... |
79 // Locks the device to an enterprise domain. | 86 // Locks the device to an enterprise domain. |
80 EnterpriseInstallAttributes::LockResult LockDevice(const std::string& user); | 87 EnterpriseInstallAttributes::LockResult LockDevice(const std::string& user); |
81 | 88 |
82 // Returns the enterprise domain if device is managed. | 89 // Returns the enterprise domain if device is managed. |
83 std::string GetEnterpriseDomain(); | 90 std::string GetEnterpriseDomain(); |
84 | 91 |
85 // Reset the device policy machinery. This stops any automatic retry behavior | 92 // Reset the device policy machinery. This stops any automatic retry behavior |
86 // and clears the error flags, so potential retries have a chance to succeed. | 93 // and clears the error flags, so potential retries have a chance to succeed. |
87 void ResetDevicePolicy(); | 94 void ResetDevicePolicy(); |
88 | 95 |
89 // Initiates a policy fetch after a successful device registration. | 96 // Initiates device and user policy fetches, if possible. Pending fetches |
90 void FetchDevicePolicy(); | 97 // will be cancelled. |
| 98 void FetchCloudPolicy(); |
91 | 99 |
92 // Initiates a user policy fetch after a successful device registration. This | 100 // Refreshes policies on each existing provider. |
93 // is only safe to call when a user device token is available. | 101 void RefreshPolicies(); |
94 void FetchUserPolicy(); | |
95 | 102 |
96 // Schedules initialization of the cloud policy backend services, if the | 103 // Schedules initialization of the cloud policy backend services, if the |
97 // services are already constructed. | 104 // services are already constructed. |
98 void ScheduleServiceInitialization(int64 delay_milliseconds); | 105 void ScheduleServiceInitialization(int64 delay_milliseconds); |
99 | 106 |
100 // Initializes the user cloud policy infrastructure. | 107 // Initializes the user cloud policy infrastructure. |
101 // If |wait_for_policy_fetch| is true, the user policy will only become fully | 108 // If |wait_for_policy_fetch| is true, the user policy will only become fully |
102 // initialized after a policy fetch is attempted. Note that Profile creation | 109 // initialized after a policy fetch is attempted. Note that Profile creation |
103 // is blocked until this initialization is complete. | 110 // is blocked until this initialization is complete. |
104 void InitializeUserPolicy(const std::string& user_name, | 111 void InitializeUserPolicy(const std::string& user_name, |
(...skipping 12 matching lines...) Expand all Loading... |
117 const CloudPolicyDataStore* GetUserCloudPolicyDataStore() const; | 124 const CloudPolicyDataStore* GetUserCloudPolicyDataStore() const; |
118 | 125 |
119 const ConfigurationPolicyHandlerList* GetHandlerList() const; | 126 const ConfigurationPolicyHandlerList* GetHandlerList() const; |
120 | 127 |
121 // Works out the user affiliation by checking the given |user_name| against | 128 // Works out the user affiliation by checking the given |user_name| against |
122 // the installation attributes. | 129 // the installation attributes. |
123 policy::CloudPolicyDataStore::UserAffiliation GetUserAffiliation( | 130 policy::CloudPolicyDataStore::UserAffiliation GetUserAffiliation( |
124 const std::string& user_name); | 131 const std::string& user_name); |
125 | 132 |
126 private: | 133 private: |
127 friend class ::TestingBrowserProcess; | |
128 | |
129 BrowserPolicyConnector(); | |
130 | |
131 // Constructor for tests that allows tests to use fake platform and cloud | |
132 // policy providers instead of using the actual ones. | |
133 BrowserPolicyConnector( | |
134 ConfigurationPolicyProvider* managed_platform_provider, | |
135 ConfigurationPolicyProvider* recommended_platform_provider, | |
136 CloudPolicyProvider* managed_cloud_provider, | |
137 CloudPolicyProvider* recommended_cloud_provider); | |
138 | |
139 // content::NotificationObserver method overrides: | 134 // content::NotificationObserver method overrides: |
140 virtual void Observe(int type, | 135 virtual void Observe(int type, |
141 const content::NotificationSource& source, | 136 const content::NotificationSource& source, |
142 const content::NotificationDetails& details) OVERRIDE; | 137 const content::NotificationDetails& details) OVERRIDE; |
143 | 138 |
144 // Initializes the device cloud policy infrasturcture. | 139 // Initializes the device cloud policy infrasturcture. |
145 void InitializeDevicePolicy(); | 140 void InitializeDevicePolicy(); |
146 | 141 |
147 // Activates the device cloud policy subsystem. This will be posted as a task | 142 // Activates the device cloud policy subsystem. This will be posted as a task |
148 // from InitializeDevicePolicy since it needs to wait for the message loops to | 143 // from InitializeDevicePolicy since it needs to wait for the message loops to |
149 // be running. | 144 // be running. |
150 void InitializeDevicePolicySubsystem(); | 145 void InitializeDevicePolicySubsystem(); |
151 | 146 |
152 static BrowserPolicyConnector* CreateForTests(); | |
153 static ConfigurationPolicyProvider* CreateManagedPlatformProvider(); | 147 static ConfigurationPolicyProvider* CreateManagedPlatformProvider(); |
154 static ConfigurationPolicyProvider* CreateRecommendedPlatformProvider(); | 148 static ConfigurationPolicyProvider* CreateRecommendedPlatformProvider(); |
155 | 149 |
156 scoped_ptr<ConfigurationPolicyProvider> managed_platform_provider_; | 150 scoped_ptr<ConfigurationPolicyProvider> managed_platform_provider_; |
157 scoped_ptr<ConfigurationPolicyProvider> recommended_platform_provider_; | 151 scoped_ptr<ConfigurationPolicyProvider> recommended_platform_provider_; |
158 | 152 |
159 scoped_ptr<CloudPolicyProvider> managed_cloud_provider_; | 153 scoped_ptr<CloudPolicyProvider> managed_cloud_provider_; |
160 scoped_ptr<CloudPolicyProvider> recommended_cloud_provider_; | 154 scoped_ptr<CloudPolicyProvider> recommended_cloud_provider_; |
161 | 155 |
162 #if defined(OS_CHROMEOS) | 156 #if defined(OS_CHROMEOS) |
(...skipping 21 matching lines...) Expand all Loading... |
184 | 178 |
185 // Used to convert policies to preferences. | 179 // Used to convert policies to preferences. |
186 ConfigurationPolicyHandlerList handler_list_; | 180 ConfigurationPolicyHandlerList handler_list_; |
187 | 181 |
188 DISALLOW_COPY_AND_ASSIGN(BrowserPolicyConnector); | 182 DISALLOW_COPY_AND_ASSIGN(BrowserPolicyConnector); |
189 }; | 183 }; |
190 | 184 |
191 } // namespace policy | 185 } // namespace policy |
192 | 186 |
193 #endif // CHROME_BROWSER_POLICY_BROWSER_POLICY_CONNECTOR_H_ | 187 #endif // CHROME_BROWSER_POLICY_BROWSER_POLICY_CONNECTOR_H_ |
OLD | NEW |