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_UTILITY_EXTENSIONS_UNPACKER_H_ | 5 #ifndef CHROME_UTILITY_EXTENSIONS_UNPACKER_H_ |
6 #define CHROME_UTILITY_EXTENSIONS_UNPACKER_H_ | 6 #define CHROME_UTILITY_EXTENSIONS_UNPACKER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 28 matching lines...) Expand all Loading... |
39 // Write the decoded images to kDecodedImagesFilename. We do this instead | 39 // Write the decoded images to kDecodedImagesFilename. We do this instead |
40 // of sending them over IPC, since they are so large. Returns true on | 40 // of sending them over IPC, since they are so large. Returns true on |
41 // success. | 41 // success. |
42 bool DumpImagesToFile(); | 42 bool DumpImagesToFile(); |
43 | 43 |
44 // Write the decoded messages to kDecodedMessageCatalogsFilename. We do this | 44 // Write the decoded messages to kDecodedMessageCatalogsFilename. We do this |
45 // instead of sending them over IPC, since they are so large. Returns true on | 45 // instead of sending them over IPC, since they are so large. Returns true on |
46 // success. | 46 // success. |
47 bool DumpMessageCatalogsToFile(); | 47 bool DumpMessageCatalogsToFile(); |
48 | 48 |
49 const string16& error_message() { return error_message_; } | 49 const base::string16& error_message() { return error_message_; } |
50 base::DictionaryValue* parsed_manifest() { | 50 base::DictionaryValue* parsed_manifest() { |
51 return parsed_manifest_.get(); | 51 return parsed_manifest_.get(); |
52 } | 52 } |
53 base::DictionaryValue* parsed_catalogs() { return parsed_catalogs_.get(); } | 53 base::DictionaryValue* parsed_catalogs() { return parsed_catalogs_.get(); } |
54 | 54 |
55 private: | 55 private: |
56 // Parse the manifest.json file inside the extension (not in the header). | 56 // Parse the manifest.json file inside the extension (not in the header). |
57 // Caller takes ownership of return value. | 57 // Caller takes ownership of return value. |
58 base::DictionaryValue* ReadManifest(); | 58 base::DictionaryValue* ReadManifest(); |
59 | 59 |
60 // Parse all _locales/*/messages.json files inside the extension. | 60 // Parse all _locales/*/messages.json files inside the extension. |
61 bool ReadAllMessageCatalogs(const std::string& default_locale); | 61 bool ReadAllMessageCatalogs(const std::string& default_locale); |
62 | 62 |
63 // Decodes the image at the given path and puts it in our list of decoded | 63 // Decodes the image at the given path and puts it in our list of decoded |
64 // images. | 64 // images. |
65 bool AddDecodedImage(const base::FilePath& path); | 65 bool AddDecodedImage(const base::FilePath& path); |
66 | 66 |
67 // Parses the catalog at the given path and puts it in our list of parsed | 67 // Parses the catalog at the given path and puts it in our list of parsed |
68 // catalogs. | 68 // catalogs. |
69 bool ReadMessageCatalog(const base::FilePath& message_path); | 69 bool ReadMessageCatalog(const base::FilePath& message_path); |
70 | 70 |
71 // Set the error message. | 71 // Set the error message. |
72 void SetError(const std::string& error); | 72 void SetError(const std::string& error); |
73 void SetUTF16Error(const string16& error); | 73 void SetUTF16Error(const base::string16& error); |
74 | 74 |
75 // The extension to unpack. | 75 // The extension to unpack. |
76 base::FilePath extension_path_; | 76 base::FilePath extension_path_; |
77 | 77 |
78 // The extension ID if known. | 78 // The extension ID if known. |
79 std::string extension_id_; | 79 std::string extension_id_; |
80 | 80 |
81 // The location to use for the created extension. | 81 // The location to use for the created extension. |
82 Manifest::Location location_; | 82 Manifest::Location location_; |
83 | 83 |
84 // The creation flags to use with the created extension. | 84 // The creation flags to use with the created extension. |
85 int creation_flags_; | 85 int creation_flags_; |
86 | 86 |
87 // The place we unpacked the extension to. | 87 // The place we unpacked the extension to. |
88 base::FilePath temp_install_dir_; | 88 base::FilePath temp_install_dir_; |
89 | 89 |
90 // The parsed version of the manifest JSON contained in the extension. | 90 // The parsed version of the manifest JSON contained in the extension. |
91 scoped_ptr<base::DictionaryValue> parsed_manifest_; | 91 scoped_ptr<base::DictionaryValue> parsed_manifest_; |
92 | 92 |
93 // A list of decoded images and the paths where those images came from. Paths | 93 // A list of decoded images and the paths where those images came from. Paths |
94 // are relative to the manifest file. | 94 // are relative to the manifest file. |
95 struct InternalData; | 95 struct InternalData; |
96 scoped_ptr<InternalData> internal_data_; | 96 scoped_ptr<InternalData> internal_data_; |
97 | 97 |
98 // Dictionary of relative paths and catalogs per path. Paths are in the form | 98 // Dictionary of relative paths and catalogs per path. Paths are in the form |
99 // of _locales/locale, without messages.json base part. | 99 // of _locales/locale, without messages.json base part. |
100 scoped_ptr<base::DictionaryValue> parsed_catalogs_; | 100 scoped_ptr<base::DictionaryValue> parsed_catalogs_; |
101 | 101 |
102 // The last error message that was set. Empty if there were no errors. | 102 // The last error message that was set. Empty if there were no errors. |
103 string16 error_message_; | 103 base::string16 error_message_; |
104 | 104 |
105 DISALLOW_COPY_AND_ASSIGN(Unpacker); | 105 DISALLOW_COPY_AND_ASSIGN(Unpacker); |
106 }; | 106 }; |
107 | 107 |
108 } // namespace extensions | 108 } // namespace extensions |
109 | 109 |
110 #endif // CHROME_UTILITY_EXTENSIONS_UNPACKER_H_ | 110 #endif // CHROME_UTILITY_EXTENSIONS_UNPACKER_H_ |
OLD | NEW |