Chromium Code Reviews| Index: chrome/browser/safe_browsing/mac_archive_type_sniffer.cc |
| diff --git a/chrome/browser/safe_browsing/mac_archive_type_sniffer.cc b/chrome/browser/safe_browsing/mac_archive_type_sniffer.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..3c0af2c863814628aba185c73f9a2b9afde10761 |
| --- /dev/null |
| +++ b/chrome/browser/safe_browsing/mac_archive_type_sniffer.cc |
| @@ -0,0 +1,34 @@ |
| +// Copyright 2017 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 "chrome/browser/safe_browsing/mac_archive_type_sniffer.h" |
| + |
| +#include "chrome/utility/safe_browsing/mac/udif.h" |
| +#include "content/public/browser/browser_thread.h" |
| + |
| +namespace safe_browsing { |
| + |
| +MacArchiveTypeSniffer::MacArchiveTypeSniffer() {} |
| + |
| +// static |
| +bool MacArchiveTypeSniffer::FileIsArchiveType(const base::FilePath& dmg_file) { |
| + DCHECK_CURRENTLY_ON(content::BrowserThread::FILE); |
| + |
| + base::File file(dmg_file, base::File::FLAG_OPEN | base::File::FLAG_READ); |
| + DCHECK(file.IsValid()); |
| + |
| + dmg::FileReadStream read_stream(file.GetPlatformFile()); |
| + |
| + dmg::UDIFParser parser(&read_stream); |
| + |
| + if (parser.GetTrailer() != NULL) { |
|
Jialiu Lin
2017/06/09 18:48:49
You can simply this as:
return !!parser.GetTraile
mortonm
2017/06/09 19:47:20
Done.
|
| + return true; |
| + } else { |
| + return false; |
| + } |
| +} |
| + |
| +MacArchiveTypeSniffer::~MacArchiveTypeSniffer() = default; |
| + |
| +} // namespace safe_browsing |