Chromium Code Reviews| Index: content/public/common/media_metadata.cc |
| diff --git a/content/public/common/media_metadata.cc b/content/public/common/media_metadata.cc |
| index dc3824c25b0cdc82b515387caec50f9ea356f6b7..2b22d1750dd7b6c5c8b43f226503738bcfce331b 100644 |
| --- a/content/public/common/media_metadata.cc |
| +++ b/content/public/common/media_metadata.cc |
| @@ -4,20 +4,47 @@ |
| #include "content/public/common/media_metadata.h" |
| +#include <algorithm> |
| + |
| namespace content { |
| const size_t MediaMetadata::kMaxIPCStringLength = 4 * 1024; |
| +const int MediaMetadata::kMaxIconSize = 4 * 1024; |
| +const size_t MediaMetadata::kMaxArtworkTypeLength = 2 * 127 + 1; |
| MediaMetadata::MediaMetadata() = default; |
| MediaMetadata::~MediaMetadata() = default; |
| bool MediaMetadata::operator==(const MediaMetadata& other) const { |
| - return title == other.title && artist == other.artist && album == other.album; |
| + return title == other.title && artist == other.artist && |
| + album == other.album && artwork == other.artwork; |
| } |
| bool MediaMetadata::operator!=(const MediaMetadata& other) const { |
| return !this->operator==(other); |
| } |
| +base::Optional<MediaMetadata::Artwork> MediaMetadata::SanitizeArtwork( |
| + const MediaMetadata::Artwork& artwork) { |
| + if (!artwork.src.is_valid() || !artwork.src.IsStandard() || |
| + (!artwork.src.SchemeIsHTTPOrHTTPS() && |
| + !artwork.src.SchemeIsFile())) { |
| + return base::nullopt; |
| + } |
| + Artwork sanitized_artwork; |
| + sanitized_artwork.src = artwork.src; |
| + sanitized_artwork.type = artwork.type.is_null() ? |
| + base::NullableString16() : |
| + base::NullableString16( |
| + artwork.type.string().substr(0, kMaxArtworkTypeLength), |
| + false); |
| + std::copy_if(artwork.sizes.begin(), artwork.sizes.end(), |
| + sanitized_artwork.sizes.begin(), |
| + [](const gfx::Size& size) { |
| + return size.width() >= 0 && size.width() <= kMaxIconSize && |
| + size.height() >= 0 && size.height() <= kMaxIconSize; }); |
|
mlamouri (slow - plz ping)
2016/06/21 13:19:46
palmer@ why do we need to check this? The sizes he
|
| + return sanitized_artwork; |
| +} |
| + |
| } // namespace content |