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

Unified Diff: chrome/browser/extensions/crx_file.cc

Issue 12578008: Move CrxFile, FileReader, ExtensionResource to src/extensions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 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 | « chrome/browser/extensions/crx_file.h ('k') | chrome/browser/extensions/crx_installer.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/crx_file.cc
diff --git a/chrome/browser/extensions/crx_file.cc b/chrome/browser/extensions/crx_file.cc
deleted file mode 100644
index e70e27be9a098957299f42672db5c47b4dc6c0b0..0000000000000000000000000000000000000000
--- a/chrome/browser/extensions/crx_file.cc
+++ /dev/null
@@ -1,68 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/extensions/crx_file.h"
-
-namespace extensions {
-
-namespace {
-
-// The current version of the crx format.
-static const uint32 kCurrentVersion = 2;
-
-// The maximum size the crx parser will tolerate for a public key.
-static const uint32 kMaxPublicKeySize = 1 << 16;
-
-// The maximum size the crx parser will tolerate for a signature.
-static const uint32 kMaxSignatureSize = 1 << 16;
-
-} // namespace
-
-// The magic string embedded in the header.
-const char kCrxFileHeaderMagic[] = "Cr24";
-
-scoped_ptr<CrxFile> CrxFile::Parse(const CrxFile::Header& header,
- CrxFile::Error* error) {
- if (HeaderIsValid(header, error))
- return scoped_ptr<CrxFile>(new CrxFile(header));
- return scoped_ptr<CrxFile>();
-}
-
-scoped_ptr<CrxFile> CrxFile::Create(const uint32 key_size,
- const uint32 signature_size,
- CrxFile::Error* error) {
- CrxFile::Header header;
- memcpy(&header.magic, kCrxFileHeaderMagic, kCrxFileHeaderMagicSize);
- header.version = kCurrentVersion;
- header.key_size = key_size;
- header.signature_size = signature_size;
- if (HeaderIsValid(header, error))
- return scoped_ptr<CrxFile>(new CrxFile(header));
- return scoped_ptr<CrxFile>();
-}
-
-CrxFile::CrxFile(const Header& header) : header_(header) {
-}
-
-bool CrxFile::HeaderIsValid(const CrxFile::Header& header,
- CrxFile::Error* error) {
- bool valid = false;
- if (strncmp(kCrxFileHeaderMagic, header.magic, sizeof(header.magic)))
- *error = kWrongMagic;
- else if (header.version != kCurrentVersion)
- *error = kInvalidVersion;
- else if (header.key_size > kMaxPublicKeySize)
- *error = kInvalidKeyTooLarge;
- else if (header.key_size == 0)
- *error = kInvalidKeyTooSmall;
- else if (header.signature_size > kMaxSignatureSize)
- *error = kInvalidSignatureTooLarge;
- else if (header.signature_size == 0)
- *error = kInvalidSignatureTooSmall;
- else
- valid = true;
- return valid;
-}
-
-} // namespace extensions
« no previous file with comments | « chrome/browser/extensions/crx_file.h ('k') | chrome/browser/extensions/crx_installer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698