| 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/common/extensions/extension_unpacker.h" | 5 #include "chrome/common/extensions/extension_unpacker.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 | 8 |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/json/json_file_value_serializer.h" | 10 #include "base/json/json_file_value_serializer.h" |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 | 245 |
| 246 // static | 246 // static |
| 247 bool ExtensionUnpacker::ReadImagesFromFile(const FilePath& extension_path, | 247 bool ExtensionUnpacker::ReadImagesFromFile(const FilePath& extension_path, |
| 248 DecodedImages* images) { | 248 DecodedImages* images) { |
| 249 FilePath path = extension_path.AppendASCII(filenames::kDecodedImagesFilename); | 249 FilePath path = extension_path.AppendASCII(filenames::kDecodedImagesFilename); |
| 250 std::string file_str; | 250 std::string file_str; |
| 251 if (!file_util::ReadFileToString(path, &file_str)) | 251 if (!file_util::ReadFileToString(path, &file_str)) |
| 252 return false; | 252 return false; |
| 253 | 253 |
| 254 IPC::Message pickle(file_str.data(), file_str.size()); | 254 IPC::Message pickle(file_str.data(), file_str.size()); |
| 255 void* iter = NULL; | 255 PickleIterator iter(pickle); |
| 256 return IPC::ReadParam(&pickle, &iter, images); | 256 return IPC::ReadParam(&pickle, &iter, images); |
| 257 } | 257 } |
| 258 | 258 |
| 259 // static | 259 // static |
| 260 bool ExtensionUnpacker::ReadMessageCatalogsFromFile( | 260 bool ExtensionUnpacker::ReadMessageCatalogsFromFile( |
| 261 const FilePath& extension_path, DictionaryValue* catalogs) { | 261 const FilePath& extension_path, DictionaryValue* catalogs) { |
| 262 FilePath path = extension_path.AppendASCII( | 262 FilePath path = extension_path.AppendASCII( |
| 263 filenames::kDecodedMessageCatalogsFilename); | 263 filenames::kDecodedMessageCatalogsFilename); |
| 264 std::string file_str; | 264 std::string file_str; |
| 265 if (!file_util::ReadFileToString(path, &file_str)) | 265 if (!file_util::ReadFileToString(path, &file_str)) |
| 266 return false; | 266 return false; |
| 267 | 267 |
| 268 IPC::Message pickle(file_str.data(), file_str.size()); | 268 IPC::Message pickle(file_str.data(), file_str.size()); |
| 269 void* iter = NULL; | 269 PickleIterator iter(pickle); |
| 270 return IPC::ReadParam(&pickle, &iter, catalogs); | 270 return IPC::ReadParam(&pickle, &iter, catalogs); |
| 271 } | 271 } |
| 272 | 272 |
| 273 bool ExtensionUnpacker::AddDecodedImage(const FilePath& path) { | 273 bool ExtensionUnpacker::AddDecodedImage(const FilePath& path) { |
| 274 // Make sure it's not referencing a file outside the extension's subdir. | 274 // Make sure it's not referencing a file outside the extension's subdir. |
| 275 if (path.IsAbsolute() || PathContainsParentDirectory(path)) { | 275 if (path.IsAbsolute() || PathContainsParentDirectory(path)) { |
| 276 SetError(kPathNamesMustBeAbsoluteOrLocalError); | 276 SetError(kPathNamesMustBeAbsoluteOrLocalError); |
| 277 return false; | 277 return false; |
| 278 } | 278 } |
| 279 | 279 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 319 return false; | 319 return false; |
| 320 } | 320 } |
| 321 parsed_catalogs_->Set(dir_name, root.release()); | 321 parsed_catalogs_->Set(dir_name, root.release()); |
| 322 | 322 |
| 323 return true; | 323 return true; |
| 324 } | 324 } |
| 325 | 325 |
| 326 void ExtensionUnpacker::SetError(const std::string &error) { | 326 void ExtensionUnpacker::SetError(const std::string &error) { |
| 327 error_message_ = UTF8ToUTF16(error); | 327 error_message_ = UTF8ToUTF16(error); |
| 328 } | 328 } |
| OLD | NEW |