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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
153 IPC_END_MESSAGE_MAP() | 155 IPC_END_MESSAGE_MAP() |
154 | 156 |
155 for (Handlers::iterator it = handlers_.begin(); | 157 for (Handlers::iterator it = handlers_.begin(); |
156 !handled && it != handlers_.end(); ++it) { | 158 !handled && it != handlers_.end(); ++it) { |
157 handled = (*it)->OnMessageReceived(message); | 159 handled = (*it)->OnMessageReceived(message); |
158 } | 160 } |
159 | 161 |
160 return handled; | 162 return handled; |
161 } | 163 } |
162 | 164 |
165 #if !defined(OS_ANDROID) | |
166 namespace { | |
Lei Zhang
2015/03/05 23:42:49
There's already an anonymous namespace at line 55.
Anand Mistry (off Chromium)
2015/03/10 07:24:23
Done.
| |
167 | |
168 void CreateProxyResolverFactory( | |
169 mojo::InterfaceRequest<net::interfaces::ProxyResolverFactory> request) { | |
170 // MojoProxyResolverFactoryImpl is strongly bound to the Mojo message pipe it | |
171 // is connected to. When that message pipe is closed, either explicitly on the | |
172 // other end (in the browser process), or by a connection error, this object | |
173 // will be destroyed. | |
174 new net::MojoProxyResolverFactoryImpl(request.Pass()); | |
eroman
2015/03/06 05:48:21
perhaps I am dense but I find this pattern confusi
Anand Mistry (off Chromium)
2015/03/10 07:24:23
I agree, but it's what we want. We want the object
| |
175 } | |
176 | |
177 } // namespace | |
178 #endif // OS_ANDROID | |
179 | |
180 void ChromeContentUtilityClient::RegisterMojoServices( | |
181 content::ServiceRegistry* registry) { | |
182 #if !defined(OS_ANDROID) | |
183 registry->AddService<net::interfaces::ProxyResolverFactory>( | |
184 base::Bind(CreateProxyResolverFactory)); | |
185 #endif | |
186 } | |
187 | |
163 // static | 188 // static |
164 void ChromeContentUtilityClient::PreSandboxStartup() { | 189 void ChromeContentUtilityClient::PreSandboxStartup() { |
165 #if defined(ENABLE_EXTENSIONS) | 190 #if defined(ENABLE_EXTENSIONS) |
166 extensions::ExtensionsHandler::PreSandboxStartup(); | 191 extensions::ExtensionsHandler::PreSandboxStartup(); |
167 #endif | 192 #endif |
168 | 193 |
169 #if defined(ENABLE_MDNS) | 194 #if defined(ENABLE_MDNS) |
170 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 195 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
171 switches::kUtilityProcessEnableMDns)) { | 196 switches::kUtilityProcessEnableMDns)) { |
172 local_discovery::ServiceDiscoveryMessageHandler::PreSandboxStartup(); | 197 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) { | 369 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. | 370 // Only one IPCDataSource may be created and added to the list of handlers. |
346 metadata::IPCDataSource* source = new metadata::IPCDataSource(total_size); | 371 metadata::IPCDataSource* source = new metadata::IPCDataSource(total_size); |
347 handlers_.push_back(source); | 372 handlers_.push_back(source); |
348 | 373 |
349 metadata::MediaMetadataParser* parser = new metadata::MediaMetadataParser( | 374 metadata::MediaMetadataParser* parser = new metadata::MediaMetadataParser( |
350 source, mime_type, get_attached_images); | 375 source, mime_type, get_attached_images); |
351 parser->Start(base::Bind(&FinishParseMediaMetadata, base::Owned(parser))); | 376 parser->Start(base::Bind(&FinishParseMediaMetadata, base::Owned(parser))); |
352 } | 377 } |
353 #endif | 378 #endif |
OLD | NEW |