Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_ACTIVE_DIRECTORY_POLICY_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_POLICY_ACTIVE_DIRECTORY_POLICY_MANAGER_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_POLICY_ACTIVE_DIRECTORY_POLICY_MANAGER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_POLICY_ACTIVE_DIRECTORY_POLICY_MANAGER_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/cancelable_callback.h" | |
| 11 #include "base/macros.h" | 10 #include "base/macros.h" |
| 12 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
| 13 #include "base/time/time.h" | |
| 14 #include "components/policy/core/common/cloud/cloud_policy_store.h" | 12 #include "components/policy/core/common/cloud/cloud_policy_store.h" |
| 15 #include "components/policy/core/common/configuration_policy_provider.h" | 13 #include "components/policy/core/common/configuration_policy_provider.h" |
| 14 #include "components/policy/core/common/policy_scheduler.h" | |
| 16 #include "components/signin/core/account_id/account_id.h" | 15 #include "components/signin/core/account_id/account_id.h" |
| 17 | 16 |
| 18 namespace policy { | 17 namespace policy { |
| 19 | 18 |
| 20 // ConfigurationPolicyProvider for device or user policy from Active Directory. | 19 // ConfigurationPolicyProvider for device or user policy from Active Directory. |
| 21 // The choice of constructor determines whether device or user policy is | 20 // The choice of constructor determines whether device or user policy is |
| 22 // provided. The policy is fetched from the Domain Controller by authpolicyd | 21 // provided. The policy is fetched from the Domain Controller by authpolicyd |
| 23 // which stores it in session manager and from where it is loaded by | 22 // which stores it in session manager and from where it is loaded by |
| 24 // ActiveDirectoryPolicyManager. | 23 // ActiveDirectoryPolicyManager. |
| 25 class ActiveDirectoryPolicyManager : public ConfigurationPolicyProvider, | 24 class ActiveDirectoryPolicyManager : public ConfigurationPolicyProvider, |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 50 | 49 |
| 51 private: | 50 private: |
| 52 // |account_id| specifies the user to manage policy for. If |account_id| is | 51 // |account_id| specifies the user to manage policy for. If |account_id| is |
| 53 // empty, device policy is managed. | 52 // empty, device policy is managed. |
| 54 ActiveDirectoryPolicyManager(const AccountId& account_id, | 53 ActiveDirectoryPolicyManager(const AccountId& account_id, |
| 55 std::unique_ptr<CloudPolicyStore> store); | 54 std::unique_ptr<CloudPolicyStore> store); |
| 56 | 55 |
| 57 // Publish the policy that's currently cached in the store. | 56 // Publish the policy that's currently cached in the store. |
| 58 void PublishPolicy(); | 57 void PublishPolicy(); |
| 59 | 58 |
| 60 // Callback from authpolicyd. | 59 // Calls into authpolicyd to fetch policy. Reports success or failure via |
| 60 // |callback|. | |
| 61 void DoRefresh(PolicyScheduler::TaskCallback callback); | |
|
pmarko
2017/06/19 10:14:37
Do you think it'd be worth mentioning in a comment
Thiemo Nagel
2017/06/19 22:29:51
I'm leaning towards not mentioning this because co
pmarko
2017/06/20 20:01:05
Ack, I was just asking about this for consistency
| |
| 62 | |
| 63 // Called by scheduler with result of policy fetch. | |
| 61 void OnPolicyRefreshed(bool success); | 64 void OnPolicyRefreshed(bool success); |
| 62 | 65 |
| 63 // Schedule next policy refresh to run after |delay|. (Deletes any previously | |
| 64 // scheduled refresh tasks.) | |
| 65 void ScheduleRefresh(base::TimeDelta delay); | |
| 66 | |
| 67 // Schedule next automatic policy refresh based on initial fetch delay or | |
| 68 // refresh interval. (Deletes any previously scheduled refresh tasks.) | |
| 69 void ScheduleAutomaticRefresh(); | |
| 70 | |
| 71 // Actually execute the scheduled policy refresh. | |
| 72 void RunScheduledRefresh(); | |
| 73 | |
| 74 const AccountId account_id_; | 66 const AccountId account_id_; |
| 75 std::unique_ptr<CloudPolicyStore> store_; | 67 std::unique_ptr<CloudPolicyStore> store_; |
| 76 | 68 |
| 77 // Whether a policy refresh is in progress (and thus any further requests need | 69 std::unique_ptr<PolicyScheduler> scheduler_; |
| 78 // to be blocked). | |
| 79 bool refresh_in_progress_ = false; | |
| 80 // Whether a refresh had been blocked and thus the next refresh needs to be | |
| 81 // scheduled at the shorter "retry" interval. | |
| 82 bool retry_refresh_ = false; | |
| 83 base::TimeTicks last_refresh_; | |
| 84 const base::TimeTicks startup_ = base::TimeTicks::Now(); | |
| 85 std::unique_ptr<base::CancelableClosure> refresh_task_; | |
| 86 | 70 |
| 87 // Must be last member. | 71 // Must be last member. |
| 88 base::WeakPtrFactory<ActiveDirectoryPolicyManager> weak_ptr_factory_; | 72 base::WeakPtrFactory<ActiveDirectoryPolicyManager> weak_ptr_factory_{this}; |
| 89 | 73 |
| 90 DISALLOW_COPY_AND_ASSIGN(ActiveDirectoryPolicyManager); | 74 DISALLOW_COPY_AND_ASSIGN(ActiveDirectoryPolicyManager); |
| 91 }; | 75 }; |
| 92 | 76 |
| 93 } // namespace policy | 77 } // namespace policy |
| 94 | 78 |
| 95 #endif // CHROME_BROWSER_CHROMEOS_POLICY_ACTIVE_DIRECTORY_POLICY_MANAGER_H_ | 79 #endif // CHROME_BROWSER_CHROMEOS_POLICY_ACTIVE_DIRECTORY_POLICY_MANAGER_H_ |
| OLD | NEW |