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

Side by Side Diff: chrome/browser/extensions/sandboxed_extension_unpacker.h

Issue 6992047: Change the web store private install API to accept a localized extension name. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 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
OLDNEW
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_BROWSER_EXTENSIONS_SANDBOXED_EXTENSION_UNPACKER_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_SANDBOXED_EXTENSION_UNPACKER_H_
6 #define CHROME_BROWSER_EXTENSIONS_SANDBOXED_EXTENSION_UNPACKER_H_ 6 #define CHROME_BROWSER_EXTENSIONS_SANDBOXED_EXTENSION_UNPACKER_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 10
11 #include "base/file_path.h" 11 #include "base/file_path.h"
12 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
13 #include "base/scoped_temp_dir.h" 13 #include "base/scoped_temp_dir.h"
14 #include "chrome/browser/utility_process_host.h" 14 #include "chrome/browser/utility_process_host.h"
15 15
16 class DictionaryValue; 16 class DictionaryValue;
17 class Extension; 17 class Extension;
18 class ResourceDispatcherHost; 18 class ResourceDispatcherHost;
19 19
20 class SandboxedExtensionUnpackerClient 20 class SandboxedExtensionUnpackerClient
21 : public base::RefCountedThreadSafe<SandboxedExtensionUnpackerClient> { 21 : public base::RefCountedThreadSafe<SandboxedExtensionUnpackerClient> {
22 public: 22 public:
23 // temp_dir - A temporary directory containing the results of the extension 23 // temp_dir - A temporary directory containing the results of the extension
24 // unpacking. The client is responsible for deleting this directory. 24 // unpacking. The client is responsible for deleting this directory.
25 // 25 //
26 // extension_root - The path to the extension root inside of temp_dir. 26 // extension_root - The path to the extension root inside of temp_dir.
27 // 27 //
28 // original_manifest - The parsed but unmodified version of the manifest,
29 // with no modifications such as localization, etc.
30 //
28 // extension - The extension that was unpacked. The client is responsible 31 // extension - The extension that was unpacked. The client is responsible
29 // for deleting this memory. 32 // for deleting this memory.
30 virtual void OnUnpackSuccess(const FilePath& temp_dir, 33 virtual void OnUnpackSuccess(const FilePath& temp_dir,
31 const FilePath& extension_root, 34 const FilePath& extension_root,
35 const DictionaryValue* original_manifest,
32 const Extension* extension) = 0; 36 const Extension* extension) = 0;
33 virtual void OnUnpackFailure(const std::string& error) = 0; 37 virtual void OnUnpackFailure(const std::string& error) = 0;
34 38
35 protected: 39 protected:
36 friend class base::RefCountedThreadSafe<SandboxedExtensionUnpackerClient>; 40 friend class base::RefCountedThreadSafe<SandboxedExtensionUnpackerClient>;
37 41
38 virtual ~SandboxedExtensionUnpackerClient() {} 42 virtual ~SandboxedExtensionUnpackerClient() {}
39 }; 43 };
40 44
41 // SandboxedExtensionUnpacker unpacks extensions from the CRX format into a 45 // SandboxedExtensionUnpacker unpacks extensions from the CRX format into a
42 // directory. This is done in a sandboxed subprocess to protect the browser 46 // directory. This is done in a sandboxed subprocess to protect the browser
43 // process from parsing complex formats like JPEG or JSON from untrusted 47 // process from parsing complex formats like JPEG or JSON from untrusted
44 // sources. 48 // sources.
45 // 49 //
46 // Unpacking an extension using this class makes minor changes to its source, 50 // Unpacking an extension using this class makes minor changes to its source,
47 // such as transcoding all images to PNG, parsing all message catalogs 51 // such as transcoding all images to PNG, parsing all message catalogs
48 // and rewriting the manifest JSON. As such, it should not be used when the 52 // and rewriting the manifest JSON. As such, it should not be used when the
49 // output is not intended to be given back to the author. 53 // output is not intended to be given back to the author.
50 // 54 //
51 // 55 //
52 // Lifetime management: 56 // Lifetime management:
53 // 57 //
54 // This class is ref-counted by each call it makes to itself on another thread, 58 // This class is ref-counted by each call it makes to itself on another thread,
55 // and by UtilityProcessHost. 59 // and by UtilityProcessHost.
56 // 60 //
57 // Additionally, we hold a reference to our own client so that it lives at least 61 // Additionally, we hold a reference to our own client so that it lives at leas t
Matt Perry 2011/05/25 01:46:06 oops
asargent_no_longer_on_chrome 2011/05/25 04:42:00 Done.
58 // long enough to receive the result of unpacking. 62 // long enough to receive the result of unpacking.
59 // 63 //
60 // 64 //
61 // NOTE: This class should only be used on the file thread. 65 // NOTE: This class should only be used on the file thread.
62 class SandboxedExtensionUnpacker : public UtilityProcessHost::Client { 66 class SandboxedExtensionUnpacker : public UtilityProcessHost::Client {
63 public: 67 public:
64 // The size of the magic character sequence at the beginning of each crx 68 // The size of the magic character sequence at the beginning of each crx
65 // file, in bytes. This should be a multiple of 4. 69 // file, in bytes. This should be a multiple of 4.
66 static const size_t kExtensionHeaderMagicSize = 4; 70 static const size_t kExtensionHeaderMagicSize = 4;
67 71
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 186
183 // Starts the utility process that unpacks our extension. 187 // Starts the utility process that unpacks our extension.
184 void StartProcessOnIOThread(const FilePath& temp_crx_path); 188 void StartProcessOnIOThread(const FilePath& temp_crx_path);
185 189
186 // SandboxedExtensionUnpacker 190 // SandboxedExtensionUnpacker
187 virtual void OnUnpackExtensionSucceeded(const DictionaryValue& manifest); 191 virtual void OnUnpackExtensionSucceeded(const DictionaryValue& manifest);
188 virtual void OnUnpackExtensionFailed(const std::string& error_message); 192 virtual void OnUnpackExtensionFailed(const std::string& error_message);
189 virtual void OnProcessCrashed(int exit_code); 193 virtual void OnProcessCrashed(int exit_code);
190 194
191 void ReportFailure(FailureReason reason, const std::string& message); 195 void ReportFailure(FailureReason reason, const std::string& message);
192 void ReportSuccess(); 196 void ReportSuccess(const DictionaryValue& original_manifest);
193 197
194 // Overwrites original manifest with safe result from utility process. 198 // Overwrites original manifest with safe result from utility process.
195 // Returns NULL on error. Caller owns the returned object. 199 // Returns NULL on error. Caller owns the returned object.
196 DictionaryValue* RewriteManifestFile(const DictionaryValue& manifest); 200 DictionaryValue* RewriteManifestFile(const DictionaryValue& manifest);
197 201
198 // Overwrites original files with safe results from utility process. 202 // Overwrites original files with safe results from utility process.
199 // Reports error and returns false if it fails. 203 // Reports error and returns false if it fails.
200 bool RewriteImageFiles(); 204 bool RewriteImageFiles();
201 bool RewriteCatalogFiles(); 205 bool RewriteCatalogFiles();
202 206
(...skipping 22 matching lines...) Expand all
225 bool got_response_; 229 bool got_response_;
226 230
227 // The public key that was extracted from the CRX header. 231 // The public key that was extracted from the CRX header.
228 std::string public_key_; 232 std::string public_key_;
229 233
230 // Time at which unpacking started. Used to compute the time unpacking takes. 234 // Time at which unpacking started. Used to compute the time unpacking takes.
231 base::TimeTicks unpack_start_time_; 235 base::TimeTicks unpack_start_time_;
232 }; 236 };
233 237
234 #endif // CHROME_BROWSER_EXTENSIONS_SANDBOXED_EXTENSION_UNPACKER_H_ 238 #endif // CHROME_BROWSER_EXTENSIONS_SANDBOXED_EXTENSION_UNPACKER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698