| 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 21 matching lines...) Expand all Loading... |
| 32 | 32 |
| 33 // Maximum of sizes in a MediaImage. | 33 // Maximum of sizes in a MediaImage. |
| 34 const size_t kMaxNumberOfImageSizes = 10; | 34 const size_t kMaxNumberOfImageSizes = 10; |
| 35 | 35 |
| 36 bool checkMediaImageSrcSanity(const KURL& src, ExecutionContext* context) { | 36 bool checkMediaImageSrcSanity(const KURL& src, ExecutionContext* context) { |
| 37 // Console warning for invalid src is printed upon MediaImage creation. | 37 // Console warning for invalid src is printed upon MediaImage creation. |
| 38 if (!src.isValid()) | 38 if (!src.isValid()) |
| 39 return false; | 39 return false; |
| 40 | 40 |
| 41 if (!src.protocolIs(url::kHttpScheme) && !src.protocolIs(url::kHttpsScheme) && | 41 if (!src.protocolIs(url::kHttpScheme) && !src.protocolIs(url::kHttpsScheme) && |
| 42 !src.protocolIs(url::kDataScheme)) { | 42 !src.protocolIs(url::kDataScheme) && !src.protocolIs(url::kBlobScheme)) { |
| 43 context->addConsoleMessage(ConsoleMessage::create( | 43 context->addConsoleMessage(ConsoleMessage::create( |
| 44 JSMessageSource, WarningMessageLevel, | 44 JSMessageSource, WarningMessageLevel, |
| 45 "MediaImage src can only be of http/https/data scheme: " + | 45 "MediaImage src can only be of http/https/data/blob scheme: " + |
| 46 src.getString())); | 46 src.getString())); |
| 47 return false; | 47 return false; |
| 48 } | 48 } |
| 49 DCHECK(src.getString().is8Bit()); | 49 DCHECK(src.getString().is8Bit()); |
| 50 if (src.getString().length() > url::kMaxURLChars) { | 50 if (src.getString().length() > url::kMaxURLChars) { |
| 51 context->addConsoleMessage(ConsoleMessage::create( | 51 context->addConsoleMessage(ConsoleMessage::create( |
| 52 JSMessageSource, WarningMessageLevel, | 52 JSMessageSource, WarningMessageLevel, |
| 53 "MediaImage src exceeds maximum URL length: " + src.getString())); | 53 "MediaImage src exceeds maximum URL length: " + src.getString())); |
| 54 return false; | 54 return false; |
| 55 } | 55 } |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 |