OLD | NEW |
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 <memory> | 8 #include <memory> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 27 matching lines...) Expand all Loading... |
38 class DeviceManagementService; | 38 class DeviceManagementService; |
39 class PolicyOAuth2TokenFetcher; | 39 class PolicyOAuth2TokenFetcher; |
40 class WildcardLoginChecker; | 40 class WildcardLoginChecker; |
41 | 41 |
42 // Implements logic for initializing user policy on Chrome OS. | 42 // Implements logic for initializing user policy on Chrome OS. |
43 class UserCloudPolicyManagerChromeOS : public CloudPolicyManager, | 43 class UserCloudPolicyManagerChromeOS : public CloudPolicyManager, |
44 public CloudPolicyClient::Observer, | 44 public CloudPolicyClient::Observer, |
45 public CloudPolicyService::Observer, | 45 public CloudPolicyService::Observer, |
46 public KeyedService { | 46 public KeyedService { |
47 public: | 47 public: |
48 // If |wait_for_policy_fetch| is true, IsInitializationComplete() is forced to | 48 // If |initial_policy_fetch_timeout| is non-zero, IsInitializationComplete() |
49 // false until either there has been a successful policy fetch from the server | 49 // is forced to false until either there has been a successful policy fetch |
50 // or |initial_policy_fetch_timeout| has expired. (The timeout may be set to | 50 // from the server or |initial_policy_fetch_timeout| has expired. (The timeout |
51 // TimeDelta::Max() to block permanently.) | 51 // may be set to TimeDelta::Max() to block permanently.) |
52 // |task_runner| is the runner for policy refresh tasks. | 52 // |task_runner| is the runner for policy refresh tasks. |
53 // |file_task_runner| is used for file operations. Currently this must be the | 53 // |file_task_runner| is used for file operations. Currently this must be the |
54 // FILE BrowserThread. | 54 // FILE BrowserThread. |
55 // |io_task_runner| is used for network IO. Currently this must be the IO | 55 // |io_task_runner| is used for network IO. Currently this must be the IO |
56 // BrowserThread. | 56 // BrowserThread. |
57 UserCloudPolicyManagerChromeOS( | 57 UserCloudPolicyManagerChromeOS( |
58 std::unique_ptr<CloudPolicyStore> store, | 58 std::unique_ptr<CloudPolicyStore> store, |
59 std::unique_ptr<CloudExternalDataManager> external_data_manager, | 59 std::unique_ptr<CloudExternalDataManager> external_data_manager, |
60 const base::FilePath& component_policy_cache_path, | 60 const base::FilePath& component_policy_cache_path, |
61 bool wait_for_policy_fetch, | |
62 base::TimeDelta initial_policy_fetch_timeout, | 61 base::TimeDelta initial_policy_fetch_timeout, |
63 const scoped_refptr<base::SequencedTaskRunner>& task_runner, | 62 const scoped_refptr<base::SequencedTaskRunner>& task_runner, |
64 const scoped_refptr<base::SequencedTaskRunner>& file_task_runner, | 63 const scoped_refptr<base::SequencedTaskRunner>& file_task_runner, |
65 const scoped_refptr<base::SequencedTaskRunner>& io_task_runner); | 64 const scoped_refptr<base::SequencedTaskRunner>& io_task_runner); |
66 ~UserCloudPolicyManagerChromeOS() override; | 65 ~UserCloudPolicyManagerChromeOS() override; |
67 | 66 |
68 // Initializes the cloud connection. |local_state| and | 67 // Initializes the cloud connection. |local_state| and |
69 // |device_management_service| must stay valid until this object is deleted. | 68 // |device_management_service| must stay valid until this object is deleted. |
70 void Connect( | 69 void Connect( |
71 PrefService* local_state, | 70 PrefService* local_state, |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 // authentication context of the signin context, and calls back | 119 // authentication context of the signin context, and calls back |
121 // OnOAuth2PolicyTokenFetched when done. | 120 // OnOAuth2PolicyTokenFetched when done. |
122 void FetchPolicyOAuthToken(); | 121 void FetchPolicyOAuthToken(); |
123 | 122 |
124 // Called once the policy access token is available, and starts the | 123 // Called once the policy access token is available, and starts the |
125 // registration with the policy server if the token was successfully fetched. | 124 // registration with the policy server if the token was successfully fetched. |
126 void OnOAuth2PolicyTokenFetched(const std::string& policy_token, | 125 void OnOAuth2PolicyTokenFetched(const std::string& policy_token, |
127 const GoogleServiceAuthError& error); | 126 const GoogleServiceAuthError& error); |
128 | 127 |
129 // Completion handler for the explicit policy fetch triggered on startup in | 128 // Completion handler for the explicit policy fetch triggered on startup in |
130 // case |wait_for_policy_fetch_| is true. |success| is true if the fetch was | 129 // case |waiting_for_initial_policy_fetch_| is true. |success| is true if the |
131 // successful. | 130 // fetch was successful. |
132 void OnInitialPolicyFetchComplete(bool success); | 131 void OnInitialPolicyFetchComplete(bool success); |
133 | 132 |
134 // Called when |policy_fetch_timeout_| times out, to cancel the blocking | 133 // Called when |policy_fetch_timeout_| times out, to cancel the blocking wait |
135 // wait for the initial policy fetch. | 134 // for the initial policy fetch. |
136 void OnBlockingFetchTimeout(); | 135 void OnBlockingFetchTimeout(); |
137 | 136 |
138 // Cancels waiting for the policy fetch and flags the | 137 // Cancels waiting for the initial policy fetch and flags the |
139 // ConfigurationPolicyProvider ready (assuming all other initialization tasks | 138 // ConfigurationPolicyProvider ready (assuming all other initialization tasks |
140 // have completed). Pass |true| if policy fetch was successful (either | 139 // have completed). Pass |true| if policy fetch was successful (either because |
141 // because policy was successfully fetched, or if DMServer has notified us | 140 // policy was successfully fetched, or if DMServer has notified us that the |
142 // that the user is not managed). | 141 // user is not managed). |
143 void CancelWaitForPolicyFetch(bool success); | 142 void CancelWaitForPolicyFetch(bool success); |
144 | 143 |
145 void StartRefreshSchedulerIfReady(); | 144 void StartRefreshSchedulerIfReady(); |
146 | 145 |
147 // Owns the store, note that CloudPolicyManager just keeps a plain pointer. | 146 // Owns the store, note that CloudPolicyManager just keeps a plain pointer. |
148 std::unique_ptr<CloudPolicyStore> store_; | 147 std::unique_ptr<CloudPolicyStore> store_; |
149 | 148 |
150 // Manages external data referenced by policies. | 149 // Manages external data referenced by policies. |
151 std::unique_ptr<CloudExternalDataManager> external_data_manager_; | 150 std::unique_ptr<CloudExternalDataManager> external_data_manager_; |
152 | 151 |
153 // Username for the wildcard login check if applicable, empty otherwise. | 152 // Username for the wildcard login check if applicable, empty otherwise. |
154 std::string wildcard_username_; | 153 std::string wildcard_username_; |
155 | 154 |
156 // Path where policy for components will be cached. | 155 // Path where policy for components will be cached. |
157 base::FilePath component_policy_cache_path_; | 156 base::FilePath component_policy_cache_path_; |
158 | 157 |
159 // Whether to wait for a policy fetch to complete before reporting | 158 // Whether we're waiting for a policy fetch to complete before reporting |
160 // IsInitializationComplete(). | 159 // IsInitializationComplete(). |
161 bool wait_for_policy_fetch_; | 160 bool waiting_for_initial_policy_fetch_; |
162 | 161 |
163 // Whether we should allow policy fetches to fail, or wait forever until they | 162 // Whether the user session is continued in case of failure of initial policy |
164 // succeed (typically we won't allow them to fail until we have loaded policy | 163 // fetch. |
165 // at least once). | 164 bool initial_policy_fetch_may_fail_; |
166 bool allow_failed_policy_fetches_; | |
167 | 165 |
168 // A timer that puts a hard limit on the maximum time to wait for the initial | 166 // A timer that puts a hard limit on the maximum time to wait for the initial |
169 // policy fetch. | 167 // policy fetch. |
170 base::Timer policy_fetch_timeout_{false, false}; | 168 base::Timer policy_fetch_timeout_{false /* retain_user_task */, |
| 169 false /* is_repeating */}; |
171 | 170 |
172 // The pref service to pass to the refresh scheduler on initialization. | 171 // The pref service to pass to the refresh scheduler on initialization. |
173 PrefService* local_state_; | 172 PrefService* local_state_; |
174 | 173 |
175 // Used to fetch the policy OAuth token, when necessary. This object holds | 174 // Used to fetch the policy OAuth token, when necessary. This object holds |
176 // a callback with an unretained reference to the manager, when it exists. | 175 // a callback with an unretained reference to the manager, when it exists. |
177 std::unique_ptr<PolicyOAuth2TokenFetcher> token_fetcher_; | 176 std::unique_ptr<PolicyOAuth2TokenFetcher> token_fetcher_; |
178 | 177 |
179 // Keeps alive the wildcard checker while its running. | 178 // Keeps alive the wildcard checker while its running. |
180 std::unique_ptr<WildcardLoginChecker> wildcard_login_checker_; | 179 std::unique_ptr<WildcardLoginChecker> wildcard_login_checker_; |
(...skipping 12 matching lines...) Expand all Loading... |
193 // TODO(emaxx): Remove after the crashes tracked at https://crbug.com/685996 | 192 // TODO(emaxx): Remove after the crashes tracked at https://crbug.com/685996 |
194 // are fixed. | 193 // are fixed. |
195 base::debug::StackTrace connect_callstack_; | 194 base::debug::StackTrace connect_callstack_; |
196 | 195 |
197 DISALLOW_COPY_AND_ASSIGN(UserCloudPolicyManagerChromeOS); | 196 DISALLOW_COPY_AND_ASSIGN(UserCloudPolicyManagerChromeOS); |
198 }; | 197 }; |
199 | 198 |
200 } // namespace policy | 199 } // namespace policy |
201 | 200 |
202 #endif // CHROME_BROWSER_CHROMEOS_POLICY_USER_CLOUD_POLICY_MANAGER_CHROMEOS_H_ | 201 #endif // CHROME_BROWSER_CHROMEOS_POLICY_USER_CLOUD_POLICY_MANAGER_CHROMEOS_H_ |
OLD | NEW |