Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(203)

Side by Side Diff: chrome/utility/chrome_content_utility_client.cc

Issue 1128453004: Embed a simple Mojo shell in content (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/chrome_content_utility_process_impl.h"
16 #include "chrome/utility/utility_message_handler.h" 17 #include "chrome/utility/utility_message_handler.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"
20 #include "content/public/common/process.mojom.h"
19 #include "content/public/common/service_registry.h" 21 #include "content/public/common/service_registry.h"
20 #include "content/public/utility/utility_thread.h" 22 #include "content/public/utility/utility_thread.h"
21 #include "courgette/courgette.h" 23 #include "courgette/courgette.h"
22 #include "courgette/third_party/bsdiff.h" 24 #include "courgette/third_party/bsdiff.h"
23 #include "ipc/ipc_channel.h" 25 #include "ipc/ipc_channel.h"
24 #include "skia/ext/image_operations.h" 26 #include "skia/ext/image_operations.h"
25 #include "third_party/skia/include/core/SkBitmap.h" 27 #include "third_party/skia/include/core/SkBitmap.h"
26 #include "third_party/zlib/google/zip.h" 28 #include "third_party/zlib/google/zip.h"
27 #include "ui/gfx/codec/jpeg_codec.h" 29 #include "ui/gfx/codec/jpeg_codec.h"
28 #include "ui/gfx/geometry/size.h" 30 #include "ui/gfx/geometry/size.h"
29 31
30 #if !defined(OS_ANDROID) 32 #if !defined(OS_ANDROID)
31 #include "chrome/utility/profile_import_handler.h" 33 #include "chrome/utility/profile_import_handler.h"
32 #include "net/proxy/mojo_proxy_resolver_factory_impl.h"
33 #endif 34 #endif
34 35
35 #if defined(OS_ANDROID) && defined(USE_SECCOMP_BPF) 36 #if defined(OS_ANDROID) && defined(USE_SECCOMP_BPF)
36 #include "sandbox/linux/seccomp-bpf/sandbox_bpf.h" 37 #include "sandbox/linux/seccomp-bpf/sandbox_bpf.h"
37 #endif 38 #endif
38 39
39 #if defined(OS_WIN) 40 #if defined(OS_WIN)
40 #include "chrome/utility/font_cache_handler_win.h" 41 #include "chrome/utility/font_cache_handler_win.h"
41 #include "chrome/utility/shell_handler_win.h" 42 #include "chrome/utility/shell_handler_win.h"
42 #endif 43 #endif
(...skipping 28 matching lines...) Expand all
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 void CreateProxyResolverFactory(
83 mojo::InterfaceRequest<net::interfaces::ProxyResolverFactory> request) {
84 // MojoProxyResolverFactoryImpl is strongly bound to the Mojo message pipe it
85 // is connected to. When that message pipe is closed, either explicitly on the
86 // other end (in the browser process), or by a connection error, this object
87 // will be destroyed.
88 new net::MojoProxyResolverFactoryImpl(request.Pass());
89 }
90 #endif // OS_ANDROID
91
92 } // namespace 82 } // namespace
93 83
94 int64_t ChromeContentUtilityClient::max_ipc_message_size_ = 84 int64_t ChromeContentUtilityClient::max_ipc_message_size_ =
95 IPC::Channel::kMaximumMessageSize; 85 IPC::Channel::kMaximumMessageSize;
96 86
97 ChromeContentUtilityClient::ChromeContentUtilityClient() 87 ChromeContentUtilityClient::ChromeContentUtilityClient()
98 : filter_messages_(false) { 88 : filter_messages_(false) {
99 #if !defined(OS_ANDROID) 89 #if !defined(OS_ANDROID)
100 handlers_.push_back(new ProfileImportHandler()); 90 handlers_.push_back(new ProfileImportHandler());
101 #endif 91 #endif
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 for (Handlers::iterator it = handlers_.begin(); 167 for (Handlers::iterator it = handlers_.begin();
178 !handled && it != handlers_.end(); ++it) { 168 !handled && it != handlers_.end(); ++it) {
179 handled = (*it)->OnMessageReceived(message); 169 handled = (*it)->OnMessageReceived(message);
180 } 170 }
181 171
182 return handled; 172 return handled;
183 } 173 }
184 174
185 void ChromeContentUtilityClient::RegisterMojoServices( 175 void ChromeContentUtilityClient::RegisterMojoServices(
186 content::ServiceRegistry* registry) { 176 content::ServiceRegistry* registry) {
187 #if !defined(OS_ANDROID) 177 if (!process_impl_)
188 registry->AddService<net::interfaces::ProxyResolverFactory>( 178 process_impl_.reset(new ChromeContentUtilityProcessImpl);
189 base::Bind(CreateProxyResolverFactory)); 179 registry->AddService(base::Bind(
190 #endif 180 &ChromeContentUtilityClient::BindProcessRequest, base::Unretained(this)));
191 } 181 }
192 182
193 // static 183 // static
194 void ChromeContentUtilityClient::PreSandboxStartup() { 184 void ChromeContentUtilityClient::PreSandboxStartup() {
195 #if defined(ENABLE_EXTENSIONS) 185 #if defined(ENABLE_EXTENSIONS)
196 extensions::ExtensionsHandler::PreSandboxStartup(); 186 extensions::ExtensionsHandler::PreSandboxStartup();
197 #endif 187 #endif
198 188
199 #if defined(ENABLE_MDNS) 189 #if defined(ENABLE_MDNS)
200 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 190 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 const std::string& mime_type, int64 total_size, bool get_attached_images) { 392 const std::string& mime_type, int64 total_size, bool get_attached_images) {
403 // Only one IPCDataSource may be created and added to the list of handlers. 393 // Only one IPCDataSource may be created and added to the list of handlers.
404 metadata::IPCDataSource* source = new metadata::IPCDataSource(total_size); 394 metadata::IPCDataSource* source = new metadata::IPCDataSource(total_size);
405 handlers_.push_back(source); 395 handlers_.push_back(source);
406 396
407 metadata::MediaMetadataParser* parser = new metadata::MediaMetadataParser( 397 metadata::MediaMetadataParser* parser = new metadata::MediaMetadataParser(
408 source, mime_type, get_attached_images); 398 source, mime_type, get_attached_images);
409 parser->Start(base::Bind(&FinishParseMediaMetadata, base::Owned(parser))); 399 parser->Start(base::Bind(&FinishParseMediaMetadata, base::Owned(parser)));
410 } 400 }
411 #endif 401 #endif
402
403 void ChromeContentUtilityClient::BindProcessRequest(
404 mojo::InterfaceRequest<content::Process> request) {
405 DCHECK(process_impl_);
406 process_bindings_.AddBinding(process_impl_.get(), request.Pass());
407 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698