| 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/user_cros_settings_provider.h" | 5 #include "chrome/browser/chromeos/user_cros_settings_provider.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "base/hash_tables.h" | 10 #include "base/hash_tables.h" |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 | 172 |
| 173 // Working horse for UserCrosSettingsProvider::RequestTrusted* family. | 173 // Working horse for UserCrosSettingsProvider::RequestTrusted* family. |
| 174 bool RequestTrustedEntity(const std::string& name) { | 174 bool RequestTrustedEntity(const std::string& name) { |
| 175 OwnershipService::Status ownership_status = | 175 OwnershipService::Status ownership_status = |
| 176 ownership_service_->GetStatus(false); | 176 ownership_service_->GetStatus(false); |
| 177 if (ownership_status == OwnershipService::OWNERSHIP_NONE) | 177 if (ownership_status == OwnershipService::OWNERSHIP_NONE) |
| 178 return true; | 178 return true; |
| 179 PrefService* prefs = g_browser_process->local_state(); | 179 PrefService* prefs = g_browser_process->local_state(); |
| 180 if (prefs->IsManagedPreference(name.c_str())) | 180 if (prefs->IsManagedPreference(name.c_str())) |
| 181 return true; | 181 return true; |
| 182 if (ownership_status == OwnershipService::OWNERSHIP_TAKEN) { | 182 if (ownership_status == OwnershipService::OWNERSHIP_USER || |
| 183 ownership_status == OwnershipService::OWNERSHIP_ENTERPRISE) { |
| 183 DCHECK(g_browser_process); | 184 DCHECK(g_browser_process); |
| 184 PrefService* prefs = g_browser_process->local_state(); | 185 PrefService* prefs = g_browser_process->local_state(); |
| 185 DCHECK(prefs); | 186 DCHECK(prefs); |
| 186 if (prefs->GetBoolean((name + kTrustedSuffix).c_str())) | 187 if (prefs->GetBoolean((name + kTrustedSuffix).c_str())) |
| 187 return true; | 188 return true; |
| 188 } | 189 } |
| 189 return false; | 190 return false; |
| 190 } | 191 } |
| 191 | 192 |
| 192 bool RequestTrustedEntity(const std::string& name, Task* callback) { | 193 bool RequestTrustedEntity(const std::string& name, Task* callback) { |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 | 270 |
| 270 // Implementation of SignedSettingsHelper::Callback. | 271 // Implementation of SignedSettingsHelper::Callback. |
| 271 virtual void OnRetrievePropertyCompleted(SignedSettings::ReturnCode code, | 272 virtual void OnRetrievePropertyCompleted(SignedSettings::ReturnCode code, |
| 272 const std::string& name, | 273 const std::string& name, |
| 273 const std::string& value) { | 274 const std::string& value) { |
| 274 if (!IsControlledBooleanSetting(name) && !IsControlledStringSetting(name)) { | 275 if (!IsControlledBooleanSetting(name) && !IsControlledStringSetting(name)) { |
| 275 NOTREACHED(); | 276 NOTREACHED(); |
| 276 return; | 277 return; |
| 277 } | 278 } |
| 278 | 279 |
| 279 bool is_owned = ownership_service_->GetStatus(true) == | 280 OwnershipService::Status ownership = ownership_service_->GetStatus(true); |
| 280 OwnershipService::OWNERSHIP_TAKEN; | 281 bool is_owned = (ownership == OwnershipService::OWNERSHIP_USER || |
| 282 ownership == OwnershipService::OWNERSHIP_ENTERPRISE); |
| 281 PrefService* prefs = g_browser_process->local_state(); | 283 PrefService* prefs = g_browser_process->local_state(); |
| 282 switch (code) { | 284 switch (code) { |
| 283 case SignedSettings::SUCCESS: | 285 case SignedSettings::SUCCESS: |
| 284 case SignedSettings::NOT_FOUND: | 286 case SignedSettings::NOT_FOUND: |
| 285 case SignedSettings::KEY_UNAVAILABLE: { | 287 case SignedSettings::KEY_UNAVAILABLE: { |
| 286 bool fallback_to_default = !is_owned | 288 bool fallback_to_default = !is_owned |
| 287 || (code == SignedSettings::NOT_FOUND); | 289 || (code == SignedSettings::NOT_FOUND); |
| 288 DCHECK(fallback_to_default || code == SignedSettings::SUCCESS); | 290 DCHECK(fallback_to_default || code == SignedSettings::SUCCESS); |
| 289 if (fallback_to_default) | 291 if (fallback_to_default) |
| 290 VLOG(1) << "Going default for cros setting " << name; | 292 VLOG(1) << "Going default for cros setting " << name; |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 552 if (cached_whitelist_update->Remove(email_value) != -1) | 554 if (cached_whitelist_update->Remove(email_value) != -1) |
| 553 prefs->ScheduleSavePersistentPrefs(); | 555 prefs->ScheduleSavePersistentPrefs(); |
| 554 } | 556 } |
| 555 | 557 |
| 556 // static | 558 // static |
| 557 void UserCrosSettingsProvider::UpdateCachedOwner(const std::string& email) { | 559 void UserCrosSettingsProvider::UpdateCachedOwner(const std::string& email) { |
| 558 UpdateCacheString(kDeviceOwner, email, USE_VALUE_SUPPLIED); | 560 UpdateCacheString(kDeviceOwner, email, USE_VALUE_SUPPLIED); |
| 559 } | 561 } |
| 560 | 562 |
| 561 } // namespace chromeos | 563 } // namespace chromeos |
| OLD | NEW |