Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(38)

Unified Diff: extensions/common/features/simple_feature.cc

Issue 1051413003: extensions: Reuse crx_file's HashedIdInHex() function in SimpleFeature. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/common/features/simple_feature.cc
diff --git a/extensions/common/features/simple_feature.cc b/extensions/common/features/simple_feature.cc
index 6a5bece485df46b7ccc9db8ef21c5d62a521ba93..34258d4f0c602f4794dc1c32dcae9b267683b08e 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<EnumType>& 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(
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698