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_store_chromeos.h" | 5 #include "chrome/browser/policy/user_cloud_policy_store_chromeos.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
11 #include "base/callback.h" | 11 #include "base/callback.h" |
12 #include "base/file_util.h" | 12 #include "base/file_util.h" |
13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
14 #include "chrome/browser/policy/proto/cloud_policy.pb.h" | 14 #include "chrome/browser/policy/proto/cloud_policy.pb.h" |
15 #include "chrome/browser/policy/proto/device_management_local.pb.h" | 15 #include "chrome/browser/policy/proto/device_management_local.pb.h" |
16 #include "chrome/browser/policy/user_policy_disk_cache.h" | 16 #include "chrome/browser/policy/user_policy_disk_cache.h" |
17 #include "chrome/browser/policy/user_policy_token_cache.h" | 17 #include "chrome/browser/policy/user_policy_token_loader.h" |
18 #include "chromeos/dbus/session_manager_client.h" | 18 #include "chromeos/dbus/session_manager_client.h" |
19 #include "content/public/browser/browser_thread.h" | 19 #include "content/public/browser/browser_thread.h" |
20 #include "google_apis/gaia/gaia_auth_util.h" | 20 #include "google_apis/gaia/gaia_auth_util.h" |
21 | 21 |
22 namespace em = enterprise_management; | 22 namespace em = enterprise_management; |
23 | 23 |
24 namespace policy { | 24 namespace policy { |
25 | 25 |
26 namespace { | 26 namespace { |
27 // Subdirectory in the user's profile for storing user policies. | 27 // Subdirectory in the user's profile for storing user policies. |
28 const FilePath::CharType kPolicyDir[] = FILE_PATH_LITERAL("Device Management"); | 28 const FilePath::CharType kPolicyDir[] = FILE_PATH_LITERAL("Device Management"); |
29 // File in the above directory for stroing user policy dmtokens. | 29 // File in the above directory for stroing user policy dmtokens. |
30 const FilePath::CharType kTokenCacheFile[] = FILE_PATH_LITERAL("Token"); | 30 const FilePath::CharType kTokenCacheFile[] = FILE_PATH_LITERAL("Token"); |
31 // File in the above directory for storing user policy data. | 31 // File in the above directory for storing user policy data. |
32 const FilePath::CharType kPolicyCacheFile[] = FILE_PATH_LITERAL("Policy"); | 32 const FilePath::CharType kPolicyCacheFile[] = FILE_PATH_LITERAL("Policy"); |
33 } // namespace | 33 } // namespace |
34 | 34 |
35 | 35 |
36 // Helper class for loading legacy policy caches. | 36 // Helper class for loading legacy policy caches. |
37 class LegacyPolicyCacheLoader : public UserPolicyTokenCache::Delegate, | 37 class LegacyPolicyCacheLoader : public UserPolicyTokenLoader::Delegate, |
38 public UserPolicyDiskCache::Delegate { | 38 public UserPolicyDiskCache::Delegate { |
39 public: | 39 public: |
40 typedef base::Callback<void(const std::string&, | 40 typedef base::Callback<void(const std::string&, |
41 const std::string&, | 41 const std::string&, |
42 CloudPolicyStore::Status, | 42 CloudPolicyStore::Status, |
43 scoped_ptr<em::PolicyFetchResponse>)> Callback; | 43 scoped_ptr<em::PolicyFetchResponse>)> Callback; |
44 | 44 |
45 LegacyPolicyCacheLoader(const FilePath& token_cache_file, | 45 LegacyPolicyCacheLoader(const FilePath& token_cache_file, |
46 const FilePath& policy_cache_file); | 46 const FilePath& policy_cache_file); |
47 virtual ~LegacyPolicyCacheLoader(); | 47 virtual ~LegacyPolicyCacheLoader(); |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
340 NotifyStoreLoaded(); | 340 NotifyStoreLoaded(); |
341 } | 341 } |
342 | 342 |
343 // static | 343 // static |
344 void UserCloudPolicyStoreChromeOS::RemoveLegacyCacheDir(const FilePath& dir) { | 344 void UserCloudPolicyStoreChromeOS::RemoveLegacyCacheDir(const FilePath& dir) { |
345 if (file_util::PathExists(dir) && !file_util::Delete(dir, true)) | 345 if (file_util::PathExists(dir) && !file_util::Delete(dir, true)) |
346 LOG(ERROR) << "Failed to remove cache dir " << dir.value(); | 346 LOG(ERROR) << "Failed to remove cache dir " << dir.value(); |
347 } | 347 } |
348 | 348 |
349 } // namespace policy | 349 } // namespace policy |
OLD | NEW |