Commit 87d12ea8 authored by Aya ElAttar's avatar Aya ElAttar Committed by Commit Bot

Override PolicyMap::Set to use base::Value instead

Added another PolicyMap::Set to override the old one
to switch from passing value as unique_ptr to base::Value.

Bug: 1092469
Change-Id: I3b87af2302ce7009e73d910d59bef1c9d4931fc3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2235792
Commit-Queue: Aya Elsayed <ayaelattar@google.com>
Auto-Submit: Aya Elsayed <ayaelattar@google.com>
Reviewed-by: default avatarMaksim Ivanov <emaxx@chromium.org>
Cr-Commit-Position: refs/heads/master@{#776104}
parent 907d0bd1
......@@ -8,6 +8,7 @@
#include <utility>
#include "base/callback.h"
#include "base/optional.h"
#include "base/stl_util.h"
#include "base/strings/strcat.h"
#include "base/strings/utf_string_conversions.h"
......@@ -224,6 +225,18 @@ void PolicyMap::Set(
Set(policy, std::move(entry));
}
void PolicyMap::Set(
const std::string& policy,
PolicyLevel level,
PolicyScope scope,
PolicySource source,
base::Optional<base::Value> value,
std::unique_ptr<ExternalDataFetcher> external_data_fetcher) {
Entry entry(level, scope, source, std::move(value),
std::move(external_data_fetcher));
Set(policy, std::move(entry));
}
void PolicyMap::Set(const std::string& policy, Entry entry) {
map_[policy] = std::move(entry);
}
......@@ -334,7 +347,7 @@ void PolicyMap::LoadFrom(const base::DictionaryValue* policies,
PolicySource source) {
for (base::DictionaryValue::Iterator it(*policies); !it.IsAtEnd();
it.Advance()) {
Set(it.key(), level, scope, source, it.value().CreateDeepCopy(), nullptr);
Set(it.key(), level, scope, source, it.value().Clone(), nullptr);
}
}
......
......@@ -143,12 +143,22 @@ class POLICY_EXPORT PolicyMap {
// Overwrites any existing information stored in the map for the key |policy|.
// Resets the error for that policy to the empty string.
// DEPRECATED: Use the other version that takes base::Optional<base::Value>
// below.
// TODO(crbug.com/1092469): Migrate the existing usages and delete this
// method.
void Set(const std::string& policy,
PolicyLevel level,
PolicyScope scope,
PolicySource source,
std::unique_ptr<base::Value> value,
std::unique_ptr<ExternalDataFetcher> external_data_fetcher);
void Set(const std::string& policy,
PolicyLevel level,
PolicyScope scope,
PolicySource source,
base::Optional<base::Value> value,
std::unique_ptr<ExternalDataFetcher> external_data_fetcher);
void Set(const std::string& policy, Entry entry);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment