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

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

Issue 6979011: Move user cloud policy to BrowserProcess. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed comments by mnissler. Created 9 years, 6 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"
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 cloud policy backend services, if the
73 // already constructed. 89 // services are already constructed.
74 void ScheduleServiceInitialization(int64 delay_milliseconds); 90 void ScheduleServiceInitialization(int64 delay_milliseconds);
75 91
92 // Initializes the user cloud policy infrasturcture.
93 // TODO(sfeuz): Listen to log-out or going-away messages of TokenService and
94 // reset the backend at that point.
95 void InitializeUserPolicy(std::string& user_name,
96 const FilePath& policy_dir,
97 TokenService* token_service);
98
76 private: 99 private:
77 friend class ::TestingBrowserProcess; 100 friend class ::TestingBrowserProcess;
78 101
79 BrowserPolicyConnector(); 102 BrowserPolicyConnector();
80 103
81 static BrowserPolicyConnector* CreateForTests(); 104 static BrowserPolicyConnector* CreateForTests();
82 static ConfigurationPolicyProvider* CreateManagedPlatformProvider(); 105 static ConfigurationPolicyProvider* CreateManagedPlatformProvider();
83 static ConfigurationPolicyProvider* CreateRecommendedPlatformProvider(); 106 static ConfigurationPolicyProvider* CreateRecommendedPlatformProvider();
84 107
85 // Constructor for tests that allows tests to use fake platform policy 108 // Constructor for tests that allows tests to use fake platform and cloud
86 // providers instead of using the actual ones. 109 // policy providers instead of using the actual ones.
87 BrowserPolicyConnector( 110 BrowserPolicyConnector(
88 ConfigurationPolicyProvider* managed_platform_provider, 111 ConfigurationPolicyProvider* managed_platform_provider,
89 ConfigurationPolicyProvider* recommended_platform_provider); 112 ConfigurationPolicyProvider* recommended_platform_provider,
113 CloudPolicyProvider* managed_cloud_provider,
114 CloudPolicyProvider* recommended_cloud_provider);
90 115
91 // Activates the cloud policy subsystem. 116 // NotificationObserver method overrides:
92 void Initialize(); 117 virtual void Observe(NotificationType type,
118 const NotificationSource& source,
119 const NotificationDetails& details);
120
121 // Initializes the device cloud policy infrasturcture.
122 void InitializeDevicePolicy();
123
124 // Activates the device cloud policy subsystem. This will be posted as a task
125 // from InitializeDevicePolicy since it needs to wait for the message loops to
126 // be running.
127 void InitializeDevicePolicySubsystem();
93 128
94 scoped_ptr<ConfigurationPolicyProvider> managed_platform_provider_; 129 scoped_ptr<ConfigurationPolicyProvider> managed_platform_provider_;
95 scoped_ptr<ConfigurationPolicyProvider> recommended_platform_provider_; 130 scoped_ptr<ConfigurationPolicyProvider> recommended_platform_provider_;
96 131
132 scoped_ptr<CloudPolicyProvider> managed_cloud_provider_;
133 scoped_ptr<CloudPolicyProvider> recommended_cloud_provider_;
134
97 #if defined(OS_CHROMEOS) 135 #if defined(OS_CHROMEOS)
98 scoped_ptr<DevicePolicyIdentityStrategy> identity_strategy_; 136 scoped_ptr<DevicePolicyIdentityStrategy> device_identity_strategy_;
137 scoped_ptr<CloudPolicySubsystem> device_cloud_policy_subsystem_;
99 scoped_ptr<EnterpriseInstallAttributes> install_attributes_; 138 scoped_ptr<EnterpriseInstallAttributes> install_attributes_;
100 #endif 139 #endif
101 scoped_ptr<CloudPolicySubsystem> cloud_policy_subsystem_; 140
141 scoped_ptr<UserPolicyIdentityStrategy> user_identity_strategy_;
142 scoped_ptr<CloudPolicySubsystem> user_cloud_policy_subsystem_;
102 143
103 ScopedRunnableMethodFactory<BrowserPolicyConnector> method_factory_; 144 ScopedRunnableMethodFactory<BrowserPolicyConnector> method_factory_;
104 145
146 // Registers the provider for notification of successful Gaia logins.
147 NotificationRegistrar registrar_;
148
149 // Weak reference to the TokenService we are listening to for user cloud
150 // policy authentication tokens.
151 TokenService* token_service_;
152
105 DISALLOW_COPY_AND_ASSIGN(BrowserPolicyConnector); 153 DISALLOW_COPY_AND_ASSIGN(BrowserPolicyConnector);
106 }; 154 };
107 155
108 } // namespace policy 156 } // namespace policy
109 157
110 #endif // CHROME_BROWSER_POLICY_BROWSER_POLICY_CONNECTOR_H_ 158 #endif // CHROME_BROWSER_POLICY_BROWSER_POLICY_CONNECTOR_H_
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/user_image_view.cc ('k') | chrome/browser/policy/browser_policy_connector.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698