OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #ifndef CHROME_BROWSER_EXTENSIONS_SANDBOXED_EXTENSION_UNPACKER_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_SANDBOXED_EXTENSION_UNPACKER_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_SANDBOXED_EXTENSION_UNPACKER_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_SANDBOXED_EXTENSION_UNPACKER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/file_path.h" | 11 #include "base/file_path.h" |
12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
13 #include "base/scoped_temp_dir.h" | 13 #include "base/scoped_temp_dir.h" |
14 #include "chrome/browser/utility_process_host.h" | 14 #include "chrome/browser/utility_process_host.h" |
15 | 15 |
16 class DictionaryValue; | 16 class DictionaryValue; |
17 class Extension; | 17 class Extension; |
18 class ResourceDispatcherHost; | 18 class ResourceDispatcherHost; |
19 | 19 |
20 class SandboxedExtensionUnpackerClient | 20 class SandboxedExtensionUnpackerClient |
21 : public base::RefCountedThreadSafe<SandboxedExtensionUnpackerClient> { | 21 : public base::RefCountedThreadSafe<SandboxedExtensionUnpackerClient> { |
22 public: | 22 public: |
23 // temp_dir - A temporary directory containing the results of the extension | 23 // temp_dir - A temporary directory containing the results of the extension |
24 // unpacking. The client is responsible for deleting this directory. | 24 // unpacking. The client is responsible for deleting this directory. |
25 // | 25 // |
26 // extension_root - The path to the extension root inside of temp_dir. | 26 // extension_root - The path to the extension root inside of temp_dir. |
27 // | 27 // |
| 28 // original_manifest - The parsed but unmodified version of the manifest, |
| 29 // with no modifications such as localization, etc. |
| 30 // |
28 // extension - The extension that was unpacked. The client is responsible | 31 // extension - The extension that was unpacked. The client is responsible |
29 // for deleting this memory. | 32 // for deleting this memory. |
30 virtual void OnUnpackSuccess(const FilePath& temp_dir, | 33 virtual void OnUnpackSuccess(const FilePath& temp_dir, |
31 const FilePath& extension_root, | 34 const FilePath& extension_root, |
| 35 const DictionaryValue* original_manifest, |
32 const Extension* extension) = 0; | 36 const Extension* extension) = 0; |
33 virtual void OnUnpackFailure(const std::string& error) = 0; | 37 virtual void OnUnpackFailure(const std::string& error) = 0; |
34 | 38 |
35 protected: | 39 protected: |
36 friend class base::RefCountedThreadSafe<SandboxedExtensionUnpackerClient>; | 40 friend class base::RefCountedThreadSafe<SandboxedExtensionUnpackerClient>; |
37 | 41 |
38 virtual ~SandboxedExtensionUnpackerClient() {} | 42 virtual ~SandboxedExtensionUnpackerClient() {} |
39 }; | 43 }; |
40 | 44 |
41 // SandboxedExtensionUnpacker unpacks extensions from the CRX format into a | 45 // SandboxedExtensionUnpacker unpacks extensions from the CRX format into a |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 | 186 |
183 // Starts the utility process that unpacks our extension. | 187 // Starts the utility process that unpacks our extension. |
184 void StartProcessOnIOThread(const FilePath& temp_crx_path); | 188 void StartProcessOnIOThread(const FilePath& temp_crx_path); |
185 | 189 |
186 // SandboxedExtensionUnpacker | 190 // SandboxedExtensionUnpacker |
187 virtual void OnUnpackExtensionSucceeded(const DictionaryValue& manifest); | 191 virtual void OnUnpackExtensionSucceeded(const DictionaryValue& manifest); |
188 virtual void OnUnpackExtensionFailed(const std::string& error_message); | 192 virtual void OnUnpackExtensionFailed(const std::string& error_message); |
189 virtual void OnProcessCrashed(int exit_code); | 193 virtual void OnProcessCrashed(int exit_code); |
190 | 194 |
191 void ReportFailure(FailureReason reason, const std::string& message); | 195 void ReportFailure(FailureReason reason, const std::string& message); |
192 void ReportSuccess(); | 196 void ReportSuccess(const DictionaryValue& original_manifest); |
193 | 197 |
194 // Overwrites original manifest with safe result from utility process. | 198 // Overwrites original manifest with safe result from utility process. |
195 // Returns NULL on error. Caller owns the returned object. | 199 // Returns NULL on error. Caller owns the returned object. |
196 DictionaryValue* RewriteManifestFile(const DictionaryValue& manifest); | 200 DictionaryValue* RewriteManifestFile(const DictionaryValue& manifest); |
197 | 201 |
198 // Overwrites original files with safe results from utility process. | 202 // Overwrites original files with safe results from utility process. |
199 // Reports error and returns false if it fails. | 203 // Reports error and returns false if it fails. |
200 bool RewriteImageFiles(); | 204 bool RewriteImageFiles(); |
201 bool RewriteCatalogFiles(); | 205 bool RewriteCatalogFiles(); |
202 | 206 |
(...skipping 22 matching lines...) Expand all Loading... |
225 bool got_response_; | 229 bool got_response_; |
226 | 230 |
227 // The public key that was extracted from the CRX header. | 231 // The public key that was extracted from the CRX header. |
228 std::string public_key_; | 232 std::string public_key_; |
229 | 233 |
230 // Time at which unpacking started. Used to compute the time unpacking takes. | 234 // Time at which unpacking started. Used to compute the time unpacking takes. |
231 base::TimeTicks unpack_start_time_; | 235 base::TimeTicks unpack_start_time_; |
232 }; | 236 }; |
233 | 237 |
234 #endif // CHROME_BROWSER_EXTENSIONS_SANDBOXED_EXTENSION_UNPACKER_H_ | 238 #endif // CHROME_BROWSER_EXTENSIONS_SANDBOXED_EXTENSION_UNPACKER_H_ |
OLD | NEW |