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

Side by Side Diff: content/browser/media/session/media_metadata_sanitizer.cc

Issue 2552283003: Allow Blob image src to be used as MediaNotification artwork (Closed)
Patch Set: Created 4 years 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 unified diff | Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/modules/mediasession/MediaMetadataSanitizer.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "content/browser/media/session/media_metadata_sanitizer.h" 5 #include "content/browser/media/session/media_metadata_sanitizer.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 9
10 #include "content/public/common/media_metadata.h" 10 #include "content/public/common/media_metadata.h"
(...skipping 14 matching lines...) Expand all
25 25
26 // Maximum number of MediaImages inside the MediaMetadata. 26 // Maximum number of MediaImages inside the MediaMetadata.
27 const size_t kMaxNumberOfMediaImages = 10; 27 const size_t kMaxNumberOfMediaImages = 10;
28 28
29 // Maximum of sizes in a MediaImage. 29 // Maximum of sizes in a MediaImage.
30 const size_t kMaxNumberOfMediaImageSizes = 10; 30 const size_t kMaxNumberOfMediaImageSizes = 10;
31 31
32 bool CheckMediaImageSrcSanity(const GURL& src) { 32 bool CheckMediaImageSrcSanity(const GURL& src) {
33 if (!src.is_valid()) 33 if (!src.is_valid())
34 return false; 34 return false;
35 if (!src.SchemeIsHTTPOrHTTPS() && !src.SchemeIs(url::kDataScheme)) 35 if (!src.SchemeIsHTTPOrHTTPS() &&
36 !src.SchemeIs(url::kDataScheme) &&
37 !src.SchemeIs(url::kBlobScheme))
36 return false; 38 return false;
37 if (src.spec().size() > url::kMaxURLChars) 39 if (src.spec().size() > url::kMaxURLChars)
38 return false; 40 return false;
39 41
40 return true; 42 return true;
41 } 43 }
42 44
43 bool CheckMediaImageSanity(const MediaMetadata::MediaImage& image) { 45 bool CheckMediaImageSanity(const MediaMetadata::MediaImage& image) {
44 if (!CheckMediaImageSrcSanity(image.src)) 46 if (!CheckMediaImageSrcSanity(image.src))
45 return false; 47 return false;
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 CheckMediaImageSanity(image) ? image : SanitizeMediaImage(image)); 104 CheckMediaImageSanity(image) ? image : SanitizeMediaImage(image));
103 105
104 if (sanitized_metadata.artwork.size() == kMaxNumberOfMediaImages) 106 if (sanitized_metadata.artwork.size() == kMaxNumberOfMediaImages)
105 break; 107 break;
106 } 108 }
107 109
108 return sanitized_metadata; 110 return sanitized_metadata;
109 } 111 }
110 112
111 } // namespace content 113 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/modules/mediasession/MediaMetadataSanitizer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698