| 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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 Send(new ExtensionUtilityHostMsg_ParseUpdateManifest_Succeeded( | 76 Send(new ExtensionUtilityHostMsg_ParseUpdateManifest_Succeeded( |
| 77 manifest.results())); | 77 manifest.results())); |
| 78 } | 78 } |
| 79 ReleaseProcessIfNeeded(); | 79 ReleaseProcessIfNeeded(); |
| 80 } | 80 } |
| 81 | 81 |
| 82 void UtilityHandler::OnUnzipToDir(const base::FilePath& zip_path, | 82 void UtilityHandler::OnUnzipToDir(const base::FilePath& zip_path, |
| 83 const base::FilePath& dir) { | 83 const base::FilePath& dir) { |
| 84 // First extract only the manifest to determine the extension type. | 84 // First extract only the manifest to determine the extension type. |
| 85 if (!zip::UnzipWithFilterCallback(zip_path, dir, | 85 if (!zip::UnzipWithFilterCallback(zip_path, dir, |
| 86 base::Bind(&Unpacker::IsManifestFile))) { | 86 base::Bind(&Unpacker::IsManifestFile), |
| 87 false /* log_skipped_files */)) { |
| 87 Send(new ExtensionUtilityHostMsg_UnzipToDir_Failed( | 88 Send(new ExtensionUtilityHostMsg_UnzipToDir_Failed( |
| 88 std::string(kExtensionHandlerUnzipError))); | 89 std::string(kExtensionHandlerUnzipError))); |
| 89 ReleaseProcessIfNeeded(); | 90 ReleaseProcessIfNeeded(); |
| 90 return; | 91 return; |
| 91 } | 92 } |
| 92 | 93 |
| 93 // Load the manifest. | 94 // Load the manifest. |
| 94 std::string error; | 95 std::string error; |
| 95 std::unique_ptr<base::DictionaryValue> dict = | 96 std::unique_ptr<base::DictionaryValue> dict = |
| 96 Unpacker::ReadManifest(dir, &error); | 97 Unpacker::ReadManifest(dir, &error); |
| 97 if (!dict.get()) { | 98 if (!dict.get()) { |
| 98 Send(new ExtensionUtilityHostMsg_UnzipToDir_Failed( | 99 Send(new ExtensionUtilityHostMsg_UnzipToDir_Failed( |
| 99 std::string(kExtensionHandlerUnzipError))); | 100 std::string(kExtensionHandlerUnzipError))); |
| 100 ReleaseProcessIfNeeded(); | 101 ReleaseProcessIfNeeded(); |
| 101 return; | 102 return; |
| 102 } | 103 } |
| 103 | 104 |
| 104 Manifest manifest(Manifest::INTERNAL, std::move(dict)); | 105 Manifest manifest(Manifest::INTERNAL, std::move(dict)); |
| 105 base::Callback<bool(const base::FilePath&)> filetype_filter_cb = | 106 base::Callback<bool(const base::FilePath&)> filetype_filter_cb = |
| 106 base::Bind(&Unpacker::ShouldExtractFile, manifest.is_theme()); | 107 base::Bind(&Unpacker::ShouldExtractFile, manifest.is_theme()); |
| 107 | 108 |
| 108 // TODO(crbug.com/645263): This silently ignores blocked file types. | 109 // TODO(crbug.com/645263): This silently ignores blocked file types. |
| 109 // Add install warnings. | 110 // Add install warnings. |
| 110 if (!zip::UnzipWithFilterCallback(zip_path, dir, filetype_filter_cb)) { | 111 if (!zip::UnzipWithFilterCallback(zip_path, dir, filetype_filter_cb, |
| 112 true /* log_skipped_files */)) { |
| 111 Send(new ExtensionUtilityHostMsg_UnzipToDir_Failed( | 113 Send(new ExtensionUtilityHostMsg_UnzipToDir_Failed( |
| 112 std::string(kExtensionHandlerUnzipError))); | 114 std::string(kExtensionHandlerUnzipError))); |
| 113 } else { | 115 } else { |
| 114 Send(new ExtensionUtilityHostMsg_UnzipToDir_Succeeded(dir)); | 116 Send(new ExtensionUtilityHostMsg_UnzipToDir_Succeeded(dir)); |
| 115 } | 117 } |
| 116 ReleaseProcessIfNeeded(); | 118 ReleaseProcessIfNeeded(); |
| 117 } | 119 } |
| 118 | 120 |
| 119 void UtilityHandler::OnUnpackExtension(const base::FilePath& directory_path, | 121 void UtilityHandler::OnUnpackExtension(const base::FilePath& directory_path, |
| 120 const std::string& extension_id, | 122 const std::string& extension_id, |
| (...skipping 10 matching lines...) Expand all Loading... |
| 131 *unpacker.parsed_manifest())); | 133 *unpacker.parsed_manifest())); |
| 132 } else { | 134 } else { |
| 133 Send(new ExtensionUtilityHostMsg_UnpackExtension_Failed( | 135 Send(new ExtensionUtilityHostMsg_UnpackExtension_Failed( |
| 134 unpacker.error_message())); | 136 unpacker.error_message())); |
| 135 } | 137 } |
| 136 ReleaseProcessIfNeeded(); | 138 ReleaseProcessIfNeeded(); |
| 137 } | 139 } |
| 138 | 140 |
| 139 | 141 |
| 140 } // namespace extensions | 142 } // namespace extensions |
| OLD | NEW |