| 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_STORE_CHROMEOS_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_POLICY_USER_CLOUD_POLICY_STORE_CHROMEOS_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_POLICY_USER_CLOUD_POLICY_STORE_CHROMEOS_H_ | 6 #define CHROME_BROWSER_CHROMEOS_POLICY_USER_CLOUD_POLICY_STORE_CHROMEOS_H_ |
| 7 | 7 |
| 8 #include <memory> |
| 8 #include <string> | 9 #include <string> |
| 9 #include <vector> | 10 #include <vector> |
| 10 | 11 |
| 11 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 12 #include "base/files/file_path.h" | 13 #include "base/files/file_path.h" |
| 13 #include "base/macros.h" | 14 #include "base/macros.h" |
| 14 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
| 15 #include "base/memory/scoped_ptr.h" | |
| 16 #include "base/memory/weak_ptr.h" | 16 #include "base/memory/weak_ptr.h" |
| 17 #include "chromeos/dbus/dbus_method_call_status.h" | 17 #include "chromeos/dbus/dbus_method_call_status.h" |
| 18 #include "components/policy/core/common/cloud/cloud_policy_validator.h" | 18 #include "components/policy/core/common/cloud/cloud_policy_validator.h" |
| 19 #include "components/policy/core/common/cloud/user_cloud_policy_store_base.h" | 19 #include "components/policy/core/common/cloud/user_cloud_policy_store_base.h" |
| 20 #include "components/signin/core/account_id/account_id.h" | 20 #include "components/signin/core/account_id/account_id.h" |
| 21 | 21 |
| 22 namespace base { | 22 namespace base { |
| 23 class SequencedTaskRunner; | 23 class SequencedTaskRunner; |
| 24 } | 24 } |
| 25 | 25 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 54 // CloudPolicyStore: | 54 // CloudPolicyStore: |
| 55 void Store(const enterprise_management::PolicyFetchResponse& policy) override; | 55 void Store(const enterprise_management::PolicyFetchResponse& policy) override; |
| 56 void Load() override; | 56 void Load() override; |
| 57 | 57 |
| 58 // Loads the policy synchronously on the current thread. | 58 // Loads the policy synchronously on the current thread. |
| 59 void LoadImmediately(); | 59 void LoadImmediately(); |
| 60 | 60 |
| 61 private: | 61 private: |
| 62 // Starts validation of |policy| before storing it. | 62 // Starts validation of |policy| before storing it. |
| 63 void ValidatePolicyForStore( | 63 void ValidatePolicyForStore( |
| 64 scoped_ptr<enterprise_management::PolicyFetchResponse> policy); | 64 std::unique_ptr<enterprise_management::PolicyFetchResponse> policy); |
| 65 | 65 |
| 66 // Completion handler for policy validation on the Store() path. | 66 // Completion handler for policy validation on the Store() path. |
| 67 // Starts a store operation if the validation succeeded. | 67 // Starts a store operation if the validation succeeded. |
| 68 void OnPolicyToStoreValidated(UserCloudPolicyValidator* validator); | 68 void OnPolicyToStoreValidated(UserCloudPolicyValidator* validator); |
| 69 | 69 |
| 70 // Called back from SessionManagerClient for policy store operations. | 70 // Called back from SessionManagerClient for policy store operations. |
| 71 void OnPolicyStored(bool success); | 71 void OnPolicyStored(bool success); |
| 72 | 72 |
| 73 // Called back from SessionManagerClient for policy load operations. | 73 // Called back from SessionManagerClient for policy load operations. |
| 74 void OnPolicyRetrieved(const std::string& policy_blob); | 74 void OnPolicyRetrieved(const std::string& policy_blob); |
| 75 | 75 |
| 76 // Starts validation of the loaded |policy| before installing it. | 76 // Starts validation of the loaded |policy| before installing it. |
| 77 void ValidateRetrievedPolicy( | 77 void ValidateRetrievedPolicy( |
| 78 scoped_ptr<enterprise_management::PolicyFetchResponse> policy); | 78 std::unique_ptr<enterprise_management::PolicyFetchResponse> policy); |
| 79 | 79 |
| 80 // Completion handler for policy validation on the Load() path. Installs the | 80 // Completion handler for policy validation on the Load() path. Installs the |
| 81 // policy and publishes it if validation succeeded. | 81 // policy and publishes it if validation succeeded. |
| 82 void OnRetrievedPolicyValidated(UserCloudPolicyValidator* validator); | 82 void OnRetrievedPolicyValidated(UserCloudPolicyValidator* validator); |
| 83 | 83 |
| 84 // Callback for loading legacy caches. | 84 // Callback for loading legacy caches. |
| 85 void OnLegacyLoadFinished( | 85 void OnLegacyLoadFinished( |
| 86 const std::string& dm_token, | 86 const std::string& dm_token, |
| 87 const std::string& device_id, | 87 const std::string& device_id, |
| 88 Status status, | 88 Status status, |
| 89 scoped_ptr<enterprise_management::PolicyFetchResponse>); | 89 std::unique_ptr<enterprise_management::PolicyFetchResponse>); |
| 90 | 90 |
| 91 // Completion callback for legacy policy validation. | 91 // Completion callback for legacy policy validation. |
| 92 void OnLegacyPolicyValidated(const std::string& dm_token, | 92 void OnLegacyPolicyValidated(const std::string& dm_token, |
| 93 const std::string& device_id, | 93 const std::string& device_id, |
| 94 UserCloudPolicyValidator* validator); | 94 UserCloudPolicyValidator* validator); |
| 95 | 95 |
| 96 // Installs legacy tokens. | 96 // Installs legacy tokens. |
| 97 void InstallLegacyTokens(const std::string& dm_token, | 97 void InstallLegacyTokens(const std::string& dm_token, |
| 98 const std::string& device_id); | 98 const std::string& device_id); |
| 99 | 99 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 113 | 113 |
| 114 // Invokes |callback| after creating |policy_key_|, if it hasn't been created | 114 // Invokes |callback| after creating |policy_key_|, if it hasn't been created |
| 115 // yet; otherwise invokes |callback| immediately. | 115 // yet; otherwise invokes |callback| immediately. |
| 116 void EnsurePolicyKeyLoaded(const base::Closure& callback); | 116 void EnsurePolicyKeyLoaded(const base::Closure& callback); |
| 117 | 117 |
| 118 // Callback for getting the sanitized username from |cryptohome_client_|. | 118 // Callback for getting the sanitized username from |cryptohome_client_|. |
| 119 void OnGetSanitizedUsername(const base::Closure& callback, | 119 void OnGetSanitizedUsername(const base::Closure& callback, |
| 120 chromeos::DBusMethodCallStatus call_status, | 120 chromeos::DBusMethodCallStatus call_status, |
| 121 const std::string& sanitized_username); | 121 const std::string& sanitized_username); |
| 122 | 122 |
| 123 scoped_ptr<UserCloudPolicyValidator> CreateValidatorForLoad( | 123 std::unique_ptr<UserCloudPolicyValidator> CreateValidatorForLoad( |
| 124 scoped_ptr<enterprise_management::PolicyFetchResponse> policy); | 124 std::unique_ptr<enterprise_management::PolicyFetchResponse> policy); |
| 125 | 125 |
| 126 chromeos::CryptohomeClient* cryptohome_client_; | 126 chromeos::CryptohomeClient* cryptohome_client_; |
| 127 chromeos::SessionManagerClient* session_manager_client_; | 127 chromeos::SessionManagerClient* session_manager_client_; |
| 128 const AccountId account_id_; | 128 const AccountId account_id_; |
| 129 base::FilePath user_policy_key_dir_; | 129 base::FilePath user_policy_key_dir_; |
| 130 | 130 |
| 131 // TODO(mnissler): Remove all the legacy policy support members below after | 131 // TODO(mnissler): Remove all the legacy policy support members below after |
| 132 // the number of pre-M20 clients drops back to zero. | 132 // the number of pre-M20 clients drops back to zero. |
| 133 base::FilePath legacy_cache_dir_; | 133 base::FilePath legacy_cache_dir_; |
| 134 scoped_ptr<LegacyPolicyCacheLoader> legacy_loader_; | 134 std::unique_ptr<LegacyPolicyCacheLoader> legacy_loader_; |
| 135 bool legacy_caches_loaded_; | 135 bool legacy_caches_loaded_; |
| 136 | 136 |
| 137 bool policy_key_loaded_; | 137 bool policy_key_loaded_; |
| 138 base::FilePath policy_key_path_; | 138 base::FilePath policy_key_path_; |
| 139 std::string policy_key_; | 139 std::string policy_key_; |
| 140 | 140 |
| 141 base::WeakPtrFactory<UserCloudPolicyStoreChromeOS> weak_factory_; | 141 base::WeakPtrFactory<UserCloudPolicyStoreChromeOS> weak_factory_; |
| 142 | 142 |
| 143 DISALLOW_COPY_AND_ASSIGN(UserCloudPolicyStoreChromeOS); | 143 DISALLOW_COPY_AND_ASSIGN(UserCloudPolicyStoreChromeOS); |
| 144 }; | 144 }; |
| 145 | 145 |
| 146 } // namespace policy | 146 } // namespace policy |
| 147 | 147 |
| 148 #endif // CHROME_BROWSER_CHROMEOS_POLICY_USER_CLOUD_POLICY_STORE_CHROMEOS_H_ | 148 #endif // CHROME_BROWSER_CHROMEOS_POLICY_USER_CLOUD_POLICY_STORE_CHROMEOS_H_ |
| OLD | NEW |