[M120 Migration][VD] Enable direct rendering for TVPlus
[platform/framework/web/chromium-efl.git] / components / crx_file / id_util.h
1 // Copyright 2014 The Chromium Authors
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 COMPONENTS_CRX_FILE_ID_UTIL_H_
6 #define COMPONENTS_CRX_FILE_ID_UTIL_H_
7
8 #include "base/strings/string_piece.h"
9
10 #include <stddef.h>
11 #include <stdint.h>
12
13 #include <string>
14
15 namespace base {
16 class FilePath;
17 }
18
19 namespace crx_file::id_util {
20
21 // The number of bytes in a legal id.
22 extern const size_t kIdSize;
23
24 // Generates an extension ID from arbitrary input. The same input string will
25 // always generate the same output ID.
26 std::string GenerateId(base::StringPiece input);
27
28 // Generates an ID from a HEX string. The same input string will always generate
29 // the same output ID.
30 std::string GenerateIdFromHex(const std::string& input);
31
32 // Generates an ID from the first |kIdSize| bytes of a SHA256 hash.
33 // |hash_size| must be at least |kIdSize|.
34 std::string GenerateIdFromHash(const uint8_t* hash, size_t hash_size);
35
36 // Generates an ID for an extension in the given path.
37 // Used while developing extensions, before they have a key.
38 std::string GenerateIdForPath(const base::FilePath& path);
39
40 // Returns the hash of an extension ID in hex.
41 std::string HashedIdInHex(const std::string& id);
42
43 // Normalizes the path for use by the extension. On Windows, this will make
44 // sure the drive letter is uppercase.
45 base::FilePath MaybeNormalizePath(const base::FilePath& path);
46
47 // Checks if |id| is a valid extension-id. Extension-ids are used for anything
48 // that comes in a CRX file, including apps, extensions, and components.
49 bool IdIsValid(base::StringPiece id);
50
51 }  // namespace crx_file::id_util
52
53 #endif  // COMPONENTS_CRX_FILE_ID_UTIL_H_