OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/media_galleries/fileapi/native_media_file_util.h" | 5 #include "chrome/browser/media_galleries/fileapi/native_media_file_util.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 } | 30 } |
31 | 31 |
32 base::File::Error IsMediaHeader(const char* buf, size_t length) { | 32 base::File::Error IsMediaHeader(const char* buf, size_t length) { |
33 if (length == 0) | 33 if (length == 0) |
34 return base::File::FILE_ERROR_SECURITY; | 34 return base::File::FILE_ERROR_SECURITY; |
35 | 35 |
36 std::string mime_type; | 36 std::string mime_type; |
37 if (!net::SniffMimeTypeFromLocalData(buf, length, &mime_type)) | 37 if (!net::SniffMimeTypeFromLocalData(buf, length, &mime_type)) |
38 return base::File::FILE_ERROR_SECURITY; | 38 return base::File::FILE_ERROR_SECURITY; |
39 | 39 |
40 if (StartsWithASCII(mime_type, "image/", true) || | 40 if (base::StartsWithASCII(mime_type, "image/", true) || |
41 StartsWithASCII(mime_type, "audio/", true) || | 41 base::StartsWithASCII(mime_type, "audio/", true) || |
42 StartsWithASCII(mime_type, "video/", true) || | 42 base::StartsWithASCII(mime_type, "video/", true) || |
43 mime_type == "application/x-shockwave-flash") { | 43 mime_type == "application/x-shockwave-flash") { |
44 return base::File::FILE_OK; | 44 return base::File::FILE_OK; |
45 } | 45 } |
46 return base::File::FILE_ERROR_SECURITY; | 46 return base::File::FILE_ERROR_SECURITY; |
47 } | 47 } |
48 | 48 |
49 void HoldFileRef( | 49 void HoldFileRef( |
50 const scoped_refptr<storage::ShareableFileReference>& file_ref) { | 50 const scoped_refptr<storage::ShareableFileReference>& file_ref) { |
51 } | 51 } |
52 | 52 |
(...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
671 return base::File::FILE_ERROR_FAILED; | 671 return base::File::FILE_ERROR_FAILED; |
672 | 672 |
673 if (!file_info.is_directory && | 673 if (!file_info.is_directory && |
674 !media_path_filter_->Match(file_path)) { | 674 !media_path_filter_->Match(file_path)) { |
675 return failure_error; | 675 return failure_error; |
676 } | 676 } |
677 | 677 |
678 *local_file_path = file_path; | 678 *local_file_path = file_path; |
679 return base::File::FILE_OK; | 679 return base::File::FILE_OK; |
680 } | 680 } |
OLD | NEW |