summaryrefslogtreecommitdiffstats
path: root/chrome/browser/browser_init.cc
diff options
context:
space:
mode:
authorrafaelw@chromium.org <rafaelw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-09 02:56:41 +0000
committerrafaelw@chromium.org <rafaelw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-09 02:56:41 +0000
commita17f946fe4acf8bef67945d76931c14607e8e404 (patch)
treee785b129ec283de54f944bced5570f347a071b49 /chrome/browser/browser_init.cc
parentc0e0ee4d9be9a9a682210ff1c7853e9f1f8e3770 (diff)
downloadchromium_src-a17f946fe4acf8bef67945d76931c14607e8e404.zip
chromium_src-a17f946fe4acf8bef67945d76931c14607e8e404.tar.gz
chromium_src-a17f946fe4acf8bef67945d76931c14607e8e404.tar.bz2
chrome.exe --package-extension generates .crx from extension directory
R=aa BUG=12114 Review URL: http://codereview.chromium.org/118328 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@17927 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/browser_init.cc')
-rw-r--r--chrome/browser/browser_init.cc44
1 files changed, 44 insertions, 0 deletions
diff --git a/chrome/browser/browser_init.cc b/chrome/browser/browser_init.cc
index 12adeb0..a65c79e 100644
--- a/chrome/browser/browser_init.cc
+++ b/chrome/browser/browser_init.cc
@@ -4,6 +4,9 @@
#include "chrome/browser/browser_init.h"
+#if defined(OS_WIN)
+#include "app/win_util.h"
+#endif
#include "app/l10n_util.h"
#include "app/resource_bundle.h"
#include "base/basictypes.h"
@@ -11,6 +14,7 @@
#include "base/compiler_specific.h"
#include "base/event_recorder.h"
#include "base/file_path.h"
+#include "base/file_util.h"
#include "base/histogram.h"
#include "base/path_service.h"
#include "base/string_util.h"
@@ -21,6 +25,9 @@
#include "chrome/browser/browser_list.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/browser_window.h"
+#if defined(OS_WIN) // TODO(port)
+#include "chrome/browser/extensions/extension_creator.h"
+#endif
#include "chrome/browser/extensions/extensions_service.h"
#include "chrome/browser/extensions/user_script_master.h"
#include "chrome/browser/first_run.h"
@@ -689,6 +696,43 @@ bool BrowserInit::ProcessCmdLineImpl(const CommandLine& command_line,
profile->GetExtensionsService()->LoadExtension(path);
profile->GetUserScriptMaster()->AddWatchedPath(path);
}
+
+ if (command_line.HasSwitch(switches::kPackExtension)) {
+ // Input Paths.
+ FilePath src_dir = FilePath::FromWStringHack(command_line.GetSwitchValue(
+ switches::kPackExtension));
+ FilePath private_key_path;
+ if (command_line.HasSwitch(switches::kPackExtensionKey)) {
+ private_key_path = FilePath::FromWStringHack(
+ command_line.GetSwitchValue(switches::kPackExtensionKey));
+ }
+
+ // Output Paths.
+ FilePath output(src_dir.DirName().Append(src_dir.BaseName().value()));
+ FilePath crx_path(output);
+ crx_path = crx_path.ReplaceExtension(chrome::kExtensionFileExtension);
+ FilePath output_private_key_path;
+ if (private_key_path.empty()) {
+ output_private_key_path = FilePath(output);
+ output_private_key_path =
+ output_private_key_path.ReplaceExtension(FILE_PATH_LITERAL("pem"));
+ }
+
+ // TODO(port): Creation & running is removed from mac & linux because
+ // ExtensionCreator depends on base/crypto/rsa_private_key and
+ // base/crypto/signature_creator, both of which only have windows
+ // implementations.
+#if defined(OS_WIN)
+ scoped_ptr<ExtensionCreator> creator(new ExtensionCreator());
+ if (!creator->Run(src_dir, crx_path, private_key_path,
+ output_private_key_path)) {
+ win_util::MessageBox(NULL, UTF8ToWide(creator->error_message()),
+ L"Extension Packaging Error", MB_OK | MB_SETFOREGROUND);
+ return false;
+ }
+#endif // defined(OS_WIN)
+ return false;
+ }
}
// Allow the command line to override the persisted setting of home page.