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 "content/public/utility/utility_thread.h" | 9 #include "content/public/utility/utility_thread.h" |
10 #include "extensions/common/constants.h" | 10 #include "extensions/common/constants.h" |
11 #include "extensions/common/extension_l10n_util.h" | 11 #include "extensions/common/extension_l10n_util.h" |
12 #include "extensions/common/extension_unpacker.mojom.h" | 12 #include "extensions/common/extension_unpacker.mojom.h" |
13 #include "extensions/common/extensions_client.h" | 13 #include "extensions/common/extensions_client.h" |
| 14 #include "extensions/common/features/feature_channel.h" |
| 15 #include "extensions/common/features/feature_session_type.h" |
14 #include "extensions/common/manifest.h" | 16 #include "extensions/common/manifest.h" |
15 #include "extensions/common/manifest_parser.mojom.h" | 17 #include "extensions/common/manifest_parser.mojom.h" |
16 #include "extensions/common/update_manifest.h" | 18 #include "extensions/common/update_manifest.h" |
17 #include "extensions/strings/grit/extensions_strings.h" | 19 #include "extensions/strings/grit/extensions_strings.h" |
18 #include "extensions/utility/unpacker.h" | 20 #include "extensions/utility/unpacker.h" |
19 #include "mojo/public/cpp/bindings/strong_binding.h" | 21 #include "mojo/public/cpp/bindings/strong_binding.h" |
20 #include "services/service_manager/public/cpp/bind_source_info.h" | 22 #include "services/service_manager/public/cpp/bind_source_info.h" |
21 #include "third_party/zlib/google/zip.h" | 23 #include "third_party/zlib/google/zip.h" |
22 #include "ui/base/l10n/l10n_util.h" | 24 #include "ui/base/l10n/l10n_util.h" |
23 #include "ui/base/ui_base_switches.h" | 25 #include "ui/base/ui_base_switches.h" |
(...skipping 20 matching lines...) Expand all Loading... |
44 UnzipCallback callback) override { | 46 UnzipCallback callback) override { |
45 std::unique_ptr<base::DictionaryValue> manifest; | 47 std::unique_ptr<base::DictionaryValue> manifest; |
46 if (UnzipFileManifestIntoPath(file, path, &manifest)) { | 48 if (UnzipFileManifestIntoPath(file, path, &manifest)) { |
47 std::move(callback).Run( | 49 std::move(callback).Run( |
48 UnzipFileIntoPath(file, path, std::move(manifest))); | 50 UnzipFileIntoPath(file, path, std::move(manifest))); |
49 } else { | 51 } else { |
50 std::move(callback).Run(false); | 52 std::move(callback).Run(false); |
51 } | 53 } |
52 } | 54 } |
53 | 55 |
54 void Unpack(const base::FilePath& path, | 56 void Unpack(version_info::Channel channel, |
| 57 extensions::FeatureSessionType type, |
| 58 const base::FilePath& path, |
55 const std::string& extension_id, | 59 const std::string& extension_id, |
56 Manifest::Location location, | 60 Manifest::Location location, |
57 int32_t creation_flags, | 61 int32_t creation_flags, |
58 UnpackCallback callback) override { | 62 UnpackCallback callback) override { |
59 CHECK_GT(location, Manifest::INVALID_LOCATION); | 63 CHECK_GT(location, Manifest::INVALID_LOCATION); |
60 CHECK_LT(location, Manifest::NUM_LOCATIONS); | 64 CHECK_LT(location, Manifest::NUM_LOCATIONS); |
61 DCHECK(ExtensionsClient::Get()); | 65 DCHECK(ExtensionsClient::Get()); |
62 | 66 |
63 content::UtilityThread::Get()->EnsureBlinkInitialized(); | 67 content::UtilityThread::Get()->EnsureBlinkInitialized(); |
64 | 68 |
| 69 // Initialize extension system global state. |
| 70 SetCurrentChannel(channel); |
| 71 SetCurrentFeatureSessionType(type); |
| 72 |
65 Unpacker unpacker(path.DirName(), path, extension_id, location, | 73 Unpacker unpacker(path.DirName(), path, extension_id, location, |
66 creation_flags); | 74 creation_flags); |
67 if (unpacker.Run()) { | 75 if (unpacker.Run()) { |
68 std::move(callback).Run(base::string16(), unpacker.TakeParsedManifest()); | 76 std::move(callback).Run(base::string16(), unpacker.TakeParsedManifest()); |
69 } else { | 77 } else { |
70 std::move(callback).Run(unpacker.error_message(), nullptr); | 78 std::move(callback).Run(unpacker.error_message(), nullptr); |
71 } | 79 } |
72 } | 80 } |
73 | 81 |
74 static bool UnzipFileManifestIntoPath( | 82 static bool UnzipFileManifestIntoPath( |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 | 154 |
147 registry->AddInterface(base::Bind(&ExtensionUnpackerImpl::Create), | 155 registry->AddInterface(base::Bind(&ExtensionUnpackerImpl::Create), |
148 base::ThreadTaskRunnerHandle::Get()); | 156 base::ThreadTaskRunnerHandle::Get()); |
149 registry->AddInterface(base::Bind(&ManifestParserImpl::Create), | 157 registry->AddInterface(base::Bind(&ManifestParserImpl::Create), |
150 base::ThreadTaskRunnerHandle::Get()); | 158 base::ThreadTaskRunnerHandle::Get()); |
151 } | 159 } |
152 | 160 |
153 } // namespace utility_handler | 161 } // namespace utility_handler |
154 | 162 |
155 } // namespace extensions | 163 } // namespace extensions |
OLD | NEW |