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/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
11 #include "base/time/time.h" | 11 #include "base/time/time.h" |
12 #include "chrome/common/chrome_utility_messages.h" | 12 #include "chrome/common/chrome_utility_messages.h" |
13 #include "chrome/common/safe_browsing/zip_analyzer.h" | 13 #include "chrome/common/safe_browsing/zip_analyzer.h" |
14 #include "chrome/utility/chrome_content_utility_ipc_whitelist.h" | 14 #include "chrome/utility/chrome_content_utility_ipc_whitelist.h" |
15 #include "chrome/utility/utility_message_handler.h" | 15 #include "chrome/utility/utility_message_handler.h" |
16 #include "content/public/child/image_decoder_utils.h" | 16 #include "content/public/child/image_decoder_utils.h" |
17 #include "content/public/common/content_switches.h" | 17 #include "content/public/common/content_switches.h" |
| 18 #include "content/public/common/service_registry.h" |
18 #include "content/public/utility/utility_thread.h" | 19 #include "content/public/utility/utility_thread.h" |
19 #include "courgette/courgette.h" | 20 #include "courgette/courgette.h" |
20 #include "courgette/third_party/bsdiff.h" | 21 #include "courgette/third_party/bsdiff.h" |
21 #include "ipc/ipc_channel.h" | 22 #include "ipc/ipc_channel.h" |
22 #include "skia/ext/image_operations.h" | 23 #include "skia/ext/image_operations.h" |
23 #include "third_party/skia/include/core/SkBitmap.h" | 24 #include "third_party/skia/include/core/SkBitmap.h" |
24 #include "third_party/zlib/google/zip.h" | 25 #include "third_party/zlib/google/zip.h" |
25 #include "ui/gfx/codec/jpeg_codec.h" | 26 #include "ui/gfx/codec/jpeg_codec.h" |
26 #include "ui/gfx/geometry/size.h" | 27 #include "ui/gfx/geometry/size.h" |
27 | 28 |
28 #if !defined(OS_ANDROID) | 29 #if !defined(OS_ANDROID) |
29 #include "chrome/utility/profile_import_handler.h" | 30 #include "chrome/utility/profile_import_handler.h" |
| 31 #include "net/proxy/mojo_proxy_resolver_factory_impl.h" |
30 #endif | 32 #endif |
31 | 33 |
32 #if defined(OS_WIN) | 34 #if defined(OS_WIN) |
33 #include "chrome/utility/font_cache_handler_win.h" | 35 #include "chrome/utility/font_cache_handler_win.h" |
34 #include "chrome/utility/shell_handler_win.h" | 36 #include "chrome/utility/shell_handler_win.h" |
35 #endif | 37 #endif |
36 | 38 |
37 #if defined(ENABLE_EXTENSIONS) | 39 #if defined(ENABLE_EXTENSIONS) |
38 #include "chrome/common/extensions/chrome_utility_extensions_messages.h" | 40 #include "chrome/common/extensions/chrome_utility_extensions_messages.h" |
39 #include "chrome/utility/extensions/extensions_handler.h" | 41 #include "chrome/utility/extensions/extensions_handler.h" |
(...skipping 24 matching lines...) Expand all Loading... |
64 void FinishParseMediaMetadata( | 66 void FinishParseMediaMetadata( |
65 metadata::MediaMetadataParser* /* parser */, | 67 metadata::MediaMetadataParser* /* parser */, |
66 const extensions::api::media_galleries::MediaMetadata& metadata, | 68 const extensions::api::media_galleries::MediaMetadata& metadata, |
67 const std::vector<metadata::AttachedImage>& attached_images) { | 69 const std::vector<metadata::AttachedImage>& attached_images) { |
68 Send(new ChromeUtilityHostMsg_ParseMediaMetadata_Finished( | 70 Send(new ChromeUtilityHostMsg_ParseMediaMetadata_Finished( |
69 true, *metadata.ToValue(), attached_images)); | 71 true, *metadata.ToValue(), attached_images)); |
70 ReleaseProcessIfNeeded(); | 72 ReleaseProcessIfNeeded(); |
71 } | 73 } |
72 #endif | 74 #endif |
73 | 75 |
| 76 #if !defined(OS_ANDROID) |
| 77 void CreateProxyResolverFactory( |
| 78 mojo::InterfaceRequest<net::interfaces::ProxyResolverFactory> request) { |
| 79 // MojoProxyResolverFactoryImpl is strongly bound to the Mojo message pipe it |
| 80 // is connected to. When that message pipe is closed, either explicitly on the |
| 81 // other end (in the browser process), or by a connection error, this object |
| 82 // will be destroyed. |
| 83 new net::MojoProxyResolverFactoryImpl(request.Pass()); |
| 84 } |
| 85 #endif // OS_ANDROID |
| 86 |
74 } // namespace | 87 } // namespace |
75 | 88 |
76 int64_t ChromeContentUtilityClient::max_ipc_message_size_ = | 89 int64_t ChromeContentUtilityClient::max_ipc_message_size_ = |
77 IPC::Channel::kMaximumMessageSize; | 90 IPC::Channel::kMaximumMessageSize; |
78 | 91 |
79 ChromeContentUtilityClient::ChromeContentUtilityClient() | 92 ChromeContentUtilityClient::ChromeContentUtilityClient() |
80 : filter_messages_(false) { | 93 : filter_messages_(false) { |
81 #if !defined(OS_ANDROID) | 94 #if !defined(OS_ANDROID) |
82 handlers_.push_back(new ProfileImportHandler()); | 95 handlers_.push_back(new ProfileImportHandler()); |
83 #endif | 96 #endif |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 IPC_END_MESSAGE_MAP() | 166 IPC_END_MESSAGE_MAP() |
154 | 167 |
155 for (Handlers::iterator it = handlers_.begin(); | 168 for (Handlers::iterator it = handlers_.begin(); |
156 !handled && it != handlers_.end(); ++it) { | 169 !handled && it != handlers_.end(); ++it) { |
157 handled = (*it)->OnMessageReceived(message); | 170 handled = (*it)->OnMessageReceived(message); |
158 } | 171 } |
159 | 172 |
160 return handled; | 173 return handled; |
161 } | 174 } |
162 | 175 |
| 176 void ChromeContentUtilityClient::RegisterMojoServices( |
| 177 content::ServiceRegistry* registry) { |
| 178 #if !defined(OS_ANDROID) |
| 179 registry->AddService<net::interfaces::ProxyResolverFactory>( |
| 180 base::Bind(CreateProxyResolverFactory)); |
| 181 #endif |
| 182 } |
| 183 |
163 // static | 184 // static |
164 void ChromeContentUtilityClient::PreSandboxStartup() { | 185 void ChromeContentUtilityClient::PreSandboxStartup() { |
165 #if defined(ENABLE_EXTENSIONS) | 186 #if defined(ENABLE_EXTENSIONS) |
166 extensions::ExtensionsHandler::PreSandboxStartup(); | 187 extensions::ExtensionsHandler::PreSandboxStartup(); |
167 #endif | 188 #endif |
168 | 189 |
169 #if defined(ENABLE_MDNS) | 190 #if defined(ENABLE_MDNS) |
170 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 191 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
171 switches::kUtilityProcessEnableMDns)) { | 192 switches::kUtilityProcessEnableMDns)) { |
172 local_discovery::ServiceDiscoveryMessageHandler::PreSandboxStartup(); | 193 local_discovery::ServiceDiscoveryMessageHandler::PreSandboxStartup(); |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
344 const std::string& mime_type, int64 total_size, bool get_attached_images) { | 365 const std::string& mime_type, int64 total_size, bool get_attached_images) { |
345 // Only one IPCDataSource may be created and added to the list of handlers. | 366 // Only one IPCDataSource may be created and added to the list of handlers. |
346 metadata::IPCDataSource* source = new metadata::IPCDataSource(total_size); | 367 metadata::IPCDataSource* source = new metadata::IPCDataSource(total_size); |
347 handlers_.push_back(source); | 368 handlers_.push_back(source); |
348 | 369 |
349 metadata::MediaMetadataParser* parser = new metadata::MediaMetadataParser( | 370 metadata::MediaMetadataParser* parser = new metadata::MediaMetadataParser( |
350 source, mime_type, get_attached_images); | 371 source, mime_type, get_attached_images); |
351 parser->Start(base::Bind(&FinishParseMediaMetadata, base::Owned(parser))); | 372 parser->Start(base::Bind(&FinishParseMediaMetadata, base::Owned(parser))); |
352 } | 373 } |
353 #endif | 374 #endif |
OLD | NEW |