Chromium Code Reviews| Index: chrome/browser/chromeos/user_cros_settings_provider.cc |
| diff --git a/chrome/browser/chromeos/user_cros_settings_provider.cc b/chrome/browser/chromeos/user_cros_settings_provider.cc |
| index 825f1da4ea26c3f851f59b6ea16c243877495838..435538b0ab65c85100982a6927aa4abe547f6f9a 100644 |
| --- a/chrome/browser/chromeos/user_cros_settings_provider.cc |
| +++ b/chrome/browser/chromeos/user_cros_settings_provider.cc |
| @@ -7,6 +7,8 @@ |
| #include <map> |
| #include <set> |
| +#include "base/bind.h" |
| +#include "base/callback.h" |
| #include "base/hash_tables.h" |
| #include "base/logging.h" |
| #include "base/memory/singleton.h" |
| @@ -56,6 +58,14 @@ const char* kListSettings[] = { |
| kAccountsPrefUsers |
| }; |
| +// Only write the property if the owner is the current logged on user. |
| +void StartStorePropertyOpIfOwner(const std::string& name, |
| + const std::string& value, |
| + SignedSettingsHelper::Callback* callback) { |
| + if (OwnershipService::GetSharedInstance()->CurrentUserIsOwner()) |
| + 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.
|
| +} |
| + |
| bool IsControlledBooleanSetting(const std::string& pref_path) { |
| // TODO(nkostylev): Using std::find for 4 value array generates this warning |
| // in chroot stl_algo.h:231: error: array subscript is above array bounds. |
| @@ -323,9 +333,13 @@ class UserCrosSettingsTrust : public SignedSettingsHelper::Callback { |
| // Temporarily allow it until we fix http://crbug.com/62626 |
| base::ThreadRestrictions::ScopedAllowIO allow_io; |
| stats_consent = GoogleUpdateSettings::GetCollectStatsConsent(); |
| - // Store this value if possible. |
| - SignedSettingsHelper::Get()->StartStorePropertyOp( |
| - path, stats_consent ? "true" : "false", this); |
| + // Only store settings if the owner is logged on, otherwise the write |
| + // will fail, triggering another read and we'll end up in an infinite |
| + // loop. Owner check needs to be done on the FILE thread. |
| + BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, |
| + base::Bind(&StartStorePropertyOpIfOwner, path, |
| + stats_consent ? "true" : "false", |
| + this)); |
| UpdateCacheBool(path, stats_consent, USE_VALUE_SUPPLIED); |
| LOG(WARNING) << "No metrics policy set will revert to checking " |
| << "consent file which is " |