| 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 "chrome/browser/extensions/sandboxed_unpacker.h" | 5 #include "chrome/browser/extensions/sandboxed_unpacker.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 | 8 |
| 9 #include "base/base64.h" | 9 #include "base/base64.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 } | 175 } |
| 176 | 176 |
| 177 // Read the decoded images back from the file we saved them to. | 177 // Read the decoded images back from the file we saved them to. |
| 178 // |extension_path| is the path to the extension we unpacked that wrote the | 178 // |extension_path| is the path to the extension we unpacked that wrote the |
| 179 // data. Returns true on success. | 179 // data. Returns true on success. |
| 180 bool ReadImagesFromFile(const base::FilePath& extension_path, | 180 bool ReadImagesFromFile(const base::FilePath& extension_path, |
| 181 DecodedImages* images) { | 181 DecodedImages* images) { |
| 182 base::FilePath path = | 182 base::FilePath path = |
| 183 extension_path.AppendASCII(kDecodedImagesFilename); | 183 extension_path.AppendASCII(kDecodedImagesFilename); |
| 184 std::string file_str; | 184 std::string file_str; |
| 185 if (!file_util::ReadFileToString(path, &file_str)) | 185 if (!base::ReadFileToString(path, &file_str)) |
| 186 return false; | 186 return false; |
| 187 | 187 |
| 188 IPC::Message pickle(file_str.data(), file_str.size()); | 188 IPC::Message pickle(file_str.data(), file_str.size()); |
| 189 PickleIterator iter(pickle); | 189 PickleIterator iter(pickle); |
| 190 return IPC::ReadParam(&pickle, &iter, images); | 190 return IPC::ReadParam(&pickle, &iter, images); |
| 191 } | 191 } |
| 192 | 192 |
| 193 // Read the decoded message catalogs back from the file we saved them to. | 193 // Read the decoded message catalogs back from the file we saved them to. |
| 194 // |extension_path| is the path to the extension we unpacked that wrote the | 194 // |extension_path| is the path to the extension we unpacked that wrote the |
| 195 // data. Returns true on success. | 195 // data. Returns true on success. |
| 196 bool ReadMessageCatalogsFromFile(const base::FilePath& extension_path, | 196 bool ReadMessageCatalogsFromFile(const base::FilePath& extension_path, |
| 197 base::DictionaryValue* catalogs) { | 197 base::DictionaryValue* catalogs) { |
| 198 base::FilePath path = extension_path.AppendASCII( | 198 base::FilePath path = extension_path.AppendASCII( |
| 199 kDecodedMessageCatalogsFilename); | 199 kDecodedMessageCatalogsFilename); |
| 200 std::string file_str; | 200 std::string file_str; |
| 201 if (!file_util::ReadFileToString(path, &file_str)) | 201 if (!base::ReadFileToString(path, &file_str)) |
| 202 return false; | 202 return false; |
| 203 | 203 |
| 204 IPC::Message pickle(file_str.data(), file_str.size()); | 204 IPC::Message pickle(file_str.data(), file_str.size()); |
| 205 PickleIterator iter(pickle); | 205 PickleIterator iter(pickle); |
| 206 return IPC::ReadParam(&pickle, &iter, catalogs); | 206 return IPC::ReadParam(&pickle, &iter, catalogs); |
| 207 } | 207 } |
| 208 | 208 |
| 209 } // namespace | 209 } // namespace |
| 210 | 210 |
| 211 SandboxedUnpacker::SandboxedUnpacker( | 211 SandboxedUnpacker::SandboxedUnpacker( |
| (...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 824 | 824 |
| 825 void SandboxedUnpacker::Cleanup() { | 825 void SandboxedUnpacker::Cleanup() { |
| 826 DCHECK(unpacker_io_task_runner_->RunsTasksOnCurrentThread()); | 826 DCHECK(unpacker_io_task_runner_->RunsTasksOnCurrentThread()); |
| 827 if (!temp_dir_.Delete()) { | 827 if (!temp_dir_.Delete()) { |
| 828 LOG(WARNING) << "Can not delete temp directory at " | 828 LOG(WARNING) << "Can not delete temp directory at " |
| 829 << temp_dir_.path().value(); | 829 << temp_dir_.path().value(); |
| 830 } | 830 } |
| 831 } | 831 } |
| 832 | 832 |
| 833 } // namespace extensions | 833 } // namespace extensions |
| OLD | NEW |