| Index: chrome/browser/chromeos/login/ownership_service.cc
|
| diff --git a/chrome/browser/chromeos/login/ownership_service.cc b/chrome/browser/chromeos/login/ownership_service.cc
|
| index 07bfc1e105a88dec6128a9005b7886ba193420f9..77ce38bf0335dc4d96dfc3fd299028b70d23b4b3 100644
|
| --- a/chrome/browser/chromeos/login/ownership_service.cc
|
| +++ b/chrome/browser/chromeos/login/ownership_service.cc
|
| @@ -1,4 +1,4 @@
|
| -// Copyright (c) 2010 The Chromium Authors. All rights reserved.
|
| +// Copyright (c) 2011 The Chromium Authors. All rights reserved.
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| @@ -9,6 +9,8 @@
|
| #include "base/lazy_instance.h"
|
| #include "base/synchronization/lock.h"
|
| #include "chrome/browser/browser_process.h"
|
| +#include "chrome/browser/chromeos/cros/cros_library.h"
|
| +#include "chrome/browser/chromeos/cros/cryptohome_library.h"
|
| #include "content/browser/browser_thread.h"
|
|
|
| // We want to use NewRunnableMethod for non-static methods of this class but
|
| @@ -72,7 +74,7 @@ OwnershipService::Status OwnershipService::GetStatus(bool blocking) {
|
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
|
| is_owned = IsAlreadyOwned();
|
| }
|
| - status = is_owned ? OWNERSHIP_TAKEN : OWNERSHIP_NONE;
|
| + status = is_owned ? DetermineOwnerType() : OWNERSHIP_NONE;
|
| SetStatus(status);
|
| return status;
|
| }
|
| @@ -119,7 +121,7 @@ void OwnershipService::Observe(NotificationType type,
|
| const NotificationSource& source,
|
| const NotificationDetails& details) {
|
| if (type.value == NotificationType::OWNER_KEY_FETCH_ATTEMPT_SUCCEEDED) {
|
| - SetStatus(OWNERSHIP_TAKEN);
|
| + SetStatus(DetermineOwnerType());
|
| notification_registrar_.RemoveAll();
|
| } else {
|
| NOTREACHED();
|
| @@ -182,15 +184,33 @@ void OwnershipService::FailAttempt(OwnerManager::Delegate* d) {
|
|
|
| void OwnershipService::FetchStatus() {
|
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
|
| - Status status = IsAlreadyOwned() ? OWNERSHIP_TAKEN : OWNERSHIP_NONE;
|
| + Status status = IsAlreadyOwned() ? DetermineOwnerType() : OWNERSHIP_NONE;
|
| SetStatus(status);
|
| }
|
|
|
| void OwnershipService::SetStatus(Status new_status) {
|
| - DCHECK(new_status == OWNERSHIP_TAKEN || new_status == OWNERSHIP_NONE);
|
| + DCHECK(new_status != OWNERSHIP_UNKNOWN);
|
| base::AutoLock lk(ownership_status_lock_);
|
| ownership_status_ = new_status;
|
| }
|
|
|
| +OwnershipService::Status OwnershipService::DetermineOwnerType() {
|
| + // We assume we are user owned if there is no valid information in the lockbox
|
| + // this should be backwards compatible and safe enough in case the data has
|
| + // been tampered with or corrupted.
|
| + OwnershipService::Status owned = OWNERSHIP_USER;
|
| + chromeos::CryptohomeLibrary* cryptohome =
|
| + chromeos::CrosLibrary::Get()->GetCryptohomeLibrary();
|
| + if (cryptohome && cryptohome->InstallAttributesIsReady() &&
|
| + !cryptohome->InstallAttributesIsFirstInstall()) {
|
| + std::string value;
|
| + if (cryptohome->InstallAttributesGet("enterprise.owned", &value)) {
|
| + owned =
|
| + (0 == value.compare("true") ? OWNERSHIP_ENTERPRISE : OWNERSHIP_USER);
|
| + }
|
| + }
|
| + return owned;
|
| +}
|
| +
|
| } // namespace chromeos
|
|
|
|
|