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

Side by Side Diff: chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.h

Issue 70863002: Refactored the ComponentCloudPolicyService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 1 month 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
« no previous file with comments | « no previous file | chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_CHROMEOS_POLICY_USER_CLOUD_POLICY_MANAGER_CHROMEOS_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_POLICY_USER_CLOUD_POLICY_MANAGER_CHROMEOS_H_
6 #define CHROME_BROWSER_CHROMEOS_POLICY_USER_CLOUD_POLICY_MANAGER_CHROMEOS_H_ 6 #define CHROME_BROWSER_CHROMEOS_POLICY_USER_CLOUD_POLICY_MANAGER_CHROMEOS_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "base/files/file_path.h"
12 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
13 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
14 #include "base/time/time.h" 15 #include "base/time/time.h"
15 #include "base/timer/timer.h" 16 #include "base/timer/timer.h"
16 #include "chrome/browser/policy/cloud/cloud_policy_client.h" 17 #include "chrome/browser/policy/cloud/cloud_policy_client.h"
17 #include "chrome/browser/policy/cloud/cloud_policy_constants.h" 18 #include "chrome/browser/policy/cloud/cloud_policy_constants.h"
18 #include "chrome/browser/policy/cloud/cloud_policy_manager.h" 19 #include "chrome/browser/policy/cloud/cloud_policy_manager.h"
19 #include "chrome/browser/policy/cloud/cloud_policy_service.h" 20 #include "chrome/browser/policy/cloud/cloud_policy_service.h"
20 #include "chrome/browser/policy/cloud/component_cloud_policy_service.h" 21 #include "chrome/browser/policy/cloud/component_cloud_policy_service.h"
21 #include "components/browser_context_keyed_service/browser_context_keyed_service .h" 22 #include "components/browser_context_keyed_service/browser_context_keyed_service .h"
22 23
23 class GoogleServiceAuthError; 24 class GoogleServiceAuthError;
24 class PrefService; 25 class PrefService;
25 26
26 namespace base { 27 namespace base {
27 class SequencedTaskRunner; 28 class SequencedTaskRunner;
28 } 29 }
29 30
30 namespace net { 31 namespace net {
31 class URLRequestContextGetter; 32 class URLRequestContextGetter;
32 } 33 }
33 34
34 namespace policy { 35 namespace policy {
35 36
36 class CloudExternalDataManager; 37 class CloudExternalDataManager;
37 class DeviceManagementService; 38 class DeviceManagementService;
38 class PolicyOAuth2TokenFetcher; 39 class PolicyOAuth2TokenFetcher;
39 class ResourceCache;
40 40
41 // UserCloudPolicyManagerChromeOS implements logic for initializing user policy 41 // UserCloudPolicyManagerChromeOS implements logic for initializing user policy
42 // on Chrome OS. 42 // on Chrome OS.
43 class UserCloudPolicyManagerChromeOS 43 class UserCloudPolicyManagerChromeOS
44 : public CloudPolicyManager, 44 : public CloudPolicyManager,
45 public CloudPolicyClient::Observer, 45 public CloudPolicyClient::Observer,
46 public CloudPolicyService::Observer, 46 public CloudPolicyService::Observer,
47 public ComponentCloudPolicyService::Delegate, 47 public ComponentCloudPolicyService::Delegate,
48 public BrowserContextKeyedService { 48 public BrowserContextKeyedService {
49 public: 49 public:
50 // |task_runner| is the runner for policy refresh tasks. 50 // |task_runner| is the runner for policy refresh tasks.
51 // If |wait_for_policy_fetch| is true, IsInitializationComplete() will return 51 // If |wait_for_policy_fetch| is true, IsInitializationComplete() will return
52 // false as long as there hasn't been a successful policy fetch. 52 // false as long as there hasn't been a successful policy fetch.
53 UserCloudPolicyManagerChromeOS( 53 UserCloudPolicyManagerChromeOS(
54 scoped_ptr<CloudPolicyStore> store, 54 scoped_ptr<CloudPolicyStore> store,
55 scoped_ptr<CloudExternalDataManager> external_data_manager, 55 scoped_ptr<CloudExternalDataManager> external_data_manager,
56 const scoped_refptr<base::SequencedTaskRunner>& task_runner, 56 const scoped_refptr<base::SequencedTaskRunner>& task_runner,
57 scoped_ptr<ResourceCache> resource_cache, 57 const base::FilePath& resource_cache_dir,
58 bool wait_for_policy_fetch, 58 bool wait_for_policy_fetch,
59 base::TimeDelta initial_policy_fetch_timeout); 59 base::TimeDelta initial_policy_fetch_timeout);
60 virtual ~UserCloudPolicyManagerChromeOS(); 60 virtual ~UserCloudPolicyManagerChromeOS();
61 61
62 // Initializes the cloud connection. |local_state| and 62 // Initializes the cloud connection. |local_state| and
63 // |device_management_service| must stay valid until this object is deleted. 63 // |device_management_service| must stay valid until this object is deleted.
64 void Connect(PrefService* local_state, 64 void Connect(PrefService* local_state,
65 DeviceManagementService* device_management_service, 65 DeviceManagementService* device_management_service,
66 scoped_refptr<net::URLRequestContextGetter> request_context, 66 scoped_refptr<net::URLRequestContextGetter> request_context,
67 UserAffiliation user_affiliation); 67 UserAffiliation user_affiliation);
68 68
69 // This class is one of the policy providers, and must be ready for the 69 // This class is one of the policy providers, and must be ready for the
70 // creation of the Profile's PrefService; all the other 70 // creation of the Profile's PrefService; all the other
71 // BrowserContextKeyedServices depend on the PrefService, so this class can't 71 // BrowserContextKeyedServices depend on the PrefService, so this class can't
72 // depend on other BCKS to avoid a circular dependency. So instead of using 72 // depend on other BCKS to avoid a circular dependency. So instead of using
73 // the ProfileOAuth2TokenService directly to get the access token, a 3rd 73 // the ProfileOAuth2TokenService directly to get the access token, a 3rd
74 // service (UserCloudPolicyTokenForwarder) will fetch it later and pass it 74 // service (UserCloudPolicyTokenForwarder) will fetch it later and pass it
75 // to this method once available. 75 // to this method once available.
76 // The |access_token| can then be used to authenticate the registration 76 // The |access_token| can then be used to authenticate the registration
77 // request to the DMServer. 77 // request to the DMServer.
78 void OnAccessTokenAvailable(const std::string& access_token); 78 void OnAccessTokenAvailable(const std::string& access_token);
79 79
80 // Returns true if the underlying CloudPolicyClient is already registered. 80 // Returns true if the underlying CloudPolicyClient is already registered.
81 bool IsClientRegistered() const; 81 bool IsClientRegistered() const;
82 82
83 // ConfigurationPolicyProvider: 83 // ConfigurationPolicyProvider:
84 virtual void Shutdown() OVERRIDE; 84 virtual void Shutdown() OVERRIDE;
85 virtual bool IsInitializationComplete(PolicyDomain domain) const OVERRIDE; 85 virtual bool IsInitializationComplete(PolicyDomain domain) const OVERRIDE;
86 virtual void OnSchemaRegistryUpdated(bool has_new_schemas) OVERRIDE;
87 86
88 // CloudPolicyManager: 87 // CloudPolicyManager:
89 virtual scoped_ptr<PolicyBundle> CreatePolicyBundle() OVERRIDE; 88 virtual scoped_ptr<PolicyBundle> CreatePolicyBundle() OVERRIDE;
90 89
91 // CloudPolicyService::Observer: 90 // CloudPolicyService::Observer:
92 virtual void OnInitializationCompleted(CloudPolicyService* service) OVERRIDE; 91 virtual void OnInitializationCompleted(CloudPolicyService* service) OVERRIDE;
93 92
94 // CloudPolicyClient::Observer: 93 // CloudPolicyClient::Observer:
95 virtual void OnPolicyFetched(CloudPolicyClient* client) OVERRIDE; 94 virtual void OnPolicyFetched(CloudPolicyClient* client) OVERRIDE;
96 virtual void OnRegistrationStateChanged(CloudPolicyClient* client) OVERRIDE; 95 virtual void OnRegistrationStateChanged(CloudPolicyClient* client) OVERRIDE;
97 virtual void OnClientError(CloudPolicyClient* client) OVERRIDE; 96 virtual void OnClientError(CloudPolicyClient* client) OVERRIDE;
98 97
99 // ComponentCloudPolicyService::Delegate: 98 // ComponentCloudPolicyService::Delegate:
100 virtual void OnComponentCloudPolicyRefreshNeeded() OVERRIDE; 99 virtual void OnComponentCloudPolicyRefreshNeeded() OVERRIDE;
101 virtual void OnComponentCloudPolicyUpdated() OVERRIDE; 100 virtual void OnComponentCloudPolicyUpdated() OVERRIDE;
102 101
103 private: 102 private:
103 void CreateComponentCloudPolicyService(
104 const scoped_refptr<net::URLRequestContextGetter>& request_context);
105
104 // Fetches a policy token using the authentication context of the signin 106 // Fetches a policy token using the authentication context of the signin
105 // Profile, and calls back to OnOAuth2PolicyTokenFetched when done. 107 // Profile, and calls back to OnOAuth2PolicyTokenFetched when done.
106 void FetchPolicyOAuthTokenUsingSigninProfile(); 108 void FetchPolicyOAuthTokenUsingSigninProfile();
107 109
108 // Called once the policy access token is available, and starts the 110 // Called once the policy access token is available, and starts the
109 // registration with the policy server if the token was successfully fetched. 111 // registration with the policy server if the token was successfully fetched.
110 void OnOAuth2PolicyTokenFetched(const std::string& policy_token, 112 void OnOAuth2PolicyTokenFetched(const std::string& policy_token,
111 const GoogleServiceAuthError& error); 113 const GoogleServiceAuthError& error);
112 114
113 // Completion handler for the explicit policy fetch triggered on startup in 115 // Completion handler for the explicit policy fetch triggered on startup in
(...skipping 11 matching lines...) Expand all
125 // Owns the store, note that CloudPolicyManager just keeps a plain pointer. 127 // Owns the store, note that CloudPolicyManager just keeps a plain pointer.
126 scoped_ptr<CloudPolicyStore> store_; 128 scoped_ptr<CloudPolicyStore> store_;
127 129
128 // Manages external data referenced by policies. 130 // Manages external data referenced by policies.
129 scoped_ptr<CloudExternalDataManager> external_data_manager_; 131 scoped_ptr<CloudExternalDataManager> external_data_manager_;
130 132
131 // Handles fetching and storing cloud policy for components. It uses the 133 // Handles fetching and storing cloud policy for components. It uses the
132 // |store_|, so destroy it first. 134 // |store_|, so destroy it first.
133 scoped_ptr<ComponentCloudPolicyService> component_policy_service_; 135 scoped_ptr<ComponentCloudPolicyService> component_policy_service_;
134 136
137 // Directory for the ResourceCache, if one is created.
138 base::FilePath resource_cache_dir_;
139
135 // Whether to wait for a policy fetch to complete before reporting 140 // Whether to wait for a policy fetch to complete before reporting
136 // IsInitializationComplete(). 141 // IsInitializationComplete().
137 bool wait_for_policy_fetch_; 142 bool wait_for_policy_fetch_;
138 143
139 // A timer that puts a hard limit on the maximum time to wait for the intial 144 // A timer that puts a hard limit on the maximum time to wait for the intial
140 // policy fetch. 145 // policy fetch.
141 base::Timer policy_fetch_timeout_; 146 base::Timer policy_fetch_timeout_;
142 147
143 // The pref service to pass to the refresh scheduler on initialization. 148 // The pref service to pass to the refresh scheduler on initialization.
144 PrefService* local_state_; 149 PrefService* local_state_;
(...skipping 11 matching lines...) Expand all
156 base::Time time_init_completed_; 161 base::Time time_init_completed_;
157 base::Time time_token_available_; 162 base::Time time_token_available_;
158 base::Time time_client_registered_; 163 base::Time time_client_registered_;
159 164
160 DISALLOW_COPY_AND_ASSIGN(UserCloudPolicyManagerChromeOS); 165 DISALLOW_COPY_AND_ASSIGN(UserCloudPolicyManagerChromeOS);
161 }; 166 };
162 167
163 } // namespace policy 168 } // namespace policy
164 169
165 #endif // CHROME_BROWSER_CHROMEOS_POLICY_USER_CLOUD_POLICY_MANAGER_CHROMEOS_H_ 170 #endif // CHROME_BROWSER_CHROMEOS_POLICY_USER_CLOUD_POLICY_MANAGER_CHROMEOS_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698