Chromium Code Reviews| 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/extensions_startup.h" | 5 #include "chrome/browser/extensions/extensions_startup.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 ExtensionsStartupUtil::ExtensionsStartupUtil() : pack_job_succeeded_(false) {} | 22 ExtensionsStartupUtil::ExtensionsStartupUtil() : pack_job_succeeded_(false) {} |
| 16 | 23 |
| 17 void ExtensionsStartupUtil::OnPackSuccess( | 24 void ExtensionsStartupUtil::OnPackSuccess( |
| 18 const FilePath& crx_path, | 25 const FilePath& crx_path, |
| 19 const FilePath& output_private_key_path) { | 26 const FilePath& output_private_key_path) { |
| 20 pack_job_succeeded_ = true; | 27 pack_job_succeeded_ = true; |
| 21 chrome::ShowMessageBox(NULL, ASCIIToUTF16("Extension Packaging Success"), | 28 PrintPackExtensionMessage( |
| 22 PackExtensionJob::StandardSuccessMessage(crx_path, | 29 UTF16ToUTF8(PackExtensionJob::StandardSuccessMessage(crx_path, |
|
Aaron Boodman
2012/08/15 03:41:43
Indent is weird here. I think that PackExtensionJo
| |
| 23 output_private_key_path), | 30 output_private_key_path))); |
| 24 chrome::MESSAGE_BOX_TYPE_INFORMATION); | |
| 25 } | 31 } |
| 26 | 32 |
| 27 void ExtensionsStartupUtil::OnPackFailure( | 33 void ExtensionsStartupUtil::OnPackFailure( |
| 28 const std::string& error_message, | 34 const std::string& error_message, |
| 29 extensions::ExtensionCreator::ErrorType type) { | 35 extensions::ExtensionCreator::ErrorType type) { |
| 30 chrome::ShowMessageBox(NULL, ASCIIToUTF16("Extension Packaging Error"), | 36 PrintPackExtensionMessage(error_message); |
| 31 UTF8ToUTF16(error_message), chrome::MESSAGE_BOX_TYPE_WARNING); | |
| 32 } | 37 } |
| 33 | 38 |
| 34 bool ExtensionsStartupUtil::PackExtension(const CommandLine& cmd_line) { | 39 bool ExtensionsStartupUtil::PackExtension(const CommandLine& cmd_line) { |
| 35 if (!cmd_line.HasSwitch(switches::kPackExtension)) | 40 if (!cmd_line.HasSwitch(switches::kPackExtension)) |
| 36 return false; | 41 return false; |
| 37 | 42 |
| 38 // Input Paths. | 43 // Input Paths. |
| 39 FilePath src_dir = cmd_line.GetSwitchValuePath(switches::kPackExtension); | 44 FilePath src_dir = cmd_line.GetSwitchValuePath(switches::kPackExtension); |
| 40 FilePath private_key_path; | 45 FilePath private_key_path; |
| 41 if (cmd_line.HasSwitch(switches::kPackExtensionKey)) { | 46 if (cmd_line.HasSwitch(switches::kPackExtensionKey)) { |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 66 std::string extension_id = cmd_line.GetSwitchValueASCII( | 71 std::string extension_id = cmd_line.GetSwitchValueASCII( |
| 67 switches::kUninstallExtension); | 72 switches::kUninstallExtension); |
| 68 return ExtensionService::UninstallExtensionHelper(extension_service, | 73 return ExtensionService::UninstallExtensionHelper(extension_service, |
| 69 extension_id); | 74 extension_id); |
| 70 } | 75 } |
| 71 | 76 |
| 72 ExtensionsStartupUtil::~ExtensionsStartupUtil() { | 77 ExtensionsStartupUtil::~ExtensionsStartupUtil() { |
| 73 if (pack_job_.get()) | 78 if (pack_job_.get()) |
| 74 pack_job_->ClearClient(); | 79 pack_job_->ClearClient(); |
| 75 } | 80 } |
| OLD | NEW |