From a1e804d26dd14e7baa983b3de52f0da1d9c9b3c1 Mon Sep 17 00:00:00 2001 From: tfarina Date: Sat, 4 Apr 2015 07:35:28 -0700 Subject: extensions: Reuse crx_file's HashedIdInHex() function in SimpleFeature. The implementation of HashExtensionId() is identical to the one in id_util.h BUG=384613 TEST=extensions_unittests R=rockot@chromium.org Review URL: https://codereview.chromium.org/1051413003 Cr-Commit-Position: refs/heads/master@{#323881} --- extensions/common/features/simple_feature.cc | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'extensions/common/features') diff --git a/extensions/common/features/simple_feature.cc b/extensions/common/features/simple_feature.cc index 6a5bece..34258d4 100644 --- a/extensions/common/features/simple_feature.cc +++ b/extensions/common/features/simple_feature.cc @@ -16,10 +16,13 @@ #include "base/strings/string_number_conversions.h" #include "base/strings/string_util.h" #include "base/strings/stringprintf.h" +#include "components/crx_file/id_util.h" #include "extensions/common/extension_api.h" #include "extensions/common/features/feature_provider.h" #include "extensions/common/switches.h" +using crx_file::id_util::HashedIdInHex; + namespace extensions { namespace { @@ -207,12 +210,6 @@ std::string ListDisplayNames(const std::vector& enum_types) { return display_name_list; } -std::string HashExtensionId(const std::string& extension_id) { - const std::string id_hash = base::SHA1HashString(extension_id); - DCHECK_EQ(base::kSHA1Length, id_hash.length()); - return base::HexEncode(id_hash.c_str(), id_hash.length()); -} - bool IsCommandLineSwitchEnabled(const std::string& switch_name) { base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); if (command_line->HasSwitch(switch_name + "=1")) @@ -568,7 +565,7 @@ bool SimpleFeature::IsIdInArray(const std::string& extension_id, const char* const* end = array + array_length; return ((std::find(start, end, extension_id) != end) || - (std::find(start, end, HashExtensionId(extension_id)) != end)); + (std::find(start, end, HashedIdInHex(extension_id)) != end)); } // static @@ -578,7 +575,7 @@ bool SimpleFeature::IsIdInList(const std::string& extension_id, return false; return (ContainsValue(list, extension_id) || - ContainsValue(list, HashExtensionId(extension_id))); + ContainsValue(list, HashedIdInHex(extension_id))); } bool SimpleFeature::MatchesManifestLocation( -- cgit v1.1