| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/utility/utility_thread.h" | 5 #include "chrome/utility/utility_thread.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 IPC_MESSAGE_HANDLER(UtilityMsg_UnpackExtension, OnUnpackExtension) | 56 IPC_MESSAGE_HANDLER(UtilityMsg_UnpackExtension, OnUnpackExtension) |
| 57 IPC_MESSAGE_HANDLER(UtilityMsg_UnpackWebResource, OnUnpackWebResource) | 57 IPC_MESSAGE_HANDLER(UtilityMsg_UnpackWebResource, OnUnpackWebResource) |
| 58 IPC_MESSAGE_HANDLER(UtilityMsg_ParseUpdateManifest, OnParseUpdateManifest) | 58 IPC_MESSAGE_HANDLER(UtilityMsg_ParseUpdateManifest, OnParseUpdateManifest) |
| 59 IPC_MESSAGE_HANDLER(UtilityMsg_DecodeImage, OnDecodeImage) | 59 IPC_MESSAGE_HANDLER(UtilityMsg_DecodeImage, OnDecodeImage) |
| 60 IPC_MESSAGE_HANDLER(UtilityMsg_RenderPDFPagesToMetafile, | 60 IPC_MESSAGE_HANDLER(UtilityMsg_RenderPDFPagesToMetafile, |
| 61 OnRenderPDFPagesToMetafile) | 61 OnRenderPDFPagesToMetafile) |
| 62 IPC_MESSAGE_HANDLER(UtilityMsg_IDBKeysFromValuesAndKeyPath, | 62 IPC_MESSAGE_HANDLER(UtilityMsg_IDBKeysFromValuesAndKeyPath, |
| 63 OnIDBKeysFromValuesAndKeyPath) | 63 OnIDBKeysFromValuesAndKeyPath) |
| 64 IPC_MESSAGE_HANDLER(UtilityMsg_BatchMode_Started, OnBatchModeStarted) | 64 IPC_MESSAGE_HANDLER(UtilityMsg_BatchMode_Started, OnBatchModeStarted) |
| 65 IPC_MESSAGE_HANDLER(UtilityMsg_BatchMode_Finished, OnBatchModeFinished) | 65 IPC_MESSAGE_HANDLER(UtilityMsg_BatchMode_Finished, OnBatchModeFinished) |
| 66 IPC_MESSAGE_HANDLER(UtilityMsg_GetPrinterCapsAndDefaults, |
| 67 OnGetPrinterCapsAndDefaults) |
| 66 IPC_END_MESSAGE_MAP() | 68 IPC_END_MESSAGE_MAP() |
| 67 } | 69 } |
| 68 | 70 |
| 69 void UtilityThread::OnUnpackExtension(const FilePath& extension_path) { | 71 void UtilityThread::OnUnpackExtension(const FilePath& extension_path) { |
| 70 ExtensionUnpacker unpacker(extension_path); | 72 ExtensionUnpacker unpacker(extension_path); |
| 71 if (unpacker.Run() && unpacker.DumpImagesToFile() && | 73 if (unpacker.Run() && unpacker.DumpImagesToFile() && |
| 72 unpacker.DumpMessageCatalogsToFile()) { | 74 unpacker.DumpMessageCatalogsToFile()) { |
| 73 Send(new UtilityHostMsg_UnpackExtension_Succeeded( | 75 Send(new UtilityHostMsg_UnpackExtension_Succeeded( |
| 74 *unpacker.parsed_manifest())); | 76 *unpacker.parsed_manifest())); |
| 75 } else { | 77 } else { |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 } | 301 } |
| 300 | 302 |
| 301 void UtilityThread::OnBatchModeStarted() { | 303 void UtilityThread::OnBatchModeStarted() { |
| 302 batch_mode_ = true; | 304 batch_mode_ = true; |
| 303 } | 305 } |
| 304 | 306 |
| 305 void UtilityThread::OnBatchModeFinished() { | 307 void UtilityThread::OnBatchModeFinished() { |
| 306 ChildProcess::current()->ReleaseProcess(); | 308 ChildProcess::current()->ReleaseProcess(); |
| 307 } | 309 } |
| 308 | 310 |
| 311 void UtilityThread::OnGetPrinterCapsAndDefaults( |
| 312 const std::string& printer_name) { |
| 313 scoped_refptr<printing::PrintBackend> print_backend = |
| 314 printing::PrintBackend::CreateInstance(NULL); |
| 315 printing::PrinterCapsAndDefaults printer_info; |
| 316 if (print_backend->GetPrinterCapsAndDefaults(printer_name, &printer_info)) { |
| 317 Send(new UtilityHostMsg_GetPrinterCapsAndDefaults_Succeeded(printer_name, |
| 318 printer_info)); |
| 319 } else { |
| 320 Send(new UtilityHostMsg_GetPrinterCapsAndDefaults_Failed(printer_name)); |
| 321 } |
| 322 ReleaseProcessIfNeeded(); |
| 323 } |
| 324 |
| 309 void UtilityThread::ReleaseProcessIfNeeded() { | 325 void UtilityThread::ReleaseProcessIfNeeded() { |
| 310 if (!batch_mode_) | 326 if (!batch_mode_) |
| 311 ChildProcess::current()->ReleaseProcess(); | 327 ChildProcess::current()->ReleaseProcess(); |
| 312 } | 328 } |
| 329 |
| OLD | NEW |