Chromium Code Reviews| Index: webkit/fileapi/media/media_path_filter.cc |
| diff --git a/webkit/fileapi/media/media_path_filter.cc b/webkit/fileapi/media/media_path_filter.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..116ba926d32df068acdf506555a5584db5e56efb |
| --- /dev/null |
| +++ b/webkit/fileapi/media/media_path_filter.cc |
| @@ -0,0 +1,51 @@ |
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "webkit/fileapi/media/media_path_filter.h" |
| + |
| +#include <algorithm> |
| +#include <string> |
| + |
| +#include "base/string_util.h" |
| +#include "net/base/mime_util.h" |
| + |
| +namespace fileapi { |
| + |
| +namespace { |
| + |
| +bool IsUnsupportedExtension(const std::string& extension) { |
| + std::string mime_type; |
| + return !net::GetMimeTypeFromExtension(extension, &mime_type) || |
| + !net::IsSupportedMimeType(mime_type); |
| +} |
| + |
| +} // namespace |
| + |
| +MediaPathFilter::MediaPathFilter() { |
| + net::GetImageExtensions(&media_file_extensions_); |
| + net::GetAudioExtensions(&media_file_extensions_); |
| + net::GetVideoExtensions(&media_file_extensions_); |
| + |
| + MediaFileExtensionList::iterator new_end = |
| + std::remove_if(media_file_extensions_.begin(), |
| + media_file_extensions_.end(), |
| + &IsUnsupportedExtension); |
| + media_file_extensions_.erase(new_end, media_file_extensions_.end()); |
| + |
| + for (MediaFileExtensionList::iterator itr = media_file_extensions_.begin(); |
| + itr != media_file_extensions_.end(); ++itr) |
| + *itr = FilePath::kExtensionSeparator + *itr; |
| + std::sort(media_file_extensions_.begin(), media_file_extensions_.end()); |
|
vandebo (ex-Chrome)
2012/08/01 01:11:05
For me information, what is the list of extensions
tzik
2012/08/01 21:46:06
It contains:
.bmp .gif .jfif .jpeg .jpg .oga .ogg
|
| +} |
| + |
| +MediaPathFilter::~MediaPathFilter() { |
| +} |
| + |
| +bool MediaPathFilter::Match(const FilePath& path) const { |
| + return std::binary_search(media_file_extensions_.begin(), |
| + media_file_extensions_.end(), |
| + StringToLowerASCII(path.Extension())); |
| +} |
| + |
| +} // namespace fileapi |