OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/scoped_handle.h" | 8 #include "base/scoped_handle.h" |
9 #include "base/scoped_temp_dir.h" | 9 #include "base/scoped_temp_dir.h" |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
(...skipping 23 matching lines...) Expand all Loading... |
34 | 34 |
35 // The file to write our decoded images to, relative to the extension_path. | 35 // The file to write our decoded images to, relative to the extension_path. |
36 const char kDecodedImagesFilename[] = "DECODED_IMAGES"; | 36 const char kDecodedImagesFilename[] = "DECODED_IMAGES"; |
37 | 37 |
38 // The file to write our decoded message catalogs to, relative to the | 38 // The file to write our decoded message catalogs to, relative to the |
39 // extension_path. | 39 // extension_path. |
40 const char kDecodedMessageCatalogsFilename[] = "DECODED_MESSAGE_CATALOGS"; | 40 const char kDecodedMessageCatalogsFilename[] = "DECODED_MESSAGE_CATALOGS"; |
41 | 41 |
42 // Errors | 42 // Errors |
43 const char* kCouldNotCreateDirectoryError = | 43 const char* kCouldNotCreateDirectoryError = |
44 "Could not create directory for unzipping."; | 44 "Could not create directory for unzipping: "; |
45 const char* kCouldNotDecodeImageError = "Could not decode theme image."; | 45 const char* kCouldNotDecodeImageError = "Could not decode theme image."; |
46 const char* kCouldNotUnzipExtension = "Could not unzip extension."; | 46 const char* kCouldNotUnzipExtension = "Could not unzip extension."; |
47 const char* kPathNamesMustBeAbsoluteOrLocalError = | 47 const char* kPathNamesMustBeAbsoluteOrLocalError = |
48 "Path names must not be absolute or contain '..'."; | 48 "Path names must not be absolute or contain '..'."; |
49 | 49 |
50 // A limit to stop us passing dangerously large canvases to the browser. | 50 // A limit to stop us passing dangerously large canvases to the browser. |
51 const int kMaxImageCanvas = 4096 * 4096; | 51 const int kMaxImageCanvas = 4096 * 4096; |
52 | 52 |
53 } // namespace | 53 } // namespace |
54 | 54 |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 return true; | 143 return true; |
144 } | 144 } |
145 | 145 |
146 bool ExtensionUnpacker::Run() { | 146 bool ExtensionUnpacker::Run() { |
147 LOG(INFO) << "Installing extension " << extension_path_.value(); | 147 LOG(INFO) << "Installing extension " << extension_path_.value(); |
148 | 148 |
149 // <profile>/Extensions/INSTALL_TEMP/<version> | 149 // <profile>/Extensions/INSTALL_TEMP/<version> |
150 temp_install_dir_ = | 150 temp_install_dir_ = |
151 extension_path_.DirName().AppendASCII(kTempExtensionName); | 151 extension_path_.DirName().AppendASCII(kTempExtensionName); |
152 if (!file_util::CreateDirectory(temp_install_dir_)) { | 152 if (!file_util::CreateDirectory(temp_install_dir_)) { |
153 SetError(kCouldNotCreateDirectoryError); | 153 #if defined(OS_WIN) |
| 154 std::string dir_string = WideToUTF8(temp_install_dir_.value()); |
| 155 #else |
| 156 std::string dir_string = temp_install_dir_.value(); |
| 157 #endif |
| 158 SetError(kCouldNotCreateDirectoryError + dir_string); |
154 return false; | 159 return false; |
155 } | 160 } |
156 | 161 |
157 if (!Unzip(extension_path_, temp_install_dir_)) { | 162 if (!Unzip(extension_path_, temp_install_dir_)) { |
158 SetError(kCouldNotUnzipExtension); | 163 SetError(kCouldNotUnzipExtension); |
159 return false; | 164 return false; |
160 } | 165 } |
161 | 166 |
162 // Parse the manifest. | 167 // Parse the manifest. |
163 parsed_manifest_.reset(ReadManifest()); | 168 parsed_manifest_.reset(ReadManifest()); |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 | 301 |
297 parsed_catalogs_->Set(relative_path.DirName().ToWStringHack(), | 302 parsed_catalogs_->Set(relative_path.DirName().ToWStringHack(), |
298 root.release()); | 303 root.release()); |
299 | 304 |
300 return true; | 305 return true; |
301 } | 306 } |
302 | 307 |
303 void ExtensionUnpacker::SetError(const std::string &error) { | 308 void ExtensionUnpacker::SetError(const std::string &error) { |
304 error_message_ = error; | 309 error_message_ = error; |
305 } | 310 } |
OLD | NEW |