#include "chrome/browser/device_api/managed_configuration_api.h"
#include <memory>
#include <optional>
#include "base/containers/contains.h"
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/json/json_string_value_serializer.h"
#include "base/task/thread_pool.h"
#include "base/values.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/device_api/managed_configuration_store.h"
#include "chrome/browser/net/system_network_context_manager.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/pref_names.h"
#include "components/pref_registry/pref_registry_syncable.h"
#include "components/prefs/pref_service.h"
#include "components/prefs/scoped_user_pref_update.h"
#include "content/public/browser/browser_thread.h"
#include "services/network/public/cpp/resource_request.h"
#include "services/network/public/cpp/simple_url_loader.h"
#include "url/origin.h"
namespace {
constexpr char kManagedConfigurationDirectoryName[] = …;
constexpr int kMaxConfigurationFileSize = …;
constexpr net::NetworkTrafficAnnotationTag kTrafficAnnotation = …;
std::string GetOriginEncoded(const url::Origin& origin) { … }
}
const char ManagedConfigurationAPI::kOriginKey[] = …;
const char ManagedConfigurationAPI::kManagedConfigurationUrlKey[] = …;
const char ManagedConfigurationAPI::kManagedConfigurationHashKey[] = …;
class ManagedConfigurationAPI::ManagedConfigurationDownloader { … };
ManagedConfigurationAPI::ManagedConfigurationAPI(Profile* profile)
: … { … }
ManagedConfigurationAPI::~ManagedConfigurationAPI() = default;
void ManagedConfigurationAPI::RegisterProfilePrefs(
user_prefs::PrefRegistrySyncable* registry) { … }
void ManagedConfigurationAPI::GetOriginPolicyConfiguration(
const url::Origin& origin,
const std::vector<std::string>& keys,
base::OnceCallback<void(std::optional<base::Value::Dict>)> callback) { … }
void ManagedConfigurationAPI::AddObserver(Observer* observer) { … }
void ManagedConfigurationAPI::RemoveObserver(Observer* observer) { … }
bool ManagedConfigurationAPI::CanHaveManagedStore(const url::Origin& origin) { … }
const std::set<url::Origin>& ManagedConfigurationAPI::GetManagedOrigins()
const { … }
void ManagedConfigurationAPI::OnConfigurationPolicyChanged() { … }
void ManagedConfigurationAPI::MaybeCreateStoreForOrigin(
const url::Origin& origin) { … }
base::FilePath ManagedConfigurationAPI::GetStoreLocation(
const url::Origin& origin) { … }
void ManagedConfigurationAPI::UpdateStoredDataForOrigin(
const url::Origin& origin,
const std::string& configuration_url,
const std::string& configuration_hash) { … }
void ManagedConfigurationAPI::DecodeData(const url::Origin& origin,
const std::string& url_hash,
std::unique_ptr<std::string> data) { … }
void ManagedConfigurationAPI::ProcessDecodedConfiguration(
const url::Origin& origin,
const std::string& url_hash,
const data_decoder::DataDecoder::ValueOrError decoding_result) { … }
void ManagedConfigurationAPI::PostStoreConfiguration(
const url::Origin& origin,
base::Value::Dict configuration) { … }
void ManagedConfigurationAPI::InformObserversIfConfigurationChanged(
const url::Origin& origin,
bool has_changed) { … }
void ManagedConfigurationAPI::PromoteObservers() { … }