| 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_POLICY_USER_CLOUD_POLICY_STORE_CHROMEOS_H_ | 5 #ifndef CHROME_BROWSER_POLICY_USER_CLOUD_POLICY_STORE_CHROMEOS_H_ |
| 6 #define CHROME_BROWSER_POLICY_USER_CLOUD_POLICY_STORE_CHROMEOS_H_ | 6 #define CHROME_BROWSER_POLICY_USER_CLOUD_POLICY_STORE_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/file_path.h" | 12 #include "base/file_path.h" |
| 13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
| 15 #include "chrome/browser/policy/cloud_policy_store.h" | |
| 16 #include "chrome/browser/policy/cloud_policy_validator.h" | 15 #include "chrome/browser/policy/cloud_policy_validator.h" |
| 16 #include "chrome/browser/policy/user_cloud_policy_store_base.h" |
| 17 | 17 |
| 18 namespace chromeos { | 18 namespace chromeos { |
| 19 class SessionManagerClient; | 19 class SessionManagerClient; |
| 20 } | 20 } |
| 21 | 21 |
| 22 namespace enterprise_management { | 22 namespace enterprise_management { |
| 23 class CloudPolicySettings; | 23 class CloudPolicySettings; |
| 24 } | 24 } |
| 25 | 25 |
| 26 namespace policy { | 26 namespace policy { |
| 27 | 27 |
| 28 class LegacyPolicyCacheLoader; | 28 class LegacyPolicyCacheLoader; |
| 29 | 29 |
| 30 // Implements a cloud policy store backed by the Chrome OS' session_manager, | 30 // Implements a cloud policy store backed by the Chrome OS' session_manager, |
| 31 // which takes care of persisting policy to disk and is accessed via DBus calls | 31 // which takes care of persisting policy to disk and is accessed via DBus calls |
| 32 // through SessionManagerClient. | 32 // through SessionManagerClient. |
| 33 // | 33 // |
| 34 // Additionally, this class drives legacy UserPolicyTokenCache and | 34 // Additionally, this class drives legacy UserPolicyTokenCache and |
| 35 // UserPolicyDiskCache instances, migrating policy from these to session_manager | 35 // UserPolicyDiskCache instances, migrating policy from these to session_manager |
| 36 // storage on the fly. | 36 // storage on the fly. |
| 37 class UserCloudPolicyStoreChromeOS : public CloudPolicyStore { | 37 class UserCloudPolicyStoreChromeOS : public UserCloudPolicyStoreBase { |
| 38 public: | 38 public: |
| 39 UserCloudPolicyStoreChromeOS( | 39 UserCloudPolicyStoreChromeOS( |
| 40 chromeos::SessionManagerClient* session_manager_client, | 40 chromeos::SessionManagerClient* session_manager_client, |
| 41 const FilePath& legacy_token_cache_file, | 41 const FilePath& legacy_token_cache_file, |
| 42 const FilePath& legacy_policy_cache_file); | 42 const FilePath& legacy_policy_cache_file); |
| 43 virtual ~UserCloudPolicyStoreChromeOS(); | 43 virtual ~UserCloudPolicyStoreChromeOS(); |
| 44 | 44 |
| 45 // CloudPolicyStore: | 45 // CloudPolicyStore: |
| 46 virtual void Store( | 46 virtual void Store( |
| 47 const enterprise_management::PolicyFetchResponse& policy) OVERRIDE; | 47 const enterprise_management::PolicyFetchResponse& policy) OVERRIDE; |
| 48 virtual void Load() OVERRIDE; | 48 virtual void Load() OVERRIDE; |
| 49 | 49 |
| 50 private: | 50 private: |
| 51 // Called back from SessionManagerClient for policy load operations. | 51 // Called back from SessionManagerClient for policy load operations. |
| 52 void OnPolicyRetrieved(const std::string& policy_blob); | 52 void OnPolicyRetrieved(const std::string& policy_blob); |
| 53 | 53 |
| 54 // Completion handler for policy validation on the Load() path. Installs the | 54 // Completion handler for policy validation on the Load() path. Installs the |
| 55 // policy and publishes it if validation succeeded. | 55 // policy and publishes it if validation succeeded. |
| 56 void OnRetrievedPolicyValidated(UserCloudPolicyValidator* validator); | 56 void OnRetrievedPolicyValidated(UserCloudPolicyValidator* validator); |
| 57 | 57 |
| 58 // Completion handler for policy validation on the Load() path. Starts a store | 58 // Completion handler for policy validation on the Load() path. Starts a store |
| 59 // operation if the validation succeeded. | 59 // operation if the validation succeeded. |
| 60 void OnPolicyToStoreValidated(UserCloudPolicyValidator* validator); | 60 void OnPolicyToStoreValidated(UserCloudPolicyValidator* validator); |
| 61 | 61 |
| 62 // Called back from SessionManagerClient for policy store operations. | 62 // Called back from SessionManagerClient for policy store operations. |
| 63 void OnPolicyStored(bool); | 63 void OnPolicyStored(bool); |
| 64 | 64 |
| 65 // Installs |policy_data| and |payload|. | |
| 66 void InstallPolicy( | |
| 67 scoped_ptr<enterprise_management::PolicyData> policy_data, | |
| 68 scoped_ptr<enterprise_management::CloudPolicySettings> payload); | |
| 69 | |
| 70 // Starts policy blob validation. | 65 // Starts policy blob validation. |
| 71 void Validate( | 66 void Validate( |
| 72 scoped_ptr<enterprise_management::PolicyFetchResponse> policy, | 67 scoped_ptr<enterprise_management::PolicyFetchResponse> policy, |
| 73 const UserCloudPolicyValidator::CompletionCallback& callback); | 68 const UserCloudPolicyValidator::CompletionCallback& callback); |
| 74 | 69 |
| 75 // Callback for loading legacy caches. | 70 // Callback for loading legacy caches. |
| 76 void OnLegacyLoadFinished( | 71 void OnLegacyLoadFinished( |
| 77 const std::string& dm_token, | 72 const std::string& dm_token, |
| 78 const std::string& device_id, | 73 const std::string& device_id, |
| 79 Status status, | 74 Status status, |
| (...skipping 20 matching lines...) Expand all Loading... |
| 100 FilePath legacy_cache_dir_; | 95 FilePath legacy_cache_dir_; |
| 101 scoped_ptr<LegacyPolicyCacheLoader> legacy_loader_; | 96 scoped_ptr<LegacyPolicyCacheLoader> legacy_loader_; |
| 102 bool legacy_caches_loaded_; | 97 bool legacy_caches_loaded_; |
| 103 | 98 |
| 104 DISALLOW_COPY_AND_ASSIGN(UserCloudPolicyStoreChromeOS); | 99 DISALLOW_COPY_AND_ASSIGN(UserCloudPolicyStoreChromeOS); |
| 105 }; | 100 }; |
| 106 | 101 |
| 107 } // namespace policy | 102 } // namespace policy |
| 108 | 103 |
| 109 #endif // CHROME_BROWSER_POLICY_USER_CLOUD_POLICY_STORE_CHROMEOS_H_ | 104 #endif // CHROME_BROWSER_POLICY_USER_CLOUD_POLICY_STORE_CHROMEOS_H_ |
| OLD | NEW |