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_BROWSER_EXTENSIONS_CRX_FILE_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_CRX_FILE_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_CRX_FILE_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_CRX_FILE_H_ |
7 | 7 |
8 #include <sys/types.h> | 8 #include <sys/types.h> |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 | 11 |
| 12 namespace extensions { |
| 13 |
12 // CRX files have a header that includes a magic key, version number, and | 14 // CRX files have a header that includes a magic key, version number, and |
13 // some signature sizing information. Use CrxFile object to validate whether | 15 // some signature sizing information. Use CrxFile object to validate whether |
14 // the header is valid or not. | 16 // the header is valid or not. |
15 | |
16 class CrxFile { | 17 class CrxFile { |
17 public: | 18 public: |
18 | 19 |
19 // The size of the magic character sequence at the beginning of each crx | 20 // The size of the magic character sequence at the beginning of each crx |
20 // file, in bytes. This should be a multiple of 4. | 21 // file, in bytes. This should be a multiple of 4. |
21 static const size_t kCrxFileHeaderMagicSize = 4; | 22 static const size_t kCrxFileHeaderMagicSize = 4; |
22 | 23 |
23 // This header is the first data at the beginning of an extension. Its | 24 // This header is the first data at the beginning of an extension. Its |
24 // contents are purposely 32-bit aligned so that it can just be slurped into | 25 // contents are purposely 32-bit aligned so that it can just be slurped into |
25 // a struct without manual parsing. | 26 // a struct without manual parsing. |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 Header header_; | 64 Header header_; |
64 | 65 |
65 // Constructor is private. Clients should use static factory methods above. | 66 // Constructor is private. Clients should use static factory methods above. |
66 explicit CrxFile(const Header& header); | 67 explicit CrxFile(const Header& header); |
67 | 68 |
68 // Checks the |header| for validity and returns true if the values are valid. | 69 // Checks the |header| for validity and returns true if the values are valid. |
69 // If false is returned, more detailed error code is returned in |error|. | 70 // If false is returned, more detailed error code is returned in |error|. |
70 static bool HeaderIsValid(const Header& header, Error* error); | 71 static bool HeaderIsValid(const Header& header, Error* error); |
71 }; | 72 }; |
72 | 73 |
| 74 } // namespace extensions |
| 75 |
73 #endif // CHROME_BROWSER_EXTENSIONS_CRX_FILE_H_ | 76 #endif // CHROME_BROWSER_EXTENSIONS_CRX_FILE_H_ |
OLD | NEW |