| 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/unpacker.h" | 5 #include "chrome/common/extensions/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/files/scoped_temp_dir.h" | 10 #include "base/files/scoped_temp_dir.h" |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 std::vector<InstallWarning> warnings; | 190 std::vector<InstallWarning> warnings; |
| 191 if (!extension_file_util::ValidateExtension(extension.get(), | 191 if (!extension_file_util::ValidateExtension(extension.get(), |
| 192 &error, &warnings)) { | 192 &error, &warnings)) { |
| 193 SetError(error); | 193 SetError(error); |
| 194 return false; | 194 return false; |
| 195 } | 195 } |
| 196 extension->AddInstallWarnings(warnings); | 196 extension->AddInstallWarnings(warnings); |
| 197 | 197 |
| 198 // Decode any images that the browser needs to display. | 198 // Decode any images that the browser needs to display. |
| 199 std::set<base::FilePath> image_paths = | 199 std::set<base::FilePath> image_paths = |
| 200 extension_file_util::GetBrowserImagePaths(extension); | 200 extension_file_util::GetBrowserImagePaths(extension.get()); |
| 201 for (std::set<base::FilePath>::iterator it = image_paths.begin(); | 201 for (std::set<base::FilePath>::iterator it = image_paths.begin(); |
| 202 it != image_paths.end(); ++it) { | 202 it != image_paths.end(); |
| 203 ++it) { |
| 203 if (!AddDecodedImage(*it)) | 204 if (!AddDecodedImage(*it)) |
| 204 return false; // Error was already reported. | 205 return false; // Error was already reported. |
| 205 } | 206 } |
| 206 | 207 |
| 207 // Parse all message catalogs (if any). | 208 // Parse all message catalogs (if any). |
| 208 parsed_catalogs_.reset(new DictionaryValue); | 209 parsed_catalogs_.reset(new DictionaryValue); |
| 209 if (!LocaleInfo::GetDefaultLocale(extension).empty()) { | 210 if (!LocaleInfo::GetDefaultLocale(extension.get()).empty()) { |
| 210 if (!ReadAllMessageCatalogs(LocaleInfo::GetDefaultLocale(extension))) | 211 if (!ReadAllMessageCatalogs(LocaleInfo::GetDefaultLocale(extension.get()))) |
| 211 return false; // Error was already reported. | 212 return false; // Error was already reported. |
| 212 } | 213 } |
| 213 | 214 |
| 214 return true; | 215 return true; |
| 215 } | 216 } |
| 216 | 217 |
| 217 bool Unpacker::DumpImagesToFile() { | 218 bool Unpacker::DumpImagesToFile() { |
| 218 IPC::Message pickle; // We use a Message so we can use WriteParam. | 219 IPC::Message pickle; // We use a Message so we can use WriteParam. |
| 219 IPC::WriteParam(&pickle, decoded_images_); | 220 IPC::WriteParam(&pickle, decoded_images_); |
| 220 | 221 |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 335 | 336 |
| 336 void Unpacker::SetError(const std::string &error) { | 337 void Unpacker::SetError(const std::string &error) { |
| 337 SetUTF16Error(UTF8ToUTF16(error)); | 338 SetUTF16Error(UTF8ToUTF16(error)); |
| 338 } | 339 } |
| 339 | 340 |
| 340 void Unpacker::SetUTF16Error(const string16 &error) { | 341 void Unpacker::SetUTF16Error(const string16 &error) { |
| 341 error_message_ = error; | 342 error_message_ = error; |
| 342 } | 343 } |
| 343 | 344 |
| 344 } // namespace extensions | 345 } // namespace extensions |
| OLD | NEW |