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

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

Issue 406713002: Allow drag-and-drop of zipped extensions on chrome://extensions (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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/unpacked_installer.h ('k') | chrome/browser/resources/extensions/extensions.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/unpacked_installer.cc
diff --git a/chrome/browser/extensions/unpacked_installer.cc b/chrome/browser/extensions/unpacked_installer.cc
index 732e119162a381c0770e3303f07bd1c150f193c3..0f35f9f9df10ffa42db46386e27b483d9018c29d 100644
--- a/chrome/browser/extensions/unpacked_installer.cc
+++ b/chrome/browser/extensions/unpacked_installer.cc
@@ -28,6 +28,7 @@
#include "extensions/common/id_util.h"
#include "extensions/common/manifest.h"
#include "sync/api/string_ordinal.h"
+#include "third_party/zlib/google/zip.h"
using content::BrowserThread;
using extensions::Extension;
@@ -36,6 +37,10 @@ namespace {
const char kUnpackedExtensionsBlacklistedError[] =
"Loading of unpacked extensions is disabled by the administrator.";
+const char kUnpackedInstallerTempDirError[] =
+ "Could not create temporary directory for zipped extension.";
+const char kUnpackedInstallerUnzipError[] =
+ "Could not unzip extension for install.";
// Manages an ExtensionInstallPrompt for a particular extension.
class SimpleExtensionLoadPrompt : public ExtensionInstallPrompt::Delegate {
@@ -168,6 +173,47 @@ bool UnpackedInstaller::LoadFromCommandLine(const base::FilePath& path_in,
return true;
}
+void UnpackedInstaller::LoadFromZipFile(const base::FilePath& zip_path) {
+ BrowserThread::PostTask(
+ BrowserThread::FILE,
+ FROM_HERE,
+ base::Bind(&UnpackedInstaller::UnpackZipFileAndLoad, this, zip_path));
+}
+
+void UnpackedInstaller::UnpackZipFileAndLoad(const base::FilePath& zip_path) {
+ CHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
+ base::FilePath temp_path;
+ if (!base::CreateTemporaryDirInDir(
elijahtaylor1 2014/07/18 23:47:43 I didn't know of a great way to notify the user/de
asargent_no_longer_on_chrome 2014/07/22 22:51:01 I wonder if it would be better to unzip into a new
elijahtaylor1 2014/07/23 00:19:07 It's probably better to do in a temp dir, but it c
+ zip_path.DirName(),
+ zip_path.RemoveExtension().BaseName().value() +
+ FILE_PATH_LITERAL("_"),
+ &temp_path)) {
+ // Set extension_path_ so a meaningful error is displayed, it would normally
+ // be set by UnpackedInstaller::Load
+ extension_path_ = zip_path;
+ BrowserThread::PostTask(
+ BrowserThread::UI,
+ FROM_HERE,
+ base::Bind(&UnpackedInstaller::ReportExtensionLoadError,
+ this,
+ kUnpackedInstallerTempDirError));
+ return;
+ }
+ if (!zip::Unzip(zip_path, temp_path)) {
asargent_no_longer_on_chrome 2014/07/22 22:51:01 For regular extension installation, we do the unzi
elijahtaylor1 2014/07/23 00:19:07 Yeah, I first tried to use the sandboxed unpacker,
meacer 2014/07/23 00:32:15 I agree with Antony, it's best to do this in the s
+ // Set extension_path_ so a meaningful error is displayed, it would normally
+ // be set by UnpackedInstaller::Load
+ extension_path_ = zip_path;
+ BrowserThread::PostTask(
+ BrowserThread::UI,
+ FROM_HERE,
+ base::Bind(&UnpackedInstaller::ReportExtensionLoadError,
+ this,
+ kUnpackedInstallerUnzipError));
+ return;
+ }
+ Load(temp_path);
+}
+
void UnpackedInstaller::ShowInstallPrompt() {
CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
if (!service_weak_.get())
« no previous file with comments | « chrome/browser/extensions/unpacked_installer.h ('k') | chrome/browser/resources/extensions/extensions.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698