OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_UNPACKER_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_SANDBOXED_UNPACKER_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_SANDBOXED_UNPACKER_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_SANDBOXED_UNPACKER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
11 #include "base/files/scoped_temp_dir.h" | 11 #include "base/files/scoped_temp_dir.h" |
12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted_delete_on_message_loop.h" |
13 #include "base/time/time.h" | 13 #include "base/time/time.h" |
| 14 #include "content/public/browser/browser_thread.h" |
14 #include "content/public/browser/utility_process_host_client.h" | 15 #include "content/public/browser/utility_process_host_client.h" |
15 #include "extensions/browser/crx_file_info.h" | 16 #include "extensions/browser/crx_file_info.h" |
16 #include "extensions/browser/install/crx_install_error.h" | 17 #include "extensions/browser/install/crx_install_error.h" |
17 #include "extensions/common/manifest.h" | 18 #include "extensions/common/manifest.h" |
18 | 19 |
19 class SkBitmap; | 20 class SkBitmap; |
20 | 21 |
21 namespace base { | 22 namespace base { |
22 class DictionaryValue; | 23 class DictionaryValue; |
23 class SequencedTaskRunner; | 24 class SequencedTaskRunner; |
24 } | 25 } |
25 | 26 |
26 namespace crypto { | 27 namespace crypto { |
27 class SecureHash; | 28 class SecureHash; |
28 } | 29 } |
29 | 30 |
30 namespace extensions { | 31 namespace extensions { |
31 class Extension; | 32 class Extension; |
32 | 33 |
33 class SandboxedUnpackerClient | 34 class SandboxedUnpackerClient |
34 : public base::RefCountedThreadSafe<SandboxedUnpackerClient> { | 35 : public base::RefCountedDeleteOnMessageLoop<SandboxedUnpackerClient> { |
35 public: | 36 public: |
| 37 // Initialize the ref-counted base to always delete on the UI thread. Note |
| 38 // the constructor call must also happen on the UI thread. |
| 39 SandboxedUnpackerClient(); |
| 40 |
36 // temp_dir - A temporary directory containing the results of the extension | 41 // temp_dir - A temporary directory containing the results of the extension |
37 // unpacking. The client is responsible for deleting this directory. | 42 // unpacking. The client is responsible for deleting this directory. |
38 // | 43 // |
39 // extension_root - The path to the extension root inside of temp_dir. | 44 // extension_root - The path to the extension root inside of temp_dir. |
40 // | 45 // |
41 // original_manifest - The parsed but unmodified version of the manifest, | 46 // original_manifest - The parsed but unmodified version of the manifest, |
42 // with no modifications such as localization, etc. | 47 // with no modifications such as localization, etc. |
43 // | 48 // |
44 // extension - The extension that was unpacked. The client is responsible | 49 // extension - The extension that was unpacked. The client is responsible |
45 // for deleting this memory. | 50 // for deleting this memory. |
46 // | 51 // |
47 // install_icon - The icon we will display in the installation UI, if any. | 52 // install_icon - The icon we will display in the installation UI, if any. |
48 virtual void OnUnpackSuccess(const base::FilePath& temp_dir, | 53 virtual void OnUnpackSuccess(const base::FilePath& temp_dir, |
49 const base::FilePath& extension_root, | 54 const base::FilePath& extension_root, |
50 const base::DictionaryValue* original_manifest, | 55 const base::DictionaryValue* original_manifest, |
51 const Extension* extension, | 56 const Extension* extension, |
52 const SkBitmap& install_icon) = 0; | 57 const SkBitmap& install_icon) = 0; |
53 virtual void OnUnpackFailure(const CrxInstallError& error) = 0; | 58 virtual void OnUnpackFailure(const CrxInstallError& error) = 0; |
54 | 59 |
55 protected: | 60 protected: |
56 friend class base::RefCountedThreadSafe<SandboxedUnpackerClient>; | 61 friend class base::RefCountedDeleteOnMessageLoop<SandboxedUnpackerClient>; |
| 62 friend class base::DeleteHelper<SandboxedUnpackerClient>; |
57 | 63 |
58 virtual ~SandboxedUnpackerClient() {} | 64 virtual ~SandboxedUnpackerClient() {} |
59 }; | 65 }; |
60 | 66 |
61 // SandboxedUnpacker unpacks extensions from the CRX format into a | 67 // SandboxedUnpacker unpacks extensions from the CRX format into a |
62 // directory. This is done in a sandboxed subprocess to protect the browser | 68 // directory. This is done in a sandboxed subprocess to protect the browser |
63 // process from parsing complex formats like JPEG or JSON from untrusted | 69 // process from parsing complex formats like JPEG or JSON from untrusted |
64 // sources. | 70 // sources. |
65 // | 71 // |
66 // Unpacking an extension using this class makes minor changes to its source, | 72 // Unpacking an extension using this class makes minor changes to its source, |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 // when calling Extenion::Create() by the crx installer. | 263 // when calling Extenion::Create() by the crx installer. |
258 int creation_flags_; | 264 int creation_flags_; |
259 | 265 |
260 // Sequenced task runner where file I/O operations will be performed at. | 266 // Sequenced task runner where file I/O operations will be performed at. |
261 scoped_refptr<base::SequencedTaskRunner> unpacker_io_task_runner_; | 267 scoped_refptr<base::SequencedTaskRunner> unpacker_io_task_runner_; |
262 }; | 268 }; |
263 | 269 |
264 } // namespace extensions | 270 } // namespace extensions |
265 | 271 |
266 #endif // CHROME_BROWSER_EXTENSIONS_SANDBOXED_UNPACKER_H_ | 272 #endif // CHROME_BROWSER_EXTENSIONS_SANDBOXED_UNPACKER_H_ |
OLD | NEW |