summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/DEPS1
-rw-r--r--chrome/browser/chromeos/imageburner/burn_manager.cc2
-rw-r--r--chrome/browser/component_updater/component_unpacker.cc2
-rw-r--r--chrome/browser/extensions/extension_creator.cc2
-rw-r--r--chrome/browser/feedback/feedback_data.cc2
-rw-r--r--chrome/browser/safe_browsing/download_protection_service_unittest.cc2
-rw-r--r--chrome/chrome_common.gypi9
-rw-r--r--chrome/chrome_tests_unit.gypi2
-rw-r--r--chrome/common/extensions/unpacker.cc2
-rw-r--r--chrome/common/safe_browsing/zip_analyzer.cc2
-rw-r--r--chrome/test/webdriver/webdriver_capabilities_parser_unittest.cc2
-rw-r--r--chrome/test/webdriver/webdriver_util.cc2
-rw-r--r--chrome/utility/chrome_content_utility_client.cc2
-rw-r--r--components/components.gyp1
-rw-r--r--components/components_tests.gypi5
-rwxr-xr-xcomponents/test/data/zip/create_test_zip.sh (renamed from chrome/test/data/zip/create_test_zip.sh)0
-rw-r--r--components/test/data/zip/evil.zip (renamed from chrome/test/data/zip/evil.zip)bin241 -> 241 bytes
-rw-r--r--components/test/data/zip/evil_via_absolute_file_name.zip (renamed from chrome/test/data/zip/evil_via_absolute_file_name.zip)bin172 -> 172 bytes
-rw-r--r--components/test/data/zip/evil_via_invalid_utf8.zip (renamed from chrome/test/data/zip/evil_via_invalid_utf8.zip)bin4585 -> 4585 bytes
-rw-r--r--components/test/data/zip/test.zip (renamed from chrome/test/data/zip/test.zip)bin5065 -> 5065 bytes
-rw-r--r--components/test/data/zip/test/foo.txt (renamed from chrome/test/data/zip/test/foo.txt)0
-rw-r--r--components/test/data/zip/test/foo/bar.txt (renamed from chrome/test/data/zip/test/foo/bar.txt)0
-rw-r--r--components/test/data/zip/test/foo/bar/.hidden (renamed from chrome/test/data/zip/test/foo/bar/.hidden)0
-rw-r--r--components/test/data/zip/test/foo/bar/baz.txt (renamed from chrome/test/data/zip/test/foo/bar/baz.txt)0
-rw-r--r--components/test/data/zip/test/foo/bar/quux.txt (renamed from chrome/test/data/zip/test/foo/bar/quux.txt)0
-rw-r--r--components/test/data/zip/test_nocompress.zip (renamed from chrome/test/data/zip/test_nocompress.zip)bin14252 -> 14252 bytes
-rw-r--r--components/zip.gypi26
-rw-r--r--components/zip/DEPS7
-rw-r--r--components/zip/OWNERS2
-rw-r--r--components/zip/zip.cc (renamed from chrome/common/zip.cc)6
-rw-r--r--components/zip/zip.h (renamed from chrome/common/zip.h)6
-rw-r--r--components/zip/zip_internal.cc (renamed from chrome/common/zip_internal.cc)4
-rw-r--r--components/zip/zip_internal.h (renamed from chrome/common/zip_internal.h)6
-rw-r--r--components/zip/zip_reader.cc (renamed from chrome/common/zip_reader.cc)4
-rw-r--r--components/zip/zip_reader.h (renamed from chrome/common/zip_reader.h)6
-rw-r--r--components/zip/zip_reader_unittest.cc (renamed from chrome/common/zip_reader_unittest.cc)18
-rw-r--r--components/zip/zip_unittest.cc (renamed from chrome/common/zip_unittest.cc)29
37 files changed, 103 insertions, 49 deletions
diff --git a/chrome/DEPS b/chrome/DEPS
index 190ae30..e9ef37f 100644
--- a/chrome/DEPS
+++ b/chrome/DEPS
@@ -25,6 +25,7 @@ include_rules = [
"+chrome/common",
"+chrome/test",
"+components/visitedlink/common",
+ "+components/zip",
"+content/public/common",
"+content/public/test",
"+content/test/gpu",
diff --git a/chrome/browser/chromeos/imageburner/burn_manager.cc b/chrome/browser/chromeos/imageburner/burn_manager.cc
index 6d9c96f..1321787 100644
--- a/chrome/browser/chromeos/imageburner/burn_manager.cc
+++ b/chrome/browser/chromeos/imageburner/burn_manager.cc
@@ -14,9 +14,9 @@
#include "chrome/browser/chromeos/net/connectivity_state_helper.h"
#include "chrome/browser/chromeos/system/statistics_provider.h"
#include "chrome/common/chrome_paths.h"
-#include "chrome/common/zip.h"
#include "chromeos/dbus/dbus_thread_manager.h"
#include "chromeos/dbus/image_burner_client.h"
+#include "components/zip/zip.h"
#include "content/public/browser/browser_thread.h"
#include "grit/generated_resources.h"
#include "net/url_request/url_fetcher.h"
diff --git a/chrome/browser/component_updater/component_unpacker.cc b/chrome/browser/component_updater/component_unpacker.cc
index ca5aba1..782a8df 100644
--- a/chrome/browser/component_updater/component_unpacker.cc
+++ b/chrome/browser/component_updater/component_unpacker.cc
@@ -14,7 +14,7 @@
#include "base/strings/string_number_conversions.h"
#include "chrome/browser/component_updater/component_updater_service.h"
#include "chrome/common/extensions/extension_constants.h"
-#include "chrome/common/zip.h"
+#include "components/zip/zip.h"
#include "crypto/secure_hash.h"
#include "crypto/signature_verifier.h"
#include "extensions/common/crx_file.h"
diff --git a/chrome/browser/extensions/extension_creator.cc b/chrome/browser/extensions/extension_creator.cc
index a143534..988bfb6 100644
--- a/chrome/browser/extensions/extension_creator.cc
+++ b/chrome/browser/extensions/extension_creator.cc
@@ -16,7 +16,7 @@
#include "chrome/browser/extensions/extension_creator_filter.h"
#include "chrome/common/extensions/extension.h"
#include "chrome/common/extensions/extension_file_util.h"
-#include "chrome/common/zip.h"
+#include "components/zip/zip.h"
#include "crypto/rsa_private_key.h"
#include "crypto/signature_creator.h"
#include "extensions/common/crx_file.h"
diff --git a/chrome/browser/feedback/feedback_data.cc b/chrome/browser/feedback/feedback_data.cc
index 3d35b1e..8c394d6 100644
--- a/chrome/browser/feedback/feedback_data.cc
+++ b/chrome/browser/feedback/feedback_data.cc
@@ -20,7 +20,7 @@
#endif
#if defined(OS_CHROMEOS)
-#include "chrome/common/zip.h"
+#include "components/zip/zip.h"
#endif
using content::BrowserThread;
diff --git a/chrome/browser/safe_browsing/download_protection_service_unittest.cc b/chrome/browser/safe_browsing/download_protection_service_unittest.cc
index a79e70b..e8da2ee 100644
--- a/chrome/browser/safe_browsing/download_protection_service_unittest.cc
+++ b/chrome/browser/safe_browsing/download_protection_service_unittest.cc
@@ -23,7 +23,7 @@
#include "chrome/browser/safe_browsing/safe_browsing_service.h"
#include "chrome/browser/safe_browsing/signature_util.h"
#include "chrome/common/safe_browsing/csd.pb.h"
-#include "chrome/common/zip.h"
+#include "components/zip/zip.h"
#include "content/public/test/mock_download_item.h"
#include "content/public/test/test_browser_thread.h"
#include "googleurl/src/gurl.h"
diff --git a/chrome/chrome_common.gypi b/chrome/chrome_common.gypi
index 9e0744d..4efaaf6 100644
--- a/chrome/chrome_common.gypi
+++ b/chrome/chrome_common.gypi
@@ -38,6 +38,7 @@
'<(DEPTH)/chrome/chrome_resources.gyp:theme_resources',
'<(DEPTH)/chrome/common_constants.gyp:common_constants',
'<(DEPTH)/components/components.gyp:visitedlink_common',
+ '<(DEPTH)/components/components.gyp:zip',
'<(DEPTH)/content/content.gyp:content_common',
'<(DEPTH)/net/net.gyp:net',
'<(DEPTH)/skia/skia.gyp:skia',
@@ -47,8 +48,6 @@
'<(DEPTH)/third_party/libxml/libxml.gyp:libxml',
'<(DEPTH)/third_party/mt19937ar/mt19937ar.gyp:mt19937ar',
'<(DEPTH)/third_party/sqlite/sqlite.gyp:sqlite',
- '<(DEPTH)/third_party/zlib/zlib.gyp:minizip',
- '<(DEPTH)/third_party/zlib/zlib.gyp:zlib',
'<(DEPTH)/ui/ui.gyp:ui_resources',
'<(DEPTH)/webkit/support/webkit_support.gyp:user_agent',
],
@@ -411,12 +410,6 @@
'common/web_resource/web_resource_unpacker.h',
'common/worker_thread_ticker.cc',
'common/worker_thread_ticker.h',
- 'common/zip.cc', # Requires zlib directly.
- 'common/zip.h',
- 'common/zip_internal.cc',
- 'common/zip_internal.h',
- 'common/zip_reader.cc',
- 'common/zip_reader.h',
],
'conditions': [
['enable_extensions==1', {
diff --git a/chrome/chrome_tests_unit.gypi b/chrome/chrome_tests_unit.gypi
index 2b3fe5d..f47ca1b 100644
--- a/chrome/chrome_tests_unit.gypi
+++ b/chrome/chrome_tests_unit.gypi
@@ -1578,8 +1578,6 @@
'common/time_format_unittest.cc',
'common/web_apps_unittest.cc',
'common/worker_thread_ticker_unittest.cc',
- 'common/zip_reader_unittest.cc',
- 'common/zip_unittest.cc',
'nacl/nacl_ipc_adapter_unittest.cc',
'nacl/nacl_validation_query_unittest.cc',
'renderer/chrome_content_renderer_client_unittest.cc',
diff --git a/chrome/common/extensions/unpacker.cc b/chrome/common/extensions/unpacker.cc
index c5e1182..37b417b 100644
--- a/chrome/common/extensions/unpacker.cc
+++ b/chrome/common/extensions/unpacker.cc
@@ -22,7 +22,7 @@
#include "chrome/common/extensions/extension_manifest_constants.h"
#include "chrome/common/extensions/manifest.h"
#include "chrome/common/url_constants.h"
-#include "chrome/common/zip.h"
+#include "components/zip/zip.h"
#include "content/public/common/common_param_traits.h"
#include "extensions/common/constants.h"
#include "grit/generated_resources.h"
diff --git a/chrome/common/safe_browsing/zip_analyzer.cc b/chrome/common/safe_browsing/zip_analyzer.cc
index a17ed64..4a1a951 100644
--- a/chrome/common/safe_browsing/zip_analyzer.cc
+++ b/chrome/common/safe_browsing/zip_analyzer.cc
@@ -6,7 +6,7 @@
#include "base/logging.h"
#include "chrome/common/safe_browsing/download_protection_util.h"
-#include "chrome/common/zip_reader.h"
+#include "components/zip/zip_reader.h"
namespace safe_browsing {
namespace zip_analyzer {
diff --git a/chrome/test/webdriver/webdriver_capabilities_parser_unittest.cc b/chrome/test/webdriver/webdriver_capabilities_parser_unittest.cc
index 5ae36b3..c7131a5 100644
--- a/chrome/test/webdriver/webdriver_capabilities_parser_unittest.cc
+++ b/chrome/test/webdriver/webdriver_capabilities_parser_unittest.cc
@@ -8,9 +8,9 @@
#include "base/files/scoped_temp_dir.h"
#include "base/values.h"
#include "chrome/common/chrome_switches.h"
-#include "chrome/common/zip.h"
#include "chrome/test/webdriver/webdriver_capabilities_parser.h"
#include "chrome/test/webdriver/webdriver_logging.h"
+#include "components/zip/zip.h"
#include "testing/gtest/include/gtest/gtest.h"
using base::DictionaryValue;
diff --git a/chrome/test/webdriver/webdriver_util.cc b/chrome/test/webdriver/webdriver_util.cc
index 568e842..eba3916 100644
--- a/chrome/test/webdriver/webdriver_util.cc
+++ b/chrome/test/webdriver/webdriver_util.cc
@@ -19,8 +19,8 @@
#include "base/strings/string_split.h"
#include "base/third_party/icu/icu_utf.h"
#include "chrome/common/automation_id.h"
-#include "chrome/common/zip.h"
#include "chrome/test/automation/automation_json_requests.h"
+#include "components/zip/zip.h"
using base::DictionaryValue;
using base::ListValue;
diff --git a/chrome/utility/chrome_content_utility_client.cc b/chrome/utility/chrome_content_utility_client.cc
index fcbd16a..79e4408 100644
--- a/chrome/utility/chrome_content_utility_client.cc
+++ b/chrome/utility/chrome_content_utility_client.cc
@@ -33,8 +33,8 @@
#include "chrome/common/extensions/update_manifest.h"
#include "chrome/common/safe_browsing/zip_analyzer.h"
#include "chrome/common/web_resource/web_resource_unpacker.h"
-#include "chrome/common/zip.h"
#include "chrome/utility/profile_import_handler.h"
+#include "components/zip/zip.h"
#include "content/public/utility/utility_thread.h"
#include "printing/backend/print_backend.h"
#include "printing/page_range.h"
diff --git a/components/components.gyp b/components/components.gyp
index 589c241..a8b29a2 100644
--- a/components/components.gyp
+++ b/components/components.gyp
@@ -18,5 +18,6 @@
'visitedlink.gypi',
'webdata.gypi',
'web_contents_delegate_android.gypi',
+ 'zip.gypi',
],
}
diff --git a/components/components_tests.gypi b/components/components_tests.gypi
index 7695f76..c14f73f 100644
--- a/components/components_tests.gypi
+++ b/components/components_tests.gypi
@@ -16,6 +16,8 @@
'navigation_interception/intercept_navigation_resource_throttle_unittest.cc',
'test/run_all_unittests.cc',
'visitedlink/test/visitedlink_unittest.cc',
+ 'zip/zip_reader_unittest.cc',
+ 'zip/zip_unittest.cc',
],
'include_dirs': [
'..',
@@ -40,6 +42,9 @@
'visitedlink_browser',
'visitedlink_renderer',
'../content/content_resources.gyp:content_resources',
+
+ # Dependencies of zip
+ 'zip',
],
'conditions': [
['OS == "android" and gtest_target_type == "shared_library"', {
diff --git a/chrome/test/data/zip/create_test_zip.sh b/components/test/data/zip/create_test_zip.sh
index e19d675..e19d675 100755
--- a/chrome/test/data/zip/create_test_zip.sh
+++ b/components/test/data/zip/create_test_zip.sh
diff --git a/chrome/test/data/zip/evil.zip b/components/test/data/zip/evil.zip
index 8fb908a..8fb908a 100644
--- a/chrome/test/data/zip/evil.zip
+++ b/components/test/data/zip/evil.zip
Binary files differ
diff --git a/chrome/test/data/zip/evil_via_absolute_file_name.zip b/components/test/data/zip/evil_via_absolute_file_name.zip
index 2415f81..2415f81 100644
--- a/chrome/test/data/zip/evil_via_absolute_file_name.zip
+++ b/components/test/data/zip/evil_via_absolute_file_name.zip
Binary files differ
diff --git a/chrome/test/data/zip/evil_via_invalid_utf8.zip b/components/test/data/zip/evil_via_invalid_utf8.zip
index 94b633e..94b633e 100644
--- a/chrome/test/data/zip/evil_via_invalid_utf8.zip
+++ b/components/test/data/zip/evil_via_invalid_utf8.zip
Binary files differ
diff --git a/chrome/test/data/zip/test.zip b/components/test/data/zip/test.zip
index 4bafe30..4bafe30 100644
--- a/chrome/test/data/zip/test.zip
+++ b/components/test/data/zip/test.zip
Binary files differ
diff --git a/chrome/test/data/zip/test/foo.txt b/components/test/data/zip/test/foo.txt
index 257cc56..257cc56 100644
--- a/chrome/test/data/zip/test/foo.txt
+++ b/components/test/data/zip/test/foo.txt
diff --git a/chrome/test/data/zip/test/foo/bar.txt b/components/test/data/zip/test/foo/bar.txt
index 5716ca5..5716ca5 100644
--- a/chrome/test/data/zip/test/foo/bar.txt
+++ b/components/test/data/zip/test/foo/bar.txt
diff --git a/chrome/test/data/zip/test/foo/bar/.hidden b/components/test/data/zip/test/foo/bar/.hidden
index 136c05e..136c05e 100644
--- a/chrome/test/data/zip/test/foo/bar/.hidden
+++ b/components/test/data/zip/test/foo/bar/.hidden
diff --git a/chrome/test/data/zip/test/foo/bar/baz.txt b/components/test/data/zip/test/foo/bar/baz.txt
index 7601807..7601807 100644
--- a/chrome/test/data/zip/test/foo/bar/baz.txt
+++ b/components/test/data/zip/test/foo/bar/baz.txt
diff --git a/chrome/test/data/zip/test/foo/bar/quux.txt b/components/test/data/zip/test/foo/bar/quux.txt
index 4797879..4797879 100644
--- a/chrome/test/data/zip/test/foo/bar/quux.txt
+++ b/components/test/data/zip/test/foo/bar/quux.txt
diff --git a/chrome/test/data/zip/test_nocompress.zip b/components/test/data/zip/test_nocompress.zip
index 25d66c2..25d66c2 100644
--- a/chrome/test/data/zip/test_nocompress.zip
+++ b/components/test/data/zip/test_nocompress.zip
Binary files differ
diff --git a/components/zip.gypi b/components/zip.gypi
new file mode 100644
index 0000000..e983b59
--- /dev/null
+++ b/components/zip.gypi
@@ -0,0 +1,26 @@
+# Copyright (c) 2013 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.
+
+{
+ 'targets': [
+ {
+ 'target_name': 'zip',
+ 'type': 'static_library',
+ 'dependencies': [
+ '../third_party/zlib/zlib.gyp:minizip',
+ ],
+ 'include_dirs': [
+ '..',
+ ],
+ 'sources': [
+ 'zip/zip.cc',
+ 'zip/zip.h',
+ 'zip/zip_internal.cc',
+ 'zip/zip_internal.h',
+ 'zip/zip_reader.cc',
+ 'zip/zip_reader.h',
+ ],
+ },
+ ],
+}
diff --git a/components/zip/DEPS b/components/zip/DEPS
new file mode 100644
index 0000000..200eaf8
--- /dev/null
+++ b/components/zip/DEPS
@@ -0,0 +1,7 @@
+include_rules = [
+ # No need for a content dependency - and it's better to enforce it.
+ "-content",
+
+ "+net/base",
+ "+third_party/zlib/contrib/minizip",
+]
diff --git a/components/zip/OWNERS b/components/zip/OWNERS
new file mode 100644
index 0000000..ff93254
--- /dev/null
+++ b/components/zip/OWNERS
@@ -0,0 +1,2 @@
+hshi@chromium.org
+satorux@chromium.org
diff --git a/chrome/common/zip.cc b/components/zip/zip.cc
index e8bbbfb..7521641 100644
--- a/chrome/common/zip.cc
+++ b/components/zip/zip.cc
@@ -2,15 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/common/zip.h"
+#include "components/zip/zip.h"
#include "base/bind.h"
#include "base/file_util.h"
#include "base/logging.h"
#include "base/string16.h"
#include "base/string_util.h"
-#include "chrome/common/zip_internal.h"
-#include "chrome/common/zip_reader.h"
+#include "components/zip/zip_internal.h"
+#include "components/zip/zip_reader.h"
#include "net/base/file_stream.h"
#if defined(USE_SYSTEM_MINIZIP)
diff --git a/chrome/common/zip.h b/components/zip/zip.h
index da8175f..a997c9c 100644
--- a/chrome/common/zip.h
+++ b/components/zip/zip.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_COMMON_ZIP_H_
-#define CHROME_COMMON_ZIP_H_
+#ifndef COMPONENTS_ZIP_ZIP_H_
+#define COMPONENTS_ZIP_ZIP_H_
#include "base/callback.h"
#include "base/files/file_path.h"
@@ -41,4 +41,4 @@ bool Unzip(const base::FilePath& zip_file, const base::FilePath& dest_dir);
} // namespace zip
-#endif // CHROME_COMMON_ZIP_H_
+#endif // COMPONENTS_ZIP_ZIP_H_
diff --git a/chrome/common/zip_internal.cc b/components/zip/zip_internal.cc
index 2f4021b..0efbcfe 100644
--- a/chrome/common/zip_internal.cc
+++ b/components/zip/zip_internal.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/common/zip.h"
+#include "components/zip/zip.h"
#include <algorithm>
@@ -10,9 +10,9 @@
#include "base/utf_string_conversions.h"
#if defined(USE_SYSTEM_MINIZIP)
+#include <minizip/ioapi.h>
#include <minizip/unzip.h>
#include <minizip/zip.h>
-#include <minizip/ioapi.h>
#else
#include "third_party/zlib/contrib/minizip/unzip.h"
#include "third_party/zlib/contrib/minizip/zip.h"
diff --git a/chrome/common/zip_internal.h b/components/zip/zip_internal.h
index c71f1a5..4f1ea4f 100644
--- a/chrome/common/zip_internal.h
+++ b/components/zip/zip_internal.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_COMMON_ZIP_INTERNAL_H_
-#define CHROME_COMMON_ZIP_INTERNAL_H_
+#ifndef COMPONENTS_ZIP_ZIP_INTERNAL_H_
+#define COMPONENTS_ZIP_ZIP_INTERNAL_H_
#if defined(OS_WIN)
#include <windows.h>
@@ -59,4 +59,4 @@ const int kZipBufSize = 8192;
} // namespace internal
} // namespace zip
-#endif // CHROME_COMMON_ZIP_INTERNAL_H_
+#endif // COMPONENTS_ZIP_ZIP_INTERNAL_H_
diff --git a/chrome/common/zip_reader.cc b/components/zip/zip_reader.cc
index eb2ba98..9cb3695 100644
--- a/chrome/common/zip_reader.cc
+++ b/components/zip/zip_reader.cc
@@ -2,13 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/common/zip_reader.h"
+#include "components/zip/zip_reader.h"
#include "base/file_util.h"
#include "base/logging.h"
#include "base/string_util.h"
#include "base/utf_string_conversions.h"
-#include "chrome/common/zip_internal.h"
+#include "components/zip/zip_internal.h"
#include "net/base/file_stream.h"
#if defined(USE_SYSTEM_MINIZIP)
diff --git a/chrome/common/zip_reader.h b/components/zip/zip_reader.h
index ff4d443..0bb171c 100644
--- a/chrome/common/zip_reader.h
+++ b/components/zip/zip_reader.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_COMMON_ZIP_READER_H_
-#define CHROME_COMMON_ZIP_READER_H_
+#ifndef COMPONENTS_ZIP_ZIP_READER_H_
+#define COMPONENTS_ZIP_ZIP_READER_H_
#include <string>
@@ -174,4 +174,4 @@ class ZipReader {
} // namespace zip
-#endif // CHROME_COMMON_ZIP_READER_H_
+#endif // COMPONENTS_ZIP_ZIP_READER_H_
diff --git a/chrome/common/zip_reader_unittest.cc b/components/zip/zip_reader_unittest.cc
index fdad562..0b4b554 100644
--- a/chrome/common/zip_reader_unittest.cc
+++ b/components/zip/zip_reader_unittest.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/common/zip_reader.h"
+#include "components/zip/zip_reader.h"
#include <set>
#include <string>
@@ -15,8 +15,7 @@
#include "base/platform_file.h"
#include "base/time.h"
#include "base/utf_string_conversions.h"
-#include "chrome/common/chrome_paths.h"
-#include "chrome/common/zip_internal.h"
+#include "components/zip/zip_internal.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/platform_test.h"
@@ -75,7 +74,7 @@ class ZipReaderTest : public PlatformTest {
ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
test_dir_ = temp_dir_.path();
- ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir_));
+ ASSERT_TRUE(GetTestDataDirectory(&test_data_dir_));
test_data_dir_ = test_data_dir_.AppendASCII("zip");
test_zip_file_ = test_data_dir_.AppendASCII("test.zip");
@@ -102,6 +101,17 @@ class ZipReaderTest : public PlatformTest {
PlatformTest::TearDown();
}
+ bool GetTestDataDirectory(base::FilePath* path) {
+ bool success = PathService::Get(base::DIR_SOURCE_ROOT, path);
+ EXPECT_TRUE(success);
+ if (!success)
+ return false;
+ *path = path->AppendASCII("components");
+ *path = path->AppendASCII("test");
+ *path = path->AppendASCII("data");
+ return true;
+ }
+
// The path to temporary directory used to contain the test operations.
base::FilePath test_dir_;
// The path to the test data directory where test.zip etc. are located.
diff --git a/chrome/common/zip_unittest.cc b/components/zip/zip_unittest.cc
index 4f02573..b314e8c 100644
--- a/chrome/common/zip_unittest.cc
+++ b/components/zip/zip_unittest.cc
@@ -6,12 +6,12 @@
#include <vector>
#include "base/file_util.h"
+#include "base/files/file_path.h"
#include "base/files/scoped_temp_dir.h"
#include "base/path_service.h"
#include "base/string_util.h"
-#include "chrome/common/chrome_paths.h"
-#include "chrome/common/zip.h"
-#include "chrome/common/zip_reader.h"
+#include "components/zip/zip.h"
+#include "components/zip/zip_reader.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/platform_test.h"
@@ -49,10 +49,21 @@ class ZipTest : public PlatformTest {
PlatformTest::TearDown();
}
+ bool GetTestDataDirectory(base::FilePath* path) {
+ bool success = PathService::Get(base::DIR_SOURCE_ROOT, path);
+ EXPECT_TRUE(success);
+ if (!success)
+ return false;
+ *path = path->AppendASCII("components");
+ *path = path->AppendASCII("test");
+ *path = path->AppendASCII("data");
+ return true;
+ }
+
void TestUnzipFile(const base::FilePath::StringType& filename,
bool expect_hidden_files) {
base::FilePath test_dir;
- ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_dir));
+ ASSERT_TRUE(GetTestDataDirectory(&test_dir));
test_dir = test_dir.AppendASCII("zip");
TestUnzipFile(test_dir.Append(filename), expect_hidden_files);
}
@@ -108,7 +119,7 @@ TEST_F(ZipTest, UnzipUncompressed) {
TEST_F(ZipTest, UnzipEvil) {
base::FilePath path;
- ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &path));
+ ASSERT_TRUE(GetTestDataDirectory(&path));
path = path.AppendASCII("zip").AppendASCII("evil.zip");
// Unzip the zip file into a sub directory of test_dir_ so evil.zip
// won't create a persistent file outside test_dir_ in case of a
@@ -123,7 +134,7 @@ TEST_F(ZipTest, UnzipEvil) {
TEST_F(ZipTest, UnzipEvil2) {
base::FilePath path;
- ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &path));
+ ASSERT_TRUE(GetTestDataDirectory(&path));
// The zip file contains an evil file with invalid UTF-8 in its file
// name.
path = path.AppendASCII("zip").AppendASCII("evil_via_invalid_utf8.zip");
@@ -138,7 +149,7 @@ TEST_F(ZipTest, UnzipEvil2) {
TEST_F(ZipTest, Zip) {
base::FilePath src_dir;
- ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &src_dir));
+ ASSERT_TRUE(GetTestDataDirectory(&src_dir));
src_dir = src_dir.AppendASCII("zip").AppendASCII("test");
base::ScopedTempDir temp_dir;
@@ -151,7 +162,7 @@ TEST_F(ZipTest, Zip) {
TEST_F(ZipTest, ZipIgnoreHidden) {
base::FilePath src_dir;
- ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &src_dir));
+ ASSERT_TRUE(GetTestDataDirectory(&src_dir));
src_dir = src_dir.AppendASCII("zip").AppendASCII("test");
base::ScopedTempDir temp_dir;
@@ -165,7 +176,7 @@ TEST_F(ZipTest, ZipIgnoreHidden) {
#if defined(OS_POSIX)
TEST_F(ZipTest, ZipFiles) {
base::FilePath src_dir;
- ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &src_dir));
+ ASSERT_TRUE(GetTestDataDirectory(&src_dir));
src_dir = src_dir.AppendASCII("zip").AppendASCII("test");
base::ScopedTempDir temp_dir;