| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/utility/utility_handler.h" | 5 #include "extensions/utility/utility_handler.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
| 9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
| 10 #include "base/i18n/rtl.h" | 10 #include "base/i18n/rtl.h" |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 } | 92 } |
| 93 | 93 |
| 94 void UtilityHandler::OnUnpackExtension( | 94 void UtilityHandler::OnUnpackExtension( |
| 95 const base::FilePath& extension_path, | 95 const base::FilePath& extension_path, |
| 96 const std::string& extension_id, | 96 const std::string& extension_id, |
| 97 int location, | 97 int location, |
| 98 int creation_flags) { | 98 int creation_flags) { |
| 99 CHECK_GT(location, Manifest::INVALID_LOCATION); | 99 CHECK_GT(location, Manifest::INVALID_LOCATION); |
| 100 CHECK_LT(location, Manifest::NUM_LOCATIONS); | 100 CHECK_LT(location, Manifest::NUM_LOCATIONS); |
| 101 DCHECK(ExtensionsClient::Get()); | 101 DCHECK(ExtensionsClient::Get()); |
| 102 content::UtilityThread::Get()->EnsureBlinkInitialized(); |
| 102 base::FilePath working_dir = extension_path.DirName(); | 103 base::FilePath working_dir = extension_path.DirName(); |
| 103 base::FilePath unzipped_dir = working_dir.AppendASCII(kTempExtensionName); | 104 base::FilePath unzipped_dir = working_dir.AppendASCII(kTempExtensionName); |
| 104 base::string16 error; | 105 base::string16 error; |
| 105 if (!base::CreateDirectory(unzipped_dir)) { | 106 if (!base::CreateDirectory(unzipped_dir)) { |
| 106 Send(new ExtensionUtilityHostMsg_UnpackExtension_Failed( | 107 Send(new ExtensionUtilityHostMsg_UnpackExtension_Failed( |
| 107 l10n_util::GetStringFUTF16( | 108 l10n_util::GetStringFUTF16( |
| 108 IDS_EXTENSION_PACKAGE_DIRECTORY_ERROR, | 109 IDS_EXTENSION_PACKAGE_DIRECTORY_ERROR, |
| 109 base::i18n::GetDisplayStringInLTRDirectionality( | 110 base::i18n::GetDisplayStringInLTRDirectionality( |
| 110 unzipped_dir.LossyDisplayName())))); | 111 unzipped_dir.LossyDisplayName())))); |
| 111 } else if (!zip::Unzip(extension_path, unzipped_dir)) { | 112 } else if (!zip::Unzip(extension_path, unzipped_dir)) { |
| 112 Send(new ExtensionUtilityHostMsg_UnpackExtension_Failed( | 113 Send(new ExtensionUtilityHostMsg_UnpackExtension_Failed( |
| 113 l10n_util::GetStringUTF16(IDS_EXTENSION_PACKAGE_UNZIP_ERROR))); | 114 l10n_util::GetStringUTF16(IDS_EXTENSION_PACKAGE_UNZIP_ERROR))); |
| 114 } else { | 115 } else { |
| 115 Unpacker unpacker(working_dir, unzipped_dir, extension_id, | 116 Unpacker unpacker(working_dir, unzipped_dir, extension_id, |
| 116 static_cast<Manifest::Location>(location), | 117 static_cast<Manifest::Location>(location), |
| 117 creation_flags); | 118 creation_flags); |
| 118 if (unpacker.Run()) { | 119 if (unpacker.Run()) { |
| 119 Send(new ExtensionUtilityHostMsg_UnpackExtension_Succeeded( | 120 Send(new ExtensionUtilityHostMsg_UnpackExtension_Succeeded( |
| 120 *unpacker.parsed_manifest())); | 121 *unpacker.parsed_manifest())); |
| 121 } else { | 122 } else { |
| 122 Send(new ExtensionUtilityHostMsg_UnpackExtension_Failed( | 123 Send(new ExtensionUtilityHostMsg_UnpackExtension_Failed( |
| 123 unpacker.error_message())); | 124 unpacker.error_message())); |
| 124 } | 125 } |
| 125 } | 126 } |
| 126 ReleaseProcessIfNeeded(); | 127 ReleaseProcessIfNeeded(); |
| 127 } | 128 } |
| 128 | 129 |
| 129 | 130 |
| 130 } // namespace extensions | 131 } // namespace extensions |
| OLD | NEW |