| 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" |
| 11 #include "base/message_loop.h" | 11 #include "base/message_loop.h" |
| 12 #include "base/path_service.h" | 12 #include "base/path_service.h" |
| 13 #include "chrome/browser/policy/cloud_policy_refresh_scheduler.h" | 13 #include "chrome/browser/policy/cloud_policy_refresh_scheduler.h" |
| 14 #include "chrome/browser/policy/cloud_policy_service.h" | 14 #include "chrome/browser/policy/cloud_policy_service.h" |
| 15 #include "chrome/browser/policy/policy_constants.h" | 15 #include "chrome/browser/policy/policy_constants.h" |
| 16 #include "chrome/common/chrome_paths.h" | 16 #include "chrome/common/chrome_paths.h" |
| 17 #include "chrome/common/chrome_switches.h" | 17 #include "chrome/common/chrome_switches.h" |
| 18 #include "chrome/common/pref_names.h" | 18 #include "chrome/common/pref_names.h" |
| 19 #include "policy/policy_constants.h" | |
| 20 | 19 |
| 21 #if defined(OS_CHROMEOS) | 20 #if defined(OS_CHROMEOS) |
| 22 #include "chrome/browser/policy/user_cloud_policy_store_chromeos.h" | 21 #include "chrome/browser/policy/user_cloud_policy_store_chromeos.h" |
| 23 #include "chromeos/dbus/dbus_thread_manager.h" | 22 #include "chromeos/dbus/dbus_thread_manager.h" |
| 24 #include "chromeos/dbus/session_manager_client.h" | 23 #include "chromeos/dbus/session_manager_client.h" |
| 25 #endif | 24 #endif |
| 26 | 25 |
| 27 namespace policy { | 26 namespace policy { |
| 28 | 27 |
| 29 namespace { | 28 namespace { |
| 30 | 29 |
| 31 #if defined(OS_CHROMEOS) | 30 #if defined(OS_CHROMEOS) |
| 32 // Paths for the legacy policy caches in the profile directory. | 31 // Paths for the legacy policy caches in the profile directory. |
| 33 // 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. |
| 34 | 33 |
| 35 // Subdirectory in the user's profile for storing user policies. | 34 // Subdirectory in the user's profile for storing user policies. |
| 36 const FilePath::CharType kPolicyDir[] = FILE_PATH_LITERAL("Device Management"); | 35 const FilePath::CharType kPolicyDir[] = FILE_PATH_LITERAL("Device Management"); |
| 37 // File in the above directory for stroing user policy dmtokens. | 36 // File in the above directory for stroing user policy dmtokens. |
| 38 const FilePath::CharType kTokenCacheFile[] = FILE_PATH_LITERAL("Token"); | 37 const FilePath::CharType kTokenCacheFile[] = FILE_PATH_LITERAL("Token"); |
| 39 // File in the above directory for storing user policy data. | 38 // File in the above directory for storing user policy data. |
| 40 const FilePath::CharType kPolicyCacheFile[] = FILE_PATH_LITERAL("Policy"); | 39 const FilePath::CharType kPolicyCacheFile[] = FILE_PATH_LITERAL("Policy"); |
| 41 #endif | 40 #endif |
| 42 | 41 |
| 43 } // namespace | 42 } // namespace |
| 44 | 43 |
| 45 UserCloudPolicyManager::UserCloudPolicyManager( | 44 UserCloudPolicyManager::UserCloudPolicyManager( |
| 46 const PolicyDefinitionList* policy_list, | |
| 47 scoped_ptr<CloudPolicyStore> store, | 45 scoped_ptr<CloudPolicyStore> store, |
| 48 bool wait_for_policy_fetch) | 46 bool wait_for_policy_fetch) |
| 49 : ConfigurationPolicyProvider(policy_list), | 47 : wait_for_policy_fetch_(wait_for_policy_fetch), |
| 50 wait_for_policy_fetch_(wait_for_policy_fetch), | |
| 51 wait_for_policy_refresh_(false), | 48 wait_for_policy_refresh_(false), |
| 52 store_(store.Pass()) { | 49 store_(store.Pass()) { |
| 53 store_->Load(); | 50 store_->Load(); |
| 54 store_->AddObserver(this); | 51 store_->AddObserver(this); |
| 55 } | 52 } |
| 56 | 53 |
| 57 UserCloudPolicyManager::~UserCloudPolicyManager() { | 54 UserCloudPolicyManager::~UserCloudPolicyManager() { |
| 58 Shutdown(); | 55 Shutdown(); |
| 59 store_->RemoveObserver(this); | 56 store_->RemoveObserver(this); |
| 60 } | 57 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 71 .Append(command_line->GetSwitchValuePath(switches::kLoginProfile)) | 68 .Append(command_line->GetSwitchValuePath(switches::kLoginProfile)) |
| 72 .Append(kPolicyDir); | 69 .Append(kPolicyDir); |
| 73 const FilePath policy_cache_file = policy_dir.Append(kPolicyCacheFile); | 70 const FilePath policy_cache_file = policy_dir.Append(kPolicyCacheFile); |
| 74 const FilePath token_cache_file = policy_dir.Append(kTokenCacheFile); | 71 const FilePath token_cache_file = policy_dir.Append(kTokenCacheFile); |
| 75 | 72 |
| 76 scoped_ptr<CloudPolicyStore> store( | 73 scoped_ptr<CloudPolicyStore> store( |
| 77 new UserCloudPolicyStoreChromeOS( | 74 new UserCloudPolicyStoreChromeOS( |
| 78 chromeos::DBusThreadManager::Get()->GetSessionManagerClient(), | 75 chromeos::DBusThreadManager::Get()->GetSessionManagerClient(), |
| 79 token_cache_file, policy_cache_file)); | 76 token_cache_file, policy_cache_file)); |
| 80 return scoped_ptr<UserCloudPolicyManager>( | 77 return scoped_ptr<UserCloudPolicyManager>( |
| 81 new UserCloudPolicyManager(GetChromePolicyDefinitionList(), | 78 new UserCloudPolicyManager(store.Pass(), wait_for_policy_fetch)); |
| 82 store.Pass(), wait_for_policy_fetch)); | |
| 83 } | 79 } |
| 84 #endif | 80 #endif |
| 85 | 81 |
| 86 void UserCloudPolicyManager::Initialize(PrefService* prefs, | 82 void UserCloudPolicyManager::Initialize(PrefService* prefs, |
| 87 DeviceManagementService* service, | 83 DeviceManagementService* service, |
| 88 UserAffiliation user_affiliation) { | 84 UserAffiliation user_affiliation) { |
| 89 DCHECK(!service_.get()); | 85 DCHECK(!service_.get()); |
| 90 prefs_ = prefs; | 86 prefs_ = prefs; |
| 91 scoped_ptr<CloudPolicyClient> client( | 87 scoped_ptr<CloudPolicyClient> client( |
| 92 new CloudPolicyClient(std::string(), std::string(), user_affiliation, | 88 new CloudPolicyClient(std::string(), std::string(), user_affiliation, |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 void UserCloudPolicyManager::OnInitialPolicyFetchComplete() { | 189 void UserCloudPolicyManager::OnInitialPolicyFetchComplete() { |
| 194 CancelWaitForPolicyFetch(); | 190 CancelWaitForPolicyFetch(); |
| 195 } | 191 } |
| 196 | 192 |
| 197 void UserCloudPolicyManager::OnRefreshComplete() { | 193 void UserCloudPolicyManager::OnRefreshComplete() { |
| 198 wait_for_policy_refresh_ = false; | 194 wait_for_policy_refresh_ = false; |
| 199 CheckAndPublishPolicy(); | 195 CheckAndPublishPolicy(); |
| 200 } | 196 } |
| 201 | 197 |
| 202 } // namespace policy | 198 } // namespace policy |
| OLD | NEW |