| 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 "base/file_util.h" | 5 #include "base/file_util.h" |
| 6 #include "base/files/scoped_temp_dir.h" | 6 #include "base/files/scoped_temp_dir.h" |
| 7 #include "base/memory/ref_counted.h" | 7 #include "base/memory/ref_counted.h" |
| 8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
| 9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 | 88 |
| 89 // Try bots won't let us write into DIR_TEST_DATA, so we have to write the | 89 // Try bots won't let us write into DIR_TEST_DATA, so we have to write the |
| 90 // CRX to the temp directory, and create a subdirectory into which to | 90 // CRX to the temp directory, and create a subdirectory into which to |
| 91 // unpack it. | 91 // unpack it. |
| 92 FilePath crx_path = temp_dir_.path().AppendASCII(crx_name); | 92 FilePath crx_path = temp_dir_.path().AppendASCII(crx_name); |
| 93 ASSERT_TRUE(file_util::CopyFile(original_path, crx_path)) << | 93 ASSERT_TRUE(file_util::CopyFile(original_path, crx_path)) << |
| 94 "Original path: " << original_path.value() << | 94 "Original path: " << original_path.value() << |
| 95 ", Crx path: " << crx_path.value(); | 95 ", Crx path: " << crx_path.value(); |
| 96 | 96 |
| 97 unpacker_.reset(new Unpacker( | 97 unpacker_.reset(new Unpacker( |
| 98 crx_path, std::string(), Extension::INTERNAL, Extension::NO_FLAGS)); | 98 crx_path, std::string(), Manifest::INTERNAL, Extension::NO_FLAGS)); |
| 99 | 99 |
| 100 // Build a temp area where the extension will be unpacked. | 100 // Build a temp area where the extension will be unpacked. |
| 101 temp_path_ = | 101 temp_path_ = |
| 102 temp_dir_.path().AppendASCII("sandboxed_unpacker_test_Temp"); | 102 temp_dir_.path().AppendASCII("sandboxed_unpacker_test_Temp"); |
| 103 ASSERT_TRUE(file_util::CreateDirectory(temp_path_)); | 103 ASSERT_TRUE(file_util::CreateDirectory(temp_path_)); |
| 104 | 104 |
| 105 sandboxed_unpacker_ = | 105 sandboxed_unpacker_ = |
| 106 new SandboxedUnpacker( | 106 new SandboxedUnpacker( |
| 107 crx_path, false, Extension::INTERNAL, Extension::NO_FLAGS, | 107 crx_path, false, Manifest::INTERNAL, Extension::NO_FLAGS, |
| 108 extensions_dir_.path(), | 108 extensions_dir_.path(), |
| 109 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE), | 109 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE), |
| 110 client_); | 110 client_); |
| 111 | 111 |
| 112 EXPECT_TRUE(PrepareUnpackerEnv()); | 112 EXPECT_TRUE(PrepareUnpackerEnv()); |
| 113 } | 113 } |
| 114 | 114 |
| 115 bool PrepareUnpackerEnv() { | 115 bool PrepareUnpackerEnv() { |
| 116 sandboxed_unpacker_->extension_root_ = | 116 sandboxed_unpacker_->extension_root_ = |
| 117 temp_dir_.path().AppendASCII(extension_filenames::kTempExtensionName); | 117 temp_dir_.path().AppendASCII(extension_filenames::kTempExtensionName); |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 // Check that there is newer _locales/en_US/messages.json file. | 215 // Check that there is newer _locales/en_US/messages.json file. |
| 216 base::PlatformFileInfo new_info; | 216 base::PlatformFileInfo new_info; |
| 217 EXPECT_TRUE(file_util::GetFileInfo(messages_file, &new_info)); | 217 EXPECT_TRUE(file_util::GetFileInfo(messages_file, &new_info)); |
| 218 | 218 |
| 219 EXPECT_TRUE(new_info.last_modified > old_info.last_modified); | 219 EXPECT_TRUE(new_info.last_modified > old_info.last_modified); |
| 220 | 220 |
| 221 ASSERT_TRUE(TempFilesRemoved()); | 221 ASSERT_TRUE(TempFilesRemoved()); |
| 222 } | 222 } |
| 223 | 223 |
| 224 } // namespace extensions | 224 } // namespace extensions |
| OLD | NEW |