summaryrefslogtreecommitdiffstats
path: root/chrome/common/extensions/extension_file_util.h
diff options
context:
space:
mode:
authoraa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-19 22:27:06 +0000
committeraa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-19 22:27:06 +0000
commitca3dbf513dde28bb92b0337f87d2ed05c43b75ff (patch)
tree86ee10b963618590ffc9f4590e9a355adbdd8697 /chrome/common/extensions/extension_file_util.h
parent6a2ba7116c62a97aa0d11af35deba3be6e8589dc (diff)
downloadchromium_src-ca3dbf513dde28bb92b0337f87d2ed05c43b75ff.zip
chromium_src-ca3dbf513dde28bb92b0337f87d2ed05c43b75ff.tar.gz
chromium_src-ca3dbf513dde28bb92b0337f87d2ed05c43b75ff.tar.bz2
Allow extensions to be overinstalled with extensions of same
version. This is useful during development, for switching themes, and for user scripts (since user scripts have no development mode). Since we can't always immediately delete the version directory for an extension after unloading it (because some files might be in use), this required changing the directory layout of the extensions directory to allow multiple copies of the same version of the same extension to be present at once. This was done by adding a counter to the version directory name. Also get rid of all the old "Current Version" cruft, since we no longer use that. BUG=26538 Review URL: http://codereview.chromium.org/1521039 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@47740 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/extensions/extension_file_util.h')
-rw-r--r--chrome/common/extensions/extension_file_util.h73
1 files changed, 21 insertions, 52 deletions
diff --git a/chrome/common/extensions/extension_file_util.h b/chrome/common/extensions/extension_file_util.h
index dc6a5bd..5f3150b 100644
--- a/chrome/common/extensions/extension_file_util.h
+++ b/chrome/common/extensions/extension_file_util.h
@@ -20,52 +20,17 @@ namespace extension_file_util {
// extension in.
extern const char kInstallDirectoryName[];
-// The name of the file that contains the current version of an installed
-// extension.
-extern const char kCurrentVersionFileName[];
-
-// Move source_dir to dest_dir (it will actually be named dest_dir, not inside
-// dest_dir). If the parent path doesn't exist, create it. If something else is
-// already there, remove it.
-bool MoveDirSafely(const FilePath& source_dir, const FilePath& dest_dir);
-
-// Updates the Current Version file inside the installed extension.
-bool SetCurrentVersion(const FilePath& dest_dir,
- const std::string& version,
- std::string* error);
-
-// Reads the Current Version file.
-bool ReadCurrentVersion(const FilePath& dir, std::string* version_string);
-
-// Determine what type of install it is (new, upgrade, overinstall, downgrade)
-// given the current version and a newly installing version. |extensions_dir| is
-// the root directory containing all extensions in the user profile.
-// |extension_id| and |current_version_str| are the id and version of the
-// extension contained in |src_dir|, if any.
-//
-// Returns the full path to the destination version directory and the type of
-// install that was attempted.
-Extension::InstallType CompareToInstalledVersion(
- const FilePath& extensions_dir,
- const std::string& extension_id,
- const std::string& current_version_str,
- const std::string& new_version_str,
- FilePath* version_dir);
-
-// Sanity check that the directory has the minimum files to be a working
-// extension.
-bool SanityCheckExtension(const FilePath& extension_root);
-
-// Installs an extension unpacked in |src_dir|.
-//
-// On failure, also returns an error message.
-//
-// NOTE: |src_dir| is not actually copied in the case of downgrades or
-// overinstall of previous verisons of the extension. In that case, the function
-// returns true and install_type is populated.
-bool InstallExtension(const FilePath& src_dir,
- const FilePath& version_dir,
- std::string* error);
+// Copies |unpacked_source_dir| into the right location under |extensions_dir|.
+// The destination directiory is returned on success, or empty path is returned
+// on failure.
+FilePath InstallExtension(const FilePath& unpacked_source_dir,
+ const std::string& id,
+ const std::string& version,
+ const FilePath& extensions_dir);
+
+// Removes all versions of the extension with |id| from |extensions_dir|.
+void UninstallExtension(const FilePath& extensions_dir,
+ const std::string& id);
// Loads and validates an extension from the specified directory. Returns NULL
// on failure, with a description of the error in |error|.
@@ -77,14 +42,18 @@ Extension* LoadExtension(const FilePath& extension_root,
// Otherwise, a description of the error is returned in |error|.
bool ValidateExtension(Extension* extension, std::string* error);
-// Uninstalls the extension |id| from the install directory |extensions_dir|.
-void UninstallExtension(const std::string& id, const FilePath& extensions_dir);
-
-// Clean up directories that aren't valid extensions from the install directory.
+// Cleans up the extension install directory. It can end up with garbage in it
+// if extensions can't initially be removed when they are uninstalled (eg if a
+// file is in use).
+//
+// |extensions_dir| is the install directory to look in. |extension_paths| is a
+// map from extension id to full installation path.
+//
+// Obsolete version directories are removed, as are directories that aren't
+// found in |extension_paths|.
void GarbageCollectExtensions(
const FilePath& extensions_dir,
- const std::set<std::string>& installed_ids,
- const std::map<std::string, std::string>& installed_versions);
+ const std::map<std::string, FilePath>& extension_paths);
// Loads extension message catalogs and returns message bundle.
// Returns NULL on error, or if extension is not localized.