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

Side by Side Diff: chrome/browser/extensions/extension_file_util.h

Issue 174036: Get rid of the extension's "Current Version" file. (Closed)
Patch Set: merge conflicts Created 11 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_FILE_UTIL_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_FILE_UTIL_H_
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_FILE_UTIL_H_ 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_FILE_UTIL_H_
7 7
8 #include <set>
8 #include <string> 9 #include <string>
9 10
10 #include "base/file_path.h" 11 #include "base/file_path.h"
11 #include "chrome/common/extensions/extension.h" 12 #include "chrome/common/extensions/extension.h"
12 13
13 // Utilties for manipulating the on-disk storage of extensions. 14 // Utilties for manipulating the on-disk storage of extensions.
14 namespace extension_file_util { 15 namespace extension_file_util {
15 16
16 // The name of the directory inside the profile that we store installed 17 // The name of the directory inside the profile that we store installed
17 // extension in. 18 // extension in.
18 extern const char kInstallDirectoryName[]; 19 extern const char kInstallDirectoryName[];
19 20
20 // The name of the file that contains the current version of an installed 21 // The name of the file that contains the current version of an installed
21 // extension. 22 // extension.
22 extern const char kCurrentVersionFileName[]; 23 extern const char kCurrentVersionFileName[];
23 24
24 // Move source_dir to dest_dir (it will actually be named dest_dir, not inside 25 // Move source_dir to dest_dir (it will actually be named dest_dir, not inside
25 // dest_dir). If the parent path doesn't exixt, create it. If something else is 26 // dest_dir). If the parent path doesn't exixt, create it. If something else is
26 // already there, remove it. 27 // already there, remove it.
27 bool MoveDirSafely(const FilePath& source_dir, const FilePath& dest_dir); 28 bool MoveDirSafely(const FilePath& source_dir, const FilePath& dest_dir);
28 29
29 // Updates the Current Version file inside the installed extension. 30 // Updates the Current Version file inside the installed extension.
30 bool SetCurrentVersion(const FilePath& dest_dir, const std::string& version, 31 bool SetCurrentVersion(const FilePath& dest_dir, const std::string& version,
31 std::string* error); 32 std::string* error);
32 33
33 // Reads the Current Version file. 34 // Reads the Current Version file.
34 bool ReadCurrentVersion(const FilePath& dir, std::string* version_string); 35 bool ReadCurrentVersion(const FilePath& dir, std::string* version_string);
35 36
36 // Determine what type of install (new, upgrade, overinstall, downgrade) a given 37 // Determine what type of install it is (new, upgrade, overinstall, downgrade)
37 // id/version combination is. Also returns the current version, if any, in 38 // given the current version and a newly installing version. |extensions_dir| is
38 // current_version_str. 39 // the root directory containing all extensions in the user profile.
40 // |extension_id| and |current_version_str| are the id and version of the
41 // extension contained in |src_dir|, if any.
42 //
43 // Returns the full path to the destination version directory and the type of
44 // install that was attempted.
39 Extension::InstallType CompareToInstalledVersion( 45 Extension::InstallType CompareToInstalledVersion(
40 const FilePath& install_directory, const std::string& id, 46 const FilePath& extensions_dir,
41 const std::string& new_version_str, std::string *current_version_str); 47 const std::string& extension_id,
48 const std::string& current_version_str,
49 const std::string& new_version_str,
50 FilePath* version_dir);
42 51
43 // Sanity check that the directory has the minimum files to be a working 52 // Sanity check that the directory has the minimum files to be a working
44 // extension. 53 // extension.
45 bool SanityCheckExtension(const FilePath& extension_root); 54 bool SanityCheckExtension(const FilePath& extension_root);
46 55
47 // Installs an extension unpacked in |src_dir|. |extensions_dir| is the root 56 // Installs an extension unpacked in |src_dir|.
48 // directory containing all extensions in the user profile. |extension_id| and
49 // |extension_version| are the id and version of the extension contained in
50 // |src_dir|.
51 //
52 // Returns the full path to the destination version directory and the type of
53 // install that was attempted.
54 // 57 //
55 // On failure, also returns an error message. 58 // On failure, also returns an error message.
56 // 59 //
57 // NOTE: |src_dir| is not actually copied in the case of downgrades or 60 // NOTE: |src_dir| is not actually copied in the case of downgrades or
58 // overinstall of previous verisons of the extension. In that case, the function 61 // overinstall of previous verisons of the extension. In that case, the function
59 // returns true and install_type is populated. 62 // returns true and install_type is populated.
60 bool InstallExtension(const FilePath& src_dir, 63 bool InstallExtension(const FilePath& src_dir,
61 const FilePath& extensions_dir, 64 const FilePath& version_dir,
62 const std::string& extension_id,
63 const std::string& extension_version,
64 FilePath* version_dir,
65 Extension::InstallType* install_type,
66 std::string* error); 65 std::string* error);
67 66
68 // Load an extension from the specified directory. Returns NULL on failure, with 67 // Loads and validates an extension from the specified directory. Returns NULL
69 // a description of the error in |error|. 68 // on failure, with a description of the error in |error|.
70 Extension* LoadExtension(const FilePath& extension_root, bool require_key, 69 Extension* LoadExtension(const FilePath& extension_root, bool require_key,
71 std::string* error); 70 std::string* error);
72 71
72 // Returns true if the given extension object is valid and consistent.
73 // Otherwise, a description of the error is returned in |error|.
74 bool ValidateExtension(Extension* extension, std::string* error);
75
73 // Uninstalls the extension |id| from the install directory |extensions_dir|. 76 // Uninstalls the extension |id| from the install directory |extensions_dir|.
74 void UninstallExtension(const std::string& id, const FilePath& extensions_dir); 77 void UninstallExtension(const std::string& id, const FilePath& extensions_dir);
75 78
76 // Clean up directories that aren't valid extensions from the install directory. 79 // Clean up directories that aren't valid extensions from the install directory.
77 // TODO(aa): Also consider passing in a list of known current extensions and 80 // TODO(aa): Also consider passing in a list of known current extensions and
78 // removing others? 81 // removing others?
79 void GarbageCollectExtensions(const FilePath& extensions_dir); 82 void GarbageCollectExtensions(const FilePath& extensions_dir,
83 const std::set<std::string>& installed_ids);
80 84
81 // We need to reserve the namespace of entries that start with "_" for future 85 // We need to reserve the namespace of entries that start with "_" for future
82 // use by Chrome. 86 // use by Chrome.
83 // If any files or directories are found using "_" prefix and are not on 87 // If any files or directories are found using "_" prefix and are not on
84 // reserved list we return false, and set error message. 88 // reserved list we return false, and set error message.
85 bool CheckForIllegalFilenames(const FilePath& extension_path, 89 bool CheckForIllegalFilenames(const FilePath& extension_path,
86 std::string* error); 90 std::string* error);
87 91
88 } // extension_file_util 92 } // extension_file_util
89 93
90 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_FILE_UTIL_H_ 94 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_FILE_UTIL_H_
OLDNEW
« no previous file with comments | « chrome/browser/extensions/crx_installer.cc ('k') | chrome/browser/extensions/extension_file_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698