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

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

Issue 79023002: Support cloud policy for extensions on the desktop platforms. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixed stub, again Created 7 years 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) 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/files/file_path.h"
13 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
14 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
15 #include "base/time/time.h" 15 #include "base/time/time.h"
16 #include "base/timer/timer.h" 16 #include "base/timer/timer.h"
17 #include "chrome/browser/policy/cloud/cloud_policy_client.h" 17 #include "chrome/browser/policy/cloud/cloud_policy_client.h"
18 #include "chrome/browser/policy/cloud/cloud_policy_constants.h" 18 #include "chrome/browser/policy/cloud/cloud_policy_constants.h"
19 #include "chrome/browser/policy/cloud/cloud_policy_manager.h" 19 #include "chrome/browser/policy/cloud/cloud_policy_manager.h"
20 #include "chrome/browser/policy/cloud/cloud_policy_service.h" 20 #include "chrome/browser/policy/cloud/cloud_policy_service.h"
21 #include "chrome/browser/policy/cloud/component_cloud_policy_service.h"
22 #include "components/browser_context_keyed_service/browser_context_keyed_service .h" 21 #include "components/browser_context_keyed_service/browser_context_keyed_service .h"
23 22
24 class GoogleServiceAuthError; 23 class GoogleServiceAuthError;
25 class PrefService; 24 class PrefService;
26 25
27 namespace base { 26 namespace base {
28 class SequencedTaskRunner; 27 class SequencedTaskRunner;
29 } 28 }
30 29
31 namespace net { 30 namespace net {
32 class URLRequestContextGetter; 31 class URLRequestContextGetter;
33 } 32 }
34 33
35 namespace policy { 34 namespace policy {
36 35
37 class CloudExternalDataManager; 36 class CloudExternalDataManager;
38 class DeviceManagementService; 37 class DeviceManagementService;
39 class PolicyOAuth2TokenFetcher; 38 class PolicyOAuth2TokenFetcher;
40 39
41 // UserCloudPolicyManagerChromeOS implements logic for initializing user policy 40 // UserCloudPolicyManagerChromeOS implements logic for initializing user policy
42 // on Chrome OS. 41 // on Chrome OS.
43 class UserCloudPolicyManagerChromeOS 42 class UserCloudPolicyManagerChromeOS
44 : public CloudPolicyManager, 43 : public CloudPolicyManager,
45 public CloudPolicyClient::Observer, 44 public CloudPolicyClient::Observer,
46 public CloudPolicyService::Observer, 45 public CloudPolicyService::Observer,
47 public ComponentCloudPolicyService::Delegate,
48 public BrowserContextKeyedService { 46 public BrowserContextKeyedService {
49 public: 47 public:
50 // |task_runner| is the runner for policy refresh tasks.
51 // If |wait_for_policy_fetch| is true, IsInitializationComplete() will return 48 // If |wait_for_policy_fetch| is true, IsInitializationComplete() will return
52 // false as long as there hasn't been a successful policy fetch. 49 // false as long as there hasn't been a successful policy fetch.
50 // |task_runner| is the runner for policy refresh tasks.
51 // |file_task_runner| is used for file operations.
52 // |io_task_runner| is used for network IO.
53 // Note: currently these must be the FILE and the IO BrowserThreads.
bartfab (slow) 2013/11/25 15:05:50 Nit: "these" is ambiguous (there are three task ru
Joao da Silva 2013/11/25 16:44:11 Done.
53 UserCloudPolicyManagerChromeOS( 54 UserCloudPolicyManagerChromeOS(
54 scoped_ptr<CloudPolicyStore> store, 55 scoped_ptr<CloudPolicyStore> store,
55 scoped_ptr<CloudExternalDataManager> external_data_manager, 56 scoped_ptr<CloudExternalDataManager> external_data_manager,
57 const base::FilePath& component_policy_cache_path,
58 bool wait_for_policy_fetch,
59 base::TimeDelta initial_policy_fetch_timeout,
56 const scoped_refptr<base::SequencedTaskRunner>& task_runner, 60 const scoped_refptr<base::SequencedTaskRunner>& task_runner,
57 const base::FilePath& resource_cache_dir, 61 const scoped_refptr<base::SequencedTaskRunner>& file_task_runner,
58 bool wait_for_policy_fetch, 62 const scoped_refptr<base::SequencedTaskRunner>& io_task_runner);
59 base::TimeDelta initial_policy_fetch_timeout);
60 virtual ~UserCloudPolicyManagerChromeOS(); 63 virtual ~UserCloudPolicyManagerChromeOS();
61 64
62 // Initializes the cloud connection. |local_state| and 65 // Initializes the cloud connection. |local_state| and
63 // |device_management_service| must stay valid until this object is deleted. 66 // |device_management_service| must stay valid until this object is deleted.
64 void Connect(PrefService* local_state, 67 void Connect(PrefService* local_state,
65 DeviceManagementService* device_management_service, 68 DeviceManagementService* device_management_service,
66 scoped_refptr<net::URLRequestContextGetter> request_context, 69 scoped_refptr<net::URLRequestContextGetter> request_context,
67 UserAffiliation user_affiliation); 70 UserAffiliation user_affiliation);
68 71
69 // This class is one of the policy providers, and must be ready for the 72 // This class is one of the policy providers, and must be ready for the
70 // creation of the Profile's PrefService; all the other 73 // creation of the Profile's PrefService; all the other
71 // BrowserContextKeyedServices depend on the PrefService, so this class can't 74 // BrowserContextKeyedServices depend on the PrefService, so this class can't
72 // depend on other BCKS to avoid a circular dependency. So instead of using 75 // depend on other BCKS to avoid a circular dependency. So instead of using
73 // the ProfileOAuth2TokenService directly to get the access token, a 3rd 76 // the ProfileOAuth2TokenService directly to get the access token, a 3rd
74 // service (UserCloudPolicyTokenForwarder) will fetch it later and pass it 77 // service (UserCloudPolicyTokenForwarder) will fetch it later and pass it
75 // to this method once available. 78 // to this method once available.
76 // The |access_token| can then be used to authenticate the registration 79 // The |access_token| can then be used to authenticate the registration
77 // request to the DMServer. 80 // request to the DMServer.
78 void OnAccessTokenAvailable(const std::string& access_token); 81 void OnAccessTokenAvailable(const std::string& access_token);
79 82
80 // Returns true if the underlying CloudPolicyClient is already registered. 83 // Returns true if the underlying CloudPolicyClient is already registered.
81 bool IsClientRegistered() const; 84 bool IsClientRegistered() const;
82 85
83 // ConfigurationPolicyProvider: 86 // ConfigurationPolicyProvider:
84 virtual void Shutdown() OVERRIDE; 87 virtual void Shutdown() OVERRIDE;
85 virtual bool IsInitializationComplete(PolicyDomain domain) const OVERRIDE; 88 virtual bool IsInitializationComplete(PolicyDomain domain) const OVERRIDE;
86 89
87 // CloudPolicyManager:
88 virtual scoped_ptr<PolicyBundle> CreatePolicyBundle() OVERRIDE;
89
90 // CloudPolicyService::Observer: 90 // CloudPolicyService::Observer:
91 virtual void OnInitializationCompleted(CloudPolicyService* service) OVERRIDE; 91 virtual void OnInitializationCompleted(CloudPolicyService* service) OVERRIDE;
92 92
93 // CloudPolicyClient::Observer: 93 // CloudPolicyClient::Observer:
94 virtual void OnPolicyFetched(CloudPolicyClient* client) OVERRIDE; 94 virtual void OnPolicyFetched(CloudPolicyClient* client) OVERRIDE;
95 virtual void OnRegistrationStateChanged(CloudPolicyClient* client) OVERRIDE; 95 virtual void OnRegistrationStateChanged(CloudPolicyClient* client) OVERRIDE;
96 virtual void OnClientError(CloudPolicyClient* client) OVERRIDE; 96 virtual void OnClientError(CloudPolicyClient* client) OVERRIDE;
97 97
98 // ComponentCloudPolicyService::Delegate: 98 // ComponentCloudPolicyService::Delegate:
99 virtual void OnComponentCloudPolicyUpdated() OVERRIDE; 99 virtual void OnComponentCloudPolicyUpdated() OVERRIDE;
100 100
101 private: 101 private:
102 void CreateComponentCloudPolicyService(
103 const scoped_refptr<net::URLRequestContextGetter>& request_context);
104
105 // Fetches a policy token using the authentication context of the signin 102 // Fetches a policy token using the authentication context of the signin
106 // Profile, and calls back to OnOAuth2PolicyTokenFetched when done. 103 // Profile, and calls back to OnOAuth2PolicyTokenFetched when done.
107 void FetchPolicyOAuthTokenUsingSigninProfile(); 104 void FetchPolicyOAuthTokenUsingSigninProfile();
108 105
109 // Called once the policy access token is available, and starts the 106 // Called once the policy access token is available, and starts the
110 // registration with the policy server if the token was successfully fetched. 107 // registration with the policy server if the token was successfully fetched.
111 void OnOAuth2PolicyTokenFetched(const std::string& policy_token, 108 void OnOAuth2PolicyTokenFetched(const std::string& policy_token,
112 const GoogleServiceAuthError& error); 109 const GoogleServiceAuthError& error);
113 110
114 // Completion handler for the explicit policy fetch triggered on startup in 111 // Completion handler for the explicit policy fetch triggered on startup in
115 // case |wait_for_policy_fetch_| is true. |success| is true if the fetch was 112 // case |wait_for_policy_fetch_| is true. |success| is true if the fetch was
116 // successful. 113 // successful.
117 void OnInitialPolicyFetchComplete(bool success); 114 void OnInitialPolicyFetchComplete(bool success);
118 115
119 // Cancels waiting for the policy fetch and flags the 116 // Cancels waiting for the policy fetch and flags the
120 // ConfigurationPolicyProvider ready (assuming all other initialization tasks 117 // ConfigurationPolicyProvider ready (assuming all other initialization tasks
121 // have completed). 118 // have completed).
122 void CancelWaitForPolicyFetch(); 119 void CancelWaitForPolicyFetch();
123 120
124 void StartRefreshSchedulerIfReady(); 121 void StartRefreshSchedulerIfReady();
125 122
126 // Owns the store, note that CloudPolicyManager just keeps a plain pointer. 123 // Owns the store, note that CloudPolicyManager just keeps a plain pointer.
127 scoped_ptr<CloudPolicyStore> store_; 124 scoped_ptr<CloudPolicyStore> store_;
128 125
129 // Manages external data referenced by policies. 126 // Manages external data referenced by policies.
130 scoped_ptr<CloudExternalDataManager> external_data_manager_; 127 scoped_ptr<CloudExternalDataManager> external_data_manager_;
131 128
132 // Handles fetching and storing cloud policy for components. It uses the 129 // Path where policy for components will be cached.
133 // |store_|, so destroy it first. 130 base::FilePath component_policy_cache_path_;
134 scoped_ptr<ComponentCloudPolicyService> component_policy_service_;
135
136 // Directory for the ResourceCache, if one is created.
137 base::FilePath resource_cache_dir_;
138 131
139 // Whether to wait for a policy fetch to complete before reporting 132 // Whether to wait for a policy fetch to complete before reporting
140 // IsInitializationComplete(). 133 // IsInitializationComplete().
141 bool wait_for_policy_fetch_; 134 bool wait_for_policy_fetch_;
142 135
143 // A timer that puts a hard limit on the maximum time to wait for the intial 136 // A timer that puts a hard limit on the maximum time to wait for the intial
144 // policy fetch. 137 // policy fetch.
145 base::Timer policy_fetch_timeout_; 138 base::Timer policy_fetch_timeout_;
146 139
147 // The pref service to pass to the refresh scheduler on initialization. 140 // The pref service to pass to the refresh scheduler on initialization.
(...skipping 12 matching lines...) Expand all
160 base::Time time_init_completed_; 153 base::Time time_init_completed_;
161 base::Time time_token_available_; 154 base::Time time_token_available_;
162 base::Time time_client_registered_; 155 base::Time time_client_registered_;
163 156
164 DISALLOW_COPY_AND_ASSIGN(UserCloudPolicyManagerChromeOS); 157 DISALLOW_COPY_AND_ASSIGN(UserCloudPolicyManagerChromeOS);
165 }; 158 };
166 159
167 } // namespace policy 160 } // namespace policy
168 161
169 #endif // CHROME_BROWSER_CHROMEOS_POLICY_USER_CLOUD_POLICY_MANAGER_CHROMEOS_H_ 162 #endif // CHROME_BROWSER_CHROMEOS_POLICY_USER_CLOUD_POLICY_MANAGER_CHROMEOS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698