summaryrefslogtreecommitdiffstats
path: root/components/crx_file/id_util.cc
diff options
context:
space:
mode:
authorthestig <thestig@chromium.org>2015-01-29 10:50:32 -0800
committerCommit bot <commit-bot@chromium.org>2015-01-29 18:51:26 +0000
commit83cbcc4f27ee5c07f74dc2a3bab9b18213c28d25 (patch)
treedd002401a0e95cb6f9e3537870b72c50998af473 /components/crx_file/id_util.cc
parent391ece3aa22ebad761a63628dd10dfdef9028f7b (diff)
downloadchromium_src-83cbcc4f27ee5c07f74dc2a3bab9b18213c28d25.zip
chromium_src-83cbcc4f27ee5c07f74dc2a3bab9b18213c28d25.tar.gz
chromium_src-83cbcc4f27ee5c07f74dc2a3bab9b18213c28d25.tar.bz2
Extensions: Consolidate extension id hashing / searching.
Review URL: https://codereview.chromium.org/850853002 Cr-Commit-Position: refs/heads/master@{#313747}
Diffstat (limited to 'components/crx_file/id_util.cc')
-rw-r--r--components/crx_file/id_util.cc7
1 files changed, 7 insertions, 0 deletions
diff --git a/components/crx_file/id_util.cc b/components/crx_file/id_util.cc
index ef271ad..6209cb4 100644
--- a/components/crx_file/id_util.cc
+++ b/components/crx_file/id_util.cc
@@ -5,6 +5,7 @@
#include "components/crx_file/id_util.h"
#include "base/files/file_path.h"
+#include "base/sha1.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "crypto/sha2.h"
@@ -53,6 +54,12 @@ std::string GenerateIdForPath(const base::FilePath& path) {
return GenerateId(path_bytes);
}
+std::string HashedIdInHex(const std::string& id) {
+ const std::string id_hash = base::SHA1HashString(id);
+ DCHECK_EQ(base::kSHA1Length, id_hash.length());
+ return base::HexEncode(id_hash.c_str(), id_hash.length());
+}
+
base::FilePath MaybeNormalizePath(const base::FilePath& path) {
#if defined(OS_WIN)
// Normalize any drive letter to upper-case. We do this for consistency with