OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/startup_helper.h" | 5 #include "chrome/browser/extensions/startup_helper.h" |
6 | 6 |
7 #include "base/string_util.h" | 7 #include "base/string_util.h" |
8 #include "base/stringprintf.h" | 8 #include "base/stringprintf.h" |
9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
10 #include "chrome/browser/extensions/extension_service.h" | 10 #include "chrome/browser/extensions/extension_service.h" |
11 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
12 #include "chrome/browser/ui/simple_message_box.h" | |
13 #include "chrome/common/chrome_switches.h" | 12 #include "chrome/common/chrome_switches.h" |
14 | 13 |
| 14 namespace { |
| 15 |
| 16 void PrintPackExtensionMessage(const std::string& message) { |
| 17 base::StringPrintf("%s\n", message.c_str()); |
| 18 } |
| 19 |
| 20 } // namespace |
| 21 |
15 namespace extensions { | 22 namespace extensions { |
16 | 23 |
17 StartupHelper::StartupHelper() : pack_job_succeeded_(false) {} | 24 StartupHelper::StartupHelper() : pack_job_succeeded_(false) {} |
18 | 25 |
19 void StartupHelper::OnPackSuccess(const FilePath& crx_path, | 26 void StartupHelper::OnPackSuccess(const FilePath& crx_path, |
20 const FilePath& output_private_key_path) { | 27 const FilePath& output_private_key_path) { |
21 pack_job_succeeded_ = true; | 28 pack_job_succeeded_ = true; |
22 chrome::ShowMessageBox(NULL, ASCIIToUTF16("Extension Packaging Success"), | 29 PrintPackExtensionMessage( |
23 PackExtensionJob::StandardSuccessMessage(crx_path, | 30 UTF16ToUTF8( |
24 output_private_key_path), | 31 PackExtensionJob::StandardSuccessMessage(crx_path, |
25 chrome::MESSAGE_BOX_TYPE_INFORMATION); | 32 output_private_key_path))); |
26 } | 33 } |
27 | 34 |
28 void StartupHelper::OnPackFailure(const std::string& error_message, | 35 void StartupHelper::OnPackFailure(const std::string& error_message, |
29 ExtensionCreator::ErrorType type) { | 36 ExtensionCreator::ErrorType type) { |
30 chrome::ShowMessageBox(NULL, ASCIIToUTF16("Extension Packaging Error"), | 37 PrintPackExtensionMessage(error_message); |
31 UTF8ToUTF16(error_message), chrome::MESSAGE_BOX_TYPE_WARNING); | |
32 } | 38 } |
33 | 39 |
34 bool StartupHelper::PackExtension(const CommandLine& cmd_line) { | 40 bool StartupHelper::PackExtension(const CommandLine& cmd_line) { |
35 if (!cmd_line.HasSwitch(switches::kPackExtension)) | 41 if (!cmd_line.HasSwitch(switches::kPackExtension)) |
36 return false; | 42 return false; |
37 | 43 |
38 // Input Paths. | 44 // Input Paths. |
39 FilePath src_dir = cmd_line.GetSwitchValuePath(switches::kPackExtension); | 45 FilePath src_dir = cmd_line.GetSwitchValuePath(switches::kPackExtension); |
40 FilePath private_key_path; | 46 FilePath private_key_path; |
41 if (cmd_line.HasSwitch(switches::kPackExtensionKey)) { | 47 if (cmd_line.HasSwitch(switches::kPackExtensionKey)) { |
(...skipping 26 matching lines...) Expand all Loading... |
68 return ExtensionService::UninstallExtensionHelper(extension_service, | 74 return ExtensionService::UninstallExtensionHelper(extension_service, |
69 extension_id); | 75 extension_id); |
70 } | 76 } |
71 | 77 |
72 StartupHelper::~StartupHelper() { | 78 StartupHelper::~StartupHelper() { |
73 if (pack_job_.get()) | 79 if (pack_job_.get()) |
74 pack_job_->ClearClient(); | 80 pack_job_->ClearClient(); |
75 } | 81 } |
76 | 82 |
77 } // namespace extensions | 83 } // namespace extensions |
OLD | NEW |