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/utility/chrome_content_utility_client.h" | 5 #include "chrome/utility/chrome_content_utility_client.h" |
| 6 | 6 |
| 7 #include "base/base64.h" | 7 #include "base/base64.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| 11 #include "base/json/json_reader.h" | 11 #include "base/json/json_reader.h" |
| 12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 13 #include "base/message_loop_proxy.h" | 13 #include "base/message_loop_proxy.h" |
| 14 #include "base/threading/thread.h" | 14 #include "base/threading/thread.h" |
| 15 #include "chrome/browser/importer/importer.h" | 15 #include "chrome/browser/importer/importer.h" |
| 16 #include "chrome/browser/importer/profile_import_process_messages.h" | 16 #include "chrome/browser/importer/profile_import_process_messages.h" |
| 17 #include "chrome/common/child_process_logging.h" | 17 #include "chrome/common/child_process_logging.h" |
| 18 #include "chrome/common/chrome_paths.h" | 18 #include "chrome/common/chrome_paths.h" |
| 19 #include "chrome/common/chrome_utility_messages.h" | 19 #include "chrome/common/chrome_utility_messages.h" |
| 20 #include "chrome/common/extensions/api/extension_action/browser_action_handler.h " | |
| 20 #include "chrome/common/extensions/extension.h" | 21 #include "chrome/common/extensions/extension.h" |
| 21 #include "chrome/common/extensions/extension_l10n_util.h" | 22 #include "chrome/common/extensions/extension_l10n_util.h" |
| 23 #include "chrome/common/extensions/extension_manifest_constants.h" | |
| 24 #include "chrome/common/extensions/manifest_handler.h" | |
| 22 #include "chrome/common/extensions/unpacker.h" | 25 #include "chrome/common/extensions/unpacker.h" |
| 23 #include "chrome/common/extensions/update_manifest.h" | 26 #include "chrome/common/extensions/update_manifest.h" |
| 24 #include "chrome/common/web_resource/web_resource_unpacker.h" | 27 #include "chrome/common/web_resource/web_resource_unpacker.h" |
| 25 #include "chrome/common/zip.h" | 28 #include "chrome/common/zip.h" |
| 26 #include "chrome/utility/profile_import_handler.h" | 29 #include "chrome/utility/profile_import_handler.h" |
| 27 #include "content/public/utility/utility_thread.h" | 30 #include "content/public/utility/utility_thread.h" |
| 28 #include "printing/backend/print_backend.h" | 31 #include "printing/backend/print_backend.h" |
| 29 #include "printing/page_range.h" | 32 #include "printing/page_range.h" |
| 30 #include "third_party/skia/include/core/SkBitmap.h" | 33 #include "third_party/skia/include/core/SkBitmap.h" |
| 31 #include "ui/base/ui_base_switches.h" | 34 #include "ui/base/ui_base_switches.h" |
| 32 #include "ui/gfx/codec/jpeg_codec.h" | 35 #include "ui/gfx/codec/jpeg_codec.h" |
| 33 #include "ui/gfx/rect.h" | 36 #include "ui/gfx/rect.h" |
| 34 #include "webkit/glue/image_decoder.h" | 37 #include "webkit/glue/image_decoder.h" |
| 35 | 38 |
| 36 #if defined(OS_WIN) | 39 #if defined(OS_WIN) |
| 37 #include "base/path_service.h" | 40 #include "base/path_service.h" |
| 38 #include "base/win/iat_patch_function.h" | 41 #include "base/win/iat_patch_function.h" |
| 39 #include "base/win/scoped_handle.h" | 42 #include "base/win/scoped_handle.h" |
| 40 #include "content/public/common/content_switches.h" | 43 #include "content/public/common/content_switches.h" |
| 41 #include "printing/emf_win.h" | 44 #include "printing/emf_win.h" |
| 42 #include "ui/gfx/gdi_util.h" | 45 #include "ui/gfx/gdi_util.h" |
| 43 #endif // defined(OS_WIN) | 46 #endif // defined(OS_WIN) |
| 44 | 47 |
| 48 namespace { | |
| 49 | |
| 50 // Explicitly register all ManifestHandlers, since the subprocess won't have the | |
|
Yoyo Zhou
2012/12/28 05:19:59
Comment should read "all ManifestHandlers needed i
Devlin
2012/12/28 20:25:36
Done.
Yoyo Zhou
2012/12/28 21:35:33
I meant you could also remove the "since..." bit.
Devlin
2013/01/23 23:48:01
Done.
| |
| 51 // same ManifestHandlerRegistry. | |
| 52 void RegisterManifestHandlers() { | |
|
Yoyo Zhou
2012/12/28 05:19:59
RegisterExtensionManifestHandlers is better.
Devlin
2012/12/28 20:25:36
Done.
| |
| 53 extensions::ManifestHandler::Register( | |
| 54 extension_manifest_keys::kBrowserAction, | |
| 55 new extensions::BrowserActionHandler); | |
| 56 } | |
| 57 | |
| 58 } // namespace | |
| 59 | |
| 45 namespace chrome { | 60 namespace chrome { |
| 46 | 61 |
| 47 ChromeContentUtilityClient::ChromeContentUtilityClient() { | 62 ChromeContentUtilityClient::ChromeContentUtilityClient() { |
| 48 #if !defined(OS_ANDROID) | 63 #if !defined(OS_ANDROID) |
| 49 import_handler_.reset(new ProfileImportHandler()); | 64 import_handler_.reset(new ProfileImportHandler()); |
| 50 #endif | 65 #endif |
| 51 } | 66 } |
| 52 | 67 |
| 53 ChromeContentUtilityClient::~ChromeContentUtilityClient() { | 68 ChromeContentUtilityClient::~ChromeContentUtilityClient() { |
| 54 } | 69 } |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 109 return content::UtilityThread::Get()->Send(message); | 124 return content::UtilityThread::Get()->Send(message); |
| 110 } | 125 } |
| 111 | 126 |
| 112 void ChromeContentUtilityClient::OnUnpackExtension( | 127 void ChromeContentUtilityClient::OnUnpackExtension( |
| 113 const FilePath& extension_path, | 128 const FilePath& extension_path, |
| 114 const std::string& extension_id, | 129 const std::string& extension_id, |
| 115 int location, | 130 int location, |
| 116 int creation_flags) { | 131 int creation_flags) { |
| 117 CHECK(location > extensions::Extension::INVALID); | 132 CHECK(location > extensions::Extension::INVALID); |
| 118 CHECK(location < extensions::Extension::NUM_LOCATIONS); | 133 CHECK(location < extensions::Extension::NUM_LOCATIONS); |
| 134 RegisterManifestHandlers(); | |
| 119 extensions::Unpacker unpacker( | 135 extensions::Unpacker unpacker( |
| 120 extension_path, | 136 extension_path, |
| 121 extension_id, | 137 extension_id, |
| 122 static_cast<extensions::Extension::Location>(location), | 138 static_cast<extensions::Extension::Location>(location), |
| 123 creation_flags); | 139 creation_flags); |
| 124 if (unpacker.Run() && unpacker.DumpImagesToFile() && | 140 if (unpacker.Run() && unpacker.DumpImagesToFile() && |
| 125 unpacker.DumpMessageCatalogsToFile()) { | 141 unpacker.DumpMessageCatalogsToFile()) { |
| 126 Send(new ChromeUtilityHostMsg_UnpackExtension_Succeeded( | 142 Send(new ChromeUtilityHostMsg_UnpackExtension_Succeeded( |
| 127 *unpacker.parsed_manifest())); | 143 *unpacker.parsed_manifest())); |
| 128 } else { | 144 } else { |
| (...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 441 } else | 457 } else |
| 442 #endif | 458 #endif |
| 443 { | 459 { |
| 444 Send(new ChromeUtilityHostMsg_GetPrinterCapsAndDefaults_Failed( | 460 Send(new ChromeUtilityHostMsg_GetPrinterCapsAndDefaults_Failed( |
| 445 printer_name)); | 461 printer_name)); |
| 446 } | 462 } |
| 447 content::UtilityThread::Get()->ReleaseProcessIfNeeded(); | 463 content::UtilityThread::Get()->ReleaseProcessIfNeeded(); |
| 448 } | 464 } |
| 449 | 465 |
| 450 } // namespace chrome | 466 } // namespace chrome |
| OLD | NEW |