Chromium Code Reviews| 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" | |
| 11 #include "base/callback.h" | |
| 10 #include "base/hash_tables.h" | 12 #include "base/hash_tables.h" |
| 11 #include "base/logging.h" | 13 #include "base/logging.h" |
| 12 #include "base/memory/singleton.h" | 14 #include "base/memory/singleton.h" |
| 13 #include "base/string_util.h" | 15 #include "base/string_util.h" |
| 14 #include "base/task.h" | 16 #include "base/task.h" |
| 15 #include "base/values.h" | 17 #include "base/values.h" |
| 16 #include "chrome/browser/browser_process.h" | 18 #include "chrome/browser/browser_process.h" |
| 17 #include "chrome/browser/chromeos/cros/cros_library.h" | 19 #include "chrome/browser/chromeos/cros/cros_library.h" |
| 18 #include "chrome/browser/chromeos/cros/login_library.h" | 20 #include "chrome/browser/chromeos/cros/login_library.h" |
| 19 #include "chrome/browser/chromeos/cros/network_library.h" | 21 #include "chrome/browser/chromeos/cros/network_library.h" |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 49 | 51 |
| 50 const char* kStringSettings[] = { | 52 const char* kStringSettings[] = { |
| 51 kDeviceOwner, | 53 kDeviceOwner, |
| 52 kReleaseChannel | 54 kReleaseChannel |
| 53 }; | 55 }; |
| 54 | 56 |
| 55 const char* kListSettings[] = { | 57 const char* kListSettings[] = { |
| 56 kAccountsPrefUsers | 58 kAccountsPrefUsers |
| 57 }; | 59 }; |
| 58 | 60 |
| 61 // Only write the property if the owner is the current logged on user. | |
| 62 void StartStorePropertyOpIfOwner(const std::string& name, | |
| 63 const std::string& value, | |
| 64 SignedSettingsHelper::Callback* callback) { | |
| 65 if (OwnershipService::GetSharedInstance()->CurrentUserIsOwner()) | |
| 66 SignedSettingsHelper::Get()->StartStorePropertyOp(name, value, callback); | |
|
Mattias Nissler (ping if slow)
2011/08/18 13:43:26
I don't think it's safe to call this from the file
rkc
2011/08/19 13:24:02
Calling on the UI thread now.
Done.
| |
| 67 } | |
| 68 | |
| 59 bool IsControlledBooleanSetting(const std::string& pref_path) { | 69 bool IsControlledBooleanSetting(const std::string& pref_path) { |
| 60 // TODO(nkostylev): Using std::find for 4 value array generates this warning | 70 // TODO(nkostylev): Using std::find for 4 value array generates this warning |
| 61 // in chroot stl_algo.h:231: error: array subscript is above array bounds. | 71 // in chroot stl_algo.h:231: error: array subscript is above array bounds. |
| 62 // GCC 4.4.3 | 72 // GCC 4.4.3 |
| 63 return (pref_path == kAccountsPrefAllowNewUser) || | 73 return (pref_path == kAccountsPrefAllowNewUser) || |
| 64 (pref_path == kAccountsPrefAllowGuest) || | 74 (pref_path == kAccountsPrefAllowGuest) || |
| 65 (pref_path == kAccountsPrefShowUserNamesOnSignIn) || | 75 (pref_path == kAccountsPrefShowUserNamesOnSignIn) || |
| 66 (pref_path == kSignedDataRoamingEnabled) || | 76 (pref_path == kSignedDataRoamingEnabled) || |
| 67 (pref_path == kStatsReportingPref); | 77 (pref_path == kStatsReportingPref); |
| 68 } | 78 } |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 316 } | 326 } |
| 317 } else if (path == kStatsReportingPref) { | 327 } else if (path == kStatsReportingPref) { |
| 318 bool stats_consent = (use_value == USE_VALUE_SUPPLIED) ? value : false; | 328 bool stats_consent = (use_value == USE_VALUE_SUPPLIED) ? value : false; |
| 319 // TODO(pastarmovj): Remove this once migration is not needed anymore. | 329 // TODO(pastarmovj): Remove this once migration is not needed anymore. |
| 320 // If the value is not set we should try to migrate legacy consent file. | 330 // If the value is not set we should try to migrate legacy consent file. |
| 321 if (use_value == USE_VALUE_DEFAULT) { | 331 if (use_value == USE_VALUE_DEFAULT) { |
| 322 // Loading consent file state causes us to do blocking IO on UI thread. | 332 // Loading consent file state causes us to do blocking IO on UI thread. |
| 323 // Temporarily allow it until we fix http://crbug.com/62626 | 333 // Temporarily allow it until we fix http://crbug.com/62626 |
| 324 base::ThreadRestrictions::ScopedAllowIO allow_io; | 334 base::ThreadRestrictions::ScopedAllowIO allow_io; |
| 325 stats_consent = GoogleUpdateSettings::GetCollectStatsConsent(); | 335 stats_consent = GoogleUpdateSettings::GetCollectStatsConsent(); |
| 326 // Store this value if possible. | 336 // Only store settings if the owner is logged on, otherwise the write |
| 327 SignedSettingsHelper::Get()->StartStorePropertyOp( | 337 // will fail, triggering another read and we'll end up in an infinite |
| 328 path, stats_consent ? "true" : "false", this); | 338 // loop. Owner check needs to be done on the FILE thread. |
| 339 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, | |
| 340 base::Bind(&StartStorePropertyOpIfOwner, path, | |
| 341 stats_consent ? "true" : "false", | |
| 342 this)); | |
| 329 UpdateCacheBool(path, stats_consent, USE_VALUE_SUPPLIED); | 343 UpdateCacheBool(path, stats_consent, USE_VALUE_SUPPLIED); |
| 330 LOG(WARNING) << "No metrics policy set will revert to checking " | 344 LOG(WARNING) << "No metrics policy set will revert to checking " |
| 331 << "consent file which is " | 345 << "consent file which is " |
| 332 << (stats_consent ? "on." : "off."); | 346 << (stats_consent ? "on." : "off."); |
| 333 } | 347 } |
| 334 // TODO(pastarmovj): Remove this once we don't need to regenerate the | 348 // TODO(pastarmovj): Remove this once we don't need to regenerate the |
| 335 // consent file for the GUID anymore. | 349 // consent file for the GUID anymore. |
| 336 VLOG(1) << "Metrics policy is being set to : " << stats_consent | 350 VLOG(1) << "Metrics policy is being set to : " << stats_consent |
| 337 << "(reason : " << use_value << ")"; | 351 << "(reason : " << use_value << ")"; |
| 338 OptionsUtil::ResolveMetricsReportingEnabled(stats_consent); | 352 OptionsUtil::ResolveMetricsReportingEnabled(stats_consent); |
| (...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 664 if (cached_whitelist_update->Remove(email_value, NULL)) | 678 if (cached_whitelist_update->Remove(email_value, NULL)) |
| 665 prefs->ScheduleSavePersistentPrefs(); | 679 prefs->ScheduleSavePersistentPrefs(); |
| 666 } | 680 } |
| 667 | 681 |
| 668 // static | 682 // static |
| 669 void UserCrosSettingsProvider::UpdateCachedOwner(const std::string& email) { | 683 void UserCrosSettingsProvider::UpdateCachedOwner(const std::string& email) { |
| 670 UpdateCacheString(kDeviceOwner, email, USE_VALUE_SUPPLIED); | 684 UpdateCacheString(kDeviceOwner, email, USE_VALUE_SUPPLIED); |
| 671 } | 685 } |
| 672 | 686 |
| 673 } // namespace chromeos | 687 } // namespace chromeos |
| OLD | NEW |