Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(36)

Side by Side Diff: chrome/browser/policy/browser_policy_connector.h

Issue 7147015: Move user cloud policy to BrowserProcess (was 6979011) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase + address comments Created 9 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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"
Joao da Silva 2011/06/29 11:36:17 Nit: not needed here, FilePath can be forward decl
gfeher 2011/06/29 12:53:07 Done.
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;
Joao da Silva 2011/06/29 11:36:17 Nit: not needed.
gfeher 2011/06/29 12:53:07 Done.
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 // TODO(gfeher,mnissler): Factor out device and user specific methods into their
37 // respective classes.
38 class BrowserPolicyConnector : public NotificationObserver {
33 public: 39 public:
34 static BrowserPolicyConnector* Create(); 40 static BrowserPolicyConnector* Create();
35 ~BrowserPolicyConnector(); 41 virtual ~BrowserPolicyConnector();
36 42
37 ConfigurationPolicyProvider* GetManagedPlatformProvider() const; 43 ConfigurationPolicyProvider* GetManagedPlatformProvider() const;
38 ConfigurationPolicyProvider* GetManagedCloudProvider() const; 44 ConfigurationPolicyProvider* GetManagedCloudProvider() const;
39 ConfigurationPolicyProvider* GetRecommendedPlatformProvider() const; 45 ConfigurationPolicyProvider* GetRecommendedPlatformProvider() const;
40 ConfigurationPolicyProvider* GetRecommendedCloudProvider() const; 46 ConfigurationPolicyProvider* GetRecommendedCloudProvider() const;
41 47
42 // Returns a weak pointer to the CloudPolicySubsystem managed by this 48 // Returns a weak pointer to the CloudPolicySubsystem corresponding to the
43 // policy connector, or NULL if no such subsystem exists (i.e. when running 49 // device policy managed by this policy connector, or NULL if no such
44 // outside ChromeOS). 50 // subsystem exists (i.e. when running outside ChromeOS).
45 CloudPolicySubsystem* cloud_policy_subsystem() { 51 CloudPolicySubsystem* device_cloud_policy_subsystem() {
46 return cloud_policy_subsystem_.get(); 52 #if defined(OS_CHROMEOS)
53 return device_cloud_policy_subsystem_.get();
54 #else
55 return NULL;
56 #endif
57 }
58
59 // Returns a weak pointer to the CloudPolicySubsystem corresponding to the
60 // user policy managed by this policy connector, or NULL if no such
61 // subsystem exists (i.e. when user cloud policy is not active due to
62 // unmanaged or not logged in).
63 CloudPolicySubsystem* user_cloud_policy_subsystem() {
64 return user_cloud_policy_subsystem_.get();
47 } 65 }
48 66
49 // Used to set the credentials stored in the identity strategy associated 67 // Used to set the credentials stored in the identity strategy associated
50 // with this policy connector. 68 // with this policy connector.
51 void SetCredentials(const std::string& owner_email, 69 void SetDeviceCredentials(const std::string& owner_email,
52 const std::string& gaia_token); 70 const std::string& gaia_token);
53 71
54 // Returns true if this device is managed by an enterprise (as opposed to 72 // Returns true if this device is managed by an enterprise (as opposed to
55 // a local owner). 73 // a local owner).
56 bool IsEnterpriseManaged(); 74 bool IsEnterpriseManaged();
57 75
58 // Locks the device to an enterprise domain. 76 // Locks the device to an enterprise domain.
59 EnterpriseInstallAttributes::LockResult LockDevice(const std::string& user); 77 EnterpriseInstallAttributes::LockResult LockDevice(const std::string& user);
60 78
61 // Returns the enterprise domain if device is managed. 79 // Returns the enterprise domain if device is managed.
62 std::string GetEnterpriseDomain(); 80 std::string GetEnterpriseDomain();
63 81
64 // Exposes the StopAutoRetry() method of the CloudPolicySubsystem managed 82 // Exposes the StopAutoRetry() method of the CloudPolicySubsystem managed
65 // by this connector, which can be used to disable automatic 83 // by this connector, which can be used to disable automatic
66 // retrying behavior. 84 // retrying behavior.
67 void StopAutoRetry(); 85 void DeviceStopAutoRetry();
68 86
69 // Initiates a policy fetch after a successful device registration. 87 // Initiates a policy fetch after a successful device registration.
70 void FetchPolicy(); 88 void FetchDevicePolicy();
71 89
72 // Schedules initialization of the policy backend service, if the service is 90 // Schedules initialization of the cloud policy backend services, if the
73 // already constructed. 91 // services are already constructed.
74 void ScheduleServiceInitialization(int64 delay_milliseconds); 92 void ScheduleServiceInitialization(int64 delay_milliseconds);
75 93
94 // Initializes the user cloud policy infrasturcture.
95 // TODO(sfeuz): Listen to log-out or going-away messages of TokenService and
96 // reset the backend at that point.
97 void InitializeUserPolicy(const std::string& user_name,
98 const FilePath& policy_dir,
99 TokenService* token_service);
100
76 private: 101 private:
77 friend class ::TestingBrowserProcess; 102 friend class ::TestingBrowserProcess;
78 103
79 BrowserPolicyConnector(); 104 BrowserPolicyConnector();
80 105
81 static BrowserPolicyConnector* CreateForTests(); 106 static BrowserPolicyConnector* CreateForTests();
82 static ConfigurationPolicyProvider* CreateManagedPlatformProvider(); 107 static ConfigurationPolicyProvider* CreateManagedPlatformProvider();
83 static ConfigurationPolicyProvider* CreateRecommendedPlatformProvider(); 108 static ConfigurationPolicyProvider* CreateRecommendedPlatformProvider();
84 109
85 // Constructor for tests that allows tests to use fake platform policy 110 // Constructor for tests that allows tests to use fake platform and cloud
86 // providers instead of using the actual ones. 111 // policy providers instead of using the actual ones.
87 BrowserPolicyConnector( 112 BrowserPolicyConnector(
88 ConfigurationPolicyProvider* managed_platform_provider, 113 ConfigurationPolicyProvider* managed_platform_provider,
89 ConfigurationPolicyProvider* recommended_platform_provider); 114 ConfigurationPolicyProvider* recommended_platform_provider,
115 CloudPolicyProvider* managed_cloud_provider,
116 CloudPolicyProvider* recommended_cloud_provider);
90 117
91 // Activates the cloud policy subsystem. 118 // NotificationObserver method overrides:
92 void Initialize(); 119 virtual void Observe(NotificationType type,
120 const NotificationSource& source,
121 const NotificationDetails& details);
Joao da Silva 2011/06/29 11:36:17 Nit: OVERRIDE
gfeher 2011/06/29 12:53:07 Done.
122
123 // Initializes the device cloud policy infrasturcture.
124 void InitializeDevicePolicy();
125
126 // Activates the device cloud policy subsystem. This will be posted as a task
127 // from InitializeDevicePolicy since it needs to wait for the message loops to
128 // be running.
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_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698