#include "chrome/browser/web_applications/isolated_web_apps/update_manifest/update_manifest.h"
#include <optional>
#include <ostream>
#include <string>
#include <string_view>
#include <vector>
#include "base/containers/contains.h"
#include "base/containers/flat_map.h"
#include "base/containers/map_util.h"
#include "base/containers/to_vector.h"
#include "base/ranges/algorithm.h"
#include "base/strings/string_util.h"
#include "base/types/expected.h"
#include "base/types/expected_macros.h"
#include "base/types/optional_ref.h"
#include "base/types/optional_util.h"
#include "base/values.h"
#include "base/version.h"
#include "chrome/browser/web_applications/isolated_web_apps/isolated_web_app_version.h"
#include "services/network/public/cpp/is_potentially_trustworthy.h"
#include "third_party/abseil-cpp/absl/types/variant.h"
namespace web_app {
namespace {
base::expected<std::vector<UpdateManifest::VersionEntry>,
UpdateManifest::JsonFormatError>
ParseVersions(const base::Value::List& version_entries_value,
const GURL& update_manifest_url) { … }
base::expected<base::flat_map<UpdateChannelId, UpdateManifest::ChannelMetadata>,
UpdateManifest::JsonFormatError>
ParseChannels(const base::Value::Dict& channels_value) { … }
}
const UpdateChannelId& UpdateChannelId::default_id() { … }
base::expected<UpdateChannelId, absl::monostate> UpdateChannelId::Create(
std::string input) { … }
void PrintTo(const UpdateChannelId& id, std::ostream* os) { … }
UpdateChannelId::UpdateChannelId(std::string id) : … { … }
UpdateChannelId::~UpdateChannelId() = default;
bool UpdateChannelId::operator==(const UpdateChannelId& other) const = default;
auto UpdateChannelId::operator<=>(const UpdateChannelId& other) const = default;
bool UpdateChannelId::operator<(const UpdateChannelId& other) const = default;
base::expected<UpdateManifest, UpdateManifest::JsonFormatError>
UpdateManifest::CreateFromJson(const base::Value& json,
const GURL& update_manifest_url) { … }
UpdateManifest::UpdateManifest(
std::vector<VersionEntry> version_entries,
base::flat_map<UpdateChannelId, ChannelMetadata> channels_metadata)
: … { … }
UpdateManifest::UpdateManifest(const UpdateManifest& other) = default;
UpdateManifest& UpdateManifest::operator=(const UpdateManifest& other) =
default;
UpdateManifest::~UpdateManifest() = default;
std::optional<UpdateManifest::VersionEntry> UpdateManifest::GetLatestVersion(
const UpdateChannelId& channel_id) const { … }
UpdateManifest::ChannelMetadata UpdateManifest::GetChannelMetadata(
const UpdateChannelId& channel_id) const { … }
base::expected<UpdateManifest::VersionEntry, absl::monostate>
UpdateManifest::VersionEntry::ParseFromJson(
const base::Value::Dict& version_entry_dict,
const GURL& update_manifest_url) { … }
UpdateManifest::ChannelMetadata::ChannelMetadata(
UpdateChannelId id,
std::optional<std::string> name)
: … { … }
UpdateManifest::ChannelMetadata::ChannelMetadata(const ChannelMetadata& other) =
default;
UpdateManifest::ChannelMetadata& UpdateManifest::ChannelMetadata::operator=(
const ChannelMetadata& other) = default;
UpdateManifest::ChannelMetadata::~ChannelMetadata() = default;
bool UpdateManifest::ChannelMetadata::operator==(
const ChannelMetadata& other) const = default;
void PrintTo(const UpdateManifest::ChannelMetadata& channel_metadata,
std::ostream* os) { … }
UpdateManifest::VersionEntry::VersionEntry(
GURL src,
base::Version version,
base::flat_set<UpdateChannelId> channel_ids)
: … { … }
UpdateManifest::VersionEntry::VersionEntry(const VersionEntry& other) = default;
UpdateManifest::VersionEntry& UpdateManifest::VersionEntry::operator=(
const VersionEntry& other) = default;
UpdateManifest::VersionEntry::~VersionEntry() = default;
GURL UpdateManifest::VersionEntry::src() const { … }
base::Version UpdateManifest::VersionEntry::version() const { … }
const base::flat_set<UpdateChannelId>&
UpdateManifest::VersionEntry::channel_ids() const { … }
base::expected<base::Version, absl::monostate>
UpdateManifest::VersionEntry::ParseAndValidateVersion(
base::optional_ref<const base::Value> version_value) { … }
base::expected<GURL, absl::monostate>
UpdateManifest::VersionEntry::ParseAndValidateSrc(
base::optional_ref<const base::Value> src_value,
const GURL& update_manifest_url) { … }
base::expected<base::flat_set<UpdateChannelId>, absl::monostate>
UpdateManifest::VersionEntry::ParseAndValidateChannels(
base::optional_ref<const base::Value> channels_value) { … }
bool operator==(const UpdateManifest::VersionEntry& lhs,
const UpdateManifest::VersionEntry& rhs) = default;
std::ostream& operator<<(std::ostream& os,
const UpdateManifest::VersionEntry& version_entry) { … }
}