diff options
author | tommycli@chromium.org <tommycli@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-08-21 02:27:26 +0000 |
---|---|---|
committer | tommycli@chromium.org <tommycli@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-08-21 02:28:55 +0000 |
commit | fdd2837d51c6446e2c417390374fc328a4d25a31 (patch) | |
tree | 4c645e72d2db435562ec275305a2a4b705859204 /extensions/common/extension.cc | |
parent | 2bfa5cff6b5c3ab9d6ce4380e435b1006c18458e (diff) | |
download | chromium_src-fdd2837d51c6446e2c417390374fc328a4d25a31.zip chromium_src-fdd2837d51c6446e2c417390374fc328a4d25a31.tar.gz chromium_src-fdd2837d51c6446e2c417390374fc328a4d25a31.tar.bz2 |
Extensions: Move id_util functions to crx_file component.
Consolidates id_util functions of extension/app/component ids in the crx_file component.
It belongs there because these types of ids are not exclusive to extensions, but rather, for anything that comes in a crx file.
BUG=371463
TBR=blundell@chromium.org
Review URL: https://codereview.chromium.org/481433005
Cr-Commit-Position: refs/heads/master@{#290971}
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@290971 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'extensions/common/extension.cc')
-rw-r--r-- | extensions/common/extension.cc | 24 |
1 files changed, 4 insertions, 20 deletions
diff --git a/extensions/common/extension.cc b/extensions/common/extension.cc index c9562af..d8e798e 100644 --- a/extensions/common/extension.cc +++ b/extensions/common/extension.cc @@ -20,10 +20,10 @@ #include "base/strings/utf_string_conversions.h" #include "base/values.h" #include "base/version.h" +#include "components/crx_file/id_util.h" #include "content/public/common/url_constants.h" #include "extensions/common/constants.h" #include "extensions/common/error_utils.h" -#include "extensions/common/id_util.h" #include "extensions/common/manifest.h" #include "extensions/common/manifest_constants.h" #include "extensions/common/manifest_handler.h" @@ -133,22 +133,6 @@ scoped_refptr<Extension> Extension::Create(const base::FilePath& path, return extension; } -// static -bool Extension::IdIsValid(const std::string& id) { - // Verify that the id is legal. - if (id.size() != (id_util::kIdSize * 2)) - return false; - - // We only support lowercase IDs, because IDs can be used as URL components - // (where GURL will lowercase it). - std::string temp = base::StringToLowerASCII(id); - for (size_t i = 0; i < temp.size(); i++) - if (temp[i] < 'a' || temp[i] > 'p') - return false; - - return true; -} - Manifest::Type Extension::GetType() const { return converted_from_user_script() ? Manifest::TYPE_USER_SCRIPT : manifest_->type(); @@ -470,7 +454,7 @@ bool Extension::InitExtensionID(extensions::Manifest* manifest, *error = base::ASCIIToUTF16(errors::kInvalidKey); return false; } - std::string extension_id = id_util::GenerateId(public_key_bytes); + std::string extension_id = crx_file::id_util::GenerateId(public_key_bytes); manifest->set_extension_id(extension_id); return true; } @@ -482,7 +466,7 @@ bool Extension::InitExtensionID(extensions::Manifest* manifest, // If there is a path, we generate the ID from it. This is useful for // development mode, because it keeps the ID stable across restarts and // reloading the extension. - std::string extension_id = id_util::GenerateIdForPath(path); + std::string extension_id = crx_file::id_util::GenerateIdForPath(path); if (extension_id.empty()) { NOTREACHED() << "Could not create ID from path."; return false; @@ -503,7 +487,7 @@ Extension::Extension(const base::FilePath& path, wants_file_access_(false), creation_flags_(0) { DCHECK(path.empty() || path.IsAbsolute()); - path_ = id_util::MaybeNormalizePath(path); + path_ = crx_file::id_util::MaybeNormalizePath(path); } Extension::~Extension() { |