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

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

Issue 115595: Have the browser process rewrite manifest.json and theme images that the... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/utility_process_host.cc ('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
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 7
8 #include <string> 8 #include <string>
9 #include <vector>
9 10
10 #include "base/file_path.h" 11 #include "base/file_path.h"
12 #include "base/scoped_ptr.h"
13 #include "base/tuple.h"
11 14
12 class DictionaryValue; 15 class DictionaryValue;
16 class SkBitmap;
13 17
14 // Implements IO for the ExtensionsService. 18 // Implements IO for the ExtensionsService.
15 // TODO(aa): Extract an interface out of this for testing the frontend, once the 19 // TODO(aa): Extract an interface out of this for testing the frontend, once the
16 // frontend has significant logic to test. 20 // frontend has significant logic to test.
17 class ExtensionUnpacker { 21 class ExtensionUnpacker {
18 public: 22 public:
23 typedef std::vector< Tuple2<SkBitmap, FilePath> > DecodedImages;
24
19 explicit ExtensionUnpacker(const FilePath& extension_path) 25 explicit ExtensionUnpacker(const FilePath& extension_path)
20 : extension_path_(extension_path) {} 26 : extension_path_(extension_path) {}
21 27
22 // Install the extension file at |extension_path|. Returns true on success. 28 // Install the extension file at |extension_path|. Returns true on success.
23 // Otherwise, error_message will contain a string explaining what went wrong. 29 // Otherwise, error_message will contain a string explaining what went wrong.
24 bool Run(); 30 bool Run();
25 31
26 const std::string& error_message() { return error_message_; } 32 const std::string& error_message() { return error_message_; }
33 DictionaryValue* parsed_manifest() {
34 return parsed_manifest_.get();
35 }
36 const DecodedImages& decoded_images() { return decoded_images_; }
27 37
28 private: 38 private:
29 // Read the manifest from the front of the extension file. 39 // Parse the header on the front of the extension file and return the manifest
40 // inside it. Caller takes ownership of return value.
41 DictionaryValue* ReadPackageHeader();
42
43 // Parse the manifest.json file inside the extension (not in the header).
30 // Caller takes ownership of return value. 44 // Caller takes ownership of return value.
31 DictionaryValue* ReadManifest(); 45 DictionaryValue* ReadManifest();
32 46
47 // Decodes the image at the given path and puts it in our list of decoded
48 // images.
49 bool AddDecodedImage(const FilePath& path);
50
33 // Set the error message. 51 // Set the error message.
34 void SetError(const std::string& error); 52 void SetError(const std::string& error);
35 53
36 // The extension to unpack. 54 // The extension to unpack.
37 FilePath extension_path_; 55 FilePath extension_path_;
38 56
57 // The place we unpacked the extension to.
58 FilePath temp_install_dir_;
59
60 // The parsed version of the manifest JSON contained in the extension.
61 scoped_ptr<DictionaryValue> parsed_manifest_;
62
63 // A list of decoded images and the paths where those images came from. Paths
64 // are relative to the manifest file.
65 DecodedImages decoded_images_;
66
39 // The last error message that was set. Empty if there were no errors. 67 // The last error message that was set. Empty if there were no errors.
40 std::string error_message_; 68 std::string error_message_;
41 69
42 DISALLOW_COPY_AND_ASSIGN(ExtensionUnpacker); 70 DISALLOW_COPY_AND_ASSIGN(ExtensionUnpacker);
43 }; 71 };
44 72
45 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_UNPACKER_H_ 73 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_UNPACKER_H_
OLDNEW
« no previous file with comments | « chrome/browser/utility_process_host.cc ('k') | chrome/common/extensions/extension_unpacker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698