| Index: chrome/browser/extensions/pack_extension_job.cc
|
| diff --git a/chrome/browser/extensions/pack_extension_job.cc b/chrome/browser/extensions/pack_extension_job.cc
|
| index 19e26d8a994b40e38d63c2e721fbd45a7c8994d1..1896c1e5e03be8a2c750090872ecfdd6965e4dce 100644
|
| --- a/chrome/browser/extensions/pack_extension_job.cc
|
| +++ b/chrome/browser/extensions/pack_extension_job.cc
|
| @@ -4,15 +4,19 @@
|
|
|
| #include "chrome/browser/extensions/pack_extension_job.h"
|
|
|
| +#include "app/l10n_util.h"
|
| #include "base/message_loop.h"
|
| #include "base/utf_string_conversions.h"
|
| #include "base/task.h"
|
| #include "chrome/browser/extensions/extension_creator.h"
|
| +#include "chrome/common/chrome_constants.h"
|
| +#include "grit/generated_resources.h"
|
|
|
| PackExtensionJob::PackExtensionJob(Client* client,
|
| const FilePath& root_directory,
|
| const FilePath& key_file)
|
| - : client_(client), root_directory_(root_directory), key_file_(key_file) {
|
| + : client_(client), key_file_(key_file) {
|
| + root_directory_ = root_directory.StripTrailingSeparators();
|
| CHECK(ChromeThread::GetCurrentThreadIdentifier(&client_thread_id_));
|
| }
|
|
|
| @@ -27,10 +31,12 @@ void PackExtensionJob::ClearClient() {
|
| }
|
|
|
| void PackExtensionJob::RunOnFileThread() {
|
| - crx_file_out_ = root_directory_.ReplaceExtension(FILE_PATH_LITERAL("crx"));
|
| + crx_file_out_ = FilePath(root_directory_.value() +
|
| + chrome::kExtensionFileExtension);
|
|
|
| if (key_file_.empty())
|
| - key_file_out_ = root_directory_.ReplaceExtension(FILE_PATH_LITERAL("pem"));
|
| + key_file_out_ = FilePath(root_directory_.value() +
|
| + chrome::kExtensionKeyFileExtension);
|
|
|
| // TODO(aa): Need to internationalize the errors that ExtensionCreator
|
| // returns. See bug 20734.
|
| @@ -38,22 +44,42 @@ void PackExtensionJob::RunOnFileThread() {
|
| if (creator.Run(root_directory_, crx_file_out_, key_file_, key_file_out_)) {
|
| ChromeThread::PostTask(
|
| client_thread_id_, FROM_HERE,
|
| - NewRunnableMethod(this, &PackExtensionJob::ReportSuccessOnUIThread));
|
| + NewRunnableMethod(this,
|
| + &PackExtensionJob::ReportSuccessOnClientThread));
|
| } else {
|
| ChromeThread::PostTask(
|
| client_thread_id_, FROM_HERE,
|
| NewRunnableMethod(
|
| - this, &PackExtensionJob::ReportFailureOnUIThread,
|
| + this, &PackExtensionJob::ReportFailureOnClientThread,
|
| creator.error_message()));
|
| }
|
| }
|
|
|
| -void PackExtensionJob::ReportSuccessOnUIThread() {
|
| +void PackExtensionJob::ReportSuccessOnClientThread() {
|
| if (client_)
|
| client_->OnPackSuccess(crx_file_out_, key_file_out_);
|
| }
|
|
|
| -void PackExtensionJob::ReportFailureOnUIThread(const std::string& error) {
|
| +void PackExtensionJob::ReportFailureOnClientThread(const std::string& error) {
|
| if (client_)
|
| client_->OnPackFailure(error);
|
| }
|
| +
|
| +// static
|
| +std::wstring PackExtensionJob::StandardSuccessMessage(const FilePath& crx_file,
|
| + const FilePath& key_file)
|
| +{
|
| + // TODO(isherman): we should use string16 instead of wstring.
|
| + // See crbug.com/23581 and crbug.com/24672
|
| + std::wstring message;
|
| + if (key_file.empty()) {
|
| + return l10n_util::GetStringF(
|
| + IDS_EXTENSION_PACK_DIALOG_SUCCESS_BODY_UPDATE,
|
| + crx_file.ToWStringHack());
|
| + } else {
|
| + return l10n_util::GetStringF(
|
| + IDS_EXTENSION_PACK_DIALOG_SUCCESS_BODY_NEW,
|
| + crx_file.ToWStringHack(),
|
| + key_file.ToWStringHack());
|
| + }
|
| +}
|
|
|