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 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/file_util.h" | |
Mattias Nissler (ping if slow)
2011/06/09 14:36:26
no need for this include.
sfeuz
2011/06/13 06:53:53
Need it for FilePath.
| |
12 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
13 #include "base/task.h" | 14 #include "base/task.h" |
14 #include "chrome/browser/policy/enterprise_install_attributes.h" | 15 #include "chrome/browser/policy/enterprise_install_attributes.h" |
16 #include "content/common/notification_observer.h" | |
17 #include "content/common/notification_registrar.h" | |
15 | 18 |
16 class PrefService; | 19 class PrefService; |
17 class TestingBrowserProcess; | 20 class TestingBrowserProcess; |
18 class TokenService; | 21 class TokenService; |
19 | 22 |
20 namespace net { | |
21 class URLRequestContextGetter; | |
22 } | |
23 | |
24 namespace policy { | 23 namespace policy { |
25 | 24 |
25 class CloudPolicyProvider; | |
26 class CloudPolicySubsystem; | 26 class CloudPolicySubsystem; |
27 class ConfigurationPolicyProvider; | 27 class ConfigurationPolicyProvider; |
28 class UserPolicyIdentityStrategy; | |
29 | |
30 #if defined(OS_CHROMEOS) | |
28 class DevicePolicyIdentityStrategy; | 31 class DevicePolicyIdentityStrategy; |
32 #endif | |
29 | 33 |
30 // Manages the lifecycle of browser-global policy infrastructure, such as the | 34 // Manages the lifecycle of browser-global policy infrastructure, such as the |
31 // platform policy providers. | 35 // platform policy providers, device- and the user-cloud policy infrastructure. |
32 class BrowserPolicyConnector { | 36 class BrowserPolicyConnector : public NotificationObserver { |
33 public: | 37 public: |
34 static BrowserPolicyConnector* Create(); | 38 static BrowserPolicyConnector* Create(); |
35 ~BrowserPolicyConnector(); | 39 virtual ~BrowserPolicyConnector(); |
36 | 40 |
37 ConfigurationPolicyProvider* GetManagedPlatformProvider() const; | 41 ConfigurationPolicyProvider* GetManagedPlatformProvider() const; |
38 ConfigurationPolicyProvider* GetManagedCloudProvider() const; | 42 ConfigurationPolicyProvider* GetManagedCloudProvider() const; |
39 ConfigurationPolicyProvider* GetRecommendedPlatformProvider() const; | 43 ConfigurationPolicyProvider* GetRecommendedPlatformProvider() const; |
40 ConfigurationPolicyProvider* GetRecommendedCloudProvider() const; | 44 ConfigurationPolicyProvider* GetRecommendedCloudProvider() const; |
41 | 45 |
42 // Returns a weak pointer to the CloudPolicySubsystem managed by this | 46 // Returns a weak pointer to the CloudPolicySubsystem corresponding to the |
43 // policy connector, or NULL if no such subsystem exists (i.e. when running | 47 // device policy managed by this policy connector, or NULL if no such |
44 // outside ChromeOS). | 48 // subsystem exists (i.e. when running outside ChromeOS). |
45 CloudPolicySubsystem* cloud_policy_subsystem() { | 49 CloudPolicySubsystem* device_cloud_policy_subsystem() { |
46 return cloud_policy_subsystem_.get(); | 50 #if defined(OS_CHROMEOS) |
51 return device_cloud_policy_subsystem_.get(); | |
52 #else | |
53 return NULL; | |
54 #endif | |
55 } | |
56 | |
57 // Returns a weak pointer to the CloudPolicySubsystem corresponding to the | |
58 // user policy managed by this policy connector, or NULL if no such | |
59 // subsystem exists (i.e. when user cloud policy is not active due to | |
60 // unmanaged or not logged in). | |
61 CloudPolicySubsystem* user_cloud_policy_subsystem() { | |
62 return user_cloud_policy_subsystem_.get(); | |
47 } | 63 } |
48 | 64 |
49 // Used to set the credentials stored in the identity strategy associated | 65 // Used to set the credentials stored in the identity strategy associated |
50 // with this policy connector. | 66 // with this policy connector. |
51 void SetCredentials(const std::string& owner_email, | 67 void SetDeviceCredentials(const std::string& owner_email, |
52 const std::string& gaia_token); | 68 const std::string& gaia_token); |
53 | 69 |
54 // Returns true if this device is managed by an enterprise (as opposed to | 70 // Returns true if this device is managed by an enterprise (as opposed to |
55 // a local owner). | 71 // a local owner). |
56 bool IsEnterpriseManaged(); | 72 bool IsEnterpriseManaged(); |
57 | 73 |
58 // Locks the device to an enterprise domain. | 74 // Locks the device to an enterprise domain. |
59 EnterpriseInstallAttributes::LockResult LockDevice(const std::string& user); | 75 EnterpriseInstallAttributes::LockResult LockDevice(const std::string& user); |
60 | 76 |
61 // Returns the enterprise domain if device is managed. | 77 // Returns the enterprise domain if device is managed. |
62 std::string GetEnterpriseDomain(); | 78 std::string GetEnterpriseDomain(); |
63 | 79 |
64 // Exposes the StopAutoRetry() method of the CloudPolicySubsystem managed | 80 // Exposes the StopAutoRetry() method of the CloudPolicySubsystem managed |
65 // by this connector, which can be used to disable automatic | 81 // by this connector, which can be used to disable automatic |
66 // retrying behavior. | 82 // retrying behavior. |
67 void StopAutoRetry(); | 83 void DeviceStopAutoRetry(); |
68 | 84 |
69 // Initiates a policy fetch after a successful device registration. | 85 // Initiates a policy fetch after a successful device registration. |
70 void FetchPolicy(); | 86 void FetchDevicePolicy(); |
71 | 87 |
72 // Schedules initialization of the policy backend service, if the service is | 88 // Schedules initialization of the device policy backend service, if the |
73 // already constructed. | 89 // service is already constructed. |
74 void ScheduleServiceInitialization(int64 delay_milliseconds); | 90 void ScheduleDeviceServiceInitialization(int64 delay_milliseconds); |
91 | |
92 // Schedules initialization of the user policy backend service, if the | |
93 // service is already constructed. | |
94 void ScheduleUserServiceInitialization(int64 delay_milliseconds); | |
Mattias Nissler (ping if slow)
2011/06/09 14:36:26
Maybe we should merge these into one call? After a
sfeuz
2011/06/13 06:53:53
I agree. I think we can just call the ScheduleInit
| |
95 | |
96 // Initializes the user cloud policy infrasturcture. | |
97 // TODO(sfeuz): Listen to log-out or going-away messages of TokenService and | |
98 // reset the backend at that point. | |
99 void InitializeUserPolicy(std::string& user_name, | |
100 const FilePath& policy_dir, | |
101 TokenService* token_service); | |
75 | 102 |
76 private: | 103 private: |
77 friend class ::TestingBrowserProcess; | 104 friend class ::TestingBrowserProcess; |
78 | 105 |
79 BrowserPolicyConnector(); | 106 BrowserPolicyConnector(); |
80 | 107 |
81 static BrowserPolicyConnector* CreateForTests(); | 108 static BrowserPolicyConnector* CreateForTests(); |
82 static ConfigurationPolicyProvider* CreateManagedPlatformProvider(); | 109 static ConfigurationPolicyProvider* CreateManagedPlatformProvider(); |
83 static ConfigurationPolicyProvider* CreateRecommendedPlatformProvider(); | 110 static ConfigurationPolicyProvider* CreateRecommendedPlatformProvider(); |
84 | 111 |
85 // Constructor for tests that allows tests to use fake platform policy | 112 // Constructor for tests that allows tests to use fake platform and cloud |
86 // providers instead of using the actual ones. | 113 // policy providers instead of using the actual ones. |
87 BrowserPolicyConnector( | 114 BrowserPolicyConnector( |
88 ConfigurationPolicyProvider* managed_platform_provider, | 115 ConfigurationPolicyProvider* managed_platform_provider, |
89 ConfigurationPolicyProvider* recommended_platform_provider); | 116 ConfigurationPolicyProvider* recommended_platform_provider, |
117 CloudPolicyProvider* managed_cloud_provider, | |
118 CloudPolicyProvider* recommended_cloud_provider); | |
90 | 119 |
91 // Activates the cloud policy subsystem. | 120 // NotificationObserver method overrides: |
92 void Initialize(); | 121 virtual void Observe(NotificationType type, |
122 const NotificationSource& source, | |
123 const NotificationDetails& details); | |
124 | |
125 // Initializes the device cloud policy infrasturcture. | |
126 void InitializeDevicePolicy(); | |
127 | |
128 // Activates the device cloud policy subsystem. Will be delayed. | |
Mattias Nissler (ping if slow)
2011/06/09 14:36:26
"Will be delayed" isn't very helpful to a reader.
sfeuz
2011/06/13 06:53:53
Done.
| |
129 void InitializeDevicePolicySubsystem(); | |
93 | 130 |
94 scoped_ptr<ConfigurationPolicyProvider> managed_platform_provider_; | 131 scoped_ptr<ConfigurationPolicyProvider> managed_platform_provider_; |
95 scoped_ptr<ConfigurationPolicyProvider> recommended_platform_provider_; | 132 scoped_ptr<ConfigurationPolicyProvider> recommended_platform_provider_; |
96 | 133 |
134 scoped_ptr<CloudPolicyProvider> managed_cloud_provider_; | |
135 scoped_ptr<CloudPolicyProvider> recommended_cloud_provider_; | |
136 | |
97 #if defined(OS_CHROMEOS) | 137 #if defined(OS_CHROMEOS) |
98 scoped_ptr<DevicePolicyIdentityStrategy> identity_strategy_; | 138 scoped_ptr<DevicePolicyIdentityStrategy> device_identity_strategy_; |
139 scoped_ptr<CloudPolicySubsystem> device_cloud_policy_subsystem_; | |
99 scoped_ptr<EnterpriseInstallAttributes> install_attributes_; | 140 scoped_ptr<EnterpriseInstallAttributes> install_attributes_; |
100 #endif | 141 #endif |
101 scoped_ptr<CloudPolicySubsystem> cloud_policy_subsystem_; | 142 |
143 scoped_ptr<UserPolicyIdentityStrategy> user_identity_strategy_; | |
144 scoped_ptr<CloudPolicySubsystem> user_cloud_policy_subsystem_; | |
102 | 145 |
103 ScopedRunnableMethodFactory<BrowserPolicyConnector> method_factory_; | 146 ScopedRunnableMethodFactory<BrowserPolicyConnector> method_factory_; |
104 | 147 |
148 // Registers the provider for notification of successful Gaia logins. | |
149 NotificationRegistrar registrar_; | |
150 | |
151 // Weak reference to the TokenService we are listening to for user cloud | |
152 // policy authentication tokens. | |
153 TokenService* token_service_; | |
154 | |
105 DISALLOW_COPY_AND_ASSIGN(BrowserPolicyConnector); | 155 DISALLOW_COPY_AND_ASSIGN(BrowserPolicyConnector); |
106 }; | 156 }; |
107 | 157 |
108 } // namespace policy | 158 } // namespace policy |
109 | 159 |
110 #endif // CHROME_BROWSER_POLICY_BROWSER_POLICY_CONNECTOR_H_ | 160 #endif // CHROME_BROWSER_POLICY_BROWSER_POLICY_CONNECTOR_H_ |
OLD | NEW |