summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorevan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-09 21:33:27 +0000
committerevan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-09 21:33:27 +0000
commit28d7479be2b5a1a63441ef352a6d2028903c3335 (patch)
tree7900e80720bd51b845d875e31c1a43d2d91f97ae
parent2e49585ce107329088df6eeed6e90823dca3044f (diff)
downloadchromium_src-28d7479be2b5a1a63441ef352a6d2028903c3335.zip
chromium_src-28d7479be2b5a1a63441ef352a6d2028903c3335.tar.gz
chromium_src-28d7479be2b5a1a63441ef352a6d2028903c3335.tar.bz2
extensions: generate extension id from path by using bytes directly
Rather than converting to wstring and then back to UTF-8, just use the bytes we already have. BUG=69467 Review URL: http://codereview.chromium.org/6625065 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@77519 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/common/extensions/extension.cc5
-rw-r--r--chrome/common/extensions/extension.h1
2 files changed, 5 insertions, 1 deletions
diff --git a/chrome/common/extensions/extension.cc b/chrome/common/extensions/extension.cc
index 5df2a35..0be0dbc 100644
--- a/chrome/common/extensions/extension.cc
+++ b/chrome/common/extensions/extension.cc
@@ -499,8 +499,11 @@ bool Extension::IdIsValid(const std::string& id) {
// static
std::string Extension::GenerateIdForPath(const FilePath& path) {
FilePath new_path = Extension::MaybeNormalizePath(path);
+ std::string path_bytes =
+ std::string(reinterpret_cast<const char*>(new_path.value().data()),
+ new_path.value().size() * sizeof(FilePath::CharType));
std::string id;
- if (!GenerateId(WideToUTF8(new_path.ToWStringHack()), &id))
+ if (!GenerateId(path_bytes, &id))
return "";
return id;
}
diff --git a/chrome/common/extensions/extension.h b/chrome/common/extensions/extension.h
index 498ec66..7e2b593 100644
--- a/chrome/common/extensions/extension.h
+++ b/chrome/common/extensions/extension.h
@@ -229,6 +229,7 @@ class Extension : public base::RefCountedThreadSafe<Extension> {
static bool IdIsValid(const std::string& id);
// Generate an ID for an extension in the given path.
+ // Used while developing extensions, before they have a key.
static std::string GenerateIdForPath(const FilePath& file_name);
// Returns true if the specified file is an extension.