OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/extensions/pack_extension_job.h" | 5 #include "chrome/browser/extensions/pack_extension_job.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "base/sys_string_conversions.h" | 9 #include "base/sys_string_conversions.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 void PackExtensionJob::Run() { | 44 void PackExtensionJob::Run() { |
45 crx_file_out_ = FilePath(root_directory_.value() + | 45 crx_file_out_ = FilePath(root_directory_.value() + |
46 chrome::kExtensionFileExtension); | 46 chrome::kExtensionFileExtension); |
47 | 47 |
48 if (key_file_.empty()) | 48 if (key_file_.empty()) |
49 key_file_out_ = FilePath(root_directory_.value() + | 49 key_file_out_ = FilePath(root_directory_.value() + |
50 chrome::kExtensionKeyFileExtension); | 50 chrome::kExtensionKeyFileExtension); |
51 | 51 |
52 // TODO(aa): Need to internationalize the errors that ExtensionCreator | 52 // TODO(aa): Need to internationalize the errors that ExtensionCreator |
53 // returns. See bug 20734. | 53 // returns. See bug 20734. |
54 ExtensionCreator creator; | 54 extensions::ExtensionCreator creator; |
55 if (creator.Run(root_directory_, crx_file_out_, key_file_, key_file_out_, | 55 if (creator.Run(root_directory_, crx_file_out_, key_file_, key_file_out_, |
56 run_flags_)) { | 56 run_flags_)) { |
57 if (asynchronous_) { | 57 if (asynchronous_) { |
58 BrowserThread::PostTask( | 58 BrowserThread::PostTask( |
59 client_thread_id_, FROM_HERE, | 59 client_thread_id_, FROM_HERE, |
60 base::Bind(&PackExtensionJob::ReportSuccessOnClientThread, this)); | 60 base::Bind(&PackExtensionJob::ReportSuccessOnClientThread, this)); |
61 } else { | 61 } else { |
62 ReportSuccessOnClientThread(); | 62 ReportSuccessOnClientThread(); |
63 } | 63 } |
64 } else { | 64 } else { |
(...skipping 10 matching lines...) Expand all Loading... |
75 } | 75 } |
76 } | 76 } |
77 | 77 |
78 void PackExtensionJob::ReportSuccessOnClientThread() { | 78 void PackExtensionJob::ReportSuccessOnClientThread() { |
79 if (client_) | 79 if (client_) |
80 client_->OnPackSuccess(crx_file_out_, key_file_out_); | 80 client_->OnPackSuccess(crx_file_out_, key_file_out_); |
81 } | 81 } |
82 | 82 |
83 void PackExtensionJob::ReportFailureOnClientThread( | 83 void PackExtensionJob::ReportFailureOnClientThread( |
84 const std::string& error, | 84 const std::string& error, |
85 ExtensionCreator::ErrorType error_type) { | 85 extensions::ExtensionCreator::ErrorType error_type) { |
86 if (client_) | 86 if (client_) |
87 client_->OnPackFailure(error, error_type); | 87 client_->OnPackFailure(error, error_type); |
88 } | 88 } |
89 | 89 |
90 // static | 90 // static |
91 string16 PackExtensionJob::StandardSuccessMessage(const FilePath& crx_file, | 91 string16 PackExtensionJob::StandardSuccessMessage(const FilePath& crx_file, |
92 const FilePath& key_file) { | 92 const FilePath& key_file) { |
93 string16 crx_file_string = crx_file.LossyDisplayName(); | 93 string16 crx_file_string = crx_file.LossyDisplayName(); |
94 string16 key_file_string = key_file.LossyDisplayName(); | 94 string16 key_file_string = key_file.LossyDisplayName(); |
95 if (key_file_string.empty()) { | 95 if (key_file_string.empty()) { |
96 return l10n_util::GetStringFUTF16( | 96 return l10n_util::GetStringFUTF16( |
97 IDS_EXTENSION_PACK_DIALOG_SUCCESS_BODY_UPDATE, | 97 IDS_EXTENSION_PACK_DIALOG_SUCCESS_BODY_UPDATE, |
98 crx_file_string); | 98 crx_file_string); |
99 } else { | 99 } else { |
100 return l10n_util::GetStringFUTF16( | 100 return l10n_util::GetStringFUTF16( |
101 IDS_EXTENSION_PACK_DIALOG_SUCCESS_BODY_NEW, | 101 IDS_EXTENSION_PACK_DIALOG_SUCCESS_BODY_NEW, |
102 crx_file_string, | 102 crx_file_string, |
103 key_file_string); | 103 key_file_string); |
104 } | 104 } |
105 } | 105 } |
OLD | NEW |