| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 COMPONENTS_CRX_FILE_CRX_FILE_H_ | 5 #ifndef COMPONENTS_CRX_FILE_CRX_FILE_H_ |
| 6 #define COMPONENTS_CRX_FILE_CRX_FILE_H_ | 6 #define COMPONENTS_CRX_FILE_CRX_FILE_H_ |
| 7 | 7 |
| 8 #include <string> | |
| 9 #include <vector> | |
| 10 | |
| 11 #include <stddef.h> | 8 #include <stddef.h> |
| 12 #include <stdint.h> | 9 #include <stdint.h> |
| 13 #include <sys/types.h> | 10 #include <sys/types.h> |
| 14 #include "base/memory/scoped_ptr.h" | 11 |
| 12 #include <memory> |
| 13 #include <string> |
| 14 #include <vector> |
| 15 | 15 |
| 16 namespace base { | 16 namespace base { |
| 17 class FilePath; | 17 class FilePath; |
| 18 } | 18 } |
| 19 | 19 |
| 20 namespace crx_file { | 20 namespace crx_file { |
| 21 | 21 |
| 22 // CRX files have a header that includes a magic key, version number, and | 22 // CRX files have a header that includes a magic key, version number, and |
| 23 // some signature sizing information. Use CrxFile object to validate whether | 23 // some signature sizing information. Use CrxFile object to validate whether |
| 24 // the header is valid or not. | 24 // the header is valid or not. |
| (...skipping 20 matching lines...) Expand all Loading... |
| 45 kInvalidVersion, | 45 kInvalidVersion, |
| 46 kInvalidKeyTooLarge, | 46 kInvalidKeyTooLarge, |
| 47 kInvalidKeyTooSmall, | 47 kInvalidKeyTooSmall, |
| 48 kInvalidSignatureTooLarge, | 48 kInvalidSignatureTooLarge, |
| 49 kInvalidSignatureTooSmall, | 49 kInvalidSignatureTooSmall, |
| 50 }; | 50 }; |
| 51 | 51 |
| 52 // Construct a new CRX file header object with bytes of a header | 52 // Construct a new CRX file header object with bytes of a header |
| 53 // read from a CRX file. If a null scoped_ptr is returned, |error| | 53 // read from a CRX file. If a null scoped_ptr is returned, |error| |
| 54 // contains an error code with additional information. | 54 // contains an error code with additional information. |
| 55 static scoped_ptr<CrxFile> Parse(const Header& header, Error* error); | 55 static std::unique_ptr<CrxFile> Parse(const Header& header, Error* error); |
| 56 | 56 |
| 57 // Construct a new header for the given key and signature sizes. | 57 // Construct a new header for the given key and signature sizes. |
| 58 // Returns a null scoped_ptr if erroneous values of |key_size| and/or | 58 // Returns a null scoped_ptr if erroneous values of |key_size| and/or |
| 59 // |signature_size| are provided. |error| contains an error code with | 59 // |signature_size| are provided. |error| contains an error code with |
| 60 // additional information. | 60 // additional information. |
| 61 // Use this constructor and then .header() to obtain the Header | 61 // Use this constructor and then .header() to obtain the Header |
| 62 // for writing out to a CRX file. | 62 // for writing out to a CRX file. |
| 63 static scoped_ptr<CrxFile> Create(const uint32_t key_size, | 63 static std::unique_ptr<CrxFile> Create(const uint32_t key_size, |
| 64 const uint32_t signature_size, | 64 const uint32_t signature_size, |
| 65 Error* error); | 65 Error* error); |
| 66 | 66 |
| 67 // Returns the header structure for writing out to a CRX file. | 67 // Returns the header structure for writing out to a CRX file. |
| 68 const Header& header() const { return header_; } | 68 const Header& header() const { return header_; } |
| 69 | 69 |
| 70 // Checks a valid |header| to determine whether or not the CRX represents a | 70 // Checks a valid |header| to determine whether or not the CRX represents a |
| 71 // differential CRX. | 71 // differential CRX. |
| 72 static bool HeaderIsDelta(const Header& header); | 72 static bool HeaderIsDelta(const Header& header); |
| 73 | 73 |
| 74 enum class ValidateError { | 74 enum class ValidateError { |
| 75 NONE, | 75 NONE, |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 explicit CrxFile(const Header& header); | 109 explicit CrxFile(const Header& header); |
| 110 | 110 |
| 111 // Checks the |header| for validity and returns true if the values are valid. | 111 // Checks the |header| for validity and returns true if the values are valid. |
| 112 // If false is returned, more detailed error code is returned in |error|. | 112 // If false is returned, more detailed error code is returned in |error|. |
| 113 static bool HeaderIsValid(const Header& header, Error* error); | 113 static bool HeaderIsValid(const Header& header, Error* error); |
| 114 }; | 114 }; |
| 115 | 115 |
| 116 } // namespace crx_file | 116 } // namespace crx_file |
| 117 | 117 |
| 118 #endif // COMPONENTS_CRX_FILE_CRX_FILE_H_ | 118 #endif // COMPONENTS_CRX_FILE_CRX_FILE_H_ |
| OLD | NEW |