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

Unified Diff: chrome/browser/prefs/tracked/dictionary_hash_store_contents.cc

Issue 324493002: Move preference MACs to the protected preference stores. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove some now unnecessary changes. Created 6 years, 6 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
Index: chrome/browser/prefs/tracked/dictionary_hash_store_contents.cc
diff --git a/chrome/browser/prefs/tracked/dictionary_hash_store_contents.cc b/chrome/browser/prefs/tracked/dictionary_hash_store_contents.cc
new file mode 100644
index 0000000000000000000000000000000000000000..be3101aa5e0bbf04f96b4fd1da777bda9f956e59
--- /dev/null
+++ b/chrome/browser/prefs/tracked/dictionary_hash_store_contents.cc
@@ -0,0 +1,104 @@
+// Copyright (c) 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/prefs/tracked/dictionary_hash_store_contents.h"
+
+#include "base/callback.h"
+#include "base/logging.h"
+#include "base/prefs/persistent_pref_store.h"
+#include "base/values.h"
+#include "chrome/common/pref_names.h"
+#include "components/pref_registry/pref_registry_syncable.h"
+
+namespace {
+
+class SimpleMutableDictionary : public HashStoreContents::MutableDictionary {
+ public:
+ SimpleMutableDictionary(const std::string& key,
+ base::DictionaryValue* storage);
+
+ // MutableDictionary implementation
+ virtual base::DictionaryValue* operator->() OVERRIDE;
+
+ private:
+ const std::string key_;
+ base::DictionaryValue* storage_;
+};
+
+SimpleMutableDictionary::SimpleMutableDictionary(const std::string& key,
gab 2014/06/13 01:57:43 This is only used for the kProfilePreferenceHashes
erikwright (departed) 2014/06/16 20:51:27 The flexibility was a remnant from a previous inca
+ base::DictionaryValue* storage)
+ : key_(key), storage_(storage) {
+}
+
+base::DictionaryValue* SimpleMutableDictionary::operator->() {
+ base::DictionaryValue* mac_dictionary = NULL;
+
+ if (!storage_->GetDictionary(key_, &mac_dictionary)) {
+ mac_dictionary = new base::DictionaryValue;
+ storage_->Set(key_, mac_dictionary);
+ }
+
+ return mac_dictionary;
+}
+
+const base::DictionaryValue* GetMacDictionary(
+ const base::DictionaryValue* storage) {
gab 2014/06/13 01:57:43 Since this method needs access to the only member
erikwright (departed) 2014/06/16 20:51:27 Done.
+ const base::DictionaryValue* mac_dictionary = NULL;
+ storage->GetDictionary(prefs::kProfilePreferenceHashes, &mac_dictionary);
+ return mac_dictionary;
+}
+
+} // namespace
+
+// static
+const char DictionaryHashStoreContents::kSuperMacPref[] = "super_mac";
+
+DictionaryHashStoreContents::DictionaryHashStoreContents(
+ base::DictionaryValue* storage)
+ : storage_(storage) {
+}
+
+// static
+void DictionaryHashStoreContents::RegisterProfilePrefs(
+ user_prefs::PrefRegistrySyncable* registry) {
+ registry->RegisterDictionaryPref(
+ prefs::kProfilePreferenceHashes,
gab 2014/06/13 01:57:43 In fact, how about using a new pref altogether, e.
erikwright (departed) 2014/06/16 20:51:27 Done.
+ user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
+ registry->RegisterStringPref(
+ kSuperMacPref,
+ std::string(),
+ user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
+}
+
+std::string DictionaryHashStoreContents::hash_store_id() const {
+ return "";
+}
+
+void DictionaryHashStoreContents::Reset() {
+ storage_->Remove(prefs::kProfilePreferenceHashes, NULL);
+}
+
+bool DictionaryHashStoreContents::IsInitialized() const {
+ return storage_->GetDictionary(prefs::kProfilePreferenceHashes, NULL);
+}
+
+const base::DictionaryValue* DictionaryHashStoreContents::GetContents() const {
+ return GetMacDictionary(storage_);
+}
+
+scoped_ptr<HashStoreContents::MutableDictionary>
+DictionaryHashStoreContents::GetMutableContents() {
+ return scoped_ptr<MutableDictionary>(
+ new SimpleMutableDictionary(prefs::kProfilePreferenceHashes, storage_));
+}
+
+std::string DictionaryHashStoreContents::GetSuperMac() const {
+ std::string super_mac_string;
+ storage_->GetString(kSuperMacPref, &super_mac_string);
+ return super_mac_string;
+}
+
+void DictionaryHashStoreContents::SetSuperMac(const std::string& super_mac) {
+ storage_->SetString(kSuperMacPref, super_mac);
+}

Powered by Google App Engine
This is Rietveld 408576698