| 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" | 12 #include "chrome/browser/ui/simple_message_box.h" |
| 13 #include "chrome/common/chrome_switches.h" | 13 #include "chrome/common/chrome_switches.h" |
| 14 | 14 |
| 15 ExtensionsStartupUtil::ExtensionsStartupUtil() : pack_job_succeeded_(false) {} | 15 ExtensionsStartupUtil::ExtensionsStartupUtil() : pack_job_succeeded_(false) {} |
| 16 | 16 |
| 17 void ExtensionsStartupUtil::OnPackSuccess( | 17 void ExtensionsStartupUtil::OnPackSuccess( |
| 18 const FilePath& crx_path, | 18 const FilePath& crx_path, |
| 19 const FilePath& output_private_key_path) { | 19 const FilePath& output_private_key_path) { |
| 20 pack_job_succeeded_ = true; | 20 pack_job_succeeded_ = true; |
| 21 browser::ShowMessageBox(NULL, ASCIIToUTF16("Extension Packaging Success"), | 21 chrome::ShowMessageBox(NULL, ASCIIToUTF16("Extension Packaging Success"), |
| 22 PackExtensionJob::StandardSuccessMessage(crx_path, | 22 PackExtensionJob::StandardSuccessMessage(crx_path, |
| 23 output_private_key_path), | 23 output_private_key_path), |
| 24 browser::MESSAGE_BOX_TYPE_INFORMATION); | 24 chrome::MESSAGE_BOX_TYPE_INFORMATION); |
| 25 } | 25 } |
| 26 | 26 |
| 27 void ExtensionsStartupUtil::OnPackFailure(const std::string& error_message, | 27 void ExtensionsStartupUtil::OnPackFailure(const std::string& error_message, |
| 28 ExtensionCreator::ErrorType type) { | 28 ExtensionCreator::ErrorType type) { |
| 29 browser::ShowMessageBox(NULL, ASCIIToUTF16("Extension Packaging Error"), | 29 chrome::ShowMessageBox(NULL, ASCIIToUTF16("Extension Packaging Error"), |
| 30 UTF8ToUTF16(error_message), browser::MESSAGE_BOX_TYPE_WARNING); | 30 UTF8ToUTF16(error_message), chrome::MESSAGE_BOX_TYPE_WARNING); |
| 31 } | 31 } |
| 32 | 32 |
| 33 bool ExtensionsStartupUtil::PackExtension(const CommandLine& cmd_line) { | 33 bool ExtensionsStartupUtil::PackExtension(const CommandLine& cmd_line) { |
| 34 if (!cmd_line.HasSwitch(switches::kPackExtension)) | 34 if (!cmd_line.HasSwitch(switches::kPackExtension)) |
| 35 return false; | 35 return false; |
| 36 | 36 |
| 37 // Input Paths. | 37 // Input Paths. |
| 38 FilePath src_dir = cmd_line.GetSwitchValuePath(switches::kPackExtension); | 38 FilePath src_dir = cmd_line.GetSwitchValuePath(switches::kPackExtension); |
| 39 FilePath private_key_path; | 39 FilePath private_key_path; |
| 40 if (cmd_line.HasSwitch(switches::kPackExtensionKey)) { | 40 if (cmd_line.HasSwitch(switches::kPackExtensionKey)) { |
| (...skipping 24 matching lines...) Expand all Loading... |
| 65 std::string extension_id = cmd_line.GetSwitchValueASCII( | 65 std::string extension_id = cmd_line.GetSwitchValueASCII( |
| 66 switches::kUninstallExtension); | 66 switches::kUninstallExtension); |
| 67 return ExtensionService::UninstallExtensionHelper(extension_service, | 67 return ExtensionService::UninstallExtensionHelper(extension_service, |
| 68 extension_id); | 68 extension_id); |
| 69 } | 69 } |
| 70 | 70 |
| 71 ExtensionsStartupUtil::~ExtensionsStartupUtil() { | 71 ExtensionsStartupUtil::~ExtensionsStartupUtil() { |
| 72 if (pack_job_.get()) | 72 if (pack_job_.get()) |
| 73 pack_job_->ClearClient(); | 73 pack_job_->ClearClient(); |
| 74 } | 74 } |
| OLD | NEW |