diff options
author | aa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-17 20:36:05 +0000 |
---|---|---|
committer | aa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-17 20:36:05 +0000 |
commit | 6d37714b0e46f65b0418bc3d85f2d296bbbbdfa9 (patch) | |
tree | 33624b0b1e8397835ffec7c05eea03e3067870e0 /chrome/common/extensions/extension_unpacker.cc | |
parent | afbd35400d2a2ab034acb20584092aa71a808e72 (diff) | |
download | chromium_src-6d37714b0e46f65b0418bc3d85f2d296bbbbdfa9.zip chromium_src-6d37714b0e46f65b0418bc3d85f2d296bbbbdfa9.tar.gz chromium_src-6d37714b0e46f65b0418bc3d85f2d296bbbbdfa9.tar.bz2 |
This looks like it was causing the pipe to sometimes overfill.
BUG=38220
TEST=See bug
Review URL: http://codereview.chromium.org/1003004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@41873 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/extensions/extension_unpacker.cc')
-rw-r--r-- | chrome/common/extensions/extension_unpacker.cc | 41 |
1 files changed, 37 insertions, 4 deletions
diff --git a/chrome/common/extensions/extension_unpacker.cc b/chrome/common/extensions/extension_unpacker.cc index f79395c..8e5e6b6 100644 --- a/chrome/common/extensions/extension_unpacker.cc +++ b/chrome/common/extensions/extension_unpacker.cc @@ -35,6 +35,10 @@ const char kTempExtensionName[] = "TEMP_INSTALL"; // The file to write our decoded images to, relative to the extension_path. const char kDecodedImagesFilename[] = "DECODED_IMAGES"; +// The file to write our decoded message catalogs to, relative to the +// extension_path. +const char kDecodedMessageCatalogsFilename[] = "DECODED_MESSAGE_CATALOGS"; + // Errors const char* kCouldNotCreateDirectoryError = "Could not create directory for unzipping."; @@ -210,6 +214,21 @@ bool ExtensionUnpacker::DumpImagesToFile() { return true; } +bool ExtensionUnpacker::DumpMessageCatalogsToFile() { + IPC::Message pickle; + IPC::WriteParam(&pickle, *parsed_catalogs_.get()); + + FilePath path = extension_path_.DirName().AppendASCII( + kDecodedMessageCatalogsFilename); + if (!file_util::WriteFile(path, static_cast<const char*>(pickle.data()), + pickle.size())) { + SetError("Could not write message catalogs to disk."); + return false; + } + + return true; +} + // static bool ExtensionUnpacker::ReadImagesFromFile(const FilePath& extension_path, DecodedImages* images) { @@ -223,6 +242,19 @@ bool ExtensionUnpacker::ReadImagesFromFile(const FilePath& extension_path, return IPC::ReadParam(&pickle, &iter, images); } +// static +bool ExtensionUnpacker::ReadMessageCatalogsFromFile( + const FilePath& extension_path, DictionaryValue* catalogs) { + FilePath path = extension_path.AppendASCII(kDecodedMessageCatalogsFilename); + std::string file_str; + if (!file_util::ReadFileToString(path, &file_str)) + return false; + + IPC::Message pickle(file_str.data(), file_str.size()); + void* iter = NULL; + return IPC::ReadParam(&pickle, &iter, catalogs); +} + bool ExtensionUnpacker::AddDecodedImage(const FilePath& path) { // Make sure it's not referencing a file outside the extension's subdir. if (path.IsAbsolute() || PathContainsParentDirectory(path)) { @@ -243,9 +275,9 @@ bool ExtensionUnpacker::AddDecodedImage(const FilePath& path) { bool ExtensionUnpacker::ReadMessageCatalog(const FilePath& message_path) { std::string error; JSONFileValueSerializer serializer(message_path); - DictionaryValue* root = - static_cast<DictionaryValue*>(serializer.Deserialize(&error)); - if (!root) { + scoped_ptr<DictionaryValue> root( + static_cast<DictionaryValue*>(serializer.Deserialize(&error))); + if (!root.get()) { std::string messages_file = WideToASCII(message_path.ToWStringHack()); if (error.empty()) { // If file is missing, Deserialize will fail with empty error. @@ -262,7 +294,8 @@ bool ExtensionUnpacker::ReadMessageCatalog(const FilePath& message_path) { if (!temp_install_dir_.AppendRelativePath(message_path, &relative_path)) NOTREACHED(); - parsed_catalogs_->Set(relative_path.DirName().ToWStringHack(), root); + parsed_catalogs_->Set(relative_path.DirName().ToWStringHack(), + root.release()); return true; } |