OLD | NEW |
---|---|
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/path_service.h" | 6 #include "base/path_service.h" |
7 #include "base/ref_counted.h" | 7 #include "base/ref_counted.h" |
8 #include "base/scoped_temp_dir.h" | 8 #include "base/scoped_temp_dir.h" |
9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
10 #include "chrome/browser/extensions/sandboxed_extension_unpacker.h" | 10 #include "chrome/browser/extensions/sandboxed_extension_unpacker.h" |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
93 // Build a temp area where the extension will be unpacked. | 93 // Build a temp area where the extension will be unpacked. |
94 ASSERT_TRUE(PathService::Get(base::DIR_TEMP, &temp_dir_)); | 94 ASSERT_TRUE(PathService::Get(base::DIR_TEMP, &temp_dir_)); |
95 temp_dir_ = temp_dir_.AppendASCII("sandboxed_extension_unpacker_test_Temp"); | 95 temp_dir_ = temp_dir_.AppendASCII("sandboxed_extension_unpacker_test_Temp"); |
96 file_util::CreateDirectory(temp_dir_); | 96 file_util::CreateDirectory(temp_dir_); |
97 | 97 |
98 sandboxed_unpacker_ = | 98 sandboxed_unpacker_ = |
99 new SandboxedExtensionUnpacker(crx_path, temp_dir_, NULL, client_); | 99 new SandboxedExtensionUnpacker(crx_path, temp_dir_, NULL, client_); |
100 // Hack since SandboxedExtensionUnpacker gets its background thread id from | 100 // Hack since SandboxedExtensionUnpacker gets its background thread id from |
101 // the Start call, but we don't call it here. | 101 // the Start call, but we don't call it here. |
102 sandboxed_unpacker_->thread_identifier_ = BrowserThread::FILE; | 102 sandboxed_unpacker_->thread_identifier_ = BrowserThread::FILE; |
103 PrepareUnpackerEnv(); | 103 EXPECT_TRUE(PrepareUnpackerEnv()); |
104 } | 104 } |
105 | 105 |
106 void PrepareUnpackerEnv() { | 106 bool PrepareUnpackerEnv() { |
Paweł Hajdan Jr.
2011/01/11 13:01:10
nit: It may be useful to propagate WARN_UNUSED_RES
cbentzel
2011/01/11 19:56:38
I'll hold off on this - I don't have as much conte
| |
107 sandboxed_unpacker_->extension_root_ = | 107 sandboxed_unpacker_->extension_root_ = |
108 install_dir_.AppendASCII(extension_filenames::kTempExtensionName); | 108 install_dir_.AppendASCII(extension_filenames::kTempExtensionName); |
109 | 109 |
110 sandboxed_unpacker_->temp_dir_.Set(install_dir_); | 110 if (!sandboxed_unpacker_->temp_dir_.Set(install_dir_)) |
111 return false; | |
111 sandboxed_unpacker_->public_key_ = | 112 sandboxed_unpacker_->public_key_ = |
112 "ocnapchkplbmjmpfehjocmjnipfmogkh"; | 113 "ocnapchkplbmjmpfehjocmjnipfmogkh"; |
114 return true; | |
113 } | 115 } |
114 | 116 |
115 void OnUnpackSucceeded() { | 117 void OnUnpackSucceeded() { |
116 sandboxed_unpacker_->OnUnpackExtensionSucceeded( | 118 sandboxed_unpacker_->OnUnpackExtensionSucceeded( |
117 *unpacker_->parsed_manifest()); | 119 *unpacker_->parsed_manifest()); |
118 } | 120 } |
119 | 121 |
120 FilePath GetInstallPath() { | 122 FilePath GetInstallPath() { |
121 return install_dir_.AppendASCII(extension_filenames::kTempExtensionName); | 123 return install_dir_.AppendASCII(extension_filenames::kTempExtensionName); |
122 } | 124 } |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
200 OnUnpackSucceeded(); | 202 OnUnpackSucceeded(); |
201 | 203 |
202 // Check that there is newer _locales/en_US/messages.json file. | 204 // Check that there is newer _locales/en_US/messages.json file. |
203 base::PlatformFileInfo new_info; | 205 base::PlatformFileInfo new_info; |
204 EXPECT_TRUE(file_util::GetFileInfo(messages_file, &new_info)); | 206 EXPECT_TRUE(file_util::GetFileInfo(messages_file, &new_info)); |
205 | 207 |
206 EXPECT_TRUE(new_info.last_modified > old_info.last_modified); | 208 EXPECT_TRUE(new_info.last_modified > old_info.last_modified); |
207 | 209 |
208 ASSERT_TRUE(TempFilesRemoved()); | 210 ASSERT_TRUE(TempFilesRemoved()); |
209 } | 211 } |
OLD | NEW |