| 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/common/safe_browsing/zip_analyzer_results.h" | 14 #include "chrome/common/safe_browsing/zip_analyzer_results.h" |
| 15 #include "chrome/utility/chrome_content_utility_ipc_whitelist.h" | 15 #include "chrome/utility/chrome_content_utility_ipc_whitelist.h" |
| 16 #include "chrome/utility/utility_message_handler.h" | 16 #include "chrome/utility/utility_message_handler.h" |
| 17 #include "content/public/child/image_decoder_utils.h" | 17 #include "content/public/child/image_decoder_utils.h" |
| 18 #include "content/public/common/content_switches.h" | 18 #include "content/public/common/content_switches.h" |
| 19 #include "content/public/common/service_registry.h" | 19 #include "content/public/common/service_registry.h" |
| 20 #include "content/public/utility/utility_thread.h" | 20 #include "content/public/utility/utility_thread.h" |
| 21 #include "courgette/courgette.h" | 21 #include "courgette/courgette.h" |
| 22 #include "courgette/third_party/bsdiff.h" | 22 #include "courgette/third_party/bsdiff.h" |
| 23 #include "ipc/ipc_channel.h" | 23 #include "ipc/ipc_channel.h" |
| 24 #include "services/image_decoder/image_decoder_impl.h" |
| 24 #include "skia/ext/image_operations.h" | 25 #include "skia/ext/image_operations.h" |
| 25 #include "third_party/skia/include/core/SkBitmap.h" | 26 #include "third_party/skia/include/core/SkBitmap.h" |
| 26 #include "third_party/zlib/google/zip.h" | 27 #include "third_party/zlib/google/zip.h" |
| 27 #include "ui/gfx/codec/jpeg_codec.h" | 28 #include "ui/gfx/codec/jpeg_codec.h" |
| 28 #include "ui/gfx/geometry/size.h" | 29 #include "ui/gfx/geometry/size.h" |
| 29 | 30 |
| 30 #if !defined(OS_ANDROID) | 31 #if !defined(OS_ANDROID) |
| 31 #include "chrome/utility/profile_import_handler.h" | 32 #include "chrome/utility/profile_import_handler.h" |
| 32 #include "net/proxy/mojo_proxy_resolver_factory_impl.h" | 33 #include "net/proxy/mojo_proxy_resolver_factory_impl.h" |
| 33 #endif | 34 #endif |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 void FinishParseMediaMetadata( | 72 void FinishParseMediaMetadata( |
| 72 metadata::MediaMetadataParser* /* parser */, | 73 metadata::MediaMetadataParser* /* parser */, |
| 73 const extensions::api::media_galleries::MediaMetadata& metadata, | 74 const extensions::api::media_galleries::MediaMetadata& metadata, |
| 74 const std::vector<metadata::AttachedImage>& attached_images) { | 75 const std::vector<metadata::AttachedImage>& attached_images) { |
| 75 Send(new ChromeUtilityHostMsg_ParseMediaMetadata_Finished( | 76 Send(new ChromeUtilityHostMsg_ParseMediaMetadata_Finished( |
| 76 true, *metadata.ToValue(), attached_images)); | 77 true, *metadata.ToValue(), attached_images)); |
| 77 ReleaseProcessIfNeeded(); | 78 ReleaseProcessIfNeeded(); |
| 78 } | 79 } |
| 79 #endif | 80 #endif |
| 80 | 81 |
| 81 #if !defined(OS_ANDROID) | 82 template <class Interface, class Impl> |
| 82 void CreateProxyResolverFactory( | 83 void CreateMojoService(mojo::InterfaceRequest<Interface> request) { |
| 83 mojo::InterfaceRequest<net::interfaces::ProxyResolverFactory> request) { | 84 // The Mojo service implementation is assumed to use a StrongBinding<>, which |
| 84 // MojoProxyResolverFactoryImpl is strongly bound to the Mojo message pipe it | 85 // causes the implementation to be deleted automatically when the Mojo |
| 85 // is connected to. When that message pipe is closed, either explicitly on the | 86 // connection is closed. |
| 86 // other end (in the browser process), or by a connection error, this object | 87 new Impl(request.Pass()); |
| 87 // will be destroyed. | |
| 88 new net::MojoProxyResolverFactoryImpl(request.Pass()); | |
| 89 } | 88 } |
| 90 #endif // OS_ANDROID | |
| 91 | 89 |
| 92 } // namespace | 90 } // namespace |
| 93 | 91 |
| 94 int64_t ChromeContentUtilityClient::max_ipc_message_size_ = | 92 int64_t ChromeContentUtilityClient::max_ipc_message_size_ = |
| 95 IPC::Channel::kMaximumMessageSize; | 93 IPC::Channel::kMaximumMessageSize; |
| 96 | 94 |
| 97 ChromeContentUtilityClient::ChromeContentUtilityClient() | 95 ChromeContentUtilityClient::ChromeContentUtilityClient() |
| 98 : filter_messages_(false) { | 96 : filter_messages_(false) { |
| 99 #if !defined(OS_ANDROID) | 97 #if !defined(OS_ANDROID) |
| 100 handlers_.push_back(new ProfileImportHandler()); | 98 handlers_.push_back(new ProfileImportHandler()); |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 !handled && it != handlers_.end(); ++it) { | 176 !handled && it != handlers_.end(); ++it) { |
| 179 handled = (*it)->OnMessageReceived(message); | 177 handled = (*it)->OnMessageReceived(message); |
| 180 } | 178 } |
| 181 | 179 |
| 182 return handled; | 180 return handled; |
| 183 } | 181 } |
| 184 | 182 |
| 185 void ChromeContentUtilityClient::RegisterMojoServices( | 183 void ChromeContentUtilityClient::RegisterMojoServices( |
| 186 content::ServiceRegistry* registry) { | 184 content::ServiceRegistry* registry) { |
| 187 #if !defined(OS_ANDROID) | 185 #if !defined(OS_ANDROID) |
| 188 registry->AddService<net::interfaces::ProxyResolverFactory>( | 186 registry->AddService<net::interfaces::ProxyResolverFactory>(base::Bind( |
| 189 base::Bind(CreateProxyResolverFactory)); | 187 CreateMojoService<net::interfaces::ProxyResolverFactory, |
| 188 net::MojoProxyResolverFactoryImpl>)); |
| 190 #endif | 189 #endif |
| 190 registry->AddService<services::ImageDecoder>(base::Bind( |
| 191 CreateMojoService<services::ImageDecoder, services::ImageDecoderImpl>)); |
| 191 } | 192 } |
| 192 | 193 |
| 193 // static | 194 // static |
| 194 void ChromeContentUtilityClient::PreSandboxStartup() { | 195 void ChromeContentUtilityClient::PreSandboxStartup() { |
| 195 #if defined(ENABLE_EXTENSIONS) | 196 #if defined(ENABLE_EXTENSIONS) |
| 196 extensions::ExtensionsHandler::PreSandboxStartup(); | 197 extensions::ExtensionsHandler::PreSandboxStartup(); |
| 197 #endif | 198 #endif |
| 198 | 199 |
| 199 #if defined(ENABLE_MDNS) | 200 #if defined(ENABLE_MDNS) |
| 200 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 201 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 399 const std::string& mime_type, int64 total_size, bool get_attached_images) { | 400 const std::string& mime_type, int64 total_size, bool get_attached_images) { |
| 400 // Only one IPCDataSource may be created and added to the list of handlers. | 401 // Only one IPCDataSource may be created and added to the list of handlers. |
| 401 metadata::IPCDataSource* source = new metadata::IPCDataSource(total_size); | 402 metadata::IPCDataSource* source = new metadata::IPCDataSource(total_size); |
| 402 handlers_.push_back(source); | 403 handlers_.push_back(source); |
| 403 | 404 |
| 404 metadata::MediaMetadataParser* parser = new metadata::MediaMetadataParser( | 405 metadata::MediaMetadataParser* parser = new metadata::MediaMetadataParser( |
| 405 source, mime_type, get_attached_images); | 406 source, mime_type, get_attached_images); |
| 406 parser->Start(base::Bind(&FinishParseMediaMetadata, base::Owned(parser))); | 407 parser->Start(base::Bind(&FinishParseMediaMetadata, base::Owned(parser))); |
| 407 } | 408 } |
| 408 #endif | 409 #endif |
| OLD | NEW |