| 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 <string> | 9 #include <string> |
| 9 | 10 |
| 10 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 11 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
| 12 #include "base/macros.h" | 13 #include "base/macros.h" |
| 13 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.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 "components/keyed_service/core/keyed_service.h" | 17 #include "components/keyed_service/core/keyed_service.h" |
| 18 #include "components/policy/core/common/cloud/cloud_policy_client.h" | 18 #include "components/policy/core/common/cloud/cloud_policy_client.h" |
| 19 #include "components/policy/core/common/cloud/cloud_policy_constants.h" | 19 #include "components/policy/core/common/cloud/cloud_policy_constants.h" |
| 20 #include "components/policy/core/common/cloud/cloud_policy_manager.h" | 20 #include "components/policy/core/common/cloud/cloud_policy_manager.h" |
| 21 #include "components/policy/core/common/cloud/cloud_policy_service.h" | 21 #include "components/policy/core/common/cloud/cloud_policy_service.h" |
| 22 | 22 |
| 23 class GoogleServiceAuthError; | 23 class GoogleServiceAuthError; |
| 24 class PrefService; | 24 class PrefService; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 46 public KeyedService { | 46 public KeyedService { |
| 47 public: | 47 public: |
| 48 // If |wait_for_policy_fetch| is true, IsInitializationComplete() will return | 48 // If |wait_for_policy_fetch| is true, IsInitializationComplete() will return |
| 49 // 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. | 50 // |task_runner| is the runner for policy refresh tasks. |
| 51 // |file_task_runner| is used for file operations. Currently this must be the | 51 // |file_task_runner| is used for file operations. Currently this must be the |
| 52 // FILE BrowserThread. | 52 // FILE BrowserThread. |
| 53 // |io_task_runner| is used for network IO. Currently this must be the IO | 53 // |io_task_runner| is used for network IO. Currently this must be the IO |
| 54 // BrowserThread. | 54 // BrowserThread. |
| 55 UserCloudPolicyManagerChromeOS( | 55 UserCloudPolicyManagerChromeOS( |
| 56 scoped_ptr<CloudPolicyStore> store, | 56 std::unique_ptr<CloudPolicyStore> store, |
| 57 scoped_ptr<CloudExternalDataManager> external_data_manager, | 57 std::unique_ptr<CloudExternalDataManager> external_data_manager, |
| 58 const base::FilePath& component_policy_cache_path, | 58 const base::FilePath& component_policy_cache_path, |
| 59 bool wait_for_policy_fetch, | 59 bool wait_for_policy_fetch, |
| 60 base::TimeDelta initial_policy_fetch_timeout, | 60 base::TimeDelta initial_policy_fetch_timeout, |
| 61 const scoped_refptr<base::SequencedTaskRunner>& task_runner, | 61 const scoped_refptr<base::SequencedTaskRunner>& task_runner, |
| 62 const scoped_refptr<base::SequencedTaskRunner>& file_task_runner, | 62 const scoped_refptr<base::SequencedTaskRunner>& file_task_runner, |
| 63 const scoped_refptr<base::SequencedTaskRunner>& io_task_runner); | 63 const scoped_refptr<base::SequencedTaskRunner>& io_task_runner); |
| 64 ~UserCloudPolicyManagerChromeOS() override; | 64 ~UserCloudPolicyManagerChromeOS() override; |
| 65 | 65 |
| 66 // Initializes the cloud connection. |local_state| and | 66 // Initializes the cloud connection. |local_state| and |
| 67 // |device_management_service| must stay valid until this object is deleted. | 67 // |device_management_service| must stay valid until this object is deleted. |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 // Cancels waiting for the policy fetch and flags the | 133 // Cancels waiting for the policy fetch and flags the |
| 134 // ConfigurationPolicyProvider ready (assuming all other initialization tasks | 134 // ConfigurationPolicyProvider ready (assuming all other initialization tasks |
| 135 // have completed). Pass |true| if policy fetch was successful (either | 135 // have completed). Pass |true| if policy fetch was successful (either |
| 136 // because policy was successfully fetched, or if DMServer has notified us | 136 // because policy was successfully fetched, or if DMServer has notified us |
| 137 // that the user is not managed). | 137 // that the user is not managed). |
| 138 void CancelWaitForPolicyFetch(bool success); | 138 void CancelWaitForPolicyFetch(bool success); |
| 139 | 139 |
| 140 void StartRefreshSchedulerIfReady(); | 140 void StartRefreshSchedulerIfReady(); |
| 141 | 141 |
| 142 // Owns the store, note that CloudPolicyManager just keeps a plain pointer. | 142 // Owns the store, note that CloudPolicyManager just keeps a plain pointer. |
| 143 scoped_ptr<CloudPolicyStore> store_; | 143 std::unique_ptr<CloudPolicyStore> store_; |
| 144 | 144 |
| 145 // Manages external data referenced by policies. | 145 // Manages external data referenced by policies. |
| 146 scoped_ptr<CloudExternalDataManager> external_data_manager_; | 146 std::unique_ptr<CloudExternalDataManager> external_data_manager_; |
| 147 | 147 |
| 148 // Username for the wildcard login check if applicable, empty otherwise. | 148 // Username for the wildcard login check if applicable, empty otherwise. |
| 149 std::string wildcard_username_; | 149 std::string wildcard_username_; |
| 150 | 150 |
| 151 // Path where policy for components will be cached. | 151 // Path where policy for components will be cached. |
| 152 base::FilePath component_policy_cache_path_; | 152 base::FilePath component_policy_cache_path_; |
| 153 | 153 |
| 154 // Whether to wait for a policy fetch to complete before reporting | 154 // Whether to wait for a policy fetch to complete before reporting |
| 155 // IsInitializationComplete(). | 155 // IsInitializationComplete(). |
| 156 bool wait_for_policy_fetch_; | 156 bool wait_for_policy_fetch_; |
| 157 | 157 |
| 158 // Whether we should allow policy fetches to fail, or wait forever until they | 158 // Whether we should allow policy fetches to fail, or wait forever until they |
| 159 // succeed (typically we won't allow them to fail until we have loaded policy | 159 // succeed (typically we won't allow them to fail until we have loaded policy |
| 160 // at least once). | 160 // at least once). |
| 161 bool allow_failed_policy_fetches_; | 161 bool allow_failed_policy_fetches_; |
| 162 | 162 |
| 163 // A timer that puts a hard limit on the maximum time to wait for the initial | 163 // A timer that puts a hard limit on the maximum time to wait for the initial |
| 164 // policy fetch. | 164 // policy fetch. |
| 165 base::Timer policy_fetch_timeout_; | 165 base::Timer policy_fetch_timeout_; |
| 166 | 166 |
| 167 // The pref service to pass to the refresh scheduler on initialization. | 167 // The pref service to pass to the refresh scheduler on initialization. |
| 168 PrefService* local_state_; | 168 PrefService* local_state_; |
| 169 | 169 |
| 170 // Used to fetch the policy OAuth token, when necessary. This object holds | 170 // Used to fetch the policy OAuth token, when necessary. This object holds |
| 171 // a callback with an unretained reference to the manager, when it exists. | 171 // a callback with an unretained reference to the manager, when it exists. |
| 172 scoped_ptr<PolicyOAuth2TokenFetcher> token_fetcher_; | 172 std::unique_ptr<PolicyOAuth2TokenFetcher> token_fetcher_; |
| 173 | 173 |
| 174 // Keeps alive the wildcard checker while its running. | 174 // Keeps alive the wildcard checker while its running. |
| 175 scoped_ptr<WildcardLoginChecker> wildcard_login_checker_; | 175 std::unique_ptr<WildcardLoginChecker> wildcard_login_checker_; |
| 176 | 176 |
| 177 // The access token passed to OnAccessTokenAvailable. It is stored here so | 177 // The access token passed to OnAccessTokenAvailable. It is stored here so |
| 178 // that it can be used if OnInitializationCompleted is called later. | 178 // that it can be used if OnInitializationCompleted is called later. |
| 179 std::string access_token_; | 179 std::string access_token_; |
| 180 | 180 |
| 181 // Timestamps for collecting timing UMA stats. | 181 // Timestamps for collecting timing UMA stats. |
| 182 base::Time time_init_started_; | 182 base::Time time_init_started_; |
| 183 base::Time time_init_completed_; | 183 base::Time time_init_completed_; |
| 184 base::Time time_token_available_; | 184 base::Time time_token_available_; |
| 185 base::Time time_client_registered_; | 185 base::Time time_client_registered_; |
| 186 | 186 |
| 187 DISALLOW_COPY_AND_ASSIGN(UserCloudPolicyManagerChromeOS); | 187 DISALLOW_COPY_AND_ASSIGN(UserCloudPolicyManagerChromeOS); |
| 188 }; | 188 }; |
| 189 | 189 |
| 190 } // namespace policy | 190 } // namespace policy |
| 191 | 191 |
| 192 #endif // CHROME_BROWSER_CHROMEOS_POLICY_USER_CLOUD_POLICY_MANAGER_CHROMEOS_H_ | 192 #endif // CHROME_BROWSER_CHROMEOS_POLICY_USER_CLOUD_POLICY_MANAGER_CHROMEOS_H_ |
| OLD | NEW |