| 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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 } | 116 } |
| 117 | 117 |
| 118 bool UserCloudPolicyManager::IsClientRegistered() const { | 118 bool UserCloudPolicyManager::IsClientRegistered() const { |
| 119 if (!service_.get()) | 119 if (!service_.get()) |
| 120 return false; | 120 return false; |
| 121 return service_->client()->is_registered(); | 121 return service_->client()->is_registered(); |
| 122 } | 122 } |
| 123 | 123 |
| 124 void UserCloudPolicyManager::RegisterClient(const std::string& access_token) { | 124 void UserCloudPolicyManager::RegisterClient(const std::string& access_token) { |
| 125 DCHECK(cloud_policy_service()) << "Callers must invoke Initialize() first"; | 125 DCHECK(cloud_policy_service()) << "Callers must invoke Initialize() first"; |
| 126 if (!cloud_policy_service()->client()->is_registered()) | 126 if (!cloud_policy_service()->client()->is_registered()) { |
| 127 DVLOG(1) << "Registering client with access token: " << access_token; |
| 127 cloud_policy_service()->client()->Register(access_token); | 128 cloud_policy_service()->client()->Register(access_token); |
| 129 } |
| 128 } | 130 } |
| 129 | 131 |
| 130 bool UserCloudPolicyManager::IsInitializationComplete() const { | 132 bool UserCloudPolicyManager::IsInitializationComplete() const { |
| 131 return store_->is_initialized() && !wait_for_policy_fetch_; | 133 return store_->is_initialized() && !wait_for_policy_fetch_; |
| 132 } | 134 } |
| 133 | 135 |
| 134 void UserCloudPolicyManager::RefreshPolicies() { | 136 void UserCloudPolicyManager::RefreshPolicies() { |
| 135 if (service_.get()) { | 137 if (service_.get()) { |
| 136 wait_for_policy_refresh_ = true; | 138 wait_for_policy_refresh_ = true; |
| 137 service_->RefreshPolicy( | 139 service_->RefreshPolicy( |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 | 197 |
| 196 void UserCloudPolicyManager::Shutdown() { | 198 void UserCloudPolicyManager::Shutdown() { |
| 197 refresh_scheduler_.reset(); | 199 refresh_scheduler_.reset(); |
| 198 if (service_.get()) | 200 if (service_.get()) |
| 199 service_->client()->RemoveObserver(this); | 201 service_->client()->RemoveObserver(this); |
| 200 service_.reset(); | 202 service_.reset(); |
| 201 prefs_ = NULL; | 203 prefs_ = NULL; |
| 202 } | 204 } |
| 203 | 205 |
| 204 } // namespace policy | 206 } // namespace policy |
| OLD | NEW |