diff --git a/third_party/unrar/BUILD.gn b/third_party/unrar/BUILD.gn
index 97f4e0460ad7c..0d665e199e4b4 100644
--- a/third_party/unrar/BUILD.gn
+++ b/third_party/unrar/BUILD.gn
@@ -25,53 +25,6 @@ static_library("unrar") {
sources = [
"google/unrar_wrapper.cc",
"google/unrar_wrapper.h",
- "src/archive.cpp",
- "src/arcread.cpp",
- "src/blake2s.cpp",
- "src/cmddata.cpp",
- "src/consio.cpp",
- "src/crc.cpp",
- "src/crypt.cpp",
- "src/encname.cpp",
- "src/errhnd.cpp",
- "src/extinfo.cpp",
- "src/extract.cpp",
- "src/filcreat.cpp",
- "src/file.cpp",
- "src/filefn.cpp",
- "src/filestr.cpp",
- "src/find.cpp",
- "src/getbits.cpp",
- "src/global.cpp",
- "src/hash.cpp",
- "src/headers.cpp",
- "src/list.cpp",
- "src/match.cpp",
- "src/options.cpp",
- "src/pathfn.cpp",
- "src/qopen.cpp",
- "src/rarvm.cpp",
- "src/rawread.cpp",
- "src/rdwrfn.cpp",
- "src/recvol.cpp",
- "src/resource.cpp",
- "src/rijndael.cpp",
- "src/rs.cpp",
- "src/rs16.cpp",
- "src/scantree.cpp",
- "src/secpassword.cpp",
- "src/sha1.cpp",
- "src/sha256.cpp",
- "src/smallfn.cpp",
- "src/strfn.cpp",
- "src/strlist.cpp",
- "src/system.cpp",
- "src/threadpool.cpp",
- "src/timefn.cpp",
- "src/ui.cpp",
- "src/unicode.cpp",
- "src/unpack.cpp",
- "src/volume.cpp",
]
if (is_win) {
sources += [ "src/isnt.cpp" ]
diff --git a/third_party/unrar/google/unrar_wrapper.cc b/third_party/unrar/google/unrar_wrapper.cc
index a76b497b6ea7d..2f2f159d08071 100644
--- a/third_party/unrar/google/unrar_wrapper.cc
+++ b/third_party/unrar/google/unrar_wrapper.cc
@@ -10,7 +10,6 @@
#include "base/metrics/histogram_macros.h"
#include "base/strings/utf_string_conversions.h"
#include "build/build_config.h"
-#include "third_party/unrar/src/rar.hpp"
namespace third_party_unrar {
@@ -19,84 +18,10 @@ RarReader::RarReader() {}
RarReader::~RarReader() {}
bool RarReader::Open(base::File rar_file, base::File temp_file) {
- rar_file_ = std::move(rar_file);
- temp_file_ = std::move(temp_file);
-
- command_ = std::make_unique<CommandData>();
- // Unrar forbids empty passwords, but requires that a password be provided for
- // encrypted archives. In order to support metadata encryption, we must
- // provide some password when opening the file.
- std::wstring password_flag =
- L"-p" + (password_.empty() ? L"x" : base::UTF8ToWide(password_));
- command_->ParseArg(password_flag.data());
- command_->ParseArg(const_cast<wchar_t*>(L"x"));
- command_->ParseDone();
-
- archive_ = std::make_unique<Archive>(command_.get());
- archive_->SetFileHandle(rar_file_.GetPlatformFile());
- archive_->SetTempFileHandle(temp_file_.GetPlatformFile());
-
- bool open_success = archive_->Open(L"dummy.rar");
- if (!open_success)
- return false;
-
- bool is_valid_archive = archive_->IsArchive(/*EnableBroken=*/true);
- if (!is_valid_archive)
- return false;
-
- extractor_ = std::make_unique<CmdExtract>(command_.get());
- extractor_->ExtractArchiveInit(*archive_);
-
- return true;
+ return false;
}
bool RarReader::ExtractNextEntry() {
- bool success = true, repeat = true;
- while (success || repeat) {
- temp_file_.Seek(base::File::Whence::FROM_BEGIN, 0);
- temp_file_.SetLength(0);
- size_t header_size = archive_->ReadHeader();
- repeat = false;
- success = extractor_->ExtractCurrentFile(
- *archive_, header_size, repeat); // |repeat| is passed by reference
-
- if (archive_->GetHeaderType() == HEAD_FILE) {
-#if defined(OS_WIN)
- current_entry_.file_path = base::FilePath(archive_->FileHead.FileName);
-#else
- std::wstring wide_filename(archive_->FileHead.FileName);
- std::string filename(wide_filename.begin(), wide_filename.end());
- current_entry_.file_path = base::FilePath(filename);
-#endif
- current_entry_.is_directory = archive_->FileHead.Dir;
- current_entry_.is_encrypted = archive_->FileHead.Encrypted;
- current_entry_.file_size =
- current_entry_.is_directory ? 0 : extractor_->GetCurrentFileSize();
- current_entry_.contents_valid =
- success && ErrHandler.GetErrorCode() == RARX_SUCCESS;
- ErrHandler.Clean();
-
- if (success) {
- return true;
- }
-
- if (archive_->FileHead.Encrypted) {
- // Since Chromium doesn't have the password or the password was
- // incorrect, manually skip over the encrypted data and fill in the
- // metadata we do have.
- archive_->SeekToNext();
- return true;
- }
-
- if (extractor_->IsMissingNextVolume()) {
- // Since Chromium doesn't have the next volume, manually skip over this
- // file, but report the metadata we do have.
- archive_->SeekToNext();
- return true;
- }
- }
- }
-
return false;
}
@@ -105,11 +30,11 @@ void RarReader::SetPassword(const std::string& password) {
}
bool RarReader::HeadersEncrypted() const {
- return archive_->Encrypted;
+ return false;
}
bool RarReader::HeaderDecryptionFailed() const {
- return archive_->FailedHeaderDecryption;
+ return true;
}
} // namespace third_party_unrar
diff --git a/third_party/unrar/google/unrar_wrapper.h b/third_party/unrar/google/unrar_wrapper.h
index a0724520f0aac..765a7142a962c 100644
--- a/third_party/unrar/google/unrar_wrapper.h
+++ b/third_party/unrar/google/unrar_wrapper.h
@@ -12,9 +12,9 @@
// Forward declare the unrar symbols needed for extraction, so users of
// RarReader don't need all the symbols from unrar.
-class Archive;
-class CmdExtract;
-class CommandData;
+class Archive {};
+class CmdExtract {};
+class CommandData {};
namespace third_party_unrar {