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 @@ ...@@ -8,6 +8,7 @@
#include <utility> #include <utility>
#include "base/callback.h" #include "base/callback.h"
#include "base/optional.h"
#include "base/stl_util.h" #include "base/stl_util.h"
#include "base/strings/strcat.h" #include "base/strings/strcat.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
...@@ -224,6 +225,18 @@ void PolicyMap::Set( ...@@ -224,6 +225,18 @@ void PolicyMap::Set(
Set(policy, std::move(entry)); 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) { void PolicyMap::Set(const std::string& policy, Entry entry) {
map_[policy] = std::move(entry); map_[policy] = std::move(entry);
} }
...@@ -334,7 +347,7 @@ void PolicyMap::LoadFrom(const base::DictionaryValue* policies, ...@@ -334,7 +347,7 @@ void PolicyMap::LoadFrom(const base::DictionaryValue* policies,
PolicySource source) { PolicySource source) {
for (base::DictionaryValue::Iterator it(*policies); !it.IsAtEnd(); for (base::DictionaryValue::Iterator it(*policies); !it.IsAtEnd();
it.Advance()) { 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 { ...@@ -143,12 +143,22 @@ class POLICY_EXPORT PolicyMap {
// Overwrites any existing information stored in the map for the key |policy|. // Overwrites any existing information stored in the map for the key |policy|.
// Resets the error for that policy to the empty string. // 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, void Set(const std::string& policy,
PolicyLevel level, PolicyLevel level,
PolicyScope scope, PolicyScope scope,
PolicySource source, PolicySource source,
std::unique_ptr<base::Value> value, std::unique_ptr<base::Value> value,
std::unique_ptr<ExternalDataFetcher> external_data_fetcher); 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); 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