OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "modules/mediasession/MediaMetadataSanitizer.h" | 5 #include "modules/mediasession/MediaMetadataSanitizer.h" |
6 | 6 |
7 #include "core/dom/ExecutionContext.h" | 7 #include "core/dom/ExecutionContext.h" |
8 #include "core/inspector/ConsoleMessage.h" | 8 #include "core/inspector/ConsoleMessage.h" |
9 #include "modules/mediasession/MediaImage.h" | 9 #include "modules/mediasession/MediaImage.h" |
10 #include "modules/mediasession/MediaMetadata.h" | 10 #include "modules/mediasession/MediaMetadata.h" |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 | 67 |
68 KURL url = KURL(ParsedURLString, image->src()); | 68 KURL url = KURL(ParsedURLString, image->src()); |
69 if (!checkMediaImageSrcSanity(url, context)) | 69 if (!checkMediaImageSrcSanity(url, context)) |
70 return mojoImage; | 70 return mojoImage; |
71 | 71 |
72 mojoImage = blink::mojom::blink::MediaImage::New(); | 72 mojoImage = blink::mojom::blink::MediaImage::New(); |
73 mojoImage->src = url; | 73 mojoImage->src = url; |
74 mojoImage->type = image->type().left(kMaxImageTypeLength); | 74 mojoImage->type = image->type().left(kMaxImageTypeLength); |
75 for (const auto& webSize : | 75 for (const auto& webSize : |
76 WebIconSizesParser::parseIconSizes(image->sizes())) { | 76 WebIconSizesParser::parseIconSizes(image->sizes())) { |
77 mojoImage->sizes.append(webSize); | 77 mojoImage->sizes.push_back(webSize); |
78 if (mojoImage->sizes.size() == kMaxNumberOfImageSizes) { | 78 if (mojoImage->sizes.size() == kMaxNumberOfImageSizes) { |
79 context->addConsoleMessage(ConsoleMessage::create( | 79 context->addConsoleMessage(ConsoleMessage::create( |
80 JSMessageSource, WarningMessageLevel, | 80 JSMessageSource, WarningMessageLevel, |
81 "The number of MediaImage sizes exceeds the upper limit. " | 81 "The number of MediaImage sizes exceeds the upper limit. " |
82 "All remaining MediaImage will be ignored")); | 82 "All remaining MediaImage will be ignored")); |
83 break; | 83 break; |
84 } | 84 } |
85 } | 85 } |
86 return mojoImage; | 86 return mojoImage; |
87 } | 87 } |
(...skipping 10 matching lines...) Expand all Loading... |
98 mojoMetadata = blink::mojom::blink::MediaMetadata::New(); | 98 mojoMetadata = blink::mojom::blink::MediaMetadata::New(); |
99 | 99 |
100 mojoMetadata->title = metadata->title().left(kMaxStringLength); | 100 mojoMetadata->title = metadata->title().left(kMaxStringLength); |
101 mojoMetadata->artist = metadata->artist().left(kMaxStringLength); | 101 mojoMetadata->artist = metadata->artist().left(kMaxStringLength); |
102 mojoMetadata->album = metadata->album().left(kMaxStringLength); | 102 mojoMetadata->album = metadata->album().left(kMaxStringLength); |
103 | 103 |
104 for (const auto image : metadata->artwork()) { | 104 for (const auto image : metadata->artwork()) { |
105 blink::mojom::blink::MediaImagePtr mojoImage = | 105 blink::mojom::blink::MediaImagePtr mojoImage = |
106 sanitizeMediaImageAndConvertToMojo(image.get(), context); | 106 sanitizeMediaImageAndConvertToMojo(image.get(), context); |
107 if (!mojoImage.is_null()) | 107 if (!mojoImage.is_null()) |
108 mojoMetadata->artwork.append(std::move(mojoImage)); | 108 mojoMetadata->artwork.push_back(std::move(mojoImage)); |
109 if (mojoMetadata->artwork.size() == kMaxNumberOfMediaImages) { | 109 if (mojoMetadata->artwork.size() == kMaxNumberOfMediaImages) { |
110 context->addConsoleMessage(ConsoleMessage::create( | 110 context->addConsoleMessage(ConsoleMessage::create( |
111 JSMessageSource, WarningMessageLevel, | 111 JSMessageSource, WarningMessageLevel, |
112 "The number of MediaImage sizes exceeds the upper limit. " | 112 "The number of MediaImage sizes exceeds the upper limit. " |
113 "All remaining MediaImage will be ignored")); | 113 "All remaining MediaImage will be ignored")); |
114 break; | 114 break; |
115 } | 115 } |
116 } | 116 } |
117 return mojoMetadata; | 117 return mojoMetadata; |
118 } | 118 } |
119 | 119 |
120 } // namespace blink | 120 } // namespace blink |
OLD | NEW |