summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormrossetti@chromium.org <mrossetti@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-05 00:43:37 +0000
committermrossetti@chromium.org <mrossetti@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-05 00:43:37 +0000
commitca0e201094b6f34d4703b3a8daa88e5328c60bc4 (patch)
treeda1030dede740c5b1bc60d43a9f4c9b36f6dcc29
parent038a1619f9df1f91c4da9af660810fd6b4759c65 (diff)
downloadchromium_src-ca0e201094b6f34d4703b3a8daa88e5328c60bc4.zip
chromium_src-ca0e201094b6f34d4703b3a8daa88e5328c60bc4.tar.gz
chromium_src-ca0e201094b6f34d4703b3a8daa88e5328c60bc4.tar.bz2
Revert 116407 - Update Extension Pack UI to warn before overwriting existing CRX
BUG=35194 TEST=Try packing an extension from the browser, both overwriting and not overwriting an existing crx. And do a commandline browser extension pack. Review URL: http://codereview.chromium.org/9044002 TBR=aa@chromium.org Review URL: http://codereview.chromium.org/9102001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@116419 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--AUTHORS1
-rw-r--r--chrome/app/generated_resources.grd9
-rw-r--r--chrome/browser/extensions/extension_browsertest.cc5
-rw-r--r--chrome/browser/extensions/extension_creator.cc25
-rw-r--r--chrome/browser/extensions/extension_creator.h29
-rw-r--r--chrome/browser/extensions/extension_service_unittest.cc51
-rw-r--r--chrome/browser/extensions/extensions_startup.cc11
-rw-r--r--chrome/browser/extensions/extensions_startup.h5
-rw-r--r--chrome/browser/extensions/pack_extension_job.cc22
-rw-r--r--chrome/browser/extensions/pack_extension_job.h14
-rw-r--r--chrome/browser/resources/options/extension_settings.js19
-rw-r--r--chrome/browser/resources/options/pack_extension_overlay.js2
-rw-r--r--chrome/browser/ui/webui/options/pack_extension_handler.cc42
-rw-r--r--chrome/browser/ui/webui/options/pack_extension_handler.h9
14 files changed, 58 insertions, 186 deletions
diff --git a/AUTHORS b/AUTHORS
index bb8f348f..a18cdab 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -150,7 +150,6 @@ Intel Corporation <*@intel.com>
Halton Huo <halton.huo@gmail.com>
Shiliu Wang <aofdwsl@gmail.com>
Gao Chun <gaochun.dev@gmail.com>
-Clinton Staley <clintstaley@gmail.com>
Devlin Cronin <rdevlin.cronin@gmail.com>
Junmin Zhu <junmin.zhu@intel.com>
Cem Kocagil <cem.kocagil@gmail.com>
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd
index 75bb279..f5c9320 100644
--- a/chrome/app/generated_resources.grd
+++ b/chrome/app/generated_resources.grd
@@ -4088,15 +4088,6 @@ Update checks have repeatedly failed for the extension "<ph name="EXTENSION_NAME
<message name="IDS_EXTENSION_PRIVATE_KEY_NO_EXISTS" desc="Warning displayed in pack dialog when the private key for the extension does not exist.">
Input value for private key must exist.
</message>
- <message name="IDS_EXTENSION_PACK_WARNING_TITLE" desc="Warning title message for pack extension">
- Pack Extension Warning
- </message>
- <message name="IDS_EXTENSION_CRX_EXISTS" desc="Warning displayed in pack dialog when the crx file already exists.">
- There is already a CRX file present with this name.
- </message>
- <message name="IDS_EXTENSION_PROCEED_ANYWAY" desc="Button to continue with operation in extension packing">
- Proceed anyway
- </message>
<message name="IDS_EXTENSION_PRIVATE_KEY_FAILED_TO_READ" desc="Warning displayed in pack dialog when was not possible to read the private key of the extension.">
Failed to read private key.
</message>
diff --git a/chrome/browser/extensions/extension_browsertest.cc b/chrome/browser/extensions/extension_browsertest.cc
index f6876f0..f660393 100644
--- a/chrome/browser/extensions/extension_browsertest.cc
+++ b/chrome/browser/extensions/extension_browsertest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -190,8 +190,7 @@ FilePath ExtensionBrowserTest::PackExtensionWithOptions(
if (!creator->Run(dir_path,
crx_path,
pem_path,
- pem_out_path,
- ExtensionCreator::kOverwriteCRX)) {
+ pem_out_path)) {
ADD_FAILURE() << "ExtensionCreator::Run() failed: "
<< creator->error_message();
return FilePath();
diff --git a/chrome/browser/extensions/extension_creator.cc b/chrome/browser/extensions/extension_creator.cc
index 394c6e8..97a5d5f 100644
--- a/chrome/browser/extensions/extension_creator.cc
+++ b/chrome/browser/extensions/extension_creator.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -27,15 +27,10 @@ namespace {
const int kRSAKeySize = 1024;
};
-ExtensionCreator::ExtensionCreator() : error_type_(kOther) {
-}
-
bool ExtensionCreator::InitializeInput(
const FilePath& extension_dir,
- const FilePath& crx_path,
const FilePath& private_key_path,
- const FilePath& private_key_output_path,
- int run_flags) {
+ const FilePath& private_key_output_path) {
// Validate input |extension_dir|.
if (extension_dir.value().empty() ||
!file_util::DirectoryExists(extension_dir)) {
@@ -69,15 +64,6 @@ bool ExtensionCreator::InitializeInput(
return false;
}
- // Check whether crx file already exists. Should be last check, as this is
- // a warning only.
- if (!(run_flags & kOverwriteCRX) && file_util::PathExists(crx_path)) {
- error_message_ = l10n_util::GetStringUTF8(IDS_EXTENSION_CRX_EXISTS);
- error_type_ = kCRXExists;
-
- return false;
- }
-
// Load the extension once. We don't really need it, but this does a lot of
// useful validation of the structure.
scoped_refptr<Extension> extension(
@@ -262,11 +248,10 @@ bool ExtensionCreator::WriteCRX(const FilePath& zip_path,
bool ExtensionCreator::Run(const FilePath& extension_dir,
const FilePath& crx_path,
const FilePath& private_key_path,
- const FilePath& output_private_key_path,
- int run_flags) {
+ const FilePath& output_private_key_path) {
// Check input diretory and read manifest.
- if (!InitializeInput(extension_dir, crx_path, private_key_path,
- output_private_key_path, run_flags)) {
+ if (!InitializeInput(extension_dir, private_key_path,
+ output_private_key_path)) {
return false;
}
diff --git a/chrome/browser/extensions/extension_creator.h b/chrome/browser/extensions/extension_creator.h
index ff6eae9..0499821 100644
--- a/chrome/browser/extensions/extension_creator.h
+++ b/chrome/browser/extensions/extension_creator.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -24,41 +24,25 @@ class FilePath;
// generated randomly (and optionally written to |output_private_key_path|.
class ExtensionCreator {
public:
- ExtensionCreator();
-
- // Settings to specify treatment of special or ignorable error conditions.
- enum RunFlags {
- kNoRunFlags = 0x0,
- kOverwriteCRX = 0x1
- };
-
- // Categories of error that may need special handling on the UI end.
- enum ErrorType { kOther, kCRXExists };
+ ExtensionCreator() {}
bool Run(const FilePath& extension_dir,
const FilePath& crx_path,
const FilePath& private_key_path,
- const FilePath& private_key_output_path,
- int run_flags);
+ const FilePath& private_key_output_path);
// Returns the error message that will be present if Run(...) returned false.
std::string error_message() { return error_message_; }
- ErrorType error_type() { return error_type_; }
-
private:
// Verifies input directory's existence. |extension_dir| is the source
- // directory that should contain all the extension resources. |crx_path| is
- // the path to which final crx will be written.
+ // directory that should contain all the extension resources.
// |private_key_path| is the optional path to an existing private key to sign
// the extension. If not provided, a random key will be created (in which case
// it is written to |private_key_output_path| -- if provided).
- // |flags| is a bitset of RunFlags values.
bool InitializeInput(const FilePath& extension_dir,
- const FilePath& crx_path,
const FilePath& private_key_path,
- const FilePath& private_key_output_path,
- int run_flags);
+ const FilePath& private_key_output_path);
// Reads private key from |private_key_path|.
crypto::RSAPrivateKey* ReadInputKey(const FilePath& private_key_path);
@@ -85,9 +69,6 @@ class ExtensionCreator {
// Holds a message for any error that is raised during Run(...).
std::string error_message_;
- // Type of error that was raised, if any.
- ErrorType error_type_;
-
DISALLOW_COPY_AND_ASSIGN(ExtensionCreator);
};
diff --git a/chrome/browser/extensions/extension_service_unittest.cc b/chrome/browser/extensions/extension_service_unittest.cc
index 0df2eeb..5877b2a 100644
--- a/chrome/browser/extensions/extension_service_unittest.cc
+++ b/chrome/browser/extensions/extension_service_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -579,8 +579,7 @@ class ExtensionServiceTest
ASSERT_TRUE(creator->Run(dir_path,
crx_path,
pem_path,
- pem_output_path,
- ExtensionCreator::kOverwriteCRX));
+ pem_output_path));
ASSERT_TRUE(file_util::PathExists(crx_path));
}
@@ -979,8 +978,7 @@ class PackExtensionTestClient : public PackExtensionJob::Client {
const FilePath& expected_private_key_path);
virtual void OnPackSuccess(const FilePath& crx_path,
const FilePath& private_key_path);
- virtual void OnPackFailure(const std::string& error_message,
- ExtensionCreator::ErrorType type);
+ virtual void OnPackFailure(const std::string& error_message);
private:
const FilePath expected_crx_path_;
@@ -1010,13 +1008,8 @@ void PackExtensionTestClient::OnPackSuccess(const FilePath& crx_path,
}
// The tests are designed so that we never expect to see a packing error.
-void PackExtensionTestClient::OnPackFailure(const std::string& error_message,
- ExtensionCreator::ErrorType type) {
- if (type == ExtensionCreator::kCRXExists)
- FAIL() << "Packing should not fail.";
- else
- FAIL() << "Existing CRX should have been overwritten.";
-
+void PackExtensionTestClient::OnPackFailure(const std::string& error_message) {
+ FAIL() << "Packing should not fail.";
}
// Test loading good extensions from the profile directory.
@@ -1645,32 +1638,14 @@ TEST_F(ExtensionServiceTest, PackExtension) {
scoped_ptr<ExtensionCreator> creator(new ExtensionCreator());
ASSERT_TRUE(creator->Run(input_directory, crx_path, FilePath(),
- privkey_path, ExtensionCreator::kNoRunFlags));
- ASSERT_TRUE(file_util::PathExists(crx_path));
- ASSERT_TRUE(file_util::PathExists(privkey_path));
-
- // Repeat the run with the pem file gone, and no special flags
- // Should refuse to overwrite the existing crx.
- file_util::Delete(privkey_path, false);
- ASSERT_FALSE(creator->Run(input_directory, crx_path, FilePath(),
- privkey_path, ExtensionCreator::kNoRunFlags));
-
- // OK, now try it with a flag to overwrite existing crx. Should work.
- ASSERT_TRUE(creator->Run(input_directory, crx_path, FilePath(),
- privkey_path, ExtensionCreator::kOverwriteCRX));
-
- // Repeat the run allowing existing crx, but the existing pem is still
- // an error. Should fail.
- ASSERT_FALSE(creator->Run(input_directory, crx_path, FilePath(),
- privkey_path, ExtensionCreator::kOverwriteCRX));
+ privkey_path));
ASSERT_TRUE(file_util::PathExists(privkey_path));
InstallCRX(crx_path, INSTALL_NEW);
// Try packing with invalid paths.
creator.reset(new ExtensionCreator());
- ASSERT_FALSE(creator->Run(FilePath(), FilePath(), FilePath(), FilePath(),
- ExtensionCreator::kOverwriteCRX));
+ ASSERT_FALSE(creator->Run(FilePath(), FilePath(), FilePath(), FilePath()));
// Try packing an empty directory. Should fail because an empty directory is
// not a valid extension.
@@ -1678,7 +1653,7 @@ TEST_F(ExtensionServiceTest, PackExtension) {
ASSERT_TRUE(temp_dir2.CreateUniqueTempDir());
creator.reset(new ExtensionCreator());
ASSERT_FALSE(creator->Run(temp_dir2.path(), crx_path, privkey_path,
- FilePath(), ExtensionCreator::kOverwriteCRX));
+ FilePath()));
// Try packing with an invalid manifest.
std::string invalid_manifest_content = "I am not a manifest.";
@@ -1687,7 +1662,7 @@ TEST_F(ExtensionServiceTest, PackExtension) {
invalid_manifest_content.c_str(), invalid_manifest_content.size()));
creator.reset(new ExtensionCreator());
ASSERT_FALSE(creator->Run(temp_dir2.path(), crx_path, privkey_path,
- FilePath(), ExtensionCreator::kOverwriteCRX));
+ FilePath()));
}
// Test Packaging and installing an extension whose name contains punctuation.
@@ -1742,9 +1717,9 @@ TEST_F(ExtensionServiceTest, PackPunctuatedExtension) {
temp_dir.path().Append(expected_private_key_names[i]);
PackExtensionTestClient pack_client(expected_crx_path,
expected_private_key_path);
- scoped_refptr<PackExtensionJob> packer(
- new PackExtensionJob(&pack_client, output_dir, FilePath(),
- ExtensionCreator::kOverwriteCRX));
+ scoped_refptr<PackExtensionJob> packer(new PackExtensionJob(&pack_client,
+ output_dir,
+ FilePath()));
packer->Start();
// The packer will post a notification task to the current thread's message
@@ -1786,7 +1761,7 @@ TEST_F(ExtensionServiceTest, PackExtensionOpenSSLKey) {
scoped_ptr<ExtensionCreator> creator(new ExtensionCreator());
ASSERT_TRUE(creator->Run(input_directory, crx_path, privkey_path,
- FilePath(), ExtensionCreator::kOverwriteCRX));
+ FilePath()));
InstallCRX(crx_path, INSTALL_NEW);
}
diff --git a/chrome/browser/extensions/extensions_startup.cc b/chrome/browser/extensions/extensions_startup.cc
index 017cc27..5d505ac 100644
--- a/chrome/browser/extensions/extensions_startup.cc
+++ b/chrome/browser/extensions/extensions_startup.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -27,8 +27,7 @@ void ExtensionsStartupUtil::OnPackSuccess(
crx_path, output_private_key_path)));
}
-void ExtensionsStartupUtil::OnPackFailure(const std::string& error_message,
- ExtensionCreator::ErrorType type) {
+void ExtensionsStartupUtil::OnPackFailure(const std::string& error_message) {
ShowPackExtensionMessage(L"Extension Packaging Error",
UTF8ToWide(error_message));
}
@@ -59,10 +58,8 @@ bool ExtensionsStartupUtil::PackExtension(const CommandLine& cmd_line) {
private_key_path = cmd_line.GetSwitchValuePath(switches::kPackExtensionKey);
}
- // Launch a job to perform the packing on the file thread. Ignore warnings
- // from the packing process. (e.g. Overwrite any existing crx file.)
- pack_job_ = new PackExtensionJob(this, src_dir, private_key_path,
- ExtensionCreator::kOverwriteCRX);
+ // Launch a job to perform the packing on the file thread.
+ pack_job_ = new PackExtensionJob(this, src_dir, private_key_path);
pack_job_->set_asynchronous(false);
pack_job_->Start();
diff --git a/chrome/browser/extensions/extensions_startup.h b/chrome/browser/extensions/extensions_startup.h
index c717f98..12f59d9 100644
--- a/chrome/browser/extensions/extensions_startup.h
+++ b/chrome/browser/extensions/extensions_startup.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -20,8 +20,7 @@ class ExtensionsStartupUtil : public PackExtensionJob::Client {
virtual void OnPackSuccess(const FilePath& crx_path,
const FilePath& output_private_key_path) OVERRIDE;
- virtual void OnPackFailure(const std::string& error_message,
- ExtensionCreator::ErrorType type) OVERRIDE;
+ virtual void OnPackFailure(const std::string& error_message) OVERRIDE;
// Handle --pack-extension flag from the |cmd_line| by packing the specified
// extension. Returns false if the pack job failed.
diff --git a/chrome/browser/extensions/pack_extension_job.cc b/chrome/browser/extensions/pack_extension_job.cc
index 9139264..e7d58be 100644
--- a/chrome/browser/extensions/pack_extension_job.cc
+++ b/chrome/browser/extensions/pack_extension_job.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -17,10 +17,8 @@ using content::BrowserThread;
PackExtensionJob::PackExtensionJob(Client* client,
const FilePath& root_directory,
- const FilePath& key_file,
- int run_flags)
- : client_(client), key_file_(key_file), asynchronous_(true),
- run_flags_(run_flags) {
+ const FilePath& key_file)
+ : client_(client), key_file_(key_file), asynchronous_(true) {
root_directory_ = root_directory.StripTrailingSeparators();
CHECK(BrowserThread::GetCurrentThreadIdentifier(&client_thread_id_));
}
@@ -52,8 +50,7 @@ void PackExtensionJob::Run() {
// TODO(aa): Need to internationalize the errors that ExtensionCreator
// returns. See bug 20734.
ExtensionCreator creator;
- if (creator.Run(root_directory_, crx_file_out_, key_file_, key_file_out_,
- run_flags_)) {
+ if (creator.Run(root_directory_, crx_file_out_, key_file_, key_file_out_)) {
if (asynchronous_) {
BrowserThread::PostTask(
client_thread_id_, FROM_HERE,
@@ -67,10 +64,9 @@ void PackExtensionJob::Run() {
client_thread_id_, FROM_HERE,
base::Bind(
&PackExtensionJob::ReportFailureOnClientThread, this,
- creator.error_message(), creator.error_type()));
+ creator.error_message()));
} else {
- ReportFailureOnClientThread(creator.error_message(),
- creator.error_type());
+ ReportFailureOnClientThread(creator.error_message());
}
}
}
@@ -80,11 +76,9 @@ void PackExtensionJob::ReportSuccessOnClientThread() {
client_->OnPackSuccess(crx_file_out_, key_file_out_);
}
-void PackExtensionJob::ReportFailureOnClientThread(
- const std::string& error,
- ExtensionCreator::ErrorType error_type) {
+void PackExtensionJob::ReportFailureOnClientThread(const std::string& error) {
if (client_)
- client_->OnPackFailure(error, error_type);
+ client_->OnPackFailure(error);
}
// static
diff --git a/chrome/browser/extensions/pack_extension_job.h b/chrome/browser/extensions/pack_extension_job.h
index 34ef31b..ed479cf 100644
--- a/chrome/browser/extensions/pack_extension_job.h
+++ b/chrome/browser/extensions/pack_extension_job.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -12,20 +12,19 @@
#include "base/memory/ref_counted.h"
#include "base/string16.h"
#include "content/public/browser/browser_thread.h"
-#include "chrome/browser/extensions/extension_creator.h"
// Manages packing an extension on the file thread and reporting the result
// back to the UI.
class PackExtensionJob : public base::RefCountedThreadSafe<PackExtensionJob> {
public:
+
// Interface for people who want to use PackExtensionJob to implement.
class Client {
public:
virtual void OnPackSuccess(const FilePath& crx_file,
const FilePath& key_file) = 0;
- virtual void OnPackFailure(const std::string& message,
- ExtensionCreator::ErrorType error_type) = 0;
+ virtual void OnPackFailure(const std::string& message) = 0;
protected:
virtual ~Client() {}
@@ -33,8 +32,7 @@ class PackExtensionJob : public base::RefCountedThreadSafe<PackExtensionJob> {
PackExtensionJob(Client* client,
const FilePath& root_directory,
- const FilePath& key_file,
- int run_flags);
+ const FilePath& key_file);
// Starts the packing job.
void Start();
@@ -57,8 +55,7 @@ class PackExtensionJob : public base::RefCountedThreadSafe<PackExtensionJob> {
// If |asynchronous_| is false, this is run on whichever thread calls it.
void Run();
void ReportSuccessOnClientThread();
- void ReportFailureOnClientThread(const std::string& error,
- ExtensionCreator::ErrorType error_type);
+ void ReportFailureOnClientThread(const std::string& error);
content::BrowserThread::ID client_thread_id_;
Client* client_;
@@ -67,7 +64,6 @@ class PackExtensionJob : public base::RefCountedThreadSafe<PackExtensionJob> {
FilePath crx_file_out_;
FilePath key_file_out_;
bool asynchronous_;
- int run_flags_; // Bitset of ExtensionCreator::RunFlags values
DISALLOW_COPY_AND_ASSIGN(PackExtensionJob);
};
diff --git a/chrome/browser/resources/options/extension_settings.js b/chrome/browser/resources/options/extension_settings.js
index 401f04b..06c009f 100644
--- a/chrome/browser/resources/options/extension_settings.js
+++ b/chrome/browser/resources/options/extension_settings.js
@@ -177,25 +177,6 @@ cr.define('options', function() {
ExtensionsList.decorate(extensionList);
}
- // Indicate that warning |message| has occured for pack of |crx_path| and
- // |pem_path| files. Ask if user wants override the warning. Send
- // |overrideFlags| to repeated 'pack' call to accomplish the override.
- ExtensionSettings.askToOverrideWarning
- = function(message, crx_path, pem_path, overrideFlags) {
- OptionsPage.closeOverlay();
- AlertOverlay.show(
- localStrings.getString('packExtensionWarningTitle'),
- message,
- localStrings.getString('packExtensionProceedAnyway'),
- localStrings.getString('cancel'),
- function() {
- chrome.send('pack', [crx_path, pem_path, overrideFlags]);
- },
- function() {
- OptionsPage.closeOverlay();
- });
- }
-
// Export
return {
ExtensionSettings: ExtensionSettings
diff --git a/chrome/browser/resources/options/pack_extension_overlay.js b/chrome/browser/resources/options/pack_extension_overlay.js
index c698748..530c6ab 100644
--- a/chrome/browser/resources/options/pack_extension_overlay.js
+++ b/chrome/browser/resources/options/pack_extension_overlay.js
@@ -35,7 +35,7 @@ cr.define('options', function() {
$('packExtensionCommit').onclick = function(event) {
var extensionPath = $('extensionRootDir').value;
var privateKeyPath = $('extensionPrivateKey').value;
- chrome.send('pack', [extensionPath, privateKeyPath, 0]);
+ chrome.send('pack', [extensionPath, privateKeyPath]);
};
$('browseExtensionDir').addEventListener('click',
this.handleBrowseExtensionDir_.bind(this));
diff --git a/chrome/browser/ui/webui/options/pack_extension_handler.cc b/chrome/browser/ui/webui/options/pack_extension_handler.cc
index f6b91e2..e42e34a 100644
--- a/chrome/browser/ui/webui/options/pack_extension_handler.cc
+++ b/chrome/browser/ui/webui/options/pack_extension_handler.cc
@@ -6,7 +6,6 @@
#include "base/bind.h"
#include "base/utf_string_conversions.h"
-#include "chrome/browser/extensions/extension_creator.h"
#include "grit/generated_resources.h"
#include "ui/base/l10n/l10n_util.h"
@@ -40,10 +39,6 @@ void PackExtensionHandler::GetLocalizedValues(
l10n_util::GetStringUTF16(IDS_EXTENSION_PACK_DIALOG_PRIVATE_KEY_LABEL));
localized_strings->SetString("packExtensionBrowseButton",
l10n_util::GetStringUTF16(IDS_EXTENSION_PACK_DIALOG_BROWSE));
- localized_strings->SetString("packExtensionProceedAnyway",
- l10n_util::GetStringUTF16(IDS_EXTENSION_PROCEED_ANYWAY));
- localized_strings->SetString("packExtensionWarningTitle",
- l10n_util::GetStringUTF16(IDS_EXTENSION_PACK_WARNING_TITLE));
}
void PackExtensionHandler::RegisterMessages() {
@@ -63,36 +58,23 @@ void PackExtensionHandler::OnPackSuccess(const FilePath& crx_file,
"PackExtensionOverlay.showSuccessMessage", arguments);
}
-void PackExtensionHandler::OnPackFailure(const std::string& error,
- ExtensionCreator::ErrorType type) {
- if (type == ExtensionCreator::kCRXExists) {
- web_ui()->CallJavascriptFunction(
- "ExtensionSettings.askToOverrideWarning",
- base::StringValue(error),
- base::StringValue(extension_path_),
- base::StringValue(private_key_path_),
- base::FundamentalValue(ExtensionCreator::kOverwriteCRX));
- } else {
- ShowAlert(error);
- }
+void PackExtensionHandler::OnPackFailure(const std::string& error) {
+ ShowAlert(error);
}
void PackExtensionHandler::HandlePackMessage(const ListValue* args) {
- CHECK_EQ(3U, args->GetSize());
-
- CHECK(args->GetString(0, &extension_path_));
- CHECK(args->GetString(1, &private_key_path_));
-
- double flags_double = 0.0;
- CHECK(args->GetDouble(2, &flags_double));
- int run_flags = static_cast<int>(flags_double);
+ std::string extension_path;
+ std::string private_key_path;
+ CHECK_EQ(2U, args->GetSize());
+ CHECK(args->GetString(0, &extension_path));
+ CHECK(args->GetString(1, &private_key_path));
FilePath root_directory =
- FilePath::FromWStringHack(UTF8ToWide(extension_path_));
- FilePath key_file = FilePath::FromWStringHack(UTF8ToWide(private_key_path_));
+ FilePath::FromWStringHack(UTF8ToWide(extension_path));
+ FilePath key_file = FilePath::FromWStringHack(UTF8ToWide(private_key_path));
if (root_directory.empty()) {
- if (extension_path_.empty()) {
+ if (extension_path.empty()) {
ShowAlert(l10n_util::GetStringUTF8(
IDS_EXTENSION_PACK_DIALOG_ERROR_ROOT_REQUIRED));
} else {
@@ -103,13 +85,13 @@ void PackExtensionHandler::HandlePackMessage(const ListValue* args) {
return;
}
- if (!private_key_path_.empty() && key_file.empty()) {
+ if (!private_key_path.empty() && key_file.empty()) {
ShowAlert(l10n_util::GetStringUTF8(
IDS_EXTENSION_PACK_DIALOG_ERROR_KEY_INVALID));
return;
}
- pack_job_ = new PackExtensionJob(this, root_directory, key_file, run_flags);
+ pack_job_ = new PackExtensionJob(this, root_directory, key_file);
pack_job_->Start();
}
diff --git a/chrome/browser/ui/webui/options/pack_extension_handler.h b/chrome/browser/ui/webui/options/pack_extension_handler.h
index eab6dcd..e25b37d 100644
--- a/chrome/browser/ui/webui/options/pack_extension_handler.h
+++ b/chrome/browser/ui/webui/options/pack_extension_handler.h
@@ -31,8 +31,7 @@ class PackExtensionHandler : public OptionsPageUIHandler,
virtual void OnPackSuccess(const FilePath& crx_file,
const FilePath& key_file) OVERRIDE;
- virtual void OnPackFailure(const std::string& error,
- ExtensionCreator::ErrorType) OVERRIDE;
+ virtual void OnPackFailure(const std::string& error) OVERRIDE;
private:
// Javascript callback to start packing an extension.
@@ -44,12 +43,6 @@ class PackExtensionHandler : public OptionsPageUIHandler,
// Used to package the extension.
scoped_refptr<PackExtensionJob> pack_job_;
- // Path to directory containing extension data
- std::string extension_path_;
-
- // Path for private key file, if specified, otherwise empty.
- std::string private_key_path_;
-
DISALLOW_COPY_AND_ASSIGN(PackExtensionHandler);
};