| 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/bind.h" | 10 #include "base/bind.h" |
| (...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 | 340 |
| 341 UserCrosSettingsTrust() | 341 UserCrosSettingsTrust() |
| 342 : ownership_service_(OwnershipService::GetSharedInstance()), | 342 : ownership_service_(OwnershipService::GetSharedInstance()), |
| 343 retries_left_(kNumRetriesLimit) { | 343 retries_left_(kNumRetriesLimit) { |
| 344 migration_helper_.set_callback(this); | 344 migration_helper_.set_callback(this); |
| 345 // Start prefetching Boolean and String preferences. | 345 // Start prefetching Boolean and String preferences. |
| 346 Reload(); | 346 Reload(); |
| 347 } | 347 } |
| 348 | 348 |
| 349 virtual ~UserCrosSettingsTrust() { | 349 virtual ~UserCrosSettingsTrust() { |
| 350 if (BrowserThread::CurrentlyOn(BrowserThread::UI) && | 350 if (BrowserThread::CurrentlyOn(BrowserThread::UI)) { |
| 351 CrosLibrary::Get()->EnsureLoaded()) { | |
| 352 // Cancels all pending callbacks from us. | 351 // Cancels all pending callbacks from us. |
| 353 SignedSettingsHelper::Get()->CancelCallback(this); | 352 SignedSettingsHelper::Get()->CancelCallback(this); |
| 354 } | 353 } |
| 355 } | 354 } |
| 356 | 355 |
| 357 // Called right before boolean property is changed. | 356 // Called right before boolean property is changed. |
| 358 void OnBooleanPropertyChange(const std::string& path, bool new_value) { | 357 void OnBooleanPropertyChange(const std::string& path, bool new_value) { |
| 359 if (path == kSignedDataRoamingEnabled) { | 358 if (path == kSignedDataRoamingEnabled) { |
| 360 if (!CrosLibrary::Get()->EnsureLoaded()) | |
| 361 return; | |
| 362 | |
| 363 NetworkLibrary* cros = CrosLibrary::Get()->GetNetworkLibrary(); | 359 NetworkLibrary* cros = CrosLibrary::Get()->GetNetworkLibrary(); |
| 364 if (cros->IsCellularAlwaysInRoaming()) { | 360 if (cros->IsCellularAlwaysInRoaming()) { |
| 365 // If operator requires roaming always enabled, ignore supplied value | 361 // If operator requires roaming always enabled, ignore supplied value |
| 366 // and set data roaming allowed in true always. | 362 // and set data roaming allowed in true always. |
| 367 new_value = true; | 363 new_value = true; |
| 368 } | 364 } |
| 369 cros->SetCellularDataRoamingAllowed(new_value); | 365 cros->SetCellularDataRoamingAllowed(new_value); |
| 370 } else if (path == kStatsReportingPref) { | 366 } else if (path == kStatsReportingPref) { |
| 371 // TODO(pastarmovj): Remove this once we don't need to regenerate the | 367 // TODO(pastarmovj): Remove this once we don't need to regenerate the |
| 372 // consent file for the GUID anymore. | 368 // consent file for the GUID anymore. |
| 373 OptionsUtil::ResolveMetricsReportingEnabled(new_value); | 369 OptionsUtil::ResolveMetricsReportingEnabled(new_value); |
| 374 } | 370 } |
| 375 } | 371 } |
| 376 | 372 |
| 377 // Called right after signed value was checked. | 373 // Called right after signed value was checked. |
| 378 void OnBooleanPropertyRetrieve(const std::string& path, | 374 void OnBooleanPropertyRetrieve(const std::string& path, |
| 379 bool value, | 375 bool value, |
| 380 UseValue use_value) { | 376 UseValue use_value) { |
| 381 if (path == kSignedDataRoamingEnabled) { | 377 if (path == kSignedDataRoamingEnabled) { |
| 382 if (!CrosLibrary::Get()->EnsureLoaded()) | |
| 383 return; | |
| 384 | |
| 385 NetworkLibrary* cros = CrosLibrary::Get()->GetNetworkLibrary(); | 378 NetworkLibrary* cros = CrosLibrary::Get()->GetNetworkLibrary(); |
| 386 const NetworkDevice* cellular = cros->FindCellularDevice(); | 379 const NetworkDevice* cellular = cros->FindCellularDevice(); |
| 387 if (cellular) { | 380 if (cellular) { |
| 388 bool device_value = cellular->data_roaming_allowed(); | 381 bool device_value = cellular->data_roaming_allowed(); |
| 389 if (!device_value && cros->IsCellularAlwaysInRoaming()) { | 382 if (!device_value && cros->IsCellularAlwaysInRoaming()) { |
| 390 // If operator requires roaming always enabled, ignore supplied value | 383 // If operator requires roaming always enabled, ignore supplied value |
| 391 // and set data roaming allowed in true always. | 384 // and set data roaming allowed in true always. |
| 392 cros->SetCellularDataRoamingAllowed(true); | 385 cros->SetCellularDataRoamingAllowed(true); |
| 393 } else { | 386 } else { |
| 394 bool new_value = (use_value == USE_VALUE_SUPPLIED) ? value : false; | 387 bool new_value = (use_value == USE_VALUE_SUPPLIED) ? value : false; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 423 } | 416 } |
| 424 | 417 |
| 425 void StartFetchingSetting(const std::string& name) { | 418 void StartFetchingSetting(const std::string& name) { |
| 426 DCHECK(g_browser_process); | 419 DCHECK(g_browser_process); |
| 427 PrefService* prefs = g_browser_process->local_state(); | 420 PrefService* prefs = g_browser_process->local_state(); |
| 428 if (!prefs) | 421 if (!prefs) |
| 429 return; | 422 return; |
| 430 // Do not trust before fetching complete. | 423 // Do not trust before fetching complete. |
| 431 prefs->ClearPref((name + kTrustedSuffix).c_str()); | 424 prefs->ClearPref((name + kTrustedSuffix).c_str()); |
| 432 prefs->ScheduleSavePersistentPrefs(); | 425 prefs->ScheduleSavePersistentPrefs(); |
| 433 if (CrosLibrary::Get()->EnsureLoaded()) { | 426 SignedSettingsHelper::Get()->StartRetrieveProperty(name, this); |
| 434 SignedSettingsHelper::Get()->StartRetrieveProperty(name, this); | |
| 435 } | |
| 436 } | 427 } |
| 437 | 428 |
| 438 // Implementation of SignedSettingsHelper::Callback. | 429 // Implementation of SignedSettingsHelper::Callback. |
| 439 virtual void OnRetrievePropertyCompleted(SignedSettings::ReturnCode code, | 430 virtual void OnRetrievePropertyCompleted(SignedSettings::ReturnCode code, |
| 440 const std::string& name, | 431 const std::string& name, |
| 441 const std::string& value) { | 432 const std::string& value) { |
| 442 if (!IsControlledBooleanSetting(name) && !IsControlledStringSetting(name)) { | 433 if (!IsControlledBooleanSetting(name) && !IsControlledStringSetting(name)) { |
| 443 NOTREACHED(); | 434 NOTREACHED(); |
| 444 return; | 435 return; |
| 445 } | 436 } |
| (...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 749 if (cached_whitelist_update->Remove(email_value, NULL)) | 740 if (cached_whitelist_update->Remove(email_value, NULL)) |
| 750 prefs->ScheduleSavePersistentPrefs(); | 741 prefs->ScheduleSavePersistentPrefs(); |
| 751 } | 742 } |
| 752 | 743 |
| 753 // static | 744 // static |
| 754 void UserCrosSettingsProvider::UpdateCachedOwner(const std::string& email) { | 745 void UserCrosSettingsProvider::UpdateCachedOwner(const std::string& email) { |
| 755 UpdateCacheString(kDeviceOwner, email, USE_VALUE_SUPPLIED); | 746 UpdateCacheString(kDeviceOwner, email, USE_VALUE_SUPPLIED); |
| 756 } | 747 } |
| 757 | 748 |
| 758 } // namespace chromeos | 749 } // namespace chromeos |
| OLD | NEW |