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

Unified Diff: extensions/common/extension.cc

Issue 481433005: Extensions: Move id_util functions to crx_file component. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: revert last patchset. function returns Extension* and can't use an assert. Created 6 years, 4 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 | « extensions/common/extension.h ('k') | extensions/common/extension_resource_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/common/extension.cc
diff --git a/extensions/common/extension.cc b/extensions/common/extension.cc
index c9562afe6570d9d8618f9153e8fc12beca2b910e..d8e798e516e2795c50f670fd27a6b26e4a1ed6e9 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() {
« no previous file with comments | « extensions/common/extension.h ('k') | extensions/common/extension_resource_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698