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/base64.h" | 5 #include "base/base64.h" |
6 #include "base/bind.h" | 6 #include "base/bind.h" |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 void SetupUnpackerWithDirectory(const std::string& crx_name) { | 108 void SetupUnpackerWithDirectory(const std::string& crx_name) { |
109 base::ScopedTempDir temp_dir; | 109 base::ScopedTempDir temp_dir; |
110 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); | 110 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); |
111 base::FilePath crx_path = GetCrxFullPath(crx_name); | 111 base::FilePath crx_path = GetCrxFullPath(crx_name); |
112 ASSERT_TRUE(zip::Unzip(crx_path, temp_dir.path())); | 112 ASSERT_TRUE(zip::Unzip(crx_path, temp_dir.path())); |
113 | 113 |
114 std::string fake_id = crx_file::id_util::GenerateId(crx_name); | 114 std::string fake_id = crx_file::id_util::GenerateId(crx_name); |
115 std::string fake_public_key; | 115 std::string fake_public_key; |
116 base::Base64Encode(std::string(2048, 'k'), &fake_public_key); | 116 base::Base64Encode(std::string(2048, 'k'), &fake_public_key); |
117 base::ThreadTaskRunnerHandle::Get()->PostTask( | 117 base::ThreadTaskRunnerHandle::Get()->PostTask( |
118 FROM_HERE, base::Bind(&SandboxedUnpacker::StartWithDirectory, | 118 FROM_HERE, |
119 sandboxed_unpacker_.get(), fake_id, | 119 base::Bind(&SandboxedUnpacker::StartWithDirectory, sandboxed_unpacker_, |
120 fake_public_key, temp_dir.Take())); | 120 fake_id, fake_public_key, temp_dir.Take())); |
121 client_->WaitForUnpack(); | 121 client_->WaitForUnpack(); |
122 } | 122 } |
123 | 123 |
124 base::FilePath GetInstallPath() { | 124 base::FilePath GetInstallPath() { |
125 return client_->temp_dir().AppendASCII(kTempExtensionName); | 125 return client_->temp_dir().AppendASCII(kTempExtensionName); |
126 } | 126 } |
127 | 127 |
128 base::string16 GetInstallError() { return client_->unpack_err(); } | 128 base::string16 GetInstallError() { return client_->unpack_err(); } |
129 | 129 |
130 protected: | 130 protected: |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 EXPECT_EQ(base::string16(), GetInstallError()); | 182 EXPECT_EQ(base::string16(), GetInstallError()); |
183 } | 183 } |
184 | 184 |
185 TEST_F(SandboxedUnpackerTest, SkipHashCheck) { | 185 TEST_F(SandboxedUnpackerTest, SkipHashCheck) { |
186 SetupUnpacker("good_l10n.crx", "badhash"); | 186 SetupUnpacker("good_l10n.crx", "badhash"); |
187 // Check that there is no error message. | 187 // Check that there is no error message. |
188 EXPECT_EQ(base::string16(), GetInstallError()); | 188 EXPECT_EQ(base::string16(), GetInstallError()); |
189 } | 189 } |
190 | 190 |
191 } // namespace extensions | 191 } // namespace extensions |
OLD | NEW |