Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(199)

Side by Side Diff: chrome/common/extensions/extension_unpacker.h

Issue 10704060: Move ExtensionUnpacker into extensions:: namespace, rename it to Unpacker (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Even later master Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/common/chrome_utility_messages.h ('k') | chrome/common/extensions/extension_unpacker.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_COMMON_EXTENSIONS_EXTENSION_UNPACKER_H_
6 #define CHROME_COMMON_EXTENSIONS_EXTENSION_UNPACKER_H_
7
8 #include <string>
9 #include <vector>
10
11 #include "base/file_path.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "base/tuple.h"
14 #include "chrome/common/extensions/extension.h"
15
16 class SkBitmap;
17
18 namespace base {
19 class DictionaryValue;
20 }
21
22 // 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 // 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 class ExtensionUnpacker {
27 public:
28 typedef std::vector< Tuple2<SkBitmap, FilePath> > DecodedImages;
29
30 ExtensionUnpacker(const FilePath& extension_path,
31 const std::string& extension_id,
32 extensions::Extension::Location location,
33 int creation_flags);
34 ~ExtensionUnpacker();
35
36 // Install the extension file at |extension_path|. Returns true on success.
37 // Otherwise, error_message will contain a string explaining what went wrong.
38 bool Run();
39
40 // Write the decoded images to kDecodedImagesFilename. We do this instead
41 // of sending them over IPC, since they are so large. Returns true on
42 // success.
43 bool DumpImagesToFile();
44
45 // Write the decoded messages to kDecodedMessageCatalogsFilename. We do this
46 // instead of sending them over IPC, since they are so large. Returns true on
47 // success.
48 bool DumpMessageCatalogsToFile();
49
50 // Read the decoded images back from the file we saved them to.
51 // |extension_path| is the path to the extension we unpacked that wrote the
52 // data. Returns true on success.
53 static bool ReadImagesFromFile(const FilePath& extension_path,
54 DecodedImages* images);
55
56 // Read the decoded message catalogs back from the file we saved them to.
57 // |extension_path| is the path to the extension we unpacked that wrote the
58 // data. Returns true on success.
59 static bool ReadMessageCatalogsFromFile(const FilePath& extension_path,
60 base::DictionaryValue* catalogs);
61
62 const string16& error_message() { return error_message_; }
63 base::DictionaryValue* parsed_manifest() {
64 return parsed_manifest_.get();
65 }
66 const DecodedImages& decoded_images() { return decoded_images_; }
67 base::DictionaryValue* parsed_catalogs() { return parsed_catalogs_.get(); }
68
69 private:
70 // Parse the manifest.json file inside the extension (not in the header).
71 // Caller takes ownership of return value.
72 base::DictionaryValue* ReadManifest();
73
74 // Parse all _locales/*/messages.json files inside the extension.
75 bool ReadAllMessageCatalogs(const std::string& default_locale);
76
77 // Decodes the image at the given path and puts it in our list of decoded
78 // images.
79 bool AddDecodedImage(const FilePath& path);
80
81 // Parses the catalog at the given path and puts it in our list of parsed
82 // catalogs.
83 bool ReadMessageCatalog(const FilePath& message_path);
84
85 // Set the error message.
86 void SetError(const std::string& error);
87
88 // The extension to unpack.
89 FilePath extension_path_;
90
91 // The extension ID if known.
92 std::string extension_id_;
93
94 // The location to use for the created extension.
95 extensions::Extension::Location location_;
96
97 // The creation flags to use with the created extension.
98 int creation_flags_;
99
100 // The place we unpacked the extension to.
101 FilePath temp_install_dir_;
102
103 // The parsed version of the manifest JSON contained in the extension.
104 scoped_ptr<base::DictionaryValue> parsed_manifest_;
105
106 // A list of decoded images and the paths where those images came from. Paths
107 // are relative to the manifest file.
108 DecodedImages decoded_images_;
109
110 // Dictionary of relative paths and catalogs per path. Paths are in the form
111 // of _locales/locale, without messages.json base part.
112 scoped_ptr<base::DictionaryValue> parsed_catalogs_;
113
114 // The last error message that was set. Empty if there were no errors.
115 string16 error_message_;
116
117 DISALLOW_COPY_AND_ASSIGN(ExtensionUnpacker);
118 };
119
120 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_UNPACKER_H_
OLDNEW
« no previous file with comments | « chrome/common/chrome_utility_messages.h ('k') | chrome/common/extensions/extension_unpacker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698