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

Unified Diff: extensions/common/file_util.h

Issue 236213002: Move most of extension_file_util.cc into extensions/common/file_util.cc (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: zip (file-util) Created 6 years, 8 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
Index: extensions/common/file_util.h
diff --git a/extensions/common/file_util.h b/extensions/common/file_util.h
index 770dd750b12cb21a1eda0173893f69b8776804f0..597d085bef0a7c935524041b9236ad854663554e 100644
--- a/extensions/common/file_util.h
+++ b/extensions/common/file_util.h
@@ -7,6 +7,11 @@
#include <map>
#include <string>
+#include <vector>
+
+#include "base/files/file_path.h"
+#include "base/memory/ref_counted.h"
+#include "extensions/common/manifest.h"
class ExtensionIconSet;
class GURL;
@@ -17,10 +22,78 @@ class FilePath;
namespace extensions {
class Extension;
+struct InstallWarning;
class MessageBundle;
+// Utilities for manipulating the on-disk storage of extensions.
namespace file_util {
+extern const base::FilePath::CharType kTempDirectoryName[];
James Cook 2014/04/12 00:03:22 This code is unchanged except for putting it into
+
+// Copies |unpacked_source_dir| into the right location under |extensions_dir|.
+// The destination directory is returned on success, or empty path is returned
+// on failure.
+base::FilePath InstallExtension(const base::FilePath& unpacked_source_dir,
+ const std::string& id,
+ const std::string& version,
+ const base::FilePath& extensions_dir);
+
+// Removes all versions of the extension with |id| from |extensions_dir|.
+void UninstallExtension(const base::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|.
+scoped_refptr<Extension> LoadExtension(const base::FilePath& extension_root,
+ Manifest::Location location,
+ int flags,
+ std::string* error);
+
+// The same as LoadExtension except use the provided |extension_id|.
+scoped_refptr<Extension> LoadExtension(const base::FilePath& extension_root,
+ const std::string& extension_id,
+ Manifest::Location location,
+ int flags,
+ std::string* error);
+
+// Loads an extension manifest from the specified directory. Returns NULL
+// on failure, with a description of the error in |error|.
+base::DictionaryValue* LoadManifest(const base::FilePath& extension_root,
+ std::string* error);
+
+// Returns true if the given extension object is valid and consistent.
+// May also append a series of warning messages to |warnings|, but they
+// should not prevent the extension from running.
+//
+// Otherwise, returns false, and a description of the error is
+// returned in |error|.
+bool ValidateExtension(const Extension* extension,
+ std::string* error,
+ std::vector<InstallWarning>* warnings);
+
+// Returns a list of files that contain private keys inside |extension_dir|.
+std::vector<base::FilePath> FindPrivateKeyFiles(
+ const base::FilePath& extension_dir);
+
+// We need to reserve the namespace of entries that start with "_" for future
+// use by Chrome.
+// If any files or directories are found using "_" prefix and are not on
+// reserved list we return false, and set error message.
+bool CheckForIllegalFilenames(const base::FilePath& extension_path,
+ std::string* error);
+
+// Returns a path to a temporary directory for unpacking an extension that will
+// be installed into |extensions_dir|. Creates the directory if necessary.
+// The directory will be on the same file system as |extensions_dir| so
+// that the extension directory can be efficiently renamed into place. Returns
+// an empty file path on failure.
+base::FilePath GetInstallTempDir(const base::FilePath& extensions_dir);
+
+// Helper function to delete files. This is used to avoid ugly casts which
+// would be necessary with PostMessage since base::Delete is overloaded.
+// TODO(skerner): Make a version of Delete that is not overloaded in file_util.
+void DeleteFile(const base::FilePath& path, bool recursive);
+
// Get a relative file path from a chrome-extension:// URL.
base::FilePath ExtensionURLToRelativeFilePath(const GURL& url);

Powered by Google App Engine
This is Rietveld 408576698