Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(896)

Unified Diff: content/public/common/media_metadata.cc

Issue 2015433003: Implement MediaMetadata artwork in content (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: addressed Mounir's comments Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..e6a5e9eb9dc8f912a6d61c32389c9f0d827626e6 100644
--- a/content/public/common/media_metadata.cc
+++ b/content/public/common/media_metadata.cc
@@ -4,20 +4,43 @@
#include "content/public/common/media_metadata.h"
+#include <algorithm>
+
namespace content {
const size_t MediaMetadata::kMaxIPCStringLength = 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;
jochen (gone - plz use gerrit) 2016/06/27 08:12:40 should we put some length limit on the url?
Zhiqiang Zhang (Slow) 2016/06/28 13:57:00 Limiting to 4K, maybe palmer@ can have more commen
+ sanitized_artwork.type = artwork.type.is_null() ?
+ base::NullableString16() :
+ base::NullableString16(
+ artwork.type.string().substr(0, kMaxArtworkTypeLength),
+ false);
+ std::copy(artwork.sizes.begin(), artwork.sizes.end(),
+ sanitized_artwork.sizes.begin());
+ return sanitized_artwork;
jochen (gone - plz use gerrit) 2016/06/27 08:12:40 can you avoid creating a copy of the artwork if it
Zhiqiang Zhang (Slow) 2016/06/28 13:57:01 Done. Early-returning if it's sane.
+}
+
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698