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" |
11 #include "content/public/utility/utility_thread.h" | 11 #include "content/public/utility/utility_thread.h" |
12 #include "extensions/common/constants.h" | 12 #include "extensions/common/constants.h" |
13 #include "extensions/common/extension.h" | 13 #include "extensions/common/extension.h" |
14 #include "extensions/common/extension_l10n_util.h" | 14 #include "extensions/common/extension_l10n_util.h" |
15 #include "extensions/common/extension_utility_messages.h" | 15 #include "extensions/common/extension_utility_messages.h" |
16 #include "extensions/common/extensions_client.h" | 16 #include "extensions/common/extensions_client.h" |
17 #include "extensions/common/manifest.h" | 17 #include "extensions/common/manifest.h" |
18 #include "extensions/common/update_manifest.h" | 18 #include "extensions/common/update_manifest.h" |
19 #include "extensions/strings/grit/extensions_strings.h" | 19 #include "extensions/strings/grit/extensions_strings.h" |
20 #include "extensions/utility/extension_extractor_filter.h" | |
20 #include "extensions/utility/unpacker.h" | 21 #include "extensions/utility/unpacker.h" |
21 #include "ipc/ipc_message.h" | 22 #include "ipc/ipc_message.h" |
22 #include "ipc/ipc_message_macros.h" | 23 #include "ipc/ipc_message_macros.h" |
23 #include "third_party/zlib/google/zip.h" | 24 #include "third_party/zlib/google/zip.h" |
24 #include "ui/base/l10n/l10n_util.h" | 25 #include "ui/base/l10n/l10n_util.h" |
25 #include "ui/base/ui_base_switches.h" | 26 #include "ui/base/ui_base_switches.h" |
26 | 27 |
27 namespace extensions { | 28 namespace extensions { |
28 | 29 |
29 namespace { | 30 namespace { |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
74 manifest.errors())); | 75 manifest.errors())); |
75 } else { | 76 } else { |
76 Send(new ExtensionUtilityHostMsg_ParseUpdateManifest_Succeeded( | 77 Send(new ExtensionUtilityHostMsg_ParseUpdateManifest_Succeeded( |
77 manifest.results())); | 78 manifest.results())); |
78 } | 79 } |
79 ReleaseProcessIfNeeded(); | 80 ReleaseProcessIfNeeded(); |
80 } | 81 } |
81 | 82 |
82 void UtilityHandler::OnUnzipToDir(const base::FilePath& zip_path, | 83 void UtilityHandler::OnUnzipToDir(const base::FilePath& zip_path, |
83 const base::FilePath& dir) { | 84 const base::FilePath& dir) { |
84 if (!zip::Unzip(zip_path, dir)) { | 85 scoped_refptr<ExtensionExtractorFilter> filter = |
86 new ExtensionExtractorFilter(); | |
87 const base::Callback<bool(const base::FilePath&)>& filter_cb = | |
88 base::Bind(&ExtensionExtractorFilter::ShouldExtractFile, filter); | |
89 if (!zip::UnzipWithFilterCallback(zip_path, dir, filter_cb)) { | |
Devlin
2016/09/08 21:10:16
This will silently ignore all .exe files. That's
meacer
2016/09/08 22:40:11
Done.
| |
85 Send(new ExtensionUtilityHostMsg_UnzipToDir_Failed( | 90 Send(new ExtensionUtilityHostMsg_UnzipToDir_Failed( |
86 std::string(kExtensionHandlerUnzipError))); | 91 std::string(kExtensionHandlerUnzipError))); |
87 } else { | 92 } else { |
88 Send(new ExtensionUtilityHostMsg_UnzipToDir_Succeeded(dir)); | 93 Send(new ExtensionUtilityHostMsg_UnzipToDir_Succeeded(dir)); |
89 } | 94 } |
90 | 95 |
91 ReleaseProcessIfNeeded(); | 96 ReleaseProcessIfNeeded(); |
92 } | 97 } |
93 | 98 |
94 void UtilityHandler::OnUnpackExtension(const base::FilePath& directory_path, | 99 void UtilityHandler::OnUnpackExtension(const base::FilePath& directory_path, |
(...skipping 11 matching lines...) Expand all Loading... | |
106 *unpacker.parsed_manifest())); | 111 *unpacker.parsed_manifest())); |
107 } else { | 112 } else { |
108 Send(new ExtensionUtilityHostMsg_UnpackExtension_Failed( | 113 Send(new ExtensionUtilityHostMsg_UnpackExtension_Failed( |
109 unpacker.error_message())); | 114 unpacker.error_message())); |
110 } | 115 } |
111 ReleaseProcessIfNeeded(); | 116 ReleaseProcessIfNeeded(); |
112 } | 117 } |
113 | 118 |
114 | 119 |
115 } // namespace extensions | 120 } // namespace extensions |
OLD | NEW |