| 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 "components/image_decoder/image_decoder_impl.h" |
| 17 #include "content/public/child/image_decoder_utils.h" | 18 #include "content/public/child/image_decoder_utils.h" |
| 18 #include "content/public/common/content_switches.h" | 19 #include "content/public/common/content_switches.h" |
| 19 #include "content/public/common/service_registry.h" | 20 #include "content/public/common/service_registry.h" |
| 20 #include "content/public/utility/utility_thread.h" | 21 #include "content/public/utility/utility_thread.h" |
| 21 #include "courgette/courgette.h" | 22 #include "courgette/courgette.h" |
| 22 #include "courgette/third_party/bsdiff.h" | 23 #include "courgette/third_party/bsdiff.h" |
| 23 #include "ipc/ipc_channel.h" | 24 #include "ipc/ipc_channel.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" |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 void FinishParseMediaMetadata( | 75 void FinishParseMediaMetadata( |
| 75 metadata::MediaMetadataParser* /* parser */, | 76 metadata::MediaMetadataParser* /* parser */, |
| 76 const extensions::api::media_galleries::MediaMetadata& metadata, | 77 const extensions::api::media_galleries::MediaMetadata& metadata, |
| 77 const std::vector<metadata::AttachedImage>& attached_images) { | 78 const std::vector<metadata::AttachedImage>& attached_images) { |
| 78 Send(new ChromeUtilityHostMsg_ParseMediaMetadata_Finished( | 79 Send(new ChromeUtilityHostMsg_ParseMediaMetadata_Finished( |
| 79 true, *metadata.ToValue(), attached_images)); | 80 true, *metadata.ToValue(), attached_images)); |
| 80 ReleaseProcessIfNeeded(); | 81 ReleaseProcessIfNeeded(); |
| 81 } | 82 } |
| 82 #endif | 83 #endif |
| 83 | 84 |
| 84 #if !defined(OS_ANDROID) | 85 template <class Interface, class Impl> |
| 85 void CreateProxyResolverFactory( | 86 void CreateMojoService(mojo::InterfaceRequest<Interface> request) { |
| 86 mojo::InterfaceRequest<net::interfaces::ProxyResolverFactory> request) { | 87 // The Mojo service implementation is assumed to use a StrongBinding<>, which |
| 87 // MojoProxyResolverFactoryImpl is strongly bound to the Mojo message pipe it | 88 // causes the implementation to be deleted automatically when the Mojo |
| 88 // is connected to. When that message pipe is closed, either explicitly on the | 89 // connection is closed. |
| 89 // other end (in the browser process), or by a connection error, this object | 90 new Impl(request.Pass()); |
| 90 // will be destroyed. | |
| 91 new net::MojoProxyResolverFactoryImpl(request.Pass()); | |
| 92 } | 91 } |
| 93 #endif // OS_ANDROID | |
| 94 | 92 |
| 95 } // namespace | 93 } // namespace |
| 96 | 94 |
| 97 int64_t ChromeContentUtilityClient::max_ipc_message_size_ = | 95 int64_t ChromeContentUtilityClient::max_ipc_message_size_ = |
| 98 IPC::Channel::kMaximumMessageSize; | 96 IPC::Channel::kMaximumMessageSize; |
| 99 | 97 |
| 100 ChromeContentUtilityClient::ChromeContentUtilityClient() | 98 ChromeContentUtilityClient::ChromeContentUtilityClient() |
| 101 : filter_messages_(false) { | 99 : filter_messages_(false) { |
| 102 #if !defined(OS_ANDROID) | 100 #if !defined(OS_ANDROID) |
| 103 handlers_.push_back(new ProfileImportHandler()); | 101 handlers_.push_back(new ProfileImportHandler()); |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 handled = (*it)->OnMessageReceived(message); | 182 handled = (*it)->OnMessageReceived(message); |
| 185 } | 183 } |
| 186 | 184 |
| 187 return handled; | 185 return handled; |
| 188 } | 186 } |
| 189 | 187 |
| 190 void ChromeContentUtilityClient::RegisterMojoServices( | 188 void ChromeContentUtilityClient::RegisterMojoServices( |
| 191 content::ServiceRegistry* registry) { | 189 content::ServiceRegistry* registry) { |
| 192 #if !defined(OS_ANDROID) | 190 #if !defined(OS_ANDROID) |
| 193 registry->AddService<net::interfaces::ProxyResolverFactory>( | 191 registry->AddService<net::interfaces::ProxyResolverFactory>( |
| 194 base::Bind(CreateProxyResolverFactory)); | 192 base::Bind(CreateMojoService<net::interfaces::ProxyResolverFactory, |
| 193 net::MojoProxyResolverFactoryImpl>)); |
| 195 #endif | 194 #endif |
| 195 registry->AddService<image_decoder::ImageDecoder>(base::Bind( |
| 196 CreateMojoService<image_decoder::ImageDecoder, |
| 197 image_decoder::ImageDecoderImpl>)); |
| 196 } | 198 } |
| 197 | 199 |
| 198 // static | 200 // static |
| 199 void ChromeContentUtilityClient::PreSandboxStartup() { | 201 void ChromeContentUtilityClient::PreSandboxStartup() { |
| 200 #if defined(ENABLE_EXTENSIONS) | 202 #if defined(ENABLE_EXTENSIONS) |
| 201 extensions::ExtensionsHandler::PreSandboxStartup(); | 203 extensions::ExtensionsHandler::PreSandboxStartup(); |
| 202 #endif | 204 #endif |
| 203 | 205 |
| 204 #if defined(ENABLE_MDNS) | 206 #if defined(ENABLE_MDNS) |
| 205 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 207 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 408 const std::string& mime_type, int64 total_size, bool get_attached_images) { | 410 const std::string& mime_type, int64 total_size, bool get_attached_images) { |
| 409 // Only one IPCDataSource may be created and added to the list of handlers. | 411 // Only one IPCDataSource may be created and added to the list of handlers. |
| 410 metadata::IPCDataSource* source = new metadata::IPCDataSource(total_size); | 412 metadata::IPCDataSource* source = new metadata::IPCDataSource(total_size); |
| 411 handlers_.push_back(source); | 413 handlers_.push_back(source); |
| 412 | 414 |
| 413 metadata::MediaMetadataParser* parser = new metadata::MediaMetadataParser( | 415 metadata::MediaMetadataParser* parser = new metadata::MediaMetadataParser( |
| 414 source, mime_type, get_attached_images); | 416 source, mime_type, get_attached_images); |
| 415 parser->Start(base::Bind(&FinishParseMediaMetadata, base::Owned(parser))); | 417 parser->Start(base::Bind(&FinishParseMediaMetadata, base::Owned(parser))); |
| 416 } | 418 } |
| 417 #endif | 419 #endif |
| OLD | NEW |