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

Unified Diff: webkit/fileapi/media/media_path_filter.cc

Issue 10825042: Implement media path filter (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 5 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: 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..111735dd719155682ab524d7724206483a17d54a
--- /dev/null
+++ b/webkit/fileapi/media/media_path_filter.cc
@@ -0,0 +1,27 @@
+// 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 "base/string_util.h"
+#include "net/base/mime_util.h"
+
+namespace fileapi {
+
+MediaPathFilter::MediaPathFilter() {
+ net::GetImageExtensions(&media_file_extensions_);
+ net::GetAudioExtensions(&media_file_extensions_);
+ net::GetVideoExtensions(&media_file_extensions_);
+ std::sort(media_file_extensions_.begin(), media_file_extensions_.end());
+}
+
+bool MediaPathFilter::Match(const FilePath& path) const {
+ return std::binary_search(media_file_extensions_.begin(),
+ media_file_extensions_.end(),
+ StringToLowerASCII(path.Extension()));
+}
+
+} // namespace fileapi

Powered by Google App Engine
This is Rietveld 408576698