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 "extensions/browser/sandboxed_unpacker.h" | 5 #include "extensions/browser/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 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 // |extension_path| is the path to the extension we unpacked that wrote the | 183 // |extension_path| is the path to the extension we unpacked that wrote the |
184 // data. Returns true on success. | 184 // data. Returns true on success. |
185 bool ReadImagesFromFile(const base::FilePath& extension_path, | 185 bool ReadImagesFromFile(const base::FilePath& extension_path, |
186 DecodedImages* images) { | 186 DecodedImages* images) { |
187 base::FilePath path = extension_path.AppendASCII(kDecodedImagesFilename); | 187 base::FilePath path = extension_path.AppendASCII(kDecodedImagesFilename); |
188 std::string file_str; | 188 std::string file_str; |
189 if (!base::ReadFileToString(path, &file_str)) | 189 if (!base::ReadFileToString(path, &file_str)) |
190 return false; | 190 return false; |
191 | 191 |
192 IPC::Message pickle(file_str.data(), file_str.size()); | 192 IPC::Message pickle(file_str.data(), file_str.size()); |
193 PickleIterator iter(pickle); | 193 base::PickleIterator iter(pickle); |
194 return IPC::ReadParam(&pickle, &iter, images); | 194 return IPC::ReadParam(&pickle, &iter, images); |
195 } | 195 } |
196 | 196 |
197 // Read the decoded message catalogs back from the file we saved them to. | 197 // Read the decoded message catalogs back from the file we saved them to. |
198 // |extension_path| is the path to the extension we unpacked that wrote the | 198 // |extension_path| is the path to the extension we unpacked that wrote the |
199 // data. Returns true on success. | 199 // data. Returns true on success. |
200 bool ReadMessageCatalogsFromFile(const base::FilePath& extension_path, | 200 bool ReadMessageCatalogsFromFile(const base::FilePath& extension_path, |
201 base::DictionaryValue* catalogs) { | 201 base::DictionaryValue* catalogs) { |
202 base::FilePath path = | 202 base::FilePath path = |
203 extension_path.AppendASCII(kDecodedMessageCatalogsFilename); | 203 extension_path.AppendASCII(kDecodedMessageCatalogsFilename); |
204 std::string file_str; | 204 std::string file_str; |
205 if (!base::ReadFileToString(path, &file_str)) | 205 if (!base::ReadFileToString(path, &file_str)) |
206 return false; | 206 return false; |
207 | 207 |
208 IPC::Message pickle(file_str.data(), file_str.size()); | 208 IPC::Message pickle(file_str.data(), file_str.size()); |
209 PickleIterator iter(pickle); | 209 base::PickleIterator iter(pickle); |
210 return IPC::ReadParam(&pickle, &iter, catalogs); | 210 return IPC::ReadParam(&pickle, &iter, catalogs); |
211 } | 211 } |
212 | 212 |
213 } // namespace | 213 } // namespace |
214 | 214 |
215 SandboxedUnpackerClient::SandboxedUnpackerClient() | 215 SandboxedUnpackerClient::SandboxedUnpackerClient() |
216 : RefCountedDeleteOnMessageLoop<SandboxedUnpackerClient>( | 216 : RefCountedDeleteOnMessageLoop<SandboxedUnpackerClient>( |
217 content::BrowserThread::GetMessageLoopProxyForThread( | 217 content::BrowserThread::GetMessageLoopProxyForThread( |
218 content::BrowserThread::UI)) { | 218 content::BrowserThread::UI)) { |
219 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 219 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
(...skipping 633 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
853 | 853 |
854 void SandboxedUnpacker::Cleanup() { | 854 void SandboxedUnpacker::Cleanup() { |
855 DCHECK(unpacker_io_task_runner_->RunsTasksOnCurrentThread()); | 855 DCHECK(unpacker_io_task_runner_->RunsTasksOnCurrentThread()); |
856 if (!temp_dir_.Delete()) { | 856 if (!temp_dir_.Delete()) { |
857 LOG(WARNING) << "Can not delete temp directory at " | 857 LOG(WARNING) << "Can not delete temp directory at " |
858 << temp_dir_.path().value(); | 858 << temp_dir_.path().value(); |
859 } | 859 } |
860 } | 860 } |
861 | 861 |
862 } // namespace extensions | 862 } // namespace extensions |
OLD | NEW |