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/extension.h" | 20 #include "chrome/common/extensions/extension.h" |
21 #include "chrome/common/extensions/extension_l10n_util.h" | 21 #include "chrome/common/extensions/extension_l10n_util.h" |
| 22 #include "chrome/common/extensions/extension_manifest_constants.h" |
| 23 #include "chrome/common/extensions/manifest_handler.h" |
| 24 #include "chrome/common/extensions/theme_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 needed in the utility process. |
| 51 void RegisterExtensionManifestHandlers() { |
| 52 extensions::ManifestHandler::Register(extension_manifest_keys::kTheme, |
| 53 new extensions::ThemeHandler); |
| 54 } |
| 55 |
| 56 } // namespace |
| 57 |
45 namespace chrome { | 58 namespace chrome { |
46 | 59 |
47 ChromeContentUtilityClient::ChromeContentUtilityClient() { | 60 ChromeContentUtilityClient::ChromeContentUtilityClient() { |
48 #if !defined(OS_ANDROID) | 61 #if !defined(OS_ANDROID) |
49 import_handler_.reset(new ProfileImportHandler()); | 62 import_handler_.reset(new ProfileImportHandler()); |
50 #endif | 63 #endif |
51 } | 64 } |
52 | 65 |
53 ChromeContentUtilityClient::~ChromeContentUtilityClient() { | 66 ChromeContentUtilityClient::~ChromeContentUtilityClient() { |
54 } | 67 } |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 return content::UtilityThread::Get()->Send(message); | 122 return content::UtilityThread::Get()->Send(message); |
110 } | 123 } |
111 | 124 |
112 void ChromeContentUtilityClient::OnUnpackExtension( | 125 void ChromeContentUtilityClient::OnUnpackExtension( |
113 const FilePath& extension_path, | 126 const FilePath& extension_path, |
114 const std::string& extension_id, | 127 const std::string& extension_id, |
115 int location, | 128 int location, |
116 int creation_flags) { | 129 int creation_flags) { |
117 CHECK(location > extensions::Extension::INVALID); | 130 CHECK(location > extensions::Extension::INVALID); |
118 CHECK(location < extensions::Extension::NUM_LOCATIONS); | 131 CHECK(location < extensions::Extension::NUM_LOCATIONS); |
| 132 RegisterExtensionManifestHandlers(); |
119 extensions::Unpacker unpacker( | 133 extensions::Unpacker unpacker( |
120 extension_path, | 134 extension_path, |
121 extension_id, | 135 extension_id, |
122 static_cast<extensions::Extension::Location>(location), | 136 static_cast<extensions::Extension::Location>(location), |
123 creation_flags); | 137 creation_flags); |
124 if (unpacker.Run() && unpacker.DumpImagesToFile() && | 138 if (unpacker.Run() && unpacker.DumpImagesToFile() && |
125 unpacker.DumpMessageCatalogsToFile()) { | 139 unpacker.DumpMessageCatalogsToFile()) { |
126 Send(new ChromeUtilityHostMsg_UnpackExtension_Succeeded( | 140 Send(new ChromeUtilityHostMsg_UnpackExtension_Succeeded( |
127 *unpacker.parsed_manifest())); | 141 *unpacker.parsed_manifest())); |
128 } else { | 142 } else { |
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
441 } else | 455 } else |
442 #endif | 456 #endif |
443 { | 457 { |
444 Send(new ChromeUtilityHostMsg_GetPrinterCapsAndDefaults_Failed( | 458 Send(new ChromeUtilityHostMsg_GetPrinterCapsAndDefaults_Failed( |
445 printer_name)); | 459 printer_name)); |
446 } | 460 } |
447 content::UtilityThread::Get()->ReleaseProcessIfNeeded(); | 461 content::UtilityThread::Get()->ReleaseProcessIfNeeded(); |
448 } | 462 } |
449 | 463 |
450 } // namespace chrome | 464 } // namespace chrome |
OLD | NEW |