1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168
|
// Copyright 2014 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "third_party/blink/public/common/manifest/manifest.h"
#include "third_party/blink/public/mojom/manifest/manifest.mojom-shared.h"
#include "third_party/blink/public/mojom/manifest/manifest_launch_handler.mojom-shared.h"
namespace blink {
Manifest::ImageResource::ImageResource() = default;
Manifest::ImageResource::ImageResource(const ImageResource& other) = default;
Manifest::ImageResource::~ImageResource() = default;
bool Manifest::ImageResource::operator==(
const Manifest::ImageResource& other) const {
auto AsTuple = [](const auto& item) {
return std::tie(item.src, item.type, item.sizes);
};
return AsTuple(*this) == AsTuple(other);
}
Manifest::ShortcutItem::ShortcutItem() = default;
Manifest::ShortcutItem::~ShortcutItem() = default;
bool Manifest::ShortcutItem::operator==(const ShortcutItem& other) const {
auto AsTuple = [](const auto& item) {
return std::tie(item.name, item.short_name, item.description, item.url,
item.icons);
};
return AsTuple(*this) == AsTuple(other);
}
bool Manifest::FileFilter::operator==(const FileFilter& other) const {
auto AsTuple = [](const auto& item) {
return std::tie(item.name, item.accept);
};
return AsTuple(*this) == AsTuple(other);
}
Manifest::ShareTargetParams::ShareTargetParams() = default;
Manifest::ShareTargetParams::~ShareTargetParams() = default;
bool Manifest::ShareTargetParams::operator==(
const ShareTargetParams& other) const {
auto AsTuple = [](const auto& item) {
return std::tie(item.title, item.text, item.url, item.files);
};
return AsTuple(*this) == AsTuple(other);
}
Manifest::ShareTarget::ShareTarget() = default;
Manifest::ShareTarget::~ShareTarget() = default;
bool Manifest::ShareTarget::operator==(const ShareTarget& other) const {
auto AsTuple = [](const auto& item) {
return std::tie(item.action, item.method, item.enctype, item.params);
};
return AsTuple(*this) == AsTuple(other);
}
Manifest::RelatedApplication::RelatedApplication() = default;
Manifest::RelatedApplication::~RelatedApplication() = default;
bool Manifest::RelatedApplication::operator==(
const RelatedApplication& other) const {
auto AsTuple = [](const auto& item) {
return std::tie(item.platform, item.url, item.id);
};
return AsTuple(*this) == AsTuple(other);
}
Manifest::LaunchHandler::LaunchHandler() = default;
Manifest::LaunchHandler::LaunchHandler(std::optional<ClientMode> client_mode)
: client_mode_(client_mode) {}
// See https://wicg.github.io/web-app-launch/#dfn-process-the-client_mode-member
// for more details.
Manifest::LaunchHandler::ClientMode
Manifest::LaunchHandler::parsed_client_mode() const {
return client_mode_.value_or(Manifest::LaunchHandler::ClientMode::kAuto);
}
bool Manifest::LaunchHandler::client_mode_valid_and_specified() const {
return client_mode_.has_value();
}
bool Manifest::LaunchHandler::operator==(const LaunchHandler& other) const {
return parsed_client_mode() == other.parsed_client_mode();
}
bool Manifest::LaunchHandler::operator!=(const LaunchHandler& other) const {
return !(*this == other);
}
bool Manifest::LaunchHandler::TargetsExistingClients() const {
switch (parsed_client_mode()) {
case ClientMode::kAuto:
case ClientMode::kNavigateNew:
return false;
case ClientMode::kNavigateExisting:
case ClientMode::kFocusExisting:
return true;
}
}
bool Manifest::LaunchHandler::NeverNavigateExistingClients() const {
switch (parsed_client_mode()) {
case ClientMode::kAuto:
case ClientMode::kNavigateNew:
case ClientMode::kNavigateExisting:
return false;
case ClientMode::kFocusExisting:
return true;
}
}
Manifest::TranslationItem::TranslationItem() = default;
Manifest::TranslationItem::~TranslationItem() = default;
bool Manifest::TranslationItem::operator==(const TranslationItem& other) const {
auto AsTuple = [](const auto& item) {
return std::tie(item.name, item.short_name, item.description);
};
return AsTuple(*this) == AsTuple(other);
}
Manifest::HomeTabParams::HomeTabParams() = default;
Manifest::HomeTabParams::~HomeTabParams() = default;
bool Manifest::HomeTabParams::operator==(const HomeTabParams& other) const {
auto AsTuple = [](const auto& item) {
return std::tie(item.icons, item.scope_patterns);
};
return AsTuple(*this) == AsTuple(other);
}
Manifest::NewTabButtonParams::NewTabButtonParams() = default;
Manifest::NewTabButtonParams::~NewTabButtonParams() = default;
bool Manifest::NewTabButtonParams::operator==(
const NewTabButtonParams& other) const {
return url == other.url;
}
Manifest::TabStrip::TabStrip() = default;
Manifest::TabStrip::~TabStrip() = default;
bool Manifest::TabStrip::operator==(const TabStrip& other) const {
auto AsTuple = [](const auto& item) {
return std::tie(item.home_tab, item.new_tab_button);
};
return AsTuple(*this) == AsTuple(other);
}
} // namespace blink
|