| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/login/signed_settings.h" | 5 #include "chrome/browser/chromeos/login/signed_settings.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| (...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 316 const std::string& value, | 316 const std::string& value, |
| 317 SignedSettings::Delegate<bool>* d) | 317 SignedSettings::Delegate<bool>* d) |
| 318 : name_(name), | 318 : name_(name), |
| 319 value_(value), | 319 value_(value), |
| 320 d_(d) { | 320 d_(d) { |
| 321 } | 321 } |
| 322 | 322 |
| 323 StorePropertyOp::~StorePropertyOp() {} | 323 StorePropertyOp::~StorePropertyOp() {} |
| 324 | 324 |
| 325 void StorePropertyOp::Execute() { | 325 void StorePropertyOp::Execute() { |
| 326 if (service_->GetStatus(true) != OwnershipService::OWNERSHIP_TAKEN) { | 326 if (service_->GetStatus(true) != OwnershipService::OWNERSHIP_USER && |
| 327 service_->GetStatus(true) != OwnershipService::OWNERSHIP_ENTERPRISE) { |
| 327 if (g_browser_process && | 328 if (g_browser_process && |
| 328 g_browser_process->local_state() && | 329 g_browser_process->local_state() && |
| 329 SignedSettingsTempStorage::Store(name_, value_, | 330 SignedSettingsTempStorage::Store(name_, value_, |
| 330 g_browser_process->local_state())) { | 331 g_browser_process->local_state())) { |
| 331 d_->OnSettingsOpCompleted(SUCCESS, true); | 332 d_->OnSettingsOpCompleted(SUCCESS, true); |
| 332 return; | 333 return; |
| 333 } | 334 } |
| 334 } | 335 } |
| 335 // Posts a task to the FILE thread to sign |name_|=|value_|. | 336 // Posts a task to the FILE thread to sign |name_|=|value_|. |
| 336 std::string to_sign = base::StringPrintf("%s=%s", | 337 std::string to_sign = base::StringPrintf("%s=%s", |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 380 | 381 |
| 381 RetrievePropertyOp::~RetrievePropertyOp() {} | 382 RetrievePropertyOp::~RetrievePropertyOp() {} |
| 382 | 383 |
| 383 void RetrievePropertyOp::Execute() { | 384 void RetrievePropertyOp::Execute() { |
| 384 CHECK(chromeos::CrosLibrary::Get()->EnsureLoaded()); | 385 CHECK(chromeos::CrosLibrary::Get()->EnsureLoaded()); |
| 385 // TODO(dilmah): Fix the race: | 386 // TODO(dilmah): Fix the race: |
| 386 // At the moment when device becomes owned there is lapse of time after | 387 // At the moment when device becomes owned there is lapse of time after |
| 387 // device has been owned and before temp_storage settings are finally | 388 // device has been owned and before temp_storage settings are finally |
| 388 // persisted into signed settings. | 389 // persisted into signed settings. |
| 389 // In this lapse of time Retrieve loses access to those settings. | 390 // In this lapse of time Retrieve loses access to those settings. |
| 390 if (service_->GetStatus(true) != OwnershipService::OWNERSHIP_TAKEN) { | 391 if (service_->GetStatus(true) != OwnershipService::OWNERSHIP_USER && |
| 392 service_->GetStatus(true) != OwnershipService::OWNERSHIP_ENTERPRISE) { |
| 391 if (g_browser_process && | 393 if (g_browser_process && |
| 392 g_browser_process->local_state() && | 394 g_browser_process->local_state() && |
| 393 SignedSettingsTempStorage::Retrieve( | 395 SignedSettingsTempStorage::Retrieve( |
| 394 name_, &value_, g_browser_process->local_state())) { | 396 name_, &value_, g_browser_process->local_state())) { |
| 395 BrowserThread::PostTask( | 397 BrowserThread::PostTask( |
| 396 BrowserThread::UI, FROM_HERE, | 398 BrowserThread::UI, FROM_HERE, |
| 397 NewRunnableMethod(this, | 399 NewRunnableMethod(this, |
| 398 &RetrievePropertyOp::OnKeyOpComplete, | 400 &RetrievePropertyOp::OnKeyOpComplete, |
| 399 OwnerManager::SUCCESS, std::vector<uint8>())); | 401 OwnerManager::SUCCESS, std::vector<uint8>())); |
| 400 return; | 402 return; |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 551 d_->OnSettingsOpCompleted(BAD_SIGNATURE, em::PolicyFetchResponse()); | 553 d_->OnSettingsOpCompleted(BAD_SIGNATURE, em::PolicyFetchResponse()); |
| 552 return; | 554 return; |
| 553 } | 555 } |
| 554 std::vector<uint8> sig; | 556 std::vector<uint8> sig; |
| 555 const char* sig_ptr = policy_.policy_data_signature().c_str(); | 557 const char* sig_ptr = policy_.policy_data_signature().c_str(); |
| 556 sig.assign(sig_ptr, sig_ptr + policy_.policy_data_signature().length()); | 558 sig.assign(sig_ptr, sig_ptr + policy_.policy_data_signature().length()); |
| 557 service_->StartVerifyAttempt(policy_.policy_data(), sig, this); | 559 service_->StartVerifyAttempt(policy_.policy_data(), sig, this); |
| 558 } | 560 } |
| 559 | 561 |
| 560 } // namespace chromeos | 562 } // namespace chromeos |
| OLD | NEW |