Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5493)

Unified Diff: chrome/browser/chromeos/user_cros_settings_provider.cc

Issue 7655041: Migrate crash reporting settings only if owner. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Review comments incorporated. Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..41437f237a9aa9a75f9d3057fd6dab645bef545e 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,22 @@ 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()) {
+ BrowserThread::PostTask(BrowserThread::UI,
+ FROM_HERE,
+ base::Bind(
+ &SignedSettingsHelper::StartStorePropertyOp,
+ base::Unretained(SignedSettingsHelper::Get()),
+ name,
+ value,
+ callback));
+ }
+}
+
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 +341,14 @@ 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 "
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698