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_COMMON_EXTENSIONS_EXTENSION_UNPACKER_H_ | 5 #ifndef CHROME_COMMON_EXTENSIONS_EXTENSION_UNPACKER_H_ |
6 #define CHROME_COMMON_EXTENSIONS_EXTENSION_UNPACKER_H_ | 6 #define CHROME_COMMON_EXTENSIONS_EXTENSION_UNPACKER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/file_path.h" | 12 #include "base/file_path.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "base/tuple.h" | 14 #include "base/tuple.h" |
| 15 #include "chrome/common/extensions/extension.h" |
15 | 16 |
16 class SkBitmap; | 17 class SkBitmap; |
17 | 18 |
18 namespace base { | 19 namespace base { |
19 class DictionaryValue; | 20 class DictionaryValue; |
20 } | 21 } |
21 | 22 |
22 // This class unpacks an extension. It is designed to be used in a sandboxed | 23 // This class unpacks an extension. It is designed to be used in a sandboxed |
23 // child process. We unpack and parse various bits of the extension, then | 24 // child process. We unpack and parse various bits of the extension, then |
24 // report back to the browser process, who then transcodes the pre-parsed bits | 25 // report back to the browser process, who then transcodes the pre-parsed bits |
25 // and writes them back out to disk for later use. | 26 // and writes them back out to disk for later use. |
26 class ExtensionUnpacker { | 27 class ExtensionUnpacker { |
27 public: | 28 public: |
28 typedef std::vector< Tuple2<SkBitmap, FilePath> > DecodedImages; | 29 typedef std::vector< Tuple2<SkBitmap, FilePath> > DecodedImages; |
29 | 30 |
30 explicit ExtensionUnpacker(const FilePath& extension_path); | 31 explicit ExtensionUnpacker(const FilePath& extension_path, |
| 32 Extension::Location location, |
| 33 int creation_flags); |
31 ~ExtensionUnpacker(); | 34 ~ExtensionUnpacker(); |
32 | 35 |
33 // Install the extension file at |extension_path|. Returns true on success. | 36 // Install the extension file at |extension_path|. Returns true on success. |
34 // Otherwise, error_message will contain a string explaining what went wrong. | 37 // Otherwise, error_message will contain a string explaining what went wrong. |
35 bool Run(); | 38 bool Run(); |
36 | 39 |
37 // Write the decoded images to kDecodedImagesFilename. We do this instead | 40 // Write the decoded images to kDecodedImagesFilename. We do this instead |
38 // of sending them over IPC, since they are so large. Returns true on | 41 // of sending them over IPC, since they are so large. Returns true on |
39 // success. | 42 // success. |
40 bool DumpImagesToFile(); | 43 bool DumpImagesToFile(); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 // Parses the catalog at the given path and puts it in our list of parsed | 81 // Parses the catalog at the given path and puts it in our list of parsed |
79 // catalogs. | 82 // catalogs. |
80 bool ReadMessageCatalog(const FilePath& message_path); | 83 bool ReadMessageCatalog(const FilePath& message_path); |
81 | 84 |
82 // Set the error message. | 85 // Set the error message. |
83 void SetError(const std::string& error); | 86 void SetError(const std::string& error); |
84 | 87 |
85 // The extension to unpack. | 88 // The extension to unpack. |
86 FilePath extension_path_; | 89 FilePath extension_path_; |
87 | 90 |
| 91 // The location to use for the created extension. |
| 92 Extension::Location location_; |
| 93 |
| 94 // The creation flags to use with the created extension. |
| 95 int creation_flags_; |
| 96 |
88 // The place we unpacked the extension to. | 97 // The place we unpacked the extension to. |
89 FilePath temp_install_dir_; | 98 FilePath temp_install_dir_; |
90 | 99 |
91 // The parsed version of the manifest JSON contained in the extension. | 100 // The parsed version of the manifest JSON contained in the extension. |
92 scoped_ptr<base::DictionaryValue> parsed_manifest_; | 101 scoped_ptr<base::DictionaryValue> parsed_manifest_; |
93 | 102 |
94 // A list of decoded images and the paths where those images came from. Paths | 103 // A list of decoded images and the paths where those images came from. Paths |
95 // are relative to the manifest file. | 104 // are relative to the manifest file. |
96 DecodedImages decoded_images_; | 105 DecodedImages decoded_images_; |
97 | 106 |
98 // Dictionary of relative paths and catalogs per path. Paths are in the form | 107 // Dictionary of relative paths and catalogs per path. Paths are in the form |
99 // of _locales/locale, without messages.json base part. | 108 // of _locales/locale, without messages.json base part. |
100 scoped_ptr<base::DictionaryValue> parsed_catalogs_; | 109 scoped_ptr<base::DictionaryValue> parsed_catalogs_; |
101 | 110 |
102 // The last error message that was set. Empty if there were no errors. | 111 // The last error message that was set. Empty if there were no errors. |
103 std::string error_message_; | 112 std::string error_message_; |
104 | 113 |
105 DISALLOW_COPY_AND_ASSIGN(ExtensionUnpacker); | 114 DISALLOW_COPY_AND_ASSIGN(ExtensionUnpacker); |
106 }; | 115 }; |
107 | 116 |
108 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_UNPACKER_H_ | 117 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_UNPACKER_H_ |
OLD | NEW |