| 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 #include "chrome/browser/policy/user_cloud_policy_manager.h" | 5 #include "chrome/browser/policy/user_cloud_policy_manager.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 namespace policy { | 26 namespace policy { |
| 27 | 27 |
| 28 namespace { | 28 namespace { |
| 29 | 29 |
| 30 #if defined(OS_CHROMEOS) | 30 #if defined(OS_CHROMEOS) |
| 31 // Paths for the legacy policy caches in the profile directory. | 31 // Paths for the legacy policy caches in the profile directory. |
| 32 // TODO(mnissler): Remove once the number of pre-M20 clients becomes negligible. | 32 // TODO(mnissler): Remove once the number of pre-M20 clients becomes negligible. |
| 33 | 33 |
| 34 // Subdirectory in the user's profile for storing user policies. | 34 // Subdirectory in the user's profile for storing user policies. |
| 35 const FilePath::CharType kPolicyDir[] = FILE_PATH_LITERAL("Device Management"); | 35 const FilePath::CharType kPolicyDir[] = FILE_PATH_LITERAL("Device Management"); |
| 36 // File in the above directory for stroing user policy dmtokens. | 36 // File in the above directory for storing user policy dmtokens. |
| 37 const FilePath::CharType kTokenCacheFile[] = FILE_PATH_LITERAL("Token"); | 37 const FilePath::CharType kTokenCacheFile[] = FILE_PATH_LITERAL("Token"); |
| 38 // File in the above directory for storing user policy data. | 38 // File in the above directory for storing user policy data. |
| 39 const FilePath::CharType kPolicyCacheFile[] = FILE_PATH_LITERAL("Policy"); | 39 const FilePath::CharType kPolicyCacheFile[] = FILE_PATH_LITERAL("Policy"); |
| 40 #endif | 40 #endif |
| 41 | 41 |
| 42 } // namespace | 42 } // namespace |
| 43 | 43 |
| 44 UserCloudPolicyManager::UserCloudPolicyManager( | 44 UserCloudPolicyManager::UserCloudPolicyManager( |
| 45 scoped_ptr<CloudPolicyStore> store, | 45 scoped_ptr<CloudPolicyStore> store, |
| 46 bool wait_for_policy_fetch) | 46 bool wait_for_policy_fetch) |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 } | 119 } |
| 120 | 120 |
| 121 bool UserCloudPolicyManager::IsClientRegistered() const { | 121 bool UserCloudPolicyManager::IsClientRegistered() const { |
| 122 if (!service_.get()) | 122 if (!service_.get()) |
| 123 return false; | 123 return false; |
| 124 return service_->client()->is_registered(); | 124 return service_->client()->is_registered(); |
| 125 } | 125 } |
| 126 | 126 |
| 127 void UserCloudPolicyManager::RegisterClient(const std::string& access_token) { | 127 void UserCloudPolicyManager::RegisterClient(const std::string& access_token) { |
| 128 DCHECK(cloud_policy_service()) << "Callers must invoke Initialize() first"; | 128 DCHECK(cloud_policy_service()) << "Callers must invoke Initialize() first"; |
| 129 if (!cloud_policy_service()->client()->is_registered()) | 129 if (!cloud_policy_service()->client()->is_registered()) { |
| 130 DVLOG(1) << "Registering client with access token: " << access_token; |
| 130 cloud_policy_service()->client()->Register(access_token); | 131 cloud_policy_service()->client()->Register(access_token); |
| 132 } |
| 131 } | 133 } |
| 132 | 134 |
| 133 bool UserCloudPolicyManager::IsInitializationComplete() const { | 135 bool UserCloudPolicyManager::IsInitializationComplete() const { |
| 134 return store_->is_initialized() && !wait_for_policy_fetch_; | 136 return store_->is_initialized() && !wait_for_policy_fetch_; |
| 135 } | 137 } |
| 136 | 138 |
| 137 void UserCloudPolicyManager::RefreshPolicies() { | 139 void UserCloudPolicyManager::RefreshPolicies() { |
| 138 if (service_.get()) { | 140 if (service_.get()) { |
| 139 wait_for_policy_refresh_ = true; | 141 wait_for_policy_refresh_ = true; |
| 140 service_->RefreshPolicy( | 142 service_->RefreshPolicy( |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 void UserCloudPolicyManager::OnInitialPolicyFetchComplete() { | 192 void UserCloudPolicyManager::OnInitialPolicyFetchComplete() { |
| 191 CancelWaitForPolicyFetch(); | 193 CancelWaitForPolicyFetch(); |
| 192 } | 194 } |
| 193 | 195 |
| 194 void UserCloudPolicyManager::OnRefreshComplete() { | 196 void UserCloudPolicyManager::OnRefreshComplete() { |
| 195 wait_for_policy_refresh_ = false; | 197 wait_for_policy_refresh_ = false; |
| 196 CheckAndPublishPolicy(); | 198 CheckAndPublishPolicy(); |
| 197 } | 199 } |
| 198 | 200 |
| 199 } // namespace policy | 201 } // namespace policy |
| OLD | NEW |