From ca3a2da5ee23ee373c6509a0d9a50e266567e553 Mon Sep 17 00:00:00 2001 From: Marshall Greenblatt Date: Mon, 10 Jun 2013 18:23:48 +0000 Subject: [PATCH] Add password argument to CefZipArchive::Load (issue #986). git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@1277 5089003a-bbd8-11dd-ad1f-f1f9622dbc98 --- include/wrapper/cef_zip_archive.h | 5 ++++- libcef_dll/wrapper/cef_zip_archive.cc | 3 ++- tests/unittests/zip_reader_unittest.cc | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/include/wrapper/cef_zip_archive.h b/include/wrapper/cef_zip_archive.h index b58dbca01..4e37d69a0 100644 --- a/include/wrapper/cef_zip_archive.h +++ b/include/wrapper/cef_zip_archive.h @@ -86,11 +86,14 @@ class CefZipArchive : public CefBase { /// // Load the contents of the specified zip archive stream into this object. + // If the zip archive requires a password then provide it via |password|. // If |overwriteExisting| is true then any files in this object that also // exist in the specified archive will be replaced with the new files. // Returns the number of files successfully loaded. /// - size_t Load(CefRefPtr stream, bool overwriteExisting); + size_t Load(CefRefPtr stream, + const CefString& password, + bool overwriteExisting); /// // Clears the contents of this object. diff --git a/libcef_dll/wrapper/cef_zip_archive.cc b/libcef_dll/wrapper/cef_zip_archive.cc index b248e40d2..4f5c45b3b 100644 --- a/libcef_dll/wrapper/cef_zip_archive.cc +++ b/libcef_dll/wrapper/cef_zip_archive.cc @@ -53,6 +53,7 @@ CefZipArchive::~CefZipArchive() { } size_t CefZipArchive::Load(CefRefPtr stream, + const CefString& password, bool overwriteExisting) { AutoLock lock_scope(this); @@ -76,7 +77,7 @@ size_t CefZipArchive::Load(CefRefPtr stream, continue; } - if (!reader->OpenFile(CefString())) + if (!reader->OpenFile(password)) break; name = reader->GetFileName(); diff --git a/tests/unittests/zip_reader_unittest.cc b/tests/unittests/zip_reader_unittest.cc index 41f83fdde..3ecb789e9 100644 --- a/tests/unittests/zip_reader_unittest.cc +++ b/tests/unittests/zip_reader_unittest.cc @@ -221,7 +221,7 @@ TEST(ZipReaderTest, ReadArchive) { // Create the Zip archive object. CefRefPtr archive(new CefZipArchive()); - ASSERT_EQ(archive->Load(stream, false), (size_t)5); + ASSERT_EQ(archive->Load(stream, CefString(), false), (size_t)5); ASSERT_TRUE(archive->HasFile("test_archive/file 1.txt")); ASSERT_TRUE(archive->HasFile("test_archive/folder 1/file 1a.txt"));