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/chromeos/policy/user_cloud_policy_store_chromeos.h" | 5 #include "chrome/browser/chromeos/policy/user_cloud_policy_store_chromeos.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
402 policy_->set_device_id(device_id); | 402 policy_->set_device_id(device_id); |
403 } | 403 } |
404 | 404 |
405 // Tell the rest of the world that the policy load completed. | 405 // Tell the rest of the world that the policy load completed. |
406 NotifyStoreLoaded(); | 406 NotifyStoreLoaded(); |
407 } | 407 } |
408 | 408 |
409 // static | 409 // static |
410 void UserCloudPolicyStoreChromeOS::RemoveLegacyCacheDir( | 410 void UserCloudPolicyStoreChromeOS::RemoveLegacyCacheDir( |
411 const base::FilePath& dir) { | 411 const base::FilePath& dir) { |
412 if (file_util::PathExists(dir) && !base::Delete(dir, true)) | 412 if (base::PathExists(dir) && !base::Delete(dir, true)) |
413 LOG(ERROR) << "Failed to remove cache dir " << dir.value(); | 413 LOG(ERROR) << "Failed to remove cache dir " << dir.value(); |
414 } | 414 } |
415 | 415 |
416 void UserCloudPolicyStoreChromeOS::ReloadPolicyKey( | 416 void UserCloudPolicyStoreChromeOS::ReloadPolicyKey( |
417 const base::Closure& callback) { | 417 const base::Closure& callback) { |
418 std::vector<uint8>* key = new std::vector<uint8>(); | 418 std::vector<uint8>* key = new std::vector<uint8>(); |
419 content::BrowserThread::PostBlockingPoolTaskAndReply( | 419 content::BrowserThread::PostBlockingPoolTaskAndReply( |
420 FROM_HERE, | 420 FROM_HERE, |
421 base::Bind(&UserCloudPolicyStoreChromeOS::LoadPolicyKey, | 421 base::Bind(&UserCloudPolicyStoreChromeOS::LoadPolicyKey, |
422 policy_key_path_, | 422 policy_key_path_, |
423 key), | 423 key), |
424 base::Bind(&UserCloudPolicyStoreChromeOS::OnPolicyKeyReloaded, | 424 base::Bind(&UserCloudPolicyStoreChromeOS::OnPolicyKeyReloaded, |
425 weak_factory_.GetWeakPtr(), | 425 weak_factory_.GetWeakPtr(), |
426 base::Owned(key), | 426 base::Owned(key), |
427 callback)); | 427 callback)); |
428 } | 428 } |
429 | 429 |
430 // static | 430 // static |
431 void UserCloudPolicyStoreChromeOS::LoadPolicyKey(const base::FilePath& path, | 431 void UserCloudPolicyStoreChromeOS::LoadPolicyKey(const base::FilePath& path, |
432 std::vector<uint8>* key) { | 432 std::vector<uint8>* key) { |
433 if (!file_util::PathExists(path)) { | 433 if (!base::PathExists(path)) { |
434 // There is no policy key the first time that a user fetches policy. If | 434 // There is no policy key the first time that a user fetches policy. If |
435 // |path| does not exist then that is the most likely scenario, so there's | 435 // |path| does not exist then that is the most likely scenario, so there's |
436 // no need to sample a failure. | 436 // no need to sample a failure. |
437 VLOG(1) << "No key at " << path.value(); | 437 VLOG(1) << "No key at " << path.value(); |
438 return; | 438 return; |
439 } | 439 } |
440 | 440 |
441 int64 size; | 441 int64 size; |
442 if (!file_util::GetFileSize(path, &size)) { | 442 if (!file_util::GetFileSize(path, &size)) { |
443 LOG(ERROR) << "Could not get size of " << path.value(); | 443 LOG(ERROR) << "Could not get size of " << path.value(); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
488 !sanitized_username.empty()) { | 488 !sanitized_username.empty()) { |
489 policy_key_path_ = user_policy_key_dir_.Append( | 489 policy_key_path_ = user_policy_key_dir_.Append( |
490 base::StringPrintf(kPolicyKeyFile, sanitized_username.c_str())); | 490 base::StringPrintf(kPolicyKeyFile, sanitized_username.c_str())); |
491 } else { | 491 } else { |
492 SampleValidationFailure(VALIDATION_FAILURE_DBUS); | 492 SampleValidationFailure(VALIDATION_FAILURE_DBUS); |
493 } | 493 } |
494 ReloadPolicyKey(callback); | 494 ReloadPolicyKey(callback); |
495 } | 495 } |
496 | 496 |
497 } // namespace policy | 497 } // namespace policy |
OLD | NEW |