summaryrefslogtreecommitdiff
path: root/chromium/components/user_prefs/tracked/dictionary_hash_store_contents.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/components/user_prefs/tracked/dictionary_hash_store_contents.cc')
-rw-r--r--chromium/components/user_prefs/tracked/dictionary_hash_store_contents.cc134
1 files changed, 0 insertions, 134 deletions
diff --git a/chromium/components/user_prefs/tracked/dictionary_hash_store_contents.cc b/chromium/components/user_prefs/tracked/dictionary_hash_store_contents.cc
deleted file mode 100644
index 288c1bf45db..00000000000
--- a/chromium/components/user_prefs/tracked/dictionary_hash_store_contents.cc
+++ /dev/null
@@ -1,134 +0,0 @@
-// 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 "components/user_prefs/tracked/dictionary_hash_store_contents.h"
-
-#include "base/callback.h"
-#include "base/logging.h"
-#include "base/macros.h"
-#include "base/values.h"
-#include "components/pref_registry/pref_registry_syncable.h"
-#include "components/prefs/persistent_pref_store.h"
-
-namespace {
-const char kPreferenceMACs[] = "protection.macs";
-const char kSuperMACPref[] = "protection.super_mac";
-}
-
-DictionaryHashStoreContents::DictionaryHashStoreContents(
- base::DictionaryValue* storage)
- : storage_(storage) {
-}
-
-// static
-void DictionaryHashStoreContents::RegisterProfilePrefs(
- user_prefs::PrefRegistrySyncable* registry) {
- registry->RegisterDictionaryPref(kPreferenceMACs);
- registry->RegisterStringPref(kSuperMACPref, std::string());
-}
-
-bool DictionaryHashStoreContents::IsCopyable() const {
- return false;
-}
-
-std::unique_ptr<HashStoreContents> DictionaryHashStoreContents::MakeCopy()
- const {
- NOTREACHED() << "DictionaryHashStoreContents does not support MakeCopy";
- return nullptr;
-}
-
-base::StringPiece DictionaryHashStoreContents::GetUMASuffix() const {
- // To stay consistent with existing reported data, do not append a suffix
- // when reporting UMA stats for this content.
- return base::StringPiece();
-}
-
-void DictionaryHashStoreContents::Reset() {
- storage_->Remove(kPreferenceMACs, NULL);
-}
-
-bool DictionaryHashStoreContents::GetMac(const std::string& path,
- std::string* out_value) {
- const base::DictionaryValue* macs_dict = GetContents();
- if (macs_dict)
- return macs_dict->GetString(path, out_value);
-
- return false;
-}
-
-bool DictionaryHashStoreContents::GetSplitMacs(
- const std::string& path,
- std::map<std::string, std::string>* split_macs) {
- DCHECK(split_macs);
- DCHECK(split_macs->empty());
-
- const base::DictionaryValue* macs_dict = GetContents();
- const base::DictionaryValue* split_macs_dict = NULL;
- if (!macs_dict || !macs_dict->GetDictionary(path, &split_macs_dict))
- return false;
- for (base::DictionaryValue::Iterator it(*split_macs_dict); !it.IsAtEnd();
- it.Advance()) {
- std::string mac_string;
- if (!it.value().GetAsString(&mac_string)) {
- NOTREACHED();
- continue;
- }
- split_macs->insert(make_pair(it.key(), mac_string));
- }
- return true;
-}
-
-void DictionaryHashStoreContents::SetMac(const std::string& path,
- const std::string& value) {
- base::DictionaryValue* macs_dict = GetMutableContents(true);
- macs_dict->SetString(path, value);
-}
-
-void DictionaryHashStoreContents::SetSplitMac(const std::string& path,
- const std::string& split_path,
- const std::string& value) {
- // DictionaryValue handles a '.' delimiter.
- SetMac(path + '.' + split_path, value);
-}
-
-void DictionaryHashStoreContents::ImportEntry(const std::string& path,
- const base::Value* in_value) {
- base::DictionaryValue* macs_dict = GetMutableContents(true);
- macs_dict->Set(path, in_value->DeepCopy());
-}
-
-bool DictionaryHashStoreContents::RemoveEntry(const std::string& path) {
- base::DictionaryValue* macs_dict = GetMutableContents(false);
- if (macs_dict)
- return macs_dict->RemovePath(path, NULL);
-
- return false;
-}
-
-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);
-}
-
-const base::DictionaryValue* DictionaryHashStoreContents::GetContents() const {
- const base::DictionaryValue* macs_dict = NULL;
- storage_->GetDictionary(kPreferenceMACs, &macs_dict);
- return macs_dict;
-}
-
-base::DictionaryValue* DictionaryHashStoreContents::GetMutableContents(
- bool create_if_null) {
- base::DictionaryValue* macs_dict = NULL;
- storage_->GetDictionary(kPreferenceMACs, &macs_dict);
- if (!macs_dict && create_if_null) {
- macs_dict = new base::DictionaryValue;
- storage_->Set(kPreferenceMACs, macs_dict);
- }
- return macs_dict;
-}